Alexander Ivchenko | 5c54742 | 2018-05-18 11:58:25 +0000 | [diff] [blame] | 1 | ; RUN: llc -mtriple=x86_64-unknown-unknown -x86-indirect-branch-tracking < %s | FileCheck %s |
Oren Ben Simhon | fdd72fd | 2018-03-17 13:29:46 +0000 | [diff] [blame] | 2 | |
| 3 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 4 | ;; This test verify the handling of ''nocf_check'' attribute by the backend. ;; |
| 5 | ;; The file was generated using the following C code: ;; |
| 6 | ;; ;; |
| 7 | ;; void __attribute__((nocf_check)) NoCfCheckFunc(void) {} ;; |
| 8 | ;; ;; |
| 9 | ;; typedef void(*FuncPointer)(void); ;; |
| 10 | ;; void NoCfCheckCall(FuncPointer f) { ;; |
| 11 | ;; __attribute__((nocf_check)) FuncPointer p = f; ;; |
| 12 | ;; (*p)(); ;; |
| 13 | ;; } ;; |
| 14 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 15 | |
| 16 | ; Make sure that a function with ''nocf_check'' attribute is not instrumented |
| 17 | ; with endbr instruction at the beginning. |
| 18 | define void @NoCfCheckFunc() #0 { |
| 19 | ; CHECK-LABEL: NoCfCheckFunc |
| 20 | ; CHECK-NOT: endbr64 |
| 21 | ; CHECK: retq |
| 22 | entry: |
| 23 | ret void |
| 24 | } |
| 25 | |
| 26 | ; Make sure that notrack prefix is added before a call with ''nocf_check'' attribute. |
| 27 | define void @NoCfCheckCall(void ()* %f) { |
| 28 | ; CHECK-LABEL: NoCfCheckCall |
| 29 | ; CHECK: notrack call |
| 30 | entry: |
| 31 | %f.addr = alloca void ()*, align 4 |
| 32 | %p = alloca void ()*, align 4 |
| 33 | store void ()* %f, void ()** %f.addr, align 4 |
| 34 | %0 = load void ()*, void ()** %f.addr, align 4 |
| 35 | store void ()* %0, void ()** %p, align 4 |
| 36 | %1 = load void ()*, void ()** %p, align 4 |
| 37 | call void %1() #1 |
| 38 | ret void |
| 39 | } |
| 40 | |
| 41 | attributes #0 = { noinline nocf_check nounwind optnone "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-features"="+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } |
| 42 | attributes #1 = { nocf_check } |
| 43 | |
| 44 | !llvm.module.flags = !{!0} |
| 45 | |
| 46 | !0 = !{i32 4, !"cf-protection-branch", i32 1} |