Skip to content

Commit

Permalink
merge main into amd-staging
Browse files Browse the repository at this point in the history
Change-Id: Ibdcc0f2aedf77ec18fff95baf8dc7ece0237635e
  • Loading branch information
animeshk-amd committed Sep 24, 2024
2 parents a5eed5c + 70529b2 commit 21dc2c9
Show file tree
Hide file tree
Showing 278 changed files with 7,726 additions and 3,068 deletions.
1 change: 0 additions & 1 deletion bolt/include/bolt/Core/BinaryData.h
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ inline raw_ostream &operator<<(raw_ostream &OS,
Sep = ",\n ";
TotalCount += AccessInfo.Count;
}
SS.flush();

OS << TotalCount << " total counts : " << TempString;
return OS;
Expand Down
1 change: 0 additions & 1 deletion bolt/include/bolt/Core/BinaryFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ inline raw_ostream &operator<<(raw_ostream &OS,
TotalCount += CSP.Count;
TotalMispreds += CSP.Mispreds;
}
SS.flush();

OS << TotalCount << " (" << TotalMispreds << " misses) :" << TempString;
return OS;
Expand Down
2 changes: 0 additions & 2 deletions bolt/lib/Passes/RetpolineInsertion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ std::string createRetpolineFunctionTag(BinaryContext &BC,
if (BrInfo.isReg()) {
BC.InstPrinter->printRegName(TagOS, BrInfo.BranchReg);
TagOS << "_";
TagOS.flush();
return Tag;
}

Expand Down Expand Up @@ -212,7 +211,6 @@ std::string createRetpolineFunctionTag(BinaryContext &BC,
BC.InstPrinter->printRegName(TagOS, MemRef.SegRegNum);
}

TagOS.flush();
return Tag;
}

