1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-02-01 05:01:59 +01:00
llvm-mirror/test/CodeGen/X86/indirect-branch-tracking-cm-lager.ll
Xiang1 Zhang 289e4deed8 Enable IBT(Indirect Branch Tracking) in JIT with CET(Control-flow Enforcement Technology)
Do not commit the llvm/test/ExecutionEngine/MCJIT/cet-code-model-lager.ll because it will
cause build bot fail(not suitable for window 32 target).

Summary:
This patch comes from H.J.'s 2bd54ce7fa

**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

Reviewed By: LuoYuanke

Subscribers: tstellar, efriedma, hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D76900
2020-04-07 09:48:47 +08:00

37 lines
1.0 KiB
LLVM

; 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}