brintos

brintos / llvm-project-archived public Read only

0
0
Text · 9.2 KiB · 29cdc35 Raw
182 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py2; RUN: opt < %s -passes=instcombine -S | FileCheck %s3; These tests check the optimizations specific to4; pointers being relocated at a statepoint.5 6 7declare ptr @fake_personality_function()8declare void @func()9 10define i1 @test_negative(ptr addrspace(1) %p) gc "statepoint-example" {11; CHECK-LABEL: @test_negative(12; CHECK-NEXT:  entry:13; CHECK-NEXT:    [[SAFEPOINT_TOKEN:%.*]] = tail call token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 0, i32 0, ptr nonnull elementtype(void ()) @func, i32 0, i32 0, i32 0, i32 0) [ "gc-live"(ptr addrspace(1) [[P:%.*]]) ]14; CHECK-NEXT:    [[PNEW:%.*]] = call ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[SAFEPOINT_TOKEN]], i32 0, i32 0)15; CHECK-NEXT:    [[CMP:%.*]] = icmp eq ptr addrspace(1) [[PNEW]], null16; CHECK-NEXT:    ret i1 [[CMP]]17;18entry:19  %safepoint_token = tail call token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 0, i32 0, ptr elementtype(void ()) @func, i32 0, i32 0, i32 0, i32 0) ["gc-live"(ptr addrspace(1) %p)]20  %pnew = call ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token %safepoint_token,  i32 0, i32 0)21  %cmp = icmp eq ptr addrspace(1) %pnew, null22  ret i1 %cmp23}24 25define i1 @test_nonnull(ptr addrspace(1) nonnull %p) gc "statepoint-example" {26; CHECK-LABEL: @test_nonnull(27; CHECK-NEXT:  entry:28; CHECK-NEXT:    [[SAFEPOINT_TOKEN:%.*]] = tail call token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 0, i32 0, ptr nonnull elementtype(void ()) @func, i32 0, i32 0, i32 0, i32 0) [ "gc-live"() ]29; CHECK-NEXT:    ret i1 false30;31entry:32  %safepoint_token = tail call token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 0, i32 0, ptr elementtype(void ()) @func, i32 0, i32 0, i32 0, i32 0) ["gc-live"(ptr addrspace(1) %p)]33  %pnew = call ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token %safepoint_token,  i32 0, i32 0)34  %cmp = icmp eq ptr addrspace(1) %pnew, null35  ret i1 %cmp36}37 38define i1 @test_null() gc "statepoint-example" {39; CHECK-LABEL: @test_null(40; CHECK-NEXT:  entry:41; CHECK-NEXT:    [[SAFEPOINT_TOKEN:%.*]] = tail call token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 0, i32 0, ptr nonnull elementtype(void ()) @func, i32 0, i32 0, i32 0, i32 0) [ "gc-live"() ]42; CHECK-NEXT:    ret i1 true43;44entry:45  %safepoint_token = tail call token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 0, i32 0, ptr elementtype(void ()) @func, i32 0, i32 0, i32 0, i32 0) ["gc-live"(ptr addrspace(1) null)]46  %pnew = call ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token %safepoint_token,  i32 0, i32 0)47  %cmp = icmp eq ptr addrspace(1) %pnew, null48  ret i1 %cmp49}50 51define i1 @test_undef() gc "statepoint-example" {52; CHECK-LABEL: @test_undef(53; CHECK-NEXT:  entry:54; CHECK-NEXT:    [[SAFEPOINT_TOKEN:%.*]] = tail call token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 0, i32 0, ptr nonnull elementtype(void ()) @func, i32 0, i32 0, i32 0, i32 0) [ "gc-live"() ]55; CHECK-NEXT:    ret i1 undef56;57entry:58  %safepoint_token = tail call token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 0, i32 0, ptr elementtype(void ()) @func, i32 0, i32 0, i32 0, i32 0) ["gc-live"(ptr addrspace(1) undef)]59  %pnew = call ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token %safepoint_token,  i32 0, i32 0)60  %cmp = icmp eq ptr addrspace(1) %pnew, null61  ret i1 %cmp62}63 64define i1 @test_negative_invoke(ptr addrspace(1) %p) gc "statepoint-example" personality ptr @fake_personality_function {65; CHECK-LABEL: @test_negative_invoke(66; CHECK-NEXT:  entry:67; CHECK-NEXT:    [[SAFEPOINT_TOKEN:%.*]] = invoke token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 0, i32 0, ptr nonnull elementtype(void ()) @func, i32 0, i32 0, i32 0, i32 0) [ "gc-live"(ptr addrspace(1) [[P:%.*]]) ]68; CHECK-NEXT:    to label [[NORMAL_DEST:%.*]] unwind label [[UNWIND_DEST:%.*]]69; CHECK:       normal_dest:70; CHECK-NEXT:    [[PNEW:%.*]] = call ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[SAFEPOINT_TOKEN]], i32 0, i32 0)71; CHECK-NEXT:    [[CMP:%.*]] = icmp eq ptr addrspace(1) [[PNEW]], null72; CHECK-NEXT:    ret i1 [[CMP]]73; CHECK:       unwind_dest:74; CHECK-NEXT:    [[LPAD:%.*]] = landingpad token75; CHECK-NEXT:    cleanup76; CHECK-NEXT:    [[PNEW2:%.*]] = call ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[LPAD]], i32 0, i32 0)77; CHECK-NEXT:    [[CMP2:%.*]] = icmp ne ptr addrspace(1) [[PNEW2]], null78; CHECK-NEXT:    ret i1 [[CMP2]]79;80entry:81  %safepoint_token = invoke token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 0, i32 0, ptr elementtype(void ()) @func, i32 0, i32 0, i32 0, i32 0) ["gc-live"(ptr addrspace(1) %p)]82  to label %normal_dest unwind label %unwind_dest83 84normal_dest:85  %pnew = call ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token %safepoint_token,  i32 0, i32 0)86  %cmp = icmp eq ptr addrspace(1) %pnew, null87  ret i1 %cmp88unwind_dest:89  %lpad = landingpad token90  cleanup91  %pnew2 = call ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token %lpad,  i32 0, i32 0)92  %cmp2 = icmp ne ptr addrspace(1) %pnew2, null93  ret i1 %cmp294}95 96define i1 @test_nonnull_invoke(ptr addrspace(1) nonnull %p) gc "statepoint-example" personality ptr @fake_personality_function {97; CHECK-LABEL: @test_nonnull_invoke(98; CHECK-NEXT:  entry:99; CHECK-NEXT:    [[SAFEPOINT_TOKEN:%.*]] = invoke token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 0, i32 0, ptr nonnull elementtype(void ()) @func, i32 0, i32 0, i32 0, i32 0) [ "gc-live"() ]100; CHECK-NEXT:    to label [[NORMAL_DEST:%.*]] unwind label [[UNWIND_DEST:%.*]]101; CHECK:       normal_dest:102; CHECK-NEXT:    ret i1 false103; CHECK:       unwind_dest:104; CHECK-NEXT:    [[LPAD:%.*]] = landingpad token105; CHECK-NEXT:    cleanup106; CHECK-NEXT:    ret i1 true107;108entry:109  %safepoint_token = invoke token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 0, i32 0, ptr elementtype(void ()) @func, i32 0, i32 0, i32 0, i32 0) ["gc-live"(ptr addrspace(1) %p)]110  to label %normal_dest unwind label %unwind_dest111 112normal_dest:113  %pnew = call ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token %safepoint_token,  i32 0, i32 0)114  %cmp = icmp eq ptr addrspace(1) %pnew, null115  ret i1 %cmp116unwind_dest:117  %lpad = landingpad token118  cleanup119  %pnew2 = call ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token %lpad,  i32 0, i32 0)120  %cmp2 = icmp ne ptr addrspace(1) %pnew2, null121  ret i1 %cmp2122}123 124define i1 @test_null_invoke() gc "statepoint-example" personality ptr @fake_personality_function {125; CHECK-LABEL: @test_null_invoke(126; CHECK-NEXT:  entry:127; CHECK-NEXT:    [[SAFEPOINT_TOKEN:%.*]] = invoke token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 0, i32 0, ptr nonnull elementtype(void ()) @func, i32 0, i32 0, i32 0, i32 0) [ "gc-live"() ]128; CHECK-NEXT:    to label [[NORMAL_DEST:%.*]] unwind label [[UNWIND_DEST:%.*]]129; CHECK:       normal_dest:130; CHECK-NEXT:    ret i1 true131; CHECK:       unwind_dest:132; CHECK-NEXT:    [[LPAD:%.*]] = landingpad token133; CHECK-NEXT:    cleanup134; CHECK-NEXT:    ret i1 false135;136entry:137  %safepoint_token = invoke token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 0, i32 0, ptr elementtype(void ()) @func, i32 0, i32 0, i32 0, i32 0) ["gc-live"(ptr addrspace(1) null)]138  to label %normal_dest unwind label %unwind_dest139 140normal_dest:141  %pnew = call ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token %safepoint_token,  i32 0, i32 0)142  %cmp = icmp eq ptr addrspace(1) %pnew, null143  ret i1 %cmp144unwind_dest:145  %lpad = landingpad token146  cleanup147  %pnew2 = call ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token %lpad,  i32 0, i32 0)148  %cmp2 = icmp ne ptr addrspace(1) %pnew2, null149  ret i1 %cmp2150}151 152define i1 @test_undef_invoke() gc "statepoint-example" personality ptr @fake_personality_function {153; CHECK-LABEL: @test_undef_invoke(154; CHECK-NEXT:  entry:155; CHECK-NEXT:    [[SAFEPOINT_TOKEN:%.*]] = invoke token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 0, i32 0, ptr nonnull elementtype(void ()) @func, i32 0, i32 0, i32 0, i32 0) [ "gc-live"() ]156; CHECK-NEXT:    to label [[NORMAL_DEST:%.*]] unwind label [[UNWIND_DEST:%.*]]157; CHECK:       normal_dest:158; CHECK-NEXT:    ret i1 undef159; CHECK:       unwind_dest:160; CHECK-NEXT:    [[LPAD:%.*]] = landingpad token161; CHECK-NEXT:    cleanup162; CHECK-NEXT:    ret i1 undef163;164entry:165  %safepoint_token = invoke token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 0, i32 0, ptr elementtype(void ()) @func, i32 0, i32 0, i32 0, i32 0) ["gc-live"(ptr addrspace(1) undef)]166  to label %normal_dest unwind label %unwind_dest167 168normal_dest:169  %pnew = call ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token %safepoint_token,  i32 0, i32 0)170  %cmp = icmp eq ptr addrspace(1) %pnew, null171  ret i1 %cmp172unwind_dest:173  %lpad = landingpad token174  cleanup175  %pnew2 = call ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token %lpad,  i32 0, i32 0)176  %cmp2 = icmp ne ptr addrspace(1) %pnew2, null177  ret i1 %cmp2178}179 180declare token @llvm.experimental.gc.statepoint.p0(i64, i32, ptr, i32, i32, ...)181declare ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token, i32, i32) #3182