|
| 1 | +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-globals --include-generated-funcs |
| 2 | +;; Test jump table generation with Indirect Branch Tracking on x86. |
| 3 | +; RUN: opt -S -passes=lowertypetests -mtriple=i686 %s | FileCheck --check-prefixes=X86_32 %s |
| 4 | +; RUN: opt -S -passes=lowertypetests -mtriple=x86_64 %s | FileCheck --check-prefixes=X86_64 %s |
| 5 | + |
| 6 | +@0 = private unnamed_addr constant [2 x ptr] [ptr @f, ptr @g], align 16 |
| 7 | + |
| 8 | +define void @f() !type !0 { |
| 9 | + ret void |
| 10 | +} |
| 11 | + |
| 12 | +define internal void @g() !type !0 { |
| 13 | + ret void |
| 14 | +} |
| 15 | + |
| 16 | +declare i1 @llvm.type.test(ptr %ptr, metadata %bitset) nounwind readnone |
| 17 | + |
| 18 | +define i1 @foo(ptr %p) { |
| 19 | + %x = call i1 @llvm.type.test(ptr %p, metadata !"typeid1") |
| 20 | + ret i1 %x |
| 21 | +} |
| 22 | + |
| 23 | +!llvm.module.flags = !{!1, !2, !3} |
| 24 | +!0 = !{i32 0, !"typeid1"} |
| 25 | +!1 = !{i32 8, !"cf-protection-branch", i32 1} |
| 26 | +!2 = !{i32 7, !"Dwarf Version", i32 5} |
| 27 | +!3 = !{i32 2, !"Debug Info Version", i32 3} |
| 28 | + |
| 29 | + |
| 30 | +;. |
| 31 | +; X86_32: @[[GLOB0:[0-9]+]] = private unnamed_addr constant [2 x ptr] [ptr @f, ptr @g], align 16 |
| 32 | +; X86_32: @[[GLOB1:[0-9]+]] = private constant [0 x i8] zeroinitializer |
| 33 | +; X86_32: @f = alias [16 x i8], ptr @.cfi.jumptable |
| 34 | +; X86_32: @g = internal alias [16 x i8], getelementptr inbounds ([2 x [16 x i8]], ptr @.cfi.jumptable, i32 0, i32 1) |
| 35 | +;. |
| 36 | +; X86_64: @[[GLOB0:[0-9]+]] = private unnamed_addr constant [2 x ptr] [ptr @f, ptr @g], align 16 |
| 37 | +; X86_64: @[[GLOB1:[0-9]+]] = private constant [0 x i8] zeroinitializer |
| 38 | +; X86_64: @f = alias [16 x i8], ptr @.cfi.jumptable |
| 39 | +; X86_64: @g = internal alias [16 x i8], getelementptr inbounds ([2 x [16 x i8]], ptr @.cfi.jumptable, i64 0, i64 1) |
| 40 | +;. |
| 41 | +; X86_32-LABEL: @f.cfi( |
| 42 | +; X86_32-NEXT: ret void |
| 43 | +; |
| 44 | +; |
| 45 | +; X86_32-LABEL: @g.cfi( |
| 46 | +; X86_32-NEXT: ret void |
| 47 | +; |
| 48 | +; |
| 49 | +; X86_32-LABEL: @foo( |
| 50 | +; X86_32-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[P:%.*]] to i32 |
| 51 | +; X86_32-NEXT: [[TMP2:%.*]] = sub i32 ptrtoint (ptr getelementptr (i8, ptr @.cfi.jumptable, i32 16) to i32), [[TMP1]] |
| 52 | +; X86_32-NEXT: [[TMP3:%.*]] = call i32 @llvm.fshr.i32(i32 [[TMP2]], i32 [[TMP2]], i32 4) |
| 53 | +; X86_32-NEXT: [[TMP4:%.*]] = icmp ule i32 [[TMP3]], 1 |
| 54 | +; X86_32-NEXT: ret i1 [[TMP4]] |
| 55 | +; |
| 56 | +; |
| 57 | +; X86_32-LABEL: @.cfi.jumptable( |
| 58 | +; X86_32-NEXT: entry: |
| 59 | +; X86_32-NEXT: call void asm sideeffect "endbr32\0Ajmp ${0:c}@plt\0A.balign 16, 0xcc\0A", "s"(ptr @f.cfi) |
| 60 | +; X86_32-NEXT: call void asm sideeffect "endbr32\0Ajmp ${0:c}@plt\0A.balign 16, 0xcc\0A", "s"(ptr @g.cfi) |
| 61 | +; X86_32-NEXT: unreachable |
| 62 | +; |
| 63 | +; |
| 64 | +; X86_64-LABEL: @f.cfi( |
| 65 | +; X86_64-NEXT: ret void |
| 66 | +; |
| 67 | +; |
| 68 | +; X86_64-LABEL: @g.cfi( |
| 69 | +; X86_64-NEXT: ret void |
| 70 | +; |
| 71 | +; |
| 72 | +; X86_64-LABEL: @foo( |
| 73 | +; X86_64-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[P:%.*]] to i64 |
| 74 | +; X86_64-NEXT: [[TMP2:%.*]] = sub i64 ptrtoint (ptr getelementptr (i8, ptr @.cfi.jumptable, i64 16) to i64), [[TMP1]] |
| 75 | +; X86_64-NEXT: [[TMP3:%.*]] = call i64 @llvm.fshr.i64(i64 [[TMP2]], i64 [[TMP2]], i64 4) |
| 76 | +; X86_64-NEXT: [[TMP4:%.*]] = icmp ule i64 [[TMP3]], 1 |
| 77 | +; X86_64-NEXT: ret i1 [[TMP4]] |
| 78 | +; |
| 79 | +; |
| 80 | +; X86_64-LABEL: @.cfi.jumptable( |
| 81 | +; X86_64-NEXT: entry: |
| 82 | +; X86_64-NEXT: call void asm sideeffect "endbr64\0Ajmp ${0:c}@plt\0A.balign 16, 0xcc\0A", "s"(ptr @f.cfi) |
| 83 | +; X86_64-NEXT: call void asm sideeffect "endbr64\0Ajmp ${0:c}@plt\0A.balign 16, 0xcc\0A", "s"(ptr @g.cfi) |
| 84 | +; X86_64-NEXT: unreachable |
| 85 | +; |
| 86 | +;. |
| 87 | +; X86_32: attributes #[[ATTR0:[0-9]+]] = { nocallback nofree nosync nounwind speculatable willreturn memory(none) } |
| 88 | +; X86_32: attributes #[[ATTR1:[0-9]+]] = { naked nocf_check noinline } |
| 89 | +; X86_32: attributes #[[ATTR2:[0-9]+]] = { nocallback nocreateundeforpoison nofree nosync nounwind speculatable willreturn memory(none) } |
| 90 | +;. |
| 91 | +; X86_64: attributes #[[ATTR0:[0-9]+]] = { nocallback nofree nosync nounwind speculatable willreturn memory(none) } |
| 92 | +; X86_64: attributes #[[ATTR1:[0-9]+]] = { naked nocf_check noinline } |
| 93 | +; X86_64: attributes #[[ATTR2:[0-9]+]] = { nocallback nocreateundeforpoison nofree nosync nounwind speculatable willreturn memory(none) } |
| 94 | +;. |
| 95 | +; X86_32: [[META0:![0-9]+]] = !{i32 8, !"cf-protection-branch", i32 1} |
| 96 | +; X86_32: [[META1:![0-9]+]] = !{i32 7, !"Dwarf Version", i32 5} |
| 97 | +; X86_32: [[META2:![0-9]+]] = !{i32 2, !"Debug Info Version", i32 3} |
| 98 | +; X86_32: [[META3:![0-9]+]] = !{i32 0, !"typeid1"} |
| 99 | +;. |
| 100 | +; X86_64: [[META0:![0-9]+]] = !{i32 8, !"cf-protection-branch", i32 1} |
| 101 | +; X86_64: [[META1:![0-9]+]] = !{i32 7, !"Dwarf Version", i32 5} |
| 102 | +; X86_64: [[META2:![0-9]+]] = !{i32 2, !"Debug Info Version", i32 3} |
| 103 | +; X86_64: [[META3:![0-9]+]] = !{i32 0, !"typeid1"} |
| 104 | +;. |
0 commit comments