Skip to content

Commit d61d89d

Browse files
committed
[clang] Unify -mspeculative-load-hardening as a benign compiler option (llvm#166640)
Before this patch, compilations using modules & `-mspeculative-load-hardening` failed because it was not consistent whether this option impacts module compatibility. This repairs it by always treating it as benign. This was determined by checking if the option enables any kind of preprocessor checks and comparing how the compiler handles a similar option that impacts codegen (-fvisibility=hidden) but is more widely used. resolves: rdar://163985667 (cherry picked from commit e700f15)
1 parent e01cc9a commit d61d89d

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

clang/include/clang/Basic/LangOptions.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ LANGOPT(BranchTargetEnforcement, 1, 0, NotCompatible, "Branch-target enforcement
463463
LANGOPT(BranchProtectionPAuthLR, 1, 0, NotCompatible, "Use PC as a diversifier using PAuthLR NOP instructions.")
464464
LANGOPT(GuardedControlStack, 1, 0, NotCompatible, "Guarded control stack enabled")
465465

466-
LANGOPT(SpeculativeLoadHardening, 1, 0, NotCompatible, "Speculative load hardening enabled")
466+
LANGOPT(SpeculativeLoadHardening, 1, 0, Benign, "Speculative load hardening enabled")
467467

468468
LANGOPT(RelativeCXXABIVTables, 1, 0, NotCompatible,
469469
"Use an ABI-incompatible v-table layout that uses relative references")

clang/test/ClangScanDeps/strip-codegen-args.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
// CHECK-NOT: "-flto"
1717
// CHECK-NOT: "-fno-autolink"
1818
// CHECK-NOT: "-mrelax-relocations=no"
19+
// CHECK-NOT: "-mspeculative-load-hardening"
1920
// CHECK: ]
2021
// CHECK: "name": "A"
2122
// CHECK: }
@@ -39,6 +40,11 @@
3940
"command": "clang -Imodules/A -fmodules -fmodules-cache-path=DIR/module-cache -fimplicit-modules -O2 -flto=full -fsyntax-only DIR/t3.m",
4041
"file": "DIR/t2.m"
4142
}
43+
{
44+
"directory": "DIR",
45+
"command": "clang -Imodules/A -fmodules -fmodules-cache-path=DIR/module-cache -fimplicit-modules -O2 -mspeculative-load-hardening -fsyntax-only DIR/t3.m",
46+
"file": "DIR/t3.m"
47+
}
4248
]
4349

4450
//--- modules/A/module.modulemap

0 commit comments

Comments
 (0)