Skip to content
This repository was archived by the owner on Sep 15, 2025. It is now read-only.

Commit 4253723

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:efad561890ad3584c38adae913f9939384eb804c into amd-gfx:4b0f66167c79
Local branch amd-gfx 4b0f661 Merged main:8f96be921c1a97594ee94c2789cee9b131525f63 into amd-gfx:c7b3b9d8ffb4 Remote branch main efad561 [LLD][COFF] Add support for range extension thunks for ARM64EC targets. (llvm#106289)
2 parents 4b0f661 + efad561 commit 4253723

File tree

29 files changed

+653
-87
lines changed

29 files changed

+653
-87
lines changed

clang/include/clang/CodeGen/CodeGenAction.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class CodeGenAction : public ASTFrontendAction {
5757
bool loadLinkModules(CompilerInstance &CI);
5858

5959
protected:
60-
bool BeginSourceFileAction(CompilerInstance &CI) override;
60+
bool BeginInvocation(CompilerInstance &CI) override;
6161

6262
/// Create a new code generation action. If the optional \p _VMContext
6363
/// parameter is supplied, the action uses it without taking ownership,

clang/include/clang/Frontend/FrontendActions.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,13 @@ class GenerateModuleFromModuleMapAction : public GenerateModuleAction {
152152
CreateOutputFile(CompilerInstance &CI, StringRef InFile) override;
153153
};
154154

155+
bool BeginInvocationForModules(CompilerInstance &CI);
156+
155157
/// Generates full BMI (which contains full information to generate the object
156158
/// files) for C++20 Named Modules.
157159
class GenerateModuleInterfaceAction : public GenerateModuleAction {
158160
protected:
159-
bool BeginSourceFileAction(CompilerInstance &CI) override;
161+
bool BeginInvocation(CompilerInstance &CI) override;
160162

161163
std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
162164
StringRef InFile) override;

clang/include/clang/Serialization/ASTWriter.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -500,8 +500,8 @@ class ASTWriter : public ASTDeserializationListener,
500500
std::vector<SourceRange> NonAffectingRanges;
501501
std::vector<SourceLocation::UIntTy> NonAffectingOffsetAdjustments;
502502

503-
/// A list of classes which need to emit the VTable in the corresponding
504-
/// object file.
503+
/// A list of classes in named modules which need to emit the VTable in
504+
/// the corresponding object file.
505505
llvm::SmallVector<CXXRecordDecl *> PendingEmittingVTables;
506506

507507
/// Computes input files that didn't affect compilation of the current module,

clang/include/clang/Serialization/ModuleFile.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,13 @@ class InputFile {
8888

8989
InputFile(FileEntryRef File, bool isOverridden = false,
9090
bool isOutOfDate = false) {
91-
assert(!(isOverridden && isOutOfDate) &&
92-
"an overridden cannot be out-of-date");
9391
unsigned intVal = 0;
94-
if (isOverridden)
95-
intVal = Overridden;
96-
else if (isOutOfDate)
92+
// Make isOutOfDate with higher priority than isOverridden.
93+
// It is possible if the recorded hash value mismatches.
94+
if (isOutOfDate)
9795
intVal = OutOfDate;
96+
else if (isOverridden)
97+
intVal = Overridden;
9898
Val.setPointerAndInt(&File.getMapEntry(), intVal);
9999
}
100100

clang/lib/CodeGen/CodeGenAction.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -969,9 +969,10 @@ CodeGenerator *CodeGenAction::getCodeGenerator() const {
969969
return BEConsumer->getCodeGenerator();
970970
}
971971

972-
bool CodeGenAction::BeginSourceFileAction(CompilerInstance &CI) {
972+
bool CodeGenAction::BeginInvocation(CompilerInstance &CI) {
973973
if (CI.getFrontendOpts().GenReducedBMI)
974-
CI.getLangOpts().setCompilingModule(LangOptions::CMK_ModuleInterface);
974+
return BeginInvocationForModules(CI);
975+
975976
return true;
976977
}
977978

clang/lib/Driver/ToolChain.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,12 @@ static void getAArch64MultilibFlags(const Driver &D,
221221
assert(!ArchName.empty() && "at least one architecture should be found");
222222
MArch.insert(MArch.begin(), ("-march=" + ArchName).str());
223223
Result.push_back(llvm::join(MArch, "+"));
224+
225+
const Arg *BranchProtectionArg =
226+
Args.getLastArgNoClaim(options::OPT_mbranch_protection_EQ);
227+
if (BranchProtectionArg) {
228+
Result.push_back(BranchProtectionArg->getAsString(Args));
229+
}
224230
}
225231

226232
static void getARMMultilibFlags(const Driver &D,
@@ -268,6 +274,12 @@ static void getARMMultilibFlags(const Driver &D,
268274
case arm::FloatABI::Invalid:
269275
llvm_unreachable("Invalid float ABI");
270276
}
277+
278+
const Arg *BranchProtectionArg =
279+
Args.getLastArgNoClaim(options::OPT_mbranch_protection_EQ);
280+
if (BranchProtectionArg) {
281+
Result.push_back(BranchProtectionArg->getAsString(Args));
282+
}
271283
}
272284

273285
static void getRISCVMultilibFlags(const Driver &D, const llvm::Triple &Triple,

clang/lib/Frontend/FrontendActions.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,11 +262,20 @@ GenerateModuleFromModuleMapAction::CreateOutputFile(CompilerInstance &CI,
262262
/*ForceUseTemporary=*/true);
263263
}
264264

265-
bool GenerateModuleInterfaceAction::BeginSourceFileAction(
266-
CompilerInstance &CI) {
265+
bool clang::BeginInvocationForModules(CompilerInstance &CI) {
266+
// Embed all module files for named modules.
267+
// See https://github.com/llvm/llvm-project/issues/72383 for discussion.
268+
CI.getFrontendOpts().ModulesEmbedAllFiles = true;
267269
CI.getLangOpts().setCompilingModule(LangOptions::CMK_ModuleInterface);
270+
return true;
271+
}
268272

269-
return GenerateModuleAction::BeginSourceFileAction(CI);
273+
bool GenerateModuleInterfaceAction::BeginInvocation(
274+
CompilerInstance &CI) {
275+
if (!BeginInvocationForModules(CI))
276+
return false;
277+
278+
return GenerateModuleAction::BeginInvocation(CI);
270279
}
271280

272281
std::unique_ptr<ASTConsumer>

clang/lib/Serialization/ASTWriter.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3963,6 +3963,9 @@ void ASTWriter::WriteIdentifierTable(Preprocessor &PP,
39633963
}
39643964

39653965
void ASTWriter::handleVTable(CXXRecordDecl *RD) {
3966+
if (!RD->isInNamedModule())
3967+
return;
3968+
39663969
PendingEmittingVTables.push_back(RD);
39673970
}
39683971

clang/test/Driver/print-multi-selection-flags.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@
5959
// CHECK-SVE2: --target=aarch64-unknown-none-elf
6060
// CHECK-SVE2: -march=armv{{.*}}-a{{.*}}+simd{{.*}}+sve{{.*}}+sve2{{.*}}
6161

62+
// RUN: %clang -print-multi-flags-experimental --target=arm-none-eabi -mbranch-protection=standard | FileCheck --check-prefix=CHECK-BRANCH-PROTECTION %s
63+
// RUN: %clang -print-multi-flags-experimental --target=aarch64-none-elf -mbranch-protection=standard | FileCheck --check-prefix=CHECK-BRANCH-PROTECTION %s
64+
// CHECK-BRANCH-PROTECTION: -mbranch-protection=standard
65+
6266
// RUN: %clang -print-multi-flags-experimental --target=riscv32-none-elf -march=rv32g | FileCheck --check-prefix=CHECK-RV32 %s
6367
// CHECK-RV32: --target=riscv32-unknown-none-elf
6468
// CHECK-RV32: -mabi=ilp32d

clang/test/Modules/no-local-decl-in-reduced-bmi.cppm

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
//
77
// RUN: %clang_cc1 -std=c++20 %t/a.cppm -emit-reduced-module-interface -o %t/a.pcm
88
// RUN: llvm-bcanalyzer --dump --disable-histogram --show-binary-blobs %t/a.pcm > %t/a.dump
9-
// RUN: cat %t/a.dump | FileCheck %t/a.cppm
9+
// RUN: cat %t/a.dump | FileCheck %t/a.check
1010
//
1111
// RUN: %clang_cc1 -std=c++20 %t/b.cppm -emit-reduced-module-interface -o %t/b.pcm
1212
// RUN: llvm-bcanalyzer --dump --disable-histogram --show-binary-blobs %t/b.pcm > %t/b.dump
13-
// RUN: cat %t/b.dump | FileCheck %t/b.cppm
13+
// RUN: cat %t/b.dump | FileCheck %t/b.check
1414

1515
//--- a.cppm
1616
export module a;
@@ -19,6 +19,9 @@ export int func() {
1919
return 43;
2020
}
2121

22+
//--- a.check
23+
// Use a standalone check file since now we're going to embed all source files in the BMI
24+
// so we will check the `CHECK-NOT: <DECL_VAR` in the source file otherwise.
2225
// Test that the variable declaration is not recorded completely.
2326
// CHECK-NOT: <DECL_VAR
2427

@@ -29,5 +32,6 @@ export inline int func() {
2932
return v;
3033
}
3134

35+
//--- b.check
3236
// Check that we still records the declaration from inline functions.
3337
// CHECK: <DECL_VAR

0 commit comments

Comments
 (0)