Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable IBT(Indirect Branch Tracking) in JIT with CET(Control-flow Enf…
…orcement Technology) Summary: This patch comes from H.J.'s hjl-tools@2bd54ce **This patch fix the failed llvm unit tests which running on CET machine. **(e.g. ExecutionEngine/MCJIT/MCJITTests) The reason we enable IBT at "JIT compiled with CET" is mainly that: the JIT don't know the its caller program is CET enable or not. If JIT's caller program is non-CET, it is no problem JIT generate CET code or not. But if JIT's caller program is CET enabled, JIT must generate CET code or it will cause Control protection exceptions. I have test the patch at llvm-unit-test and llvm-test-suite at CET machine. It passed. and H.J. also test it at building and running VNCserver(Virtual Network Console), it works too. (if not apply this patch, VNCserver will crash at CET machine.) Reviewers: hjl.tools, craig.topper, LuoYuanke, annita.zhang, pengfei Subscribers: tstellar, efriedma, hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D76900
- Loading branch information
Showing
5 changed files
with
92 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
llvm/test/CodeGen/X86/indirect-branch-tracking-cm-lager.ll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
; RUN: llc -mtriple=x86_64-unknown-unknown -code-model=large < %s | FileCheck %s | ||
|
||
; In large code model indirect branches are needed when branching to addresses | ||
; whose offset from the current instruction pointer is unknown. | ||
;CHECK-COUNT-3: endbr | ||
|
||
@a = dso_local local_unnamed_addr global i32 1, align 4 | ||
|
||
; Function Attrs: nofree noinline norecurse nounwind uwtable writeonly | ||
define dso_local void @ext() local_unnamed_addr #0 { | ||
entry: | ||
store i32 0, i32* @a, align 4 | ||
ret void | ||
} | ||
|
||
; Function Attrs: nofree norecurse nounwind uwtable | ||
define dso_local i32 @main() local_unnamed_addr #1 { | ||
entry: | ||
tail call fastcc void @foo() | ||
%0 = load i32, i32* @a, align 4 | ||
ret i32 %0 | ||
} | ||
|
||
; Function Attrs: nofree noinline norecurse nounwind uwtable writeonly | ||
define internal fastcc void @foo() unnamed_addr #0 { | ||
entry: | ||
tail call void @ext() | ||
ret void | ||
} | ||
|
||
!llvm.module.flags = !{!0, !1, !2, !3} | ||
|
||
!0 = !{i32 1, !"wchar_size", i32 4} | ||
!1 = !{i32 4, !"cf-protection-return", i32 1} | ||
!2 = !{i32 4, !"cf-protection-branch", i32 1} | ||
!3 = !{i32 1, !"Code Model", i32 4} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
; RUN: %lli -code-model=large %s > /dev/null | ||
target triple = "x86_64-unknown-linux-gnu" | ||
|
||
@a = dso_local local_unnamed_addr global i32 1, align 4 | ||
|
||
; Function Attrs: nofree noinline norecurse nounwind uwtable writeonly | ||
define dso_local void @ext() local_unnamed_addr #0 { | ||
entry: | ||
store i32 0, i32* @a, align 4 | ||
ret void | ||
} | ||
|
||
; Function Attrs: nofree norecurse nounwind uwtable | ||
define dso_local i32 @main() local_unnamed_addr #1 { | ||
entry: | ||
tail call fastcc void @foo() | ||
%0 = load i32, i32* @a, align 4 | ||
ret i32 %0 | ||
} | ||
|
||
; Function Attrs: nofree noinline norecurse nounwind uwtable writeonly | ||
define internal fastcc void @foo() unnamed_addr #0 { | ||
entry: | ||
tail call void @ext() | ||
ret void | ||
} | ||
|
||
!llvm.module.flags = !{!0, !1, !2, !3} | ||
|
||
!0 = !{i32 1, !"wchar_size", i32 4} | ||
!1 = !{i32 4, !"cf-protection-return", i32 1} | ||
!2 = !{i32 4, !"cf-protection-branch", i32 1} | ||
!3 = !{i32 1, !"Code Model", i32 4} |