1 ; RUN: llc -mtriple=x86_64-unknown-unknown -x86-indirect-branch-tracking < %s | FileCheck %s
3 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4 ;; This test verify the handling of ''nocf_check'' attribute by the backend. ;;
5 ;; The file was generated using the following C code: ;;
7 ;; void __attribute__((nocf_check)) NoCfCheckFunc(void) {} ;;
9 ;; typedef void(*FuncPointer)(void); ;;
10 ;; void NoCfCheckCall(FuncPointer f) { ;;
11 ;; __attribute__((nocf_check)) FuncPointer p = f; ;;
13 ;; NoCfCheckFunc(); ;;
15 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
17 ; Make sure that a function with ''nocf_check'' attribute is not instrumented
18 ; with endbr instruction at the beginning.
19 define void @NoCfCheckFunc() #0 {
20 ; CHECK-LABEL: NoCfCheckFunc
27 ; Ensure the notrack prefix is added before an indirect call using a pointer
28 ; with ''nocf_check'' attribute. Also ensure a direct call to a function with
29 ; the ''nocf_check'' attribute is correctly generated without notrack prefix.
30 define void @NoCfCheckCall(ptr %f) #1 {
31 ; CHECK-LABEL: NoCfCheckCall
33 ; CHECK: callq NoCfCheckFunc
35 %f.addr = alloca ptr, align 4
36 %p = alloca ptr, align 4
37 store ptr %f, ptr %f.addr, align 4
38 %0 = load ptr, ptr %f.addr, align 4
39 store ptr %0, ptr %p, align 4
40 %1 = load ptr, ptr %p, align 4
42 call void @NoCfCheckFunc() #2
46 attributes #0 = { nocf_check noinline nounwind optnone uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" "unsafe-fp-math"="false" "use-soft-float"="false" }
47 attributes #1 = { noinline nounwind optnone uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" "unsafe-fp-math"="false" "use-soft-float"="false" }
48 attributes #2 = { nocf_check }
50 !llvm.module.flags = !{!0}
52 !0 = !{i32 8, !"cf-protection-branch", i32 1}