Skip to content

Commit 58cb02d

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:814db6c53fae into amd-gfx:1cc8749516de
Local branch amd-gfx 1cc8749 Update test vec-load-combine.ll Remote branch main 814db6c [CodeGen][NewPM] Port GCNPreRALongBranchReg to NPM. (llvm#125844)
2 parents 1cc8749 + 814db6c commit 58cb02d

File tree

312 files changed

+8953
-3146
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

312 files changed

+8953
-3146
lines changed

clang/include/clang/Basic/TargetInfo.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1471,6 +1471,7 @@ class TargetInfo : public TransferrableTargetInfo,
14711471
/// specification
14721472
virtual bool validateBranchProtection(StringRef Spec, StringRef Arch,
14731473
BranchProtectionInfo &BPI,
1474+
const LangOptions &LO,
14741475
StringRef &Err) const {
14751476
Err = "";
14761477
return false;

clang/include/clang/Driver/Options.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6876,6 +6876,7 @@ defm backslash : OptInFC1FFlag<"backslash", "Specify that backslash in string in
68766876
defm xor_operator : OptInFC1FFlag<"xor-operator", "Enable .XOR. as a synonym of .NEQV.">;
68776877
defm logical_abbreviations : OptInFC1FFlag<"logical-abbreviations", "Enable logical abbreviations">;
68786878
defm implicit_none : OptInFC1FFlag<"implicit-none", "No implicit typing allowed unless overridden by IMPLICIT statements">;
6879+
defm implicit_none_ext : OptInFC1FFlag<"implicit-none-ext", "No implicit externals allowed">;
68796880
defm underscoring : OptInFC1FFlag<"underscoring", "Appends one trailing underscore to external names">;
68806881
defm ppc_native_vec_elem_order: BoolOptionWithoutMarshalling<"f", "ppc-native-vector-element-order",
68816882
PosFlag<SetTrue, [], [ClangOption], "Specifies PowerPC native vector element order (default)">,

clang/include/clang/Tooling/DependencyScanning/DependencyScanningService.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,18 @@ enum class ScanningOptimizations {
5555
HeaderSearch = 1,
5656

5757
/// Remove warnings from system modules.
58-
SystemWarnings = 2,
58+
SystemWarnings = (1 << 1),
5959

6060
/// Remove unused -ivfsoverlay arguments.
61-
VFS = 4,
61+
VFS = (1 << 2),
6262

6363
/// Canonicalize -D and -U options.
64-
Macros = 8,
64+
Macros = (1 << 3),
6565

66-
DSS_LAST_BITMASK_ENUM(Macros),
66+
/// Ignore the compiler's working directory if it is safe.
67+
IgnoreCWD = (1 << 4),
68+
69+
DSS_LAST_BITMASK_ENUM(IgnoreCWD),
6770
Default = All
6871
};
6972

clang/lib/AST/ASTContext.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1055,7 +1055,8 @@ void ASTContext::PrintStats() const {
10551055
void ASTContext::mergeDefinitionIntoModule(NamedDecl *ND, Module *M,
10561056
bool NotifyListeners) {
10571057
if (NotifyListeners)
1058-
if (auto *Listener = getASTMutationListener())
1058+
if (auto *Listener = getASTMutationListener();
1059+
Listener && !ND->isUnconditionallyVisible())
10591060
Listener->RedefinedHiddenDefinition(ND, M);
10601061

10611062
MergedDefModules[cast<NamedDecl>(ND->getCanonicalDecl())].push_back(M);

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4715,6 +4715,14 @@ bool Compiler<Emitter>::VisitCallExpr(const CallExpr *E) {
47154715
} else if (!this->visit(MC->getImplicitObjectArgument())) {
47164716
return false;
47174717
}
4718+
} else if (const auto *PD =
4719+
dyn_cast<CXXPseudoDestructorExpr>(E->getCallee())) {
4720+
const Expr *Base = PD->getBase();
4721+
if (!Base->isGLValue())
4722+
return this->discard(Base);
4723+
if (!this->visit(Base))
4724+
return false;
4725+
return this->emitKill(E);
47184726
} else if (!FuncDecl) {
47194727
const Expr *Callee = E->getCallee();
47204728
CalleeOffset = this->allocateLocalPrimitive(Callee, PT_FnPtr, true, false);

clang/lib/AST/ByteCode/Descriptor.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ struct alignas(void *) GlobalInlineDescriptor {
6161
};
6262
static_assert(sizeof(GlobalInlineDescriptor) == sizeof(void *), "");
6363

64+
enum class Lifetime : uint8_t {
65+
Started,
66+
Ended,
67+
};
68+
6469
/// Inline descriptor embedded in structures and arrays.
6570
///
6671
/// Such descriptors precede all composite array elements and structure fields.
@@ -100,12 +105,14 @@ struct InlineDescriptor {
100105
LLVM_PREFERRED_TYPE(bool)
101106
unsigned IsArrayElement : 1;
102107

108+
Lifetime LifeState;
109+
103110
const Descriptor *Desc;
104111

105112
InlineDescriptor(const Descriptor *D)
106113
: Offset(sizeof(InlineDescriptor)), IsConst(false), IsInitialized(false),
107114
IsBase(false), IsActive(false), IsFieldMutable(false),
108-
IsArrayElement(false), Desc(D) {}
115+
IsArrayElement(false), LifeState(Lifetime::Started), Desc(D) {}
109116

110117
void dump() const { dump(llvm::errs()); }
111118
void dump(llvm::raw_ostream &OS) const;

clang/lib/AST/ByteCode/Disasm.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ LLVM_DUMP_METHOD void Descriptor::dump(llvm::raw_ostream &OS) const {
240240
else if (isRecord())
241241
OS << " record";
242242
else if (isPrimitive())
243-
OS << " primitive";
243+
OS << " primitive " << primTypeToString(getPrimType());
244244

245245
if (isZeroSizeArray())
246246
OS << " zero-size-array";

clang/lib/AST/ByteCode/Function.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ class Scope final {
5151
return llvm::make_range(Descriptors.begin(), Descriptors.end());
5252
}
5353

54+
llvm::iterator_range<LocalVectorTy::const_reverse_iterator>
55+
locals_reverse() const {
56+
return llvm::reverse(Descriptors);
57+
}
58+
5459
private:
5560
/// Object descriptors in this block.
5661
LocalVectorTy Descriptors;

clang/lib/AST/ByteCode/Interp.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,18 @@ bool CheckInitialized(InterpState &S, CodePtr OpPC, const Pointer &Ptr,
561561
return false;
562562
}
563563

564+
static bool CheckLifetime(InterpState &S, CodePtr OpPC, const Pointer &Ptr,
565+
AccessKinds AK) {
566+
if (Ptr.getLifetime() == Lifetime::Started)
567+
return true;
568+
569+
if (!S.checkingPotentialConstantExpression()) {
570+
S.FFDiag(S.Current->getSource(OpPC), diag::note_constexpr_access_uninit)
571+
<< AK << /*uninitialized=*/false << S.Current->getRange(OpPC);
572+
}
573+
return false;
574+
}
575+
564576
bool CheckGlobalInitialized(InterpState &S, CodePtr OpPC, const Pointer &Ptr) {
565577
if (Ptr.isInitialized())
566578
return true;
@@ -605,6 +617,8 @@ bool CheckLoad(InterpState &S, CodePtr OpPC, const Pointer &Ptr,
605617
return false;
606618
if (!CheckActive(S, OpPC, Ptr, AK))
607619
return false;
620+
if (!CheckLifetime(S, OpPC, Ptr, AK))
621+
return false;
608622
if (!CheckInitialized(S, OpPC, Ptr, AK))
609623
return false;
610624
if (!CheckTemporary(S, OpPC, Ptr, AK))
@@ -634,6 +648,8 @@ bool CheckFinalLoad(InterpState &S, CodePtr OpPC, const Pointer &Ptr) {
634648
return false;
635649
if (!CheckActive(S, OpPC, Ptr, AK_Read))
636650
return false;
651+
if (!CheckLifetime(S, OpPC, Ptr, AK_Read))
652+
return false;
637653
if (!CheckInitialized(S, OpPC, Ptr, AK_Read))
638654
return false;
639655
if (!CheckTemporary(S, OpPC, Ptr, AK_Read))
@@ -650,6 +666,8 @@ bool CheckStore(InterpState &S, CodePtr OpPC, const Pointer &Ptr) {
650666
return false;
651667
if (!CheckDummy(S, OpPC, Ptr, AK_Assign))
652668
return false;
669+
if (!CheckLifetime(S, OpPC, Ptr, AK_Assign))
670+
return false;
653671
if (!CheckExtern(S, OpPC, Ptr))
654672
return false;
655673
if (!CheckRange(S, OpPC, Ptr, AK_Assign))

clang/lib/AST/ByteCode/Interp.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,6 +1254,12 @@ bool GetLocal(InterpState &S, CodePtr OpPC, uint32_t I) {
12541254
return true;
12551255
}
12561256

1257+
static inline bool Kill(InterpState &S, CodePtr OpPC) {
1258+
const auto &Ptr = S.Stk.pop<Pointer>();
1259+
Ptr.endLifetime();
1260+
return true;
1261+
}
1262+
12571263
/// 1) Pops the value from the stack.
12581264
/// 2) Writes the value to the local variable with the
12591265
/// given offset.

clang/lib/AST/ByteCode/InterpFrame.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ void InterpFrame::initScope(unsigned Idx) {
9999
}
100100

101101
void InterpFrame::destroy(unsigned Idx) {
102-
for (auto &Local : Func->getScope(Idx).locals()) {
102+
for (auto &Local : Func->getScope(Idx).locals_reverse()) {
103103
S.deallocate(localBlock(Local.Offset));
104104
}
105105
}

clang/lib/AST/ByteCode/Opcodes.td

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,11 @@ def GetLocal : AccessOpcode { let HasCustomEval = 1; }
394394
// [] -> [Pointer]
395395
def SetLocal : AccessOpcode { let HasCustomEval = 1; }
396396

397+
def Kill : Opcode {
398+
let Types = [];
399+
let Args = [];
400+
}
401+
397402
def CheckDecl : Opcode {
398403
let Args = [ArgVarDecl];
399404
}

clang/lib/AST/ByteCode/Pointer.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,22 @@ class Pointer {
687687
/// Deactivates an entire strurcutre.
688688
void deactivate() const;
689689

690+
Lifetime getLifetime() const {
691+
if (!isBlockPointer())
692+
return Lifetime::Started;
693+
if (asBlockPointer().Base < sizeof(InlineDescriptor))
694+
return Lifetime::Started;
695+
return getInlineDesc()->LifeState;
696+
}
697+
698+
void endLifetime() const {
699+
if (!isBlockPointer())
700+
return;
701+
if (asBlockPointer().Base < sizeof(InlineDescriptor))
702+
return;
703+
getInlineDesc()->LifeState = Lifetime::Ended;
704+
}
705+
690706
/// Compare two pointers.
691707
ComparisonCategoryResult compare(const Pointer &Other) const {
692708
if (!hasSameBase(*this, Other))

clang/lib/Basic/Targets/AArch64.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,11 +323,19 @@ bool AArch64TargetInfo::validateGlobalRegisterVariable(
323323

324324
bool AArch64TargetInfo::validateBranchProtection(StringRef Spec, StringRef,
325325
BranchProtectionInfo &BPI,
326+
const LangOptions &LO,
326327
StringRef &Err) const {
327328
llvm::ARM::ParsedBranchProtection PBP;
328329
if (!llvm::ARM::parseBranchProtection(Spec, PBP, Err, HasPAuthLR))
329330
return false;
330331

332+
// GCS is currently untested with ptrauth-returns, but enabling this could be
333+
// allowed in future after testing with a suitable system.
334+
if (LO.PointerAuthReturns &&
335+
(PBP.Scope != "none" || PBP.BranchProtectionPAuthLR ||
336+
PBP.GuardedControlStack))
337+
return false;
338+
331339
BPI.SignReturnAddr =
332340
llvm::StringSwitch<LangOptions::SignReturnAddressScopeKind>(PBP.Scope)
333341
.Case("non-leaf", LangOptions::SignReturnAddressScopeKind::NonLeaf)

clang/lib/Basic/Targets/AArch64.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public TargetInfo {
132132

133133
bool validateBranchProtection(StringRef Spec, StringRef Arch,
134134
BranchProtectionInfo &BPI,
135+
const LangOptions &LO,
135136
StringRef &Err) const override;
136137

137138
bool isValidCPUName(StringRef Name) const override;

clang/lib/Basic/Targets/ARM.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,7 @@ bool ARMTargetInfo::isBranchProtectionSupportedArch(StringRef Arch) const {
405405

406406
bool ARMTargetInfo::validateBranchProtection(StringRef Spec, StringRef Arch,
407407
BranchProtectionInfo &BPI,
408+
const LangOptions &LO,
408409
StringRef &Err) const {
409410
llvm::ARM::ParsedBranchProtection PBP;
410411
if (!llvm::ARM::parseBranchProtection(Spec, PBP, Err))

clang/lib/Basic/Targets/ARM.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ class LLVM_LIBRARY_VISIBILITY ARMTargetInfo : public TargetInfo {
155155
bool isBranchProtectionSupportedArch(StringRef Arch) const override;
156156
bool validateBranchProtection(StringRef Spec, StringRef Arch,
157157
BranchProtectionInfo &BPI,
158+
const LangOptions &LO,
158159
StringRef &Err) const override;
159160

160161
// FIXME: This should be based on Arch attributes, not CPU names.

clang/lib/CodeGen/CGStmt.cpp

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3305,18 +3305,9 @@ CodeGenFunction::addConvergenceControlToken(llvm::CallBase *Input) {
33053305

33063306
llvm::ConvergenceControlInst *
33073307
CodeGenFunction::emitConvergenceLoopToken(llvm::BasicBlock *BB) {
3308-
CGBuilderTy::InsertPoint IP = Builder.saveIP();
3309-
if (BB->empty())
3310-
Builder.SetInsertPoint(BB);
3311-
else
3312-
Builder.SetInsertPoint(BB->getFirstInsertionPt());
3313-
3314-
llvm::CallBase *CB = Builder.CreateIntrinsic(
3315-
llvm::Intrinsic::experimental_convergence_loop, {}, {});
3316-
Builder.restoreIP(IP);
3317-
3318-
CB = addConvergenceControlToken(CB);
3319-
return cast<llvm::ConvergenceControlInst>(CB);
3308+
llvm::ConvergenceControlInst *ParentToken = ConvergenceTokenStack.back();
3309+
assert(ParentToken);
3310+
return llvm::ConvergenceControlInst::CreateLoop(*BB, ParentToken);
33203311
}
33213312

33223313
llvm::ConvergenceControlInst *
@@ -3329,13 +3320,5 @@ CodeGenFunction::getOrEmitConvergenceEntryToken(llvm::Function *F) {
33293320
// Adding a convergence token requires the function to be marked as
33303321
// convergent.
33313322
F->setConvergent();
3332-
3333-
CGBuilderTy::InsertPoint IP = Builder.saveIP();
3334-
Builder.SetInsertPoint(&BB->front());
3335-
llvm::CallBase *I = Builder.CreateIntrinsic(
3336-
llvm::Intrinsic::experimental_convergence_entry, {}, {});
3337-
assert(isa<llvm::IntrinsicInst>(I));
3338-
Builder.restoreIP(IP);
3339-
3340-
return cast<llvm::ConvergenceControlInst>(I);
3323+
return llvm::ConvergenceControlInst::CreateEntry(*BB);
33413324
}

clang/lib/CodeGen/Targets/AArch64.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@ class AArch64TargetCodeGenInfo : public TargetCodeGenInfo {
147147
CGM.getTarget().parseTargetAttr(TA->getFeaturesStr());
148148
if (!Attr.BranchProtection.empty()) {
149149
StringRef Error;
150-
(void)CGM.getTarget().validateBranchProtection(Attr.BranchProtection,
151-
Attr.CPU, BPI, Error);
150+
(void)CGM.getTarget().validateBranchProtection(
151+
Attr.BranchProtection, Attr.CPU, BPI, CGM.getLangOpts(), Error);
152152
assert(Error.empty());
153153
}
154154
}

clang/lib/CodeGen/Targets/ARM.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,8 @@ class ARMTargetCodeGenInfo : public TargetCodeGenInfo {
149149
StringRef DiagMsg;
150150
StringRef Arch =
151151
Attr.CPU.empty() ? CGM.getTarget().getTargetOpts().CPU : Attr.CPU;
152-
if (!CGM.getTarget().validateBranchProtection(Attr.BranchProtection,
153-
Arch, BPI, DiagMsg)) {
152+
if (!CGM.getTarget().validateBranchProtection(
153+
Attr.BranchProtection, Arch, BPI, CGM.getLangOpts(), DiagMsg)) {
154154
CGM.getDiags().Report(
155155
D->getLocation(),
156156
diag::warn_target_unsupported_branch_protection_attribute)

clang/lib/Driver/ToolChains/AMDGPU.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,24 @@ class LLVM_LIBRARY_VISIBILITY ROCMToolChain : public AMDGPUToolChain {
146146
getCommonDeviceLibNames(const llvm::opt::ArgList &DriverArgs,
147147
const std::string &GPUArch,
148148
bool isOpenMP = false) const;
149+
149150
SanitizerMask getSupportedSanitizers() const override {
150151
return SanitizerKind::Address;
151152
}
153+
154+
void diagnoseUnsupportedSanitizers(const llvm::opt::ArgList &Args) const {
155+
if (!Args.hasFlag(options::OPT_fgpu_sanitize, options::OPT_fno_gpu_sanitize,
156+
true))
157+
return;
158+
auto &Diags = getDriver().getDiags();
159+
for (auto *A : Args.filtered(options::OPT_fsanitize_EQ)) {
160+
SanitizerMask K =
161+
parseSanitizerValue(A->getValue(), /*Allow Groups*/ false);
162+
if (K != SanitizerKind::Address)
163+
Diags.Report(clang::diag::warn_drv_unsupported_option_for_target)
164+
<< A->getAsString(Args) << getTriple().str();
165+
}
166+
}
152167
};
153168

154169
} // end namespace toolchains

clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ AMDGPUOpenMPToolChain::AMDGPUOpenMPToolChain(const Driver &D,
3737
// Lookup binaries into the driver directory, this is used to
3838
// discover the 'amdgpu-arch' executable.
3939
getProgramPaths().push_back(getDriver().Dir);
40+
// Diagnose unsupported sanitizer options only once.
41+
diagnoseUnsupportedSanitizers(Args);
4042
}
4143

4244
void AMDGPUOpenMPToolChain::addClangTargetOptions(
@@ -71,10 +73,10 @@ llvm::opt::DerivedArgList *AMDGPUOpenMPToolChain::TranslateArgs(
7173

7274
const OptTable &Opts = getDriver().getOpts();
7375

74-
for (Arg *A : Args) {
75-
if (!llvm::is_contained(*DAL, A))
76+
for (Arg *A : Args)
77+
if (!shouldSkipSanitizeOption(*this, Args, BoundArch, A) &&
78+
!llvm::is_contained(*DAL, A))
7679
DAL->append(A);
77-
}
7880

7981
if (!BoundArch.empty()) {
8082
DAL->eraseArg(options::OPT_march_EQ);

0 commit comments

Comments
 (0)