98 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py2; RUN: opt < %s -passes=instcombine -S | FileCheck %s3 4declare i64 @f(i32)5declare ptr @f2(i32)6 7define i32 @test_ptrauth_call(i32 %a0) {8; CHECK-LABEL: @test_ptrauth_call(9; CHECK-NEXT: [[V0:%.*]] = call i32 @f(i32 [[A0:%.*]])10; CHECK-NEXT: ret i32 [[V0]]11;12 %v0 = call i32 ptrauth(ptr @f, i32 0)(i32 %a0) [ "ptrauth"(i32 0, i64 0) ]13 ret i32 %v014}15 16define i32 @test_ptrauth_call_disc(i32 %a0) {17; CHECK-LABEL: @test_ptrauth_call_disc(18; CHECK-NEXT: [[V0:%.*]] = call i32 @f(i32 [[A0:%.*]])19; CHECK-NEXT: ret i32 [[V0]]20;21 %v0 = call i32 ptrauth(ptr @f, i32 1, i64 5678)(i32 %a0) [ "ptrauth"(i32 1, i64 5678) ]22 ret i32 %v023}24 25@f_addr_disc.ref = constant ptr ptrauth(ptr @f, i32 1, i64 0, ptr @f_addr_disc.ref)26 27define i32 @test_ptrauth_call_addr_disc(i32 %a0) {28; CHECK-LABEL: @test_ptrauth_call_addr_disc(29; CHECK-NEXT: [[V0:%.*]] = call i32 @f(i32 [[A0:%.*]])30; CHECK-NEXT: ret i32 [[V0]]31;32 %v0 = call i32 ptrauth(ptr @f, i32 1, i64 0, ptr @f_addr_disc.ref)(i32 %a0) [ "ptrauth"(i32 1, i64 ptrtoint (ptr @f_addr_disc.ref to i64)) ]33 ret i32 %v034}35 36@f_both_disc.ref = constant ptr ptrauth(ptr @f, i32 1, i64 1234, ptr @f_both_disc.ref)37 38define i32 @test_ptrauth_call_blend(i32 %a0) {39; CHECK-LABEL: @test_ptrauth_call_blend(40; CHECK-NEXT: [[V0:%.*]] = call i32 @f(i32 [[A0:%.*]])41; CHECK-NEXT: ret i32 [[V0]]42;43 %v = call i64 @llvm.ptrauth.blend(i64 ptrtoint (ptr @f_both_disc.ref to i64), i64 1234)44 %v0 = call i32 ptrauth(ptr @f, i32 1, i64 1234, ptr @f_both_disc.ref)(i32 %a0) [ "ptrauth"(i32 1, i64 %v) ]45 ret i32 %v046}47 48define i64 @test_ptrauth_call_cast(i32 %a0) {49; CHECK-LABEL: @test_ptrauth_call_cast(50; CHECK-NEXT: [[V0:%.*]] = call i64 @f2(i32 [[A0:%.*]])51; CHECK-NEXT: ret i64 [[V0]]52;53 %v0 = call i64 ptrauth(ptr @f2, i32 0)(i32 %a0) [ "ptrauth"(i32 0, i64 0) ]54 ret i64 %v055}56 57define i32 @test_ptrauth_call_mismatch_key(i32 %a0) {58; CHECK-LABEL: @test_ptrauth_call_mismatch_key(59; CHECK-NEXT: [[V0:%.*]] = call i32 ptrauth (ptr @f, i32 1, i64 5678)(i32 [[A0:%.*]]) [ "ptrauth"(i32 0, i64 5678) ]60; CHECK-NEXT: ret i32 [[V0]]61;62 %v0 = call i32 ptrauth(ptr @f, i32 1, i64 5678)(i32 %a0) [ "ptrauth"(i32 0, i64 5678) ]63 ret i32 %v064}65 66define i32 @test_ptrauth_call_mismatch_disc(i32 %a0) {67; CHECK-LABEL: @test_ptrauth_call_mismatch_disc(68; CHECK-NEXT: [[V0:%.*]] = call i32 ptrauth (ptr @f, i32 1, i64 5678)(i32 [[A0:%.*]]) [ "ptrauth"(i32 1, i64 0) ]69; CHECK-NEXT: ret i32 [[V0]]70;71 %v0 = call i32 ptrauth(ptr @f, i32 1, i64 5678)(i32 %a0) [ "ptrauth"(i32 1, i64 0) ]72 ret i32 %v073}74 75define i32 @test_ptrauth_call_mismatch_blend(i32 %a0) {76; CHECK-LABEL: @test_ptrauth_call_mismatch_blend(77; CHECK-NEXT: [[V:%.*]] = call i64 @llvm.ptrauth.blend(i64 ptrtoint (ptr @f_both_disc.ref to i64), i64 0)78; CHECK-NEXT: [[V0:%.*]] = call i32 ptrauth (ptr @f, i32 1, i64 1234, ptr @f_both_disc.ref)(i32 [[A0:%.*]]) [ "ptrauth"(i32 1, i64 [[V]]) ]79; CHECK-NEXT: ret i32 [[V0]]80;81 %v = call i64 @llvm.ptrauth.blend(i64 ptrtoint (ptr @f_both_disc.ref to i64), i64 0)82 %v0 = call i32 ptrauth(ptr @f, i32 1, i64 1234, ptr @f_both_disc.ref)(i32 %a0) [ "ptrauth"(i32 1, i64 %v) ]83 ret i32 %v084}85 86define i32 @test_ptrauth_call_mismatch_blend_addr(i32 %a0) {87; CHECK-LABEL: @test_ptrauth_call_mismatch_blend_addr(88; CHECK-NEXT: [[V:%.*]] = call i64 @llvm.ptrauth.blend(i64 ptrtoint (ptr @f_addr_disc.ref to i64), i64 1234)89; CHECK-NEXT: [[V0:%.*]] = call i32 ptrauth (ptr @f, i32 1, i64 1234, ptr @f_both_disc.ref)(i32 [[A0:%.*]]) [ "ptrauth"(i32 1, i64 [[V]]) ]90; CHECK-NEXT: ret i32 [[V0]]91;92 %v = call i64 @llvm.ptrauth.blend(i64 ptrtoint (ptr @f_addr_disc.ref to i64), i64 1234)93 %v0 = call i32 ptrauth(ptr @f, i32 1, i64 1234, ptr @f_both_disc.ref)(i32 %a0) [ "ptrauth"(i32 1, i64 %v) ]94 ret i32 %v095}96 97declare i64 @llvm.ptrauth.blend(i64, i64)98