From: Nikita Popov Date: Tue, 3 Jan 2023 13:28:22 +0000 (+0100) Subject: [RewriteStatepointsForGC] Avoid branch on undef UB in tests (NFC) X-Git-Tag: upstream/17.0.6~22315 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=20fa198687800fafc4f9fd53683cefc150d79a13;p=platform%2Fupstream%2Fllvm.git [RewriteStatepointsForGC] Avoid branch on undef UB in tests (NFC) --- diff --git a/llvm/test/Transforms/RewriteStatepointsForGC/base-pointers.ll b/llvm/test/Transforms/RewriteStatepointsForGC/base-pointers.ll index 1d13b82..d85e236 100644 --- a/llvm/test/Transforms/RewriteStatepointsForGC/base-pointers.ll +++ b/llvm/test/Transforms/RewriteStatepointsForGC/base-pointers.ll @@ -13,10 +13,10 @@ define void @test() gc "statepoint-example" { ; CHECK-NEXT: [[OBJ:%.*]] = call ptr addrspace(1) @generate_obj() ; CHECK-NEXT: br label [[LOOP:%.*]] ; CHECK: loop: -; CHECK-NEXT: [[DOT0:%.*]] = phi ptr addrspace(1) [ [[OBJ]], [[ENTRY:%.*]] ], [ [[OBJ_RELOCATED_CASTED:%.*]], [[LOOP]] ] +; CHECK-NEXT: [[DOT0:%.*]] = phi ptr addrspace(1) [ [[OBJ]], [[ENTRY:%.*]] ], [ [[OBJ_RELOCATED:%.*]], [[LOOP]] ] ; CHECK-NEXT: call void @use_obj(ptr addrspace(1) [[DOT0]]) ; CHECK-NEXT: [[STATEPOINT_TOKEN:%.*]] = call token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 2882400000, i32 0, ptr elementtype(void ()) @do_safepoint, i32 0, i32 0, i32 0, i32 0) [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0), "gc-live"(ptr addrspace(1) [[DOT0]]) ] -; CHECK-NEXT: [[OBJ_RELOCATED:%.*]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[STATEPOINT_TOKEN]], i32 0, i32 0) +; CHECK-NEXT: [[OBJ_RELOCATED]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[STATEPOINT_TOKEN]], i32 0, i32 0) ; CHECK-NEXT: br label [[LOOP]] ; entry: @@ -33,10 +33,10 @@ declare void @do_safepoint() declare void @parse_point(ptr addrspace(1)) -define ptr addrspace(1) @test1(i32 %caller, ptr addrspace(1) %a, ptr addrspace(1) %b, i32 %unknown) gc "statepoint-example" { +define ptr addrspace(1) @test1(i32 %caller, ptr addrspace(1) %a, ptr addrspace(1) %b, i32 %unknown, i1 %c) gc "statepoint-example" { ; CHECK-LABEL: @test1( ; CHECK-NEXT: entry: -; CHECK-NEXT: br i1 undef, label [[LEFT:%.*]], label [[RIGHT:%.*]] +; CHECK-NEXT: br i1 [[C:%.*]], label [[LEFT:%.*]], label [[RIGHT:%.*]] ; CHECK: left: ; CHECK-NEXT: switch i32 [[UNKNOWN:%.*]], label [[RIGHT]] [ ; CHECK-NEXT: i32 0, label [[MERGE:%.*]] @@ -52,7 +52,7 @@ define ptr addrspace(1) @test1(i32 %caller, ptr addrspace(1) %a, ptr addrspace(1 ; CHECK-NEXT: ret ptr addrspace(1) [[VALUE_RELOCATED]] ; entry: - br i1 undef, label %left, label %right + br i1 %c, label %left, label %right left: ; Our safepoint placement pass calls removeUnreachableBlocks, which does a bunch @@ -87,20 +87,20 @@ define void @test2(i1 %cnd, ptr addrspace(1) %base_obj, ptr addrspace(1) %base_a ; CHECK-NEXT: [[OBJ:%.*]] = getelementptr i64, ptr addrspace(1) [[BASE_OBJ:%.*]], i32 1 ; CHECK-NEXT: br label [[LOOP:%.*]] ; CHECK: loop: -; CHECK-NEXT: [[DOT0:%.*]] = phi ptr addrspace(1) [ [[BASE_ARG2:%.*]], [[ENTRY:%.*]] ], [ [[BASE_ARG2_RELOCATED_CASTED:%.*]], [[LOOP]] ] -; CHECK-NEXT: [[CURRENT_BASE:%.*]] = phi ptr addrspace(1) [ [[BASE_OBJ]], [[ENTRY]] ], [ [[NEXT_BASE_RELOCATED_CASTED:%.*]], [[LOOP]] ], !is_base_value !0 -; CHECK-NEXT: [[CURRENT:%.*]] = phi ptr addrspace(1) [ [[OBJ]], [[ENTRY]] ], [ [[NEXT_RELOCATED_CASTED:%.*]], [[LOOP]] ] -; CHECK-NEXT: [[EXTRA:%.*]] = phi ptr addrspace(1) [ [[OBJ]], [[ENTRY]] ], [ [[EXTRA2_RELOCATED_CASTED:%.*]], [[LOOP]] ] +; CHECK-NEXT: [[DOT0:%.*]] = phi ptr addrspace(1) [ [[BASE_ARG2:%.*]], [[ENTRY:%.*]] ], [ [[BASE_ARG2_RELOCATED:%.*]], [[LOOP]] ] +; CHECK-NEXT: [[CURRENT_BASE:%.*]] = phi ptr addrspace(1) [ [[BASE_OBJ]], [[ENTRY]] ], [ [[NEXT_BASE_RELOCATED:%.*]], [[LOOP]] ], !is_base_value !0 +; CHECK-NEXT: [[CURRENT:%.*]] = phi ptr addrspace(1) [ [[OBJ]], [[ENTRY]] ], [ [[NEXT_RELOCATED:%.*]], [[LOOP]] ] +; CHECK-NEXT: [[EXTRA:%.*]] = phi ptr addrspace(1) [ [[OBJ]], [[ENTRY]] ], [ [[EXTRA2_RELOCATED:%.*]], [[LOOP]] ] ; CHECK-NEXT: [[NEXTA:%.*]] = getelementptr i64, ptr addrspace(1) [[CURRENT]], i32 1 ; CHECK-NEXT: [[NEXT_BASE:%.*]] = select i1 [[CND:%.*]], ptr addrspace(1) [[CURRENT_BASE]], ptr addrspace(1) [[DOT0]], !is_base_value !0 ; CHECK-NEXT: [[NEXT:%.*]] = select i1 [[CND]], ptr addrspace(1) [[NEXTA]], ptr addrspace(1) [[DOT0]] ; CHECK-NEXT: [[EXTRA2_BASE:%.*]] = select i1 [[CND]], ptr addrspace(1) [[CURRENT_BASE]], ptr addrspace(1) [[DOT0]], !is_base_value !0 ; CHECK-NEXT: [[EXTRA2:%.*]] = select i1 [[CND]], ptr addrspace(1) [[NEXTA]], ptr addrspace(1) [[DOT0]] ; CHECK-NEXT: [[STATEPOINT_TOKEN:%.*]] = call token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 2882400000, i32 0, ptr elementtype(void ()) @foo, i32 0, i32 0, i32 0, i32 0) [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0), "gc-live"(ptr addrspace(1) [[NEXT_BASE]], ptr addrspace(1) [[NEXT]], ptr addrspace(1) [[EXTRA2]], ptr addrspace(1) [[DOT0]], ptr addrspace(1) [[EXTRA2_BASE]]) ] -; CHECK-NEXT: [[NEXT_BASE_RELOCATED:%.*]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[STATEPOINT_TOKEN]], i32 0, i32 0) -; CHECK-NEXT: [[NEXT_RELOCATED:%.*]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[STATEPOINT_TOKEN]], i32 0, i32 1) -; CHECK-NEXT: [[EXTRA2_RELOCATED:%.*]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[STATEPOINT_TOKEN]], i32 4, i32 2) -; CHECK-NEXT: [[BASE_ARG2_RELOCATED:%.*]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[STATEPOINT_TOKEN]], i32 3, i32 3) +; CHECK-NEXT: [[NEXT_BASE_RELOCATED]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[STATEPOINT_TOKEN]], i32 0, i32 0) +; CHECK-NEXT: [[NEXT_RELOCATED]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[STATEPOINT_TOKEN]], i32 0, i32 1) +; CHECK-NEXT: [[EXTRA2_RELOCATED]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[STATEPOINT_TOKEN]], i32 4, i32 2) +; CHECK-NEXT: [[BASE_ARG2_RELOCATED]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[STATEPOINT_TOKEN]], i32 3, i32 3) ; CHECK-NEXT: [[EXTRA2_BASE_RELOCATED:%.*]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[STATEPOINT_TOKEN]], i32 4, i32 4) ; CHECK-NEXT: br label [[LOOP]] ; diff --git a/llvm/test/Transforms/RewriteStatepointsForGC/drop-invalid-metadata.ll b/llvm/test/Transforms/RewriteStatepointsForGC/drop-invalid-metadata.ll index fdd88f8..02bf290 100644 --- a/llvm/test/Transforms/RewriteStatepointsForGC/drop-invalid-metadata.ll +++ b/llvm/test/Transforms/RewriteStatepointsForGC/drop-invalid-metadata.ll @@ -11,7 +11,7 @@ declare void @baz(i32) ; but contains the range metadata. ; Since loadedval is not marked invariant, it will prevent incorrectly sinking ; %loadedval in LICM and avoid creation of an unrelocated use of %baseaddr. -define void @test_invariant_load() gc "statepoint-example" { +define void @test_invariant_load(i1 %c) gc "statepoint-example" { ; CHECK-LABEL: @test_invariant_load ; CHECK: %loadedval = load i32, ptr addrspace(1) %baseaddr, align 8, !range !0 bb: @@ -28,7 +28,7 @@ innerloopHdr: ; preds = %innerloopl br label %innermostloophdr innermostloophdr: ; preds = %bb6, %innerloopHdr - br i1 undef, label %exitblock, label %bb6 + br i1 %c, label %exitblock, label %bb6 bb6: ; preds = %innermostloophdr switch i32 undef, label %innermostloophdr [ diff --git a/llvm/test/Transforms/RewriteStatepointsForGC/relocation.ll b/llvm/test/Transforms/RewriteStatepointsForGC/relocation.ll index 1367980..97bd237 100644 --- a/llvm/test/Transforms/RewriteStatepointsForGC/relocation.ll +++ b/llvm/test/Transforms/RewriteStatepointsForGC/relocation.ll @@ -163,10 +163,10 @@ merge: ; preds = %kill, %entry, %entr } ; Check to make sure we handle values live over an entry statepoint -define void @test6(i8 addrspace(1)* %arg1, i8 addrspace(1)* %arg2, i8 addrspace(1)* %arg3) gc "statepoint-example" { +define void @test6(i8 addrspace(1)* %arg1, i8 addrspace(1)* %arg2, i8 addrspace(1)* %arg3, i1 %c) gc "statepoint-example" { ; CHECK-LABEL: @test6 entry: - br i1 undef, label %gc.safepoint_poll.exit2, label %do_safepoint + br i1 %c, label %gc.safepoint_poll.exit2, label %do_safepoint do_safepoint: ; preds = %entry ; CHECK-LABEL: do_safepoint: diff --git a/llvm/test/Transforms/RewriteStatepointsForGC/scalar-base-vector-2.ll b/llvm/test/Transforms/RewriteStatepointsForGC/scalar-base-vector-2.ll index 8a7c580..0cbac5d 100644 --- a/llvm/test/Transforms/RewriteStatepointsForGC/scalar-base-vector-2.ll +++ b/llvm/test/Transforms/RewriteStatepointsForGC/scalar-base-vector-2.ll @@ -5,18 +5,18 @@ ; Uses of extractelement that are of scalar type should not have the BDV ; incorrectly identified as a vector type. -define void @widget() gc "statepoint-example" { +define void @widget(i1 %c) gc "statepoint-example" { ; CHECK-LABEL: @widget( ; CHECK-NEXT: bb6: ; CHECK-NEXT: [[BASE_EE:%.*]] = extractelement <2 x ptr addrspace(1)> zeroinitializer, i32 1, !is_base_value !0 ; CHECK-NEXT: [[TMP:%.*]] = extractelement <2 x ptr addrspace(1)> undef, i32 1 -; CHECK-NEXT: br i1 undef, label [[BB7:%.*]], label [[BB9:%.*]] +; CHECK-NEXT: br i1 [[C:%.*]], label [[BB7:%.*]], label [[BB9:%.*]] ; CHECK: bb7: ; CHECK-NEXT: [[TMP8:%.*]] = getelementptr inbounds i8, ptr addrspace(1) [[TMP]], i64 12 ; CHECK-NEXT: br label [[BB11:%.*]] ; CHECK: bb9: ; CHECK-NEXT: [[TMP10:%.*]] = getelementptr inbounds i8, ptr addrspace(1) [[TMP]], i64 12 -; CHECK-NEXT: br i1 undef, label [[BB11]], label [[BB15:%.*]] +; CHECK-NEXT: br i1 [[C]], label [[BB11]], label [[BB15:%.*]] ; CHECK: bb11: ; CHECK-NEXT: [[TMP12_BASE:%.*]] = phi ptr addrspace(1) [ [[BASE_EE]], [[BB7]] ], [ [[BASE_EE]], [[BB9]] ], !is_base_value !0 ; CHECK-NEXT: [[TMP12:%.*]] = phi ptr addrspace(1) [ [[TMP8]], [[BB7]] ], [ [[TMP10]], [[BB9]] ] @@ -27,7 +27,7 @@ define void @widget() gc "statepoint-example" { ; CHECK: bb15: ; CHECK-NEXT: [[TMP16_BASE:%.*]] = phi ptr addrspace(1) [ [[BASE_EE]], [[BB9]] ], [ [[TMP12_BASE_RELOCATED]], [[BB11]] ], !is_base_value !0 ; CHECK-NEXT: [[TMP16:%.*]] = phi ptr addrspace(1) [ [[TMP10]], [[BB9]] ], [ [[TMP12_RELOCATED]], [[BB11]] ] -; CHECK-NEXT: br i1 undef, label [[BB17:%.*]], label [[BB20:%.*]] +; CHECK-NEXT: br i1 [[C]], label [[BB17:%.*]], label [[BB20:%.*]] ; CHECK: bb17: ; CHECK-NEXT: [[STATEPOINT_TOKEN1:%.*]] = call token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 2882400000, i32 0, ptr elementtype(void ()) @snork, i32 0, i32 0, i32 0, i32 0) [ "deopt"(i32 undef), "gc-live"(ptr addrspace(1) [[TMP16_BASE]], ptr addrspace(1) [[TMP16]]) ] ; CHECK-NEXT: [[TMP16_BASE_RELOCATED:%.*]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[STATEPOINT_TOKEN1]], i32 0, i32 0) @@ -43,7 +43,7 @@ define void @widget() gc "statepoint-example" { ; bb6: ; preds = %bb3 %tmp = extractelement <2 x ptr addrspace(1)> undef, i32 1 - br i1 undef, label %bb7, label %bb9 + br i1 %c, label %bb7, label %bb9 bb7: ; preds = %bb6 %tmp8 = getelementptr inbounds i8, ptr addrspace(1) %tmp, i64 12 @@ -51,7 +51,7 @@ bb7: ; preds = %bb6 bb9: ; preds = %bb6, %bb6 %tmp10 = getelementptr inbounds i8, ptr addrspace(1) %tmp, i64 12 - br i1 undef, label %bb11, label %bb15 + br i1 %c, label %bb11, label %bb15 bb11: ; preds = %bb9, %bb7 %tmp12 = phi ptr addrspace(1) [ %tmp8, %bb7 ], [ %tmp10, %bb9 ] @@ -60,7 +60,7 @@ bb11: ; preds = %bb9, %bb7 bb15: ; preds = %bb11, %bb9, %bb9 %tmp16 = phi ptr addrspace(1) [ %tmp10, %bb9 ], [ %tmp12, %bb11 ] - br i1 undef, label %bb17, label %bb20 + br i1 %c, label %bb17, label %bb20 bb17: ; preds = %bb15 call void @snork() [ "deopt"(i32 undef) ] diff --git a/llvm/test/Transforms/RewriteStatepointsForGC/scalar-base-vector.ll b/llvm/test/Transforms/RewriteStatepointsForGC/scalar-base-vector.ll index 2096007..cb3853b 100644 --- a/llvm/test/Transforms/RewriteStatepointsForGC/scalar-base-vector.ll +++ b/llvm/test/Transforms/RewriteStatepointsForGC/scalar-base-vector.ll @@ -4,10 +4,10 @@ declare void @do_safepoint() declare ptr addrspace(1) @def_ptr() -define ptr addrspace(1) @test1(ptr addrspace(1) %base1, <2 x i64> %offsets) gc "statepoint-example" { +define ptr addrspace(1) @test1(ptr addrspace(1) %base1, <2 x i64> %offsets, i1 %c) gc "statepoint-example" { ; CHECK-LABEL: @test1( ; CHECK-NEXT: entry: -; CHECK-NEXT: br i1 undef, label [[FIRST:%.*]], label [[SECOND:%.*]] +; CHECK-NEXT: br i1 [[C:%.*]], label [[FIRST:%.*]], label [[SECOND:%.*]] ; CHECK: first: ; CHECK-NEXT: [[STATEPOINT_TOKEN:%.*]] = call token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 2882400000, i32 0, ptr elementtype(ptr addrspace(1) ()) @def_ptr, i32 0, i32 0, i32 0, i32 0) [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ] ; CHECK-NEXT: [[BASE21:%.*]] = call ptr addrspace(1) @llvm.experimental.gc.result.p1(token [[STATEPOINT_TOKEN]]) @@ -27,7 +27,7 @@ define ptr addrspace(1) @test1(ptr addrspace(1) %base1, <2 x i64> %offsets) gc " ; CHECK-NEXT: ret ptr addrspace(1) [[PTR_RELOCATED]] ; entry: - br i1 undef, label %first, label %second + br i1 %c, label %first, label %second first: %base2 = call ptr addrspace(1) @def_ptr() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ] @@ -124,7 +124,7 @@ entry: ret ptr addrspace(1) %ptr } -define void @test6() gc "statepoint-example" { +define void @test6(i1 %c) gc "statepoint-example" { ; CHECK-LABEL: @test6( ; CHECK-NEXT: bb: ; CHECK-NEXT: br label [[HEADER:%.*]] @@ -139,7 +139,7 @@ define void @test6() gc "statepoint-example" { ; CHECK-NEXT: [[STATEPOINT_TOKEN1:%.*]] = call token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 2882400000, i32 0, ptr elementtype(<2 x ptr addrspace(1)> ()) @baz, i32 0, i32 0, i32 0, i32 0) ; CHECK-NEXT: [[TMP262:%.*]] = call <2 x ptr addrspace(1)> @llvm.experimental.gc.result.v2p1(token [[STATEPOINT_TOKEN1]]) ; CHECK-NEXT: [[TMP27:%.*]] = extractelement <2 x ptr addrspace(1)> [[TMP262]], i32 0 -; CHECK-NEXT: br i1 undef, label [[BB7:%.*]], label [[LATCH]] +; CHECK-NEXT: br i1 [[C:%.*]], label [[BB7:%.*]], label [[LATCH]] ; CHECK: bb7: ; CHECK-NEXT: br label [[LATCH]] ; CHECK: latch: @@ -160,7 +160,7 @@ bb10: ; preds = %bb2 bb25: ; preds = %bb24 %tmp26 = call <2 x ptr addrspace(1)> @baz() %tmp27 = extractelement <2 x ptr addrspace(1)> %tmp26, i32 0 - br i1 undef, label %bb7, label %latch + br i1 %c, label %bb7, label %latch bb7: ; preds = %bb25 br label %latch