Skip to content

Commit db1cec3

Browse files
Joao Moreiraphoebewang
authored andcommitted
[X86] Fix CodeGen Module Flag for -mibt-seal
When assertions are enabled, clang will perform RoundTrip for CompilerInvocation argument generation. ibt-seal flags are currently missing in this argument generation, and because of that, the feature doesn't get enabled for these cases. Performing RoundTrip is the default for assert builds, rendering the feature broken in these scenarios. This patch fixes this and adds a test to properly verify that modules are being generated with the flag when -mibt-seal is used. Please, add any known relevant reviewer which I may have missed. [1] - https://reviews.llvm.org/D116070 Reviewed By: pengfei, gftg, aaron.ballman, nickdesaulniers Differential Revision: https://reviews.llvm.org/D118052
1 parent c96cc50 commit db1cec3

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

clang/lib/Frontend/CompilerInvocation.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1504,6 +1504,9 @@ void CompilerInvocation::GenerateCodeGenArgs(
15041504
else if (Opts.CFProtectionBranch)
15051505
GenerateArg(Args, OPT_fcf_protection_EQ, "branch", SA);
15061506

1507+
if (Opts.IBTSeal)
1508+
GenerateArg(Args, OPT_mibt_seal, SA);
1509+
15071510
for (const auto &F : Opts.LinkBitcodeFiles) {
15081511
bool Builtint = F.LinkFlags == llvm::Linker::Flags::LinkOnlyNeeded &&
15091512
F.PropagateAttrs && F.Internalize;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
// RUN: %clang -target i386-unknown-unknown -x c -E -dM -o - -fcf-protection=return %s | FileCheck %s --check-prefix=RETURN
22
// RUN: %clang -target i386-unknown-unknown -x c -E -dM -o - -fcf-protection=branch %s | FileCheck %s --check-prefix=BRANCH
33
// RUN: %clang -target i386-unknown-unknown -x c -E -dM -o - -fcf-protection=full %s | FileCheck %s --check-prefix=FULL
4+
// RUN: %clang -target i386-unknown-unknown -o - -emit-llvm -S -fcf-protection=branch -mibt-seal -flto %s | FileCheck %s --check-prefixes=CFPROT,IBTSEAL
5+
// RUN: %clang -target i386-unknown-unknown -o - -emit-llvm -S -fcf-protection=branch -flto %s | FileCheck %s --check-prefixes=CFPROT,NOIBTSEAL
6+
// RUN: %clang -target i386-unknown-unknown -o - -emit-llvm -S -fcf-protection=branch -mibt-seal %s | FileCheck %s --check-prefixes=CFPROT,NOIBTSEAL
47

58
// RETURN: #define __CET__ 2
69
// BRANCH: #define __CET__ 1
710
// FULL: #define __CET__ 3
11+
// CFPROT: "cf-protection-branch", i32 1
12+
// IBTSEAL: "ibt-seal", i32 1
13+
// NOIBTSEAL-NOT: "ibt-seal", i32 1
814
void foo() {}

0 commit comments

Comments
 (0)