Expand Down
2 changes: 0 additions & 2 deletions bolt/lib/Rewrite/RewriteInstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4245,7 +4245,6 @@ void RewriteInstance::addBoltInfoSection() {
<< "command line:";
for (int I = 0; I < Argc; ++I)
DescOS << " " << Argv[I];
DescOS.flush();

// Encode as GNU GOLD VERSION so it is easily printable by 'readelf -n'
const std::string BoltInfo =
Expand All @@ -4268,7 +4267,6 @@ void RewriteInstance::encodeBATSection() {
raw_string_ostream DescOS(DescStr);

BAT->write(*BC, DescOS);
DescOS.flush();

const std::string BoltInfo =
BinarySection::encodeELFNote("BOLT", DescStr, BinarySection::NT_BOLT_BAT);
Expand Down
1 change: 0 additions & 1 deletion bolt/lib/RuntimeLibs/InstrumentationRuntimeLibrary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,6 @@ std::string InstrumentationRuntimeLibrary::buildTables(BinaryContext &BC) {
}
// Our string table lives immediately after descriptions vector
OS << Summary->StringTable;
OS.flush();

return TablesStr;
}
Expand Down
4 changes: 2 additions & 2 deletions bolt/test/X86/log.test
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ RUN: yaml2obj %p/Inputs/blarge.yaml &> %t.exe
RUN: llvm-bolt %t.exe -o %t.null --data %p/Inputs/blarge.fdata -v=2 \
RUN: --reorder-blocks=normal --print-finalized --log-file=%t.log 2>&1 \
RUN: | FileCheck --check-prefix=CHECK --allow-empty %s
RUN: cat %t.log | FileCheck %s --check-prefix=CHECK-LOG
RUN: FileCheck %s --check-prefix=CHECK-LOG --input-file %t.log

CHECK-NOT: BOLT-INFO
CHECK-NOT: BOLT-WARNING
Expand All @@ -16,4 +16,4 @@ CHECK-NOT: BOLT-ERROR
CHECK-LOG: BOLT-INFO: Target architecture
CHECK-LOG: BOLT-INFO: BOLT version
CHECK-LOG: BOLT-INFO: basic block reordering modified layout
CHECK-LOG: Binary Function "usqrt"
CHECK-LOG: Binary Function "main"
9 changes: 3 additions & 6 deletions bolt/test/perf2bolt/perf_test.test
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,12 @@
REQUIRES: system-linux, perf

RUN: %clang %S/Inputs/perf_test.c -fuse-ld=lld -Wl,--script=%S/Inputs/perf_test.lds -o %t
RUN: perf record -e cycles:u -o %t2 -- %t
RUN: perf record -Fmax -e cycles:u -o %t2 -- %t
RUN: perf2bolt %t -p=%t2 -o %t3 -nl -ignore-build-id 2>&1 | FileCheck %s

CHECK-NOT: PERF2BOLT-ERROR
CHECK-NOT: !! WARNING !! This high mismatch ratio indicates the input binary is probably not the same binary used during profiling collection.

RUN: %clang %S/Inputs/perf_test.c -no-pie -fuse-ld=lld -o %t4
RUN: perf record -e cycles:u -o %t5 -- %t4
RUN: perf2bolt %t4 -p=%t5 -o %t6 -nl -ignore-build-id 2>&1 | FileCheck %s --check-prefix=CHECK-NO-PIE

CHECK-NO-PIE-NOT: PERF2BOLT-ERROR
CHECK-NO-PIE-NOT: !! WARNING !! This high mismatch ratio indicates the input binary is probably not the same binary used during profiling collection.
RUN: perf record -Fmax -e cycles:u -o %t5 -- %t4
RUN: perf2bolt %t4 -p=%t5 -o %t6 -nl -ignore-build-id 2>&1 | FileCheck %s
2 changes: 1 addition & 1 deletion clang/docs/OpenMPSupport.rst
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ implementation.
+------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+
| misc | error directive | :good:`done` | D139166 |
+------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+
| misc | scope construct | :none:`worked on` | D157933 |
| misc | scope construct | :good:`done` | D157933, https://github.com/llvm/llvm-project/pull/109197 |
+------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+
| misc | routines for controlling and querying team regions | :part:`partial` | D95003 (libomp only) |
+------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+
Expand Down
4 changes: 2 additions & 2 deletions clang/include/clang/Frontend/ASTUnit.h
Original file line number Diff line number Diff line change
Expand Up @@ -692,8 +692,8 @@ class ASTUnit {
///
/// \returns - The initialized ASTUnit or null if the AST failed to load.
static std::unique_ptr<ASTUnit>
LoadFromASTFile(const std::string &Filename,
const PCHContainerReader &PCHContainerRdr, WhatToLoad ToLoad,
LoadFromASTFile(StringRef Filename, const PCHContainerReader &PCHContainerRdr,
WhatToLoad ToLoad,
IntrusiveRefCntPtr<DiagnosticsEngine> Diags,
const FileSystemOptions &FileSystemOpts,
std::shared_ptr<HeaderSearchOptions> HSOpts,
Expand Down
18 changes: 10 additions & 8 deletions clang/lib/AST/ByteCode/Compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,7 @@ bool Compiler<Emitter>::VisitCastExpr(const CastExpr *CE) {
case CK_NoOp:
case CK_UserDefinedConversion:
case CK_AddressSpaceConversion:
case CK_CPointerToObjCPointerCast:
return this->delegate(SubExpr);

case CK_BitCast: {
Expand Down Expand Up @@ -3116,21 +3117,22 @@ bool Compiler<Emitter>::VisitCXXNewExpr(const CXXNewExpr *E) {
if (!this->discard(Arg1))
return false;
IsNoThrow = true;
} else if (Ctx.getLangOpts().CPlusPlus26 &&
OperatorNew->isReservedGlobalPlacementOperator()) {
} else {
// Invalid unless we have C++26 or are in a std:: function.
if (!this->emitInvalidNewDeleteExpr(E, E))
return false;

// If we have a placement-new destination, we'll later use that instead
// of allocating.
PlacementDest = Arg1;
} else {
return this->emitInvalidNewDeleteExpr(E, E);
if (OperatorNew->isReservedGlobalPlacementOperator())
PlacementDest = Arg1;
}

} else {
// Always invalid.
return this->emitInvalid(E);
}
} else if (!OperatorNew->isReplaceableGlobalAllocationFunction()) {
} else if (!OperatorNew->isReplaceableGlobalAllocationFunction())
return this->emitInvalidNewDeleteExpr(E, E);
}

const Descriptor *Desc;
if (!PlacementDest) {
Expand Down
13 changes: 13 additions & 0 deletions clang/lib/AST/ByteCode/Interp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1293,6 +1293,13 @@ bool CheckNewTypeMismatch(InterpState &S, CodePtr OpPC, const Expr *E,
if (!CheckStore(S, OpPC, Ptr))
return false;

if (!InvalidNewDeleteExpr(S, OpPC, E))
return false;

// Assume proper types in std functions.
if (S.Current->isStdFunction())
return true;

const auto *NewExpr = cast<CXXNewExpr>(E);
QualType StorageType = Ptr.getType();

Expand Down Expand Up @@ -1334,10 +1341,16 @@ bool InvalidNewDeleteExpr(InterpState &S, CodePtr OpPC, const Expr *E) {
assert(E);
const auto &Loc = S.Current->getSource(OpPC);

if (S.getLangOpts().CPlusPlus26)
return true;

if (const auto *NewExpr = dyn_cast<CXXNewExpr>(E)) {
const FunctionDecl *OperatorNew = NewExpr->getOperatorNew();

if (!S.getLangOpts().CPlusPlus26 && NewExpr->getNumPlacementArgs() > 0) {
// This is allowed pre-C++26, but only an std function.
if (S.Current->isStdFunction())
return true;
S.FFDiag(Loc, diag::note_constexpr_new_placement)
<< /*C++26 feature*/ 1 << E->getSourceRange();
} else if (NewExpr->getNumPlacementArgs() == 1 &&
Expand Down
3 changes: 1 addition & 2 deletions clang/lib/AST/ByteCode/InterpBuiltin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1345,8 +1345,7 @@ static bool interp__builtin_operator_new(InterpState &S, CodePtr OpPC,
assert(!ElemT);
// Structs etc.
const Descriptor *Desc = S.P.createDescriptor(
Call, ElemType.getTypePtr(),
NumElems.ule(1) ? std::nullopt : Descriptor::InlineDescMD,
Call, ElemType.getTypePtr(), Descriptor::InlineDescMD,
/*IsConst=*/false, /*IsTemporary=*/false, /*IsMutable=*/false,
/*Init=*/nullptr);

Expand Down
10 changes: 10 additions & 0 deletions clang/lib/AST/ByteCode/InterpFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,3 +257,13 @@ SourceRange InterpFrame::getRange(CodePtr PC) const {

return S.getRange(Func, PC);
}

bool InterpFrame::isStdFunction() const {
if (!Func)
return false;
for (const DeclContext *DC = Func->getDecl(); DC; DC = DC->getParent())
if (DC->isStdNamespace())
return true;

return false;
}
2 changes: 2 additions & 0 deletions clang/lib/AST/ByteCode/InterpFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ class InterpFrame final : public Frame {

unsigned getDepth() const { return Depth; }

bool isStdFunction() const;

void dump() const { dump(llvm::errs(), 0); }
void dump(llvm::raw_ostream &OS, unsigned Indent = 0) const;

Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Basic/Targets/BPF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ void BPFTargetInfo::getTargetDefines(const LangOptions &Opts,
}

Builder.defineMacro("__BPF_FEATURE_ADDR_SPACE_CAST");
Builder.defineMacro("__BPF_FEATURE_MAY_GOTO");

if (CPU.empty())
CPU = "v3";
Expand All @@ -48,7 +49,6 @@ void BPFTargetInfo::getTargetDefines(const LangOptions &Opts,

std::string CpuVerNumStr = CPU.substr(1);
Builder.defineMacro("__BPF_CPU_VERSION__", CpuVerNumStr);
Builder.defineMacro("__BPF_FEATURE_MAY_GOTO");

int CpuVerNum = std::stoi(CpuVerNumStr);
if (CpuVerNum >= 2)
Expand Down
9 changes: 5 additions & 4 deletions clang/lib/CodeGen/CGBuiltin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -587,9 +587,10 @@ static Value *emitCallMaybeConstrainedFPBuiltin(CodeGenFunction &CGF,
// matching the argument type. It is assumed that only the first argument is
// overloaded.
template <unsigned N>
Value *emitBuiltinWithOneOverloadedType(CodeGenFunction &CGF, const CallExpr *E,
unsigned IntrinsicID,
llvm::StringRef Name = "") {
static Value *emitBuiltinWithOneOverloadedType(CodeGenFunction &CGF,
const CallExpr *E,
unsigned IntrinsicID,
llvm::StringRef Name = "") {
static_assert(N, "expect non-empty argument");
SmallVector<Value *, N> Args;
for (unsigned I = 0; I < N; ++I)
Expand Down Expand Up @@ -18573,7 +18574,7 @@ llvm::Value *CodeGenFunction::EmitScalarOrConstFoldImmArg(unsigned ICEArguments,
}

// Return dot product intrinsic that corresponds to the QT scalar type
Intrinsic::ID getDotProductIntrinsic(CGHLSLRuntime &RT, QualType QT) {
static Intrinsic::ID getDotProductIntrinsic(CGHLSLRuntime &RT, QualType QT) {
if (QT->isFloatingType())
return RT.getFDotIntrinsic();
if (QT->isSignedIntegerType())
Expand Down
10 changes: 5 additions & 5 deletions clang/lib/CodeGen/CGOpenMPRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1514,7 +1514,7 @@ llvm::Type *CGOpenMPRuntime::getKmpc_MicroPointerTy() {
return llvm::PointerType::getUnqual(Kmpc_MicroTy);
}

llvm::OffloadEntriesInfoManager::OMPTargetDeviceClauseKind
static llvm::OffloadEntriesInfoManager::OMPTargetDeviceClauseKind
convertDeviceClause(const VarDecl *VD) {
std::optional<OMPDeclareTargetDeclAttr::DevTypeTy> DevTy =
OMPDeclareTargetDeclAttr::getDeviceType(VD);
Expand All @@ -1537,7 +1537,7 @@ convertDeviceClause(const VarDecl *VD) {
}
}

llvm::OffloadEntriesInfoManager::OMPTargetGlobalVarEntryKind
static llvm::OffloadEntriesInfoManager::OMPTargetGlobalVarEntryKind
convertCaptureClause(const VarDecl *VD) {
std::optional<OMPDeclareTargetDeclAttr::MapTypeTy> MapType =
OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(VD);
Expand Down Expand Up @@ -8885,7 +8885,7 @@ static ValueDecl *getDeclFromThisExpr(const Expr *E) {

/// Emit a string constant containing the names of the values mapped to the
/// offloading runtime library.
llvm::Constant *
static llvm::Constant *
emitMappingInformation(CodeGenFunction &CGF, llvm::OpenMPIRBuilder &OMPBuilder,
MappableExprsHandler::MappingExprInfo &MapExprs) {

Expand Down Expand Up @@ -9527,8 +9527,8 @@ static llvm::Value *emitDeviceID(
return DeviceID;
}

llvm::Value *emitDynCGGroupMem(const OMPExecutableDirective &D,
CodeGenFunction &CGF) {
static llvm::Value *emitDynCGGroupMem(const OMPExecutableDirective &D,
CodeGenFunction &CGF) {
llvm::Value *DynCGroupMem = CGF.Builder.getInt32(0);

if (auto *DynMemClause = D.getSingleClause<OMPXDynCGroupMemClause>()) {
Expand Down
15 changes: 8 additions & 7 deletions clang/lib/CodeGen/CGStmtOpenMP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3109,8 +3109,8 @@ GetAlignedMapping(const OMPLoopDirective &S, CodeGenFunction &CGF) {

// Pass OMPLoopDirective (instead of OMPSimdDirective) to make this function
// available for "loop bind(thread)", which maps to "simd".
void emitOMPSimdDirective(const OMPLoopDirective &S, CodeGenFunction &CGF,
CodeGenModule &CGM) {
static void emitOMPSimdDirective(const OMPLoopDirective &S,
CodeGenFunction &CGF, CodeGenModule &CGM) {
bool UseOMPIRBuilder =
CGM.getLangOpts().OpenMPIRBuilder && isSimdSupportedByOpenMPIRBuilder(S);
if (UseOMPIRBuilder) {
Expand Down Expand Up @@ -4368,8 +4368,8 @@ convertClauseKindToSchedKind(OpenMPScheduleClauseKind ScheduleClauseKind) {

// Pass OMPLoopDirective (instead of OMPForDirective) to make this function
// available for "loop bind(parallel)", which maps to "for".
void emitOMPForDirective(const OMPLoopDirective &S, CodeGenFunction &CGF,
CodeGenModule &CGM, bool HasCancel) {
static void emitOMPForDirective(const OMPLoopDirective &S, CodeGenFunction &CGF,
CodeGenModule &CGM, bool HasCancel) {
bool HasLastprivates = false;
bool UseOMPIRBuilder = CGM.getLangOpts().OpenMPIRBuilder &&
isForSupportedByOpenMPIRBuilder(S, HasCancel);
Expand Down Expand Up @@ -5828,7 +5828,7 @@ void CodeGenFunction::EmitOMPTaskwaitDirective(const OMPTaskwaitDirective &S) {
CGM.getOpenMPRuntime().emitTaskwaitCall(*this, S.getBeginLoc(), Data);
}

bool isSupportedByOpenMPIRBuilder(const OMPTaskgroupDirective &T) {
static bool isSupportedByOpenMPIRBuilder(const OMPTaskgroupDirective &T) {
return T.clauses().empty();
}

Expand Down Expand Up @@ -6458,8 +6458,9 @@ void CodeGenFunction::EmitOMPDistributeLoop(const OMPLoopDirective &S,

// Pass OMPLoopDirective (instead of OMPDistributeDirective) to make this
// function available for "loop bind(teams)", which maps to "distribute".
void emitOMPDistributeDirective(const OMPLoopDirective &S, CodeGenFunction &CGF,
CodeGenModule &CGM) {
static void emitOMPDistributeDirective(const OMPLoopDirective &S,
CodeGenFunction &CGF,
CodeGenModule &CGM) {
auto &&CodeGen = [&S](CodeGenFunction &CGF, PrePostActionTy &) {
CGF.EmitOMPDistributeLoop(S, emitOMPLoopBodyWithStopPoint, S.getInc());
};
Expand Down
9 changes: 5 additions & 4 deletions clang/lib/CodeGen/CodeGenModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -788,8 +788,9 @@ getLLVMVisibility(clang::LangOptions::VisibilityFromDLLStorageClassKinds K) {
llvm_unreachable("unknown option value!");
}

void setLLVMVisibility(llvm::GlobalValue &GV,
std::optional<llvm::GlobalValue::VisibilityTypes> V) {
static void
setLLVMVisibility(llvm::GlobalValue &GV,
std::optional<llvm::GlobalValue::VisibilityTypes> V) {
if (!V)
return;

Expand Down Expand Up @@ -4235,8 +4236,8 @@ TargetMVPriority(const TargetInfo &TI,
// in the cases of CPUDispatch, this causes issues. This also makes sure we
// work with internal linkage functions, so that the same function name can be
// used with internal linkage in multiple TUs.
llvm::GlobalValue::LinkageTypes getMultiversionLinkage(CodeGenModule &CGM,
GlobalDecl GD) {
static llvm::GlobalValue::LinkageTypes
getMultiversionLinkage(CodeGenModule &CGM, GlobalDecl GD) {
const FunctionDecl *FD = cast<FunctionDecl>(GD.getDecl());
if (FD->getFormalLinkage() == Linkage::Internal)
return llvm::GlobalValue::InternalLinkage;
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/CodeGen/SanitizerMetadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ static bool isAsanHwasanOrMemTag(const SanitizerSet &SS) {
SanitizerKind::HWAddress | SanitizerKind::MemTag);
}

SanitizerMask expandKernelSanitizerMasks(SanitizerMask Mask) {
static SanitizerMask expandKernelSanitizerMasks(SanitizerMask Mask) {
if (Mask & (SanitizerKind::Address | SanitizerKind::KernelAddress))
Mask |= SanitizerKind::Address | SanitizerKind::KernelAddress;
// Note: KHWASan doesn't support globals.
Expand Down
6 changes: 3 additions & 3 deletions clang/lib/CrossTU/CrossTranslationUnit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -566,9 +566,9 @@ CrossTranslationUnitContext::ASTLoader::loadFromDump(StringRef ASTDumpPath) {
IntrusiveRefCntPtr<DiagnosticsEngine> Diags(
new DiagnosticsEngine(DiagID, &*DiagOpts, DiagClient));
return ASTUnit::LoadFromASTFile(
std::string(ASTDumpPath.str()),
CI.getPCHContainerOperations()->getRawReader(), ASTUnit::LoadEverything,
Diags, CI.getFileSystemOpts(), CI.getHeaderSearchOptsPtr());
ASTDumpPath, CI.getPCHContainerOperations()->getRawReader(),
ASTUnit::LoadEverything, Diags, CI.getFileSystemOpts(),
CI.getHeaderSearchOptsPtr());
}

/// Load the AST from a source-file, which is supposed to be located inside the
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Frontend/ASTUnit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,7 @@ void ASTUnit::ConfigureDiags(IntrusiveRefCntPtr<DiagnosticsEngine> Diags,
}

std::unique_ptr<ASTUnit> ASTUnit::LoadFromASTFile(
const std::string &Filename, const PCHContainerReader &PCHContainerRdr,
StringRef Filename, const PCHContainerReader &PCHContainerRdr,
WhatToLoad ToLoad, IntrusiveRefCntPtr<DiagnosticsEngine> Diags,
const FileSystemOptions &FileSystemOpts,
std::shared_ptr<HeaderSearchOptions> HSOpts,
Expand Down
Loading

0 comments on commit 21dc2c9

Please sign in to comment.