Skip to content

Commit 784d5f9

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merge upstream LLVM into amd-gfx12
2 parents 5e9eb50 + 68152f1 commit 784d5f9

File tree

81 files changed

+1184
-651
lines changed

Some content is hidden

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

81 files changed

+1184
-651
lines changed

.github/workflows/libcxx-build-and-test.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ jobs:
128128
'generic-abi-unstable',
129129
'generic-hardening-mode-debug',
130130
'generic-hardening-mode-extensive',
131+
'generic-hardening-mode-extensive-observe-semantic',
131132
'generic-hardening-mode-fast',
132133
'generic-hardening-mode-fast-with-abi-breaks',
133134
'generic-merged',

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9331,8 +9331,28 @@ def err_atomic_builtin_pointer_size : Error<
93319331
"address argument to atomic builtin must be a pointer to 1,2,4,8 or 16 byte "
93329332
"type (%0 invalid)">;
93339333
def err_atomic_exclusive_builtin_pointer_size : Error<
9334-
"address argument to load or store exclusive builtin must be a pointer to"
9335-
" 1,2,4 or 8 byte type (%0 invalid)">;
9334+
"address argument to load or store exclusive builtin must be a pointer to "
9335+
// Because the range of legal sizes for load/store exclusive varies with the
9336+
// Arm architecture version, this error message wants to be able to specify
9337+
// various different subsets of the sizes 1, 2, 4, 8. Rather than make a
9338+
// separate diagnostic for each subset, I've arranged here that _this_ error
9339+
// can display any combination of the sizes. For each size there are two
9340+
// %select parameters: the first chooses whether you need a "," or " or " to
9341+
// separate the number from a previous one (or neither), and the second
9342+
// parameter indicates whether to display the number itself.
9343+
//
9344+
// (The very first of these parameters isn't really necessary, since you
9345+
// never want to start with "," or " or " before the first number in the
9346+
// list, but it keeps it simple to make it look exactly like the other cases,
9347+
// and also allows a loop constructing this diagnostic to handle every case
9348+
// exactly the same.)
9349+
"%select{|,| or }1%select{|1}2"
9350+
"%select{|,| or }3%select{|2}4"
9351+
"%select{|,| or }5%select{|4}6"
9352+
"%select{|,| or }7%select{|8}8"
9353+
" byte type (%0 invalid)">;
9354+
def err_atomic_exclusive_builtin_pointer_size_none : Error<
9355+
"load and store exclusive builtins are not available on this architecture">;
93369356
def err_atomic_builtin_ext_int_size : Error<
93379357
"atomic memory operand must have a power-of-two size">;
93389358
def err_atomic_builtin_bit_int_prohibit : Error<

clang/include/clang/Basic/TargetInfo.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,6 +1071,17 @@ class TargetInfo : public TransferrableTargetInfo,
10711071
/// as Custom Datapath.
10721072
uint32_t getARMCDECoprocMask() const { return ARMCDECoprocMask; }
10731073

1074+
/// For ARM targets returns a mask defining which data sizes are suitable for
1075+
/// __builtin_arm_ldrex and __builtin_arm_strex.
1076+
enum {
1077+
ARM_LDREX_B = (1 << 0), /// byte (8-bit)
1078+
ARM_LDREX_H = (1 << 1), /// half (16-bit)
1079+
ARM_LDREX_W = (1 << 2), /// word (32-bit)
1080+
ARM_LDREX_D = (1 << 3), /// double (64-bit)
1081+
};
1082+
1083+
virtual unsigned getARMLDREXMask() const { return 0; }
1084+
10741085
/// Returns whether the passed in string is a valid clobber in an
10751086
/// inline asm statement.
10761087
///

