|
1 | 1 | ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py |
2 | 2 | ; RUN: opt < %s -passes=instcombine -S | FileCheck %s |
3 | 3 |
|
| 4 | +define i32 @test_ptrauth_call_sign(ptr %p) { |
| 5 | +; CHECK-LABEL: @test_ptrauth_call_sign( |
| 6 | +; CHECK-NEXT: [[V3:%.*]] = call i32 [[P:%.*]]() |
| 7 | +; CHECK-NEXT: ret i32 [[V3]] |
| 8 | +; |
| 9 | + %v0 = ptrtoint ptr %p to i64 |
| 10 | + %v1 = call i64 @llvm.ptrauth.sign(i64 %v0, i32 2, i64 5678) |
| 11 | + %v2 = inttoptr i64 %v1 to ptr |
| 12 | + %v3 = call i32 %v2() [ "ptrauth"(i32 2, i64 5678) ] |
| 13 | + ret i32 %v3 |
| 14 | +} |
| 15 | + |
| 16 | +define i32 @test_ptrauth_call_sign_otherbundle(ptr %p) { |
| 17 | +; CHECK-LABEL: @test_ptrauth_call_sign_otherbundle( |
| 18 | +; CHECK-NEXT: [[V3:%.*]] = call i32 [[P:%.*]]() [ "somebundle"(ptr null), "otherbundle"(i64 0) ] |
| 19 | +; CHECK-NEXT: ret i32 [[V3]] |
| 20 | +; |
| 21 | + %v0 = ptrtoint ptr %p to i64 |
| 22 | + %v1 = call i64 @llvm.ptrauth.sign(i64 %v0, i32 2, i64 5678) |
| 23 | + %v2 = inttoptr i64 %v1 to ptr |
| 24 | + %v3 = call i32 %v2() [ "somebundle"(ptr null), "ptrauth"(i32 2, i64 5678), "otherbundle"(i64 0) ] |
| 25 | + ret i32 %v3 |
| 26 | +} |
| 27 | + |
4 | 28 | define i32 @test_ptrauth_call_resign(ptr %p) { |
5 | 29 | ; CHECK-LABEL: @test_ptrauth_call_resign( |
6 | 30 | ; CHECK-NEXT: [[V3:%.*]] = call i32 [[P:%.*]]() [ "ptrauth"(i32 1, i64 1234) ] |
@@ -47,27 +71,69 @@ define i32 @test_ptrauth_call_resign_blend_2(ptr %pp) { |
47 | 71 | ret i32 %v6 |
48 | 72 | } |
49 | 73 |
|
50 | | -define i32 @test_ptrauth_call_sign(ptr %p) { |
51 | | -; CHECK-LABEL: @test_ptrauth_call_sign( |
52 | | -; CHECK-NEXT: [[V3:%.*]] = call i32 [[P:%.*]]() |
| 74 | +define i32 @test_ptrauth_call_resign_mismatch_key(ptr %p) { |
| 75 | +; CHECK-LABEL: @test_ptrauth_call_resign_mismatch_key( |
| 76 | +; CHECK-NEXT: [[V0:%.*]] = ptrtoint ptr [[P:%.*]] to i64 |
| 77 | +; CHECK-NEXT: [[V1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[V0]], i32 1, i64 1234, i32 0, i64 5678) |
| 78 | +; CHECK-NEXT: [[V2:%.*]] = inttoptr i64 [[V1]] to ptr |
| 79 | +; CHECK-NEXT: [[V3:%.*]] = call i32 [[V2]]() [ "ptrauth"(i32 1, i64 5678) ] |
53 | 80 | ; CHECK-NEXT: ret i32 [[V3]] |
54 | 81 | ; |
55 | 82 | %v0 = ptrtoint ptr %p to i64 |
56 | | - %v1 = call i64 @llvm.ptrauth.sign(i64 %v0, i32 2, i64 5678) |
| 83 | + %v1 = call i64 @llvm.ptrauth.resign(i64 %v0, i32 1, i64 1234, i32 0, i64 5678) |
57 | 84 | %v2 = inttoptr i64 %v1 to ptr |
58 | | - %v3 = call i32 %v2() [ "ptrauth"(i32 2, i64 5678) ] |
| 85 | + %v3 = call i32 %v2() [ "ptrauth"(i32 1, i64 5678) ] |
59 | 86 | ret i32 %v3 |
60 | 87 | } |
61 | 88 |
|
62 | | -define i32 @test_ptrauth_call_sign_otherbundle(ptr %p) { |
63 | | -; CHECK-LABEL: @test_ptrauth_call_sign_otherbundle( |
64 | | -; CHECK-NEXT: [[V3:%.*]] = call i32 [[P:%.*]]() [ "somebundle"(ptr null), "otherbundle"(i64 0) ] |
| 89 | +define i32 @test_ptrauth_call_resign_mismatch_disc(ptr %p) { |
| 90 | +; CHECK-LABEL: @test_ptrauth_call_resign_mismatch_disc( |
| 91 | +; CHECK-NEXT: [[V0:%.*]] = ptrtoint ptr [[P:%.*]] to i64 |
| 92 | +; CHECK-NEXT: [[V1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[V0]], i32 1, i64 1234, i32 0, i64 9900) |
| 93 | +; CHECK-NEXT: [[V2:%.*]] = inttoptr i64 [[V1]] to ptr |
| 94 | +; CHECK-NEXT: [[V3:%.*]] = call i32 [[V2]]() [ "ptrauth"(i32 1, i64 5678) ] |
65 | 95 | ; CHECK-NEXT: ret i32 [[V3]] |
66 | 96 | ; |
67 | 97 | %v0 = ptrtoint ptr %p to i64 |
68 | | - %v1 = call i64 @llvm.ptrauth.sign(i64 %v0, i32 2, i64 5678) |
| 98 | + %v1 = call i64 @llvm.ptrauth.resign(i64 %v0, i32 1, i64 1234, i32 0, i64 9900) |
69 | 99 | %v2 = inttoptr i64 %v1 to ptr |
70 | | - %v3 = call i32 %v2() [ "somebundle"(ptr null), "ptrauth"(i32 2, i64 5678), "otherbundle"(i64 0) ] |
| 100 | + %v3 = call i32 %v2() [ "ptrauth"(i32 1, i64 5678) ] |
| 101 | + ret i32 %v3 |
| 102 | +} |
| 103 | + |
| 104 | +define i32 @test_ptrauth_call_resign_mismatch_blend(ptr %pp) { |
| 105 | +; CHECK-LABEL: @test_ptrauth_call_resign_mismatch_blend( |
| 106 | +; CHECK-NEXT: [[V0:%.*]] = load ptr, ptr [[PP:%.*]], align 8 |
| 107 | +; CHECK-NEXT: [[V1:%.*]] = ptrtoint ptr [[PP]] to i64 |
| 108 | +; CHECK-NEXT: [[V2:%.*]] = ptrtoint ptr [[V0]] to i64 |
| 109 | +; CHECK-NEXT: [[V6:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[V1]], i64 5678) |
| 110 | +; CHECK-NEXT: [[V4:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[V2]], i32 1, i64 1234, i32 1, i64 [[V6]]) |
| 111 | +; CHECK-NEXT: [[V5:%.*]] = inttoptr i64 [[V4]] to ptr |
| 112 | +; CHECK-NEXT: [[V3:%.*]] = call i32 [[V5]]() [ "ptrauth"(i32 1, i64 [[V1]]) ] |
| 113 | +; CHECK-NEXT: ret i32 [[V3]] |
| 114 | +; |
| 115 | + %v0 = load ptr, ptr %pp, align 8 |
| 116 | + %v1 = ptrtoint ptr %pp to i64 |
| 117 | + %v2 = ptrtoint ptr %v0 to i64 |
| 118 | + %v3 = call i64 @llvm.ptrauth.blend(i64 %v1, i64 5678) |
| 119 | + %v4 = call i64 @llvm.ptrauth.resign(i64 %v2, i32 1, i64 1234, i32 1, i64 %v3) |
| 120 | + %v5 = inttoptr i64 %v4 to ptr |
| 121 | + %v6 = call i32 %v5() [ "ptrauth"(i32 1, i64 %v1) ] |
| 122 | + ret i32 %v6 |
| 123 | +} |
| 124 | + |
| 125 | +define i32 @test_ptrauth_call_resign_changing_call_key(ptr %p) { |
| 126 | +; CHECK-LABEL: @test_ptrauth_call_resign_changing_call_key( |
| 127 | +; CHECK-NEXT: [[V0:%.*]] = ptrtoint ptr [[P:%.*]] to i64 |
| 128 | +; CHECK-NEXT: [[V1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[V0]], i32 2, i64 1234, i32 1, i64 5678) |
| 129 | +; CHECK-NEXT: [[V2:%.*]] = inttoptr i64 [[V1]] to ptr |
| 130 | +; CHECK-NEXT: [[V3:%.*]] = call i32 [[V2]]() [ "ptrauth"(i32 1, i64 5678) ] |
| 131 | +; CHECK-NEXT: ret i32 [[V3]] |
| 132 | +; |
| 133 | + %v0 = ptrtoint ptr %p to i64 |
| 134 | + %v1 = call i64 @llvm.ptrauth.resign(i64 %v0, i32 2, i64 1234, i32 1, i64 5678) |
| 135 | + %v2 = inttoptr i64 %v1 to ptr |
| 136 | + %v3 = call i32 %v2() [ "ptrauth"(i32 1, i64 5678) ] |
71 | 137 | ret i32 %v3 |
72 | 138 | } |
73 | 139 |
|
|
0 commit comments