clang/include/clang/Frontend/FrontendAction.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ class FrontendAction {
8484
/// \return True on success; on failure ExecutionAction() and
8585
/// EndSourceFileAction() will not be called.
8686
virtual bool BeginSourceFileAction(CompilerInstance &CI) {
87+
if (CurrentInput.isPreprocessed())
88+
CI.getPreprocessor().SetMacroExpansionOnlyInDirectives();
8789
return true;
8890
}
8991

@@ -98,7 +100,11 @@ class FrontendAction {
98100
///
99101
/// This is guaranteed to only be called following a successful call to
100102
/// BeginSourceFileAction (and BeginSourceFile).
101-
virtual void EndSourceFileAction() {}
103+
virtual void EndSourceFileAction() {
104+
if (CurrentInput.isPreprocessed())
105+
// Reset the preprocessor macro expansion to the default.
106+
getCompilerInstance().getPreprocessor().SetEnableMacroExpansion();
107+
}
102108

103109
/// Callback at the end of processing a single input, to determine
104110
/// if the output files should be erased or not.

clang/include/clang/Lex/Preprocessor.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1847,6 +1847,10 @@ class Preprocessor {
18471847
MacroExpansionInDirectivesOverride = true;
18481848
}
18491849

1850+
void SetEnableMacroExpansion() {
1851+
DisableMacroExpansion = MacroExpansionInDirectivesOverride = false;
1852+
}
1853+
18501854
/// Peeks ahead N tokens and returns that token without consuming any
18511855
/// tokens.
18521856
///

clang/include/clang/Sema/SemaARM.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ class SemaARM : public SemaBase {
4444

4545
bool CheckImmediateArg(CallExpr *TheCall, unsigned CheckTy, unsigned ArgIdx,
4646
unsigned EltBitWidth, unsigned VecBitWidth);
47-
bool CheckARMBuiltinExclusiveCall(unsigned BuiltinID, CallExpr *TheCall,
48-
unsigned MaxWidth);
47+
bool CheckARMBuiltinExclusiveCall(const TargetInfo &TI, unsigned BuiltinID,
48+
CallExpr *TheCall);
4949
bool CheckNeonBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID,
5050
CallExpr *TheCall);
5151
bool PerformNeonImmChecks(

clang/lib/Basic/Targets/ARM.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -618,21 +618,21 @@ bool ARMTargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
618618
LDREX = 0;
619619
else if (ArchKind == llvm::ARM::ArchKind::ARMV6K ||
620620
ArchKind == llvm::ARM::ArchKind::ARMV6KZ)
621-
LDREX = LDREX_D | LDREX_W | LDREX_H | LDREX_B;
621+
LDREX = ARM_LDREX_D | ARM_LDREX_W | ARM_LDREX_H | ARM_LDREX_B;
622622
else
623-
LDREX = LDREX_W;
623+
LDREX = ARM_LDREX_W;
624624
break;
625625
case 7:
626626
case 8:
627627
if (ArchProfile == llvm::ARM::ProfileKind::M)
628-
LDREX = LDREX_W | LDREX_H | LDREX_B;
628+
LDREX = ARM_LDREX_W | ARM_LDREX_H | ARM_LDREX_B;
629629
else
630-
LDREX = LDREX_D | LDREX_W | LDREX_H | LDREX_B;
630+
LDREX = ARM_LDREX_D | ARM_LDREX_W | ARM_LDREX_H | ARM_LDREX_B;
631631
break;
632632
case 9:
633633
assert(ArchProfile != llvm::ARM::ProfileKind::M &&
634634
"No Armv9-M architectures defined");
635-
LDREX = LDREX_D | LDREX_W | LDREX_H | LDREX_B;
635+
LDREX = ARM_LDREX_D | ARM_LDREX_W | ARM_LDREX_H | ARM_LDREX_B;
636636
}
637637

638638
if (!(FPU & NeonFPU) && FPMath == FP_Neon) {

clang/lib/Basic/Targets/ARM.h

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,6 @@ class LLVM_LIBRARY_VISIBILITY ARMTargetInfo : public TargetInfo {
9898
LLVM_PREFERRED_TYPE(bool)
9999
unsigned HasBTI : 1;
100100

101-
enum {
102-
LDREX_B = (1 << 0), /// byte (8-bit)
103-
LDREX_H = (1 << 1), /// half (16-bit)
104-
LDREX_W = (1 << 2), /// word (32-bit)
105-
LDREX_D = (1 << 3), /// double (64-bit)
106-
};
107-
108101
uint32_t LDREX;
109102

110103
// ACLE 6.5.1 Hardware floating point
@@ -225,6 +218,8 @@ class LLVM_LIBRARY_VISIBILITY ARMTargetInfo : public TargetInfo {
225218

226219
bool hasBitIntType() const override { return true; }
227220

221+
unsigned getARMLDREXMask() const override { return LDREX; }
222+
228223
const char *getBFloat16Mangling() const override { return "u6__bf16"; };
229224

230225
std::pair<unsigned, unsigned> hardwareInterferenceSizes() const override {

clang/lib/CodeGen/CodeGenAction.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -908,6 +908,8 @@ bool CodeGenAction::loadLinkModules(CompilerInstance &CI) {
908908
bool CodeGenAction::hasIRSupport() const { return true; }
909909

910910
void CodeGenAction::EndSourceFileAction() {
911+
ASTFrontendAction::EndSourceFileAction();
912+
911913
// If the consumer creation failed, do nothing.
912914
if (!getCompilerInstance().hasASTConsumer())
913915
return;
@@ -932,7 +934,7 @@ CodeGenerator *CodeGenAction::getCodeGenerator() const {
932934
bool CodeGenAction::BeginSourceFileAction(CompilerInstance &CI) {
933935
if (CI.getFrontendOpts().GenReducedBMI)
934936
CI.getLangOpts().setCompilingModule(LangOptions::CMK_ModuleInterface);
935-
return true;
937+
return ASTFrontendAction::BeginSourceFileAction(CI);
936938
}
937939

938940
static std::unique_ptr<raw_pwrite_stream>

clang/lib/Frontend/FrontendActions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ bool GeneratePCHAction::shouldEraseOutputFiles() {
181181

182182
bool GeneratePCHAction::BeginSourceFileAction(CompilerInstance &CI) {
183183
CI.getLangOpts().CompilingPCH = true;
184-
return true;
184+
return ASTFrontendAction::BeginSourceFileAction(CI);
185185
}
186186

187187
std::vector<std::unique_ptr<ASTConsumer>>

0 commit comments

Comments
 (0)