From 5a132499fb39c1dee15a1bc4ff0246c6f1282871 Mon Sep 17 00:00:00 2001 From: Nuno Lopes Date: Mon, 13 Jun 2022 08:59:07 +0100 Subject: [PATCH] [NFC] Remove straight UB from SROA tests Including 'br undef', store/load to undef pointers. Plus some cosmetics: select undef, insertvalue undef -> poison. Recommit c1b6103 with fix. --- llvm/test/Transforms/SROA/address-spaces.ll | 5 +- llvm/test/Transforms/SROA/addrspacecast.ll | 28 ++--- llvm/test/Transforms/SROA/alloca-address-space.ll | 4 +- llvm/test/Transforms/SROA/assume.ll | 5 +- llvm/test/Transforms/SROA/basictest-opaque-ptrs.ll | 132 ++++++++++----------- llvm/test/Transforms/SROA/basictest.ll | 105 ++++++++-------- llvm/test/Transforms/SROA/dbg-single-piece.ll | 11 +- llvm/test/Transforms/SROA/dead-inst.ll | 13 +- llvm/test/Transforms/SROA/fca.ll | 4 +- llvm/test/Transforms/SROA/phi-and-select.ll | 66 +++++------ llvm/test/Transforms/SROA/phi-gep.ll | 47 ++++---- .../Transforms/SROA/phi-with-duplicate-pred.ll | 34 +++--- llvm/test/Transforms/SROA/select-gep.ll | 6 +- llvm/test/Transforms/SROA/select-load.ll | 4 +- .../SROA/vector-promotion-different-size.ll | 41 ++++--- llvm/test/Transforms/SROA/vector-promotion.ll | 12 +- llvm/test/Transforms/SROA/vectors-of-pointers.ll | 10 +- 17 files changed, 271 insertions(+), 256 deletions(-) diff --git a/llvm/test/Transforms/SROA/address-spaces.ll b/llvm/test/Transforms/SROA/address-spaces.ll index 4303a92..c7e9078 100644 --- a/llvm/test/Transforms/SROA/address-spaces.ll +++ b/llvm/test/Transforms/SROA/address-spaces.ll @@ -52,8 +52,7 @@ define void @test_address_space_0_1(<2 x i64>* %a, i16 addrspace(1)* %b) { %struct.struct_test_27.0.13 = type { i32, float, i64, i8, [4 x i32] } -; Function Attrs: nounwind -define void @copy_struct([5 x i64] %in.coerce) { +define void @copy_struct([5 x i64] %in.coerce, i8 addrspace(1)* align 4 %ptr) { ; CHECK-LABEL: @copy_struct( ; CHECK-NOT: memcpy for.end: @@ -62,7 +61,7 @@ for.end: store [5 x i64] %in.coerce, [5 x i64]* %0, align 8 %scevgep9 = getelementptr %struct.struct_test_27.0.13, %struct.struct_test_27.0.13* %in, i32 0, i32 4, i32 0 %scevgep910 = bitcast i32* %scevgep9 to i8* - call void @llvm.memcpy.p1i8.p0i8.i32(i8 addrspace(1)* align 4 undef, i8* align 4 %scevgep910, i32 16, i1 false) + call void @llvm.memcpy.p1i8.p0i8.i32(i8 addrspace(1)* align 4 %ptr, i8* align 4 %scevgep910, i32 16, i1 false) ret void } diff --git a/llvm/test/Transforms/SROA/addrspacecast.ll b/llvm/test/Transforms/SROA/addrspacecast.ll index 612d65e..aed08f8 100644 --- a/llvm/test/Transforms/SROA/addrspacecast.ll +++ b/llvm/test/Transforms/SROA/addrspacecast.ll @@ -256,10 +256,10 @@ define void @select_addrspacecast(i1 %a, i1 %b) { ; CHECK-NEXT: ret void ; %c = alloca i64, align 8 - %p.0.c = select i1 undef, i64* %c, i64* %c + %p.0.c = select i1 %a, i64* %c, i64* %c %asc = addrspacecast i64* %p.0.c to i64 addrspace(1)* - %cond.in = select i1 undef, i64 addrspace(1)* %asc, i64 addrspace(1)* %asc + %cond.in = select i1 %b, i64 addrspace(1)* %asc, i64 addrspace(1)* %asc %cond = load i64, i64 addrspace(1)* %cond.in, align 8 ret void } @@ -268,15 +268,15 @@ define void @select_addrspacecast_const_op(i1 %a, i1 %b) { ; CHECK-LABEL: @select_addrspacecast_const_op( ; CHECK-NEXT: [[C:%.*]] = alloca i64, align 8 ; CHECK-NEXT: [[C_0_ASC_SROA_CAST:%.*]] = addrspacecast i64* [[C]] to i64 addrspace(1)* -; CHECK-NEXT: [[COND_IN:%.*]] = select i1 undef, i64 addrspace(1)* [[C_0_ASC_SROA_CAST]], i64 addrspace(1)* null +; CHECK-NEXT: [[COND_IN:%.*]] = select i1 [[B:%.*]], i64 addrspace(1)* [[C_0_ASC_SROA_CAST]], i64 addrspace(1)* null ; CHECK-NEXT: [[COND:%.*]] = load i64, i64 addrspace(1)* [[COND_IN]], align 8 ; CHECK-NEXT: ret void ; %c = alloca i64, align 8 - %p.0.c = select i1 undef, i64* %c, i64* %c + %p.0.c = select i1 %a, i64* %c, i64* %c %asc = addrspacecast i64* %p.0.c to i64 addrspace(1)* - %cond.in = select i1 undef, i64 addrspace(1)* %asc, i64 addrspace(1)* null + %cond.in = select i1 %b, i64 addrspace(1)* %asc, i64 addrspace(1)* null %cond = load i64, i64 addrspace(1)* %cond.in, align 8 ret void } @@ -288,14 +288,14 @@ define void @select_addrspacecast_const_op(i1 %a, i1 %b) { define void @select_addrspacecast_gv(i1 %a, i1 %b) { ; CHECK-LABEL: @select_addrspacecast_gv( ; CHECK-NEXT: [[COND_SROA_SPECULATE_LOAD_FALSE:%.*]] = load i64, i64 addrspace(1)* @gv, align 8 -; CHECK-NEXT: [[COND_SROA_SPECULATED:%.*]] = select i1 undef, i64 undef, i64 [[COND_SROA_SPECULATE_LOAD_FALSE]] +; CHECK-NEXT: [[COND_SROA_SPECULATED:%.*]] = select i1 [[B:%.*]], i64 undef, i64 [[COND_SROA_SPECULATE_LOAD_FALSE]] ; CHECK-NEXT: ret void ; %c = alloca i64, align 8 - %p.0.c = select i1 undef, i64* %c, i64* %c + %p.0.c = select i1 %a, i64* %c, i64* %c %asc = addrspacecast i64* %p.0.c to i64 addrspace(1)* - %cond.in = select i1 undef, i64 addrspace(1)* %asc, i64 addrspace(1)* @gv + %cond.in = select i1 %b, i64 addrspace(1)* %asc, i64 addrspace(1)* @gv %cond = load i64, i64 addrspace(1)* %cond.in, align 8 ret void } @@ -303,21 +303,21 @@ define void @select_addrspacecast_gv(i1 %a, i1 %b) { define void @select_addrspacecast_gv_constexpr(i1 %a, i1 %b) { ; CHECK-LABEL: @select_addrspacecast_gv_constexpr( ; CHECK-NEXT: [[COND_SROA_SPECULATE_LOAD_FALSE:%.*]] = load i64, i64 addrspace(2)* addrspacecast (i64 addrspace(1)* @gv to i64 addrspace(2)*), align 8 -; CHECK-NEXT: [[COND_SROA_SPECULATED:%.*]] = select i1 undef, i64 undef, i64 [[COND_SROA_SPECULATE_LOAD_FALSE]] +; CHECK-NEXT: [[COND_SROA_SPECULATED:%.*]] = select i1 [[B:%.*]], i64 undef, i64 [[COND_SROA_SPECULATE_LOAD_FALSE]] ; CHECK-NEXT: ret void ; %c = alloca i64, align 8 - %p.0.c = select i1 undef, i64* %c, i64* %c + %p.0.c = select i1 %a, i64* %c, i64* %c %asc = addrspacecast i64* %p.0.c to i64 addrspace(2)* - %cond.in = select i1 undef, i64 addrspace(2)* %asc, i64 addrspace(2)* addrspacecast (i64 addrspace(1)* @gv to i64 addrspace(2)*) + %cond.in = select i1 %b, i64 addrspace(2)* %asc, i64 addrspace(2)* addrspacecast (i64 addrspace(1)* @gv to i64 addrspace(2)*) %cond = load i64, i64 addrspace(2)* %cond.in, align 8 ret void } -define i8 @select_addrspacecast_i8() { +define i8 @select_addrspacecast_i8(i1 %c) { ; CHECK-LABEL: @select_addrspacecast_i8( -; CHECK-NEXT: [[RET_SROA_SPECULATED:%.*]] = select i1 undef, i8 undef, i8 undef +; CHECK-NEXT: [[RET_SROA_SPECULATED:%.*]] = select i1 [[C:%.*]], i8 undef, i8 undef ; CHECK-NEXT: ret i8 [[RET_SROA_SPECULATED]] ; %a = alloca i8 @@ -326,7 +326,7 @@ define i8 @select_addrspacecast_i8() { %a.ptr = addrspacecast i8* %a to i8 addrspace(1)* %b.ptr = addrspacecast i8* %b to i8 addrspace(1)* - %ptr = select i1 undef, i8 addrspace(1)* %a.ptr, i8 addrspace(1)* %b.ptr + %ptr = select i1 %c, i8 addrspace(1)* %a.ptr, i8 addrspace(1)* %b.ptr %ret = load i8, i8 addrspace(1)* %ptr ret i8 %ret } diff --git a/llvm/test/Transforms/SROA/alloca-address-space.ll b/llvm/test/Transforms/SROA/alloca-address-space.ll index 03f4500..fa0fc24 100644 --- a/llvm/test/Transforms/SROA/alloca-address-space.ll +++ b/llvm/test/Transforms/SROA/alloca-address-space.ll @@ -54,14 +54,14 @@ define void @test_address_space_0_1(<2 x i64> addrspace(2)* %a, i16 addrspace(1) ; CHECK-LABEL: @copy_struct( ; CHECK-NOT: memcpy -define void @copy_struct([5 x i64] %in.coerce) { +define void @copy_struct([5 x i64] %in.coerce, i8 addrspace(1)* align 4 %ptr) { for.end: %in = alloca %struct.struct_test_27.0.13, align 8, addrspace(2) %0 = bitcast %struct.struct_test_27.0.13 addrspace(2)* %in to [5 x i64] addrspace(2)* store [5 x i64] %in.coerce, [5 x i64] addrspace(2)* %0, align 8 %scevgep9 = getelementptr %struct.struct_test_27.0.13, %struct.struct_test_27.0.13 addrspace(2)* %in, i32 0, i32 4, i32 0 %scevgep910 = bitcast i32 addrspace(2)* %scevgep9 to i8 addrspace(2)* - call void @llvm.memcpy.p1i8.p2i8.i32(i8 addrspace(1)* align 4 undef, i8 addrspace(2)* align 4 %scevgep910, i32 16, i1 false) + call void @llvm.memcpy.p1i8.p2i8.i32(i8 addrspace(1)* align 4 %ptr, i8 addrspace(2)* align 4 %scevgep910, i32 16, i1 false) ret void } diff --git a/llvm/test/Transforms/SROA/assume.ll b/llvm/test/Transforms/SROA/assume.ll index 2c24e2f..9043d49 100644 --- a/llvm/test/Transforms/SROA/assume.ll +++ b/llvm/test/Transforms/SROA/assume.ll @@ -1,7 +1,6 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py ; RUN: opt < %s -passes=sroa -S | FileCheck %s -source_filename = "tmp.cpp" target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu" @@ -11,7 +10,7 @@ target triple = "x86_64-unknown-linux-gnu" %class.ao = type { %class.ai } %class.ai = type { i32, i32 } -define linkonce_odr dso_local void @_ZN2bg2baIiEC2ES_() unnamed_addr align 2 { +define void @_ZN2bg2baIiEC2ES_(i64 %v) { ; CHECK-LABEL: @_ZN2bg2baIiEC2ES_( ; CHECK-NEXT: entry: ; CHECK-NEXT: call void @llvm.assume(i1 true) [ "ignore"(%struct.bi* undef) ] @@ -19,7 +18,7 @@ define linkonce_odr dso_local void @_ZN2bg2baIiEC2ES_() unnamed_addr align 2 { ; entry: %y = alloca i64, align 8 - store i64 undef, i64* %y, align 8 + store i64 %v, i64* %y, align 8 %0 = bitcast i64* %y to %struct.n.2* %1 = bitcast %struct.n.2* %0 to %struct.bi* call void @llvm.assume(i1 true) [ "nonnull"(%struct.bi* %1) ] diff --git a/llvm/test/Transforms/SROA/basictest-opaque-ptrs.ll b/llvm/test/Transforms/SROA/basictest-opaque-ptrs.ll index 339149b..a524add 100644 --- a/llvm/test/Transforms/SROA/basictest-opaque-ptrs.ll +++ b/llvm/test/Transforms/SROA/basictest-opaque-ptrs.ll @@ -515,7 +515,7 @@ define %S2 @test8(%S2* %arg) { ; CHECK-NEXT: [[S2_NEXT_S1:%.*]] = load ptr, ptr [[S2_NEXT_S1_PTR]], align 8, !tbaa [[TBAA3]] ; CHECK-NEXT: [[S2_NEXT_NEXT_PTR:%.*]] = getelementptr [[S2]], ptr [[S2_NEXT]], i64 0, i32 1 ; CHECK-NEXT: [[S2_NEXT_NEXT:%.*]] = load ptr, ptr [[S2_NEXT_NEXT_PTR]], align 8, !tbaa [[TBAA7]] -; CHECK-NEXT: [[RESULT1:%.*]] = insertvalue [[S2]] undef, ptr [[S2_NEXT_S1]], 0 +; CHECK-NEXT: [[RESULT1:%.*]] = insertvalue [[S2]] poison, ptr [[S2_NEXT_S1]], 0 ; CHECK-NEXT: [[RESULT2:%.*]] = insertvalue [[S2]] [[RESULT1]], ptr [[S2_NEXT_NEXT]], 1 ; CHECK-NEXT: ret [[S2]] [[RESULT2]] ; @@ -535,7 +535,7 @@ entry: store %S2* %s2.next.next, %S2** %new.next.ptr, !tbaa !9 %new.s1 = load %S1*, %S1** %new.s1.ptr - %result1 = insertvalue %S2 undef, %S1* %new.s1, 0 + %result1 = insertvalue %S2 poison, %S1* %new.s1, 0 %new.next = load %S2*, %S2** %new.next.ptr %result2 = insertvalue %S2 %result1, %S2* %new.next, 1 ret %S2 %result2 @@ -594,10 +594,10 @@ entry: ret %S2* %s2ptr } -define i32 @test11() { +define i32 @test11(i1 %c) { ; CHECK-LABEL: @test11( ; CHECK-NEXT: entry: -; CHECK-NEXT: br i1 undef, label [[GOOD:%.*]], label [[BAD:%.*]] +; CHECK-NEXT: br i1 [[C:%.*]], label [[GOOD:%.*]], label [[BAD:%.*]] ; CHECK: good: ; CHECK-NEXT: ret i32 0 ; CHECK: bad: @@ -606,7 +606,7 @@ define i32 @test11() { entry: %X = alloca i32 - br i1 undef, label %good, label %bad + br i1 %c, label %good, label %bad good: %Y = getelementptr i32, i32* %X, i64 0 @@ -855,7 +855,7 @@ entry: %opaque = type opaque -define i32 @test19(%opaque* %x) { +define i64 @test19(%opaque* %x) { ; This input will cause us to try to compute a natural GEP when rewriting ; pointers in such a way that we try to GEP through the opaque type. Previously, ; a check for an unsized type was missing and this crashed. Ensure it behaves @@ -866,7 +866,7 @@ define i32 @test19(%opaque* %x) { ; CHECK-NEXT: [[A_SROA_0_0_COPYLOAD:%.*]] = load i64, ptr [[CAST1]], align 1 ; CHECK-NEXT: [[A_SROA_2_0_CAST1_SROA_IDX:%.*]] = getelementptr inbounds i8, ptr [[CAST1]], i64 8 ; CHECK-NEXT: [[A_SROA_2_0_COPYLOAD:%.*]] = load ptr, ptr [[A_SROA_2_0_CAST1_SROA_IDX]], align 1 -; CHECK-NEXT: ret i32 undef +; CHECK-NEXT: ret i64 [[A_SROA_0_0_COPYLOAD]] ; entry: @@ -876,12 +876,12 @@ entry: call void @llvm.memcpy.p0i8.p0i8.i32(i8* %cast2, i8* %cast1, i32 16, i1 false) %gep = getelementptr inbounds { i64, i8* }, { i64, i8* }* %a, i32 0, i32 0 %val = load i64, i64* %gep - ret i32 undef + ret i64 %val } declare void @llvm.memcpy.p0i8.p1i8.i32(i8* nocapture, i8 addrspace(1)* nocapture, i32, i32, i1) nounwind -define i32 @test19_addrspacecast(%opaque* %x) { +define i64 @test19_addrspacecast(%opaque* %x) { ; This input will cause us to try to compute a natural GEP when rewriting ; pointers in such a way that we try to GEP through the opaque type. Previously, ; a check for an unsized type was missing and this crashed. Ensure it behaves @@ -892,7 +892,7 @@ define i32 @test19_addrspacecast(%opaque* %x) { ; CHECK-NEXT: [[A_SROA_0_0_COPYLOAD:%.*]] = load i64, ptr addrspace(1) [[CAST1]], align 1 ; CHECK-NEXT: [[A_SROA_2_0_CAST1_SROA_IDX:%.*]] = getelementptr inbounds i8, ptr addrspace(1) [[CAST1]], i16 8 ; CHECK-NEXT: [[A_SROA_2_0_COPYLOAD:%.*]] = load ptr, ptr addrspace(1) [[A_SROA_2_0_CAST1_SROA_IDX]], align 1 -; CHECK-NEXT: ret i32 undef +; CHECK-NEXT: ret i64 [[A_SROA_0_0_COPYLOAD]] ; entry: @@ -902,7 +902,7 @@ entry: call void @llvm.memcpy.p0i8.p1i8.i32(i8* %cast2, i8 addrspace(1)* %cast1, i32 16, i32 1, i1 false) %gep = getelementptr inbounds { i64, i8* }, { i64, i8* }* %a, i32 0, i32 0 %val = load i64, i64* %gep - ret i32 undef + ret i64 %val } define i32 @test20() { @@ -983,13 +983,13 @@ entry: ret void } -define void @PR13916.2() { +define void @PR13916.2(i1 %c) { ; Check whether we continue to handle them correctly when they start off with ; different pointer value chains, but during rewriting we coalesce them into the ; same value. ; CHECK-LABEL: @PR13916.2( ; CHECK-NEXT: entry: -; CHECK-NEXT: br i1 undef, label [[IF_THEN:%.*]], label [[IF_END:%.*]] +; CHECK-NEXT: br i1 [[C:%.*]], label [[IF_THEN:%.*]], label [[IF_END:%.*]] ; CHECK: if.then: ; CHECK-NEXT: br label [[IF_END]] ; CHECK: if.end: @@ -998,7 +998,7 @@ define void @PR13916.2() { entry: %a = alloca %PR13916.struct, align 1 - br i1 undef, label %if.then, label %if.end + br i1 %c, label %if.then, label %if.end if.then: %tmp0 = bitcast %PR13916.struct* %a to i8* @@ -1012,41 +1012,41 @@ if.end: ret void } -define void @PR13990() { +define void @PR13990(i1 %c1, i1 %c2, i1 %c3, i1 %c4, i8* %ptr) { ; Ensure we can handle cases where processing one alloca causes the other ; alloca to become dead and get deleted. This might crash or fail under ; Valgrind if we regress. ; CHECK-LABEL: @PR13990( ; CHECK-NEXT: entry: -; CHECK-NEXT: br i1 undef, label [[BB1:%.*]], label [[BB2:%.*]] +; CHECK-NEXT: br i1 [[C1:%.*]], label [[BB1:%.*]], label [[BB2:%.*]] ; CHECK: bb1: -; CHECK-NEXT: br i1 undef, label [[BB2]], label [[BB3:%.*]] +; CHECK-NEXT: br i1 [[C2:%.*]], label [[BB2]], label [[BB3:%.*]] ; CHECK: bb2: -; CHECK-NEXT: br i1 undef, label [[BB3]], label [[BB4:%.*]] +; CHECK-NEXT: br i1 [[C4:%.*]], label [[BB3]], label [[BB4:%.*]] ; CHECK: bb3: -; CHECK-NEXT: unreachable +; CHECK-NEXT: ret void ; CHECK: bb4: -; CHECK-NEXT: unreachable +; CHECK-NEXT: ret void ; entry: %tmp1 = alloca i8* %tmp2 = alloca i8* - br i1 undef, label %bb1, label %bb2 + br i1 %c1, label %bb1, label %bb2 bb1: - store i8* undef, i8** %tmp2 - br i1 undef, label %bb2, label %bb3 + store i8* %ptr, i8** %tmp2 + br i1 %c2, label %bb2, label %bb3 bb2: - %tmp50 = select i1 undef, i8** %tmp2, i8** %tmp1 - br i1 undef, label %bb3, label %bb4 + %tmp50 = select i1 %c3, i8** %tmp2, i8** %tmp1 + br i1 %c4, label %bb3, label %bb4 bb3: - unreachable + ret void bb4: - unreachable + ret void } define double @PR13969(double %x) { @@ -1075,14 +1075,14 @@ entry: %PR14034.struct = type { { {} }, i32, %PR14034.list } %PR14034.list = type { %PR14034.list*, %PR14034.list* } -define void @PR14034() { +define void @PR14034(%PR14034.list* %ptr, %PR14034.struct* %ptr2) { ; This test case tries to form GEPs into the empty leading struct members, and ; subsequently crashed (under valgrind) before we fixed the PR. The important ; thing is to handle empty structs gracefully. ; CHECK-LABEL: @PR14034( ; CHECK-NEXT: entry: ; CHECK-NEXT: [[A_SROA_0:%.*]] = alloca [12 x i8], align 8 -; CHECK-NEXT: [[CAST0:%.*]] = bitcast ptr undef to ptr +; CHECK-NEXT: [[CAST0:%.*]] = bitcast ptr [[PTR2:%.*]] to ptr ; CHECK-NEXT: call void @llvm.memcpy.p0.p0.i32(ptr align 1 [[CAST0]], ptr align 8 [[A_SROA_0]], i32 12, i1 false) ; CHECK-NEXT: ret void ; @@ -1091,8 +1091,8 @@ entry: %a = alloca %PR14034.struct %list = getelementptr %PR14034.struct, %PR14034.struct* %a, i32 0, i32 2 %prev = getelementptr %PR14034.list, %PR14034.list* %list, i32 0, i32 1 - store %PR14034.list* undef, %PR14034.list** %prev - %cast0 = bitcast %PR14034.struct* undef to i8* + store %PR14034.list* %ptr, %PR14034.list** %prev + %cast0 = bitcast %PR14034.struct* %ptr2 to i8* %cast1 = bitcast %PR14034.struct* %a to i8* call void @llvm.memcpy.p0i8.p0i8.i32(i8* %cast0, i8* %cast1, i32 12, i1 false) ret void @@ -1103,17 +1103,17 @@ define i32 @test22(i32 %x) { ; types involving wrapper aggregates and zero-length aggregate members. ; CHECK-LABEL: @test22( ; CHECK-NEXT: entry: -; CHECK-NEXT: [[WRAP1:%.*]] = insertvalue [1 x { i32 }] undef, i32 [[X:%.*]], 0, 0 +; CHECK-NEXT: [[WRAP1:%.*]] = insertvalue [1 x { i32 }] poison, i32 [[X:%.*]], 0, 0 ; CHECK-NEXT: [[WRAP1_FCA_0_0_EXTRACT:%.*]] = extractvalue [1 x { i32 }] [[WRAP1]], 0, 0 ; CHECK-NEXT: [[TMP0:%.*]] = bitcast i32 [[WRAP1_FCA_0_0_EXTRACT]] to float ; CHECK-NEXT: [[LOAD1_FCA_0_0_0_INSERT:%.*]] = insertvalue { [1 x { float }] } poison, float [[TMP0]], 0, 0, 0 ; CHECK-NEXT: [[UNWRAP1:%.*]] = extractvalue { [1 x { float }] } [[LOAD1_FCA_0_0_0_INSERT]], 0, 0 -; CHECK-NEXT: [[WRAP2:%.*]] = insertvalue { {}, { float }, [0 x i8] } undef, { float } [[UNWRAP1]], 1 +; CHECK-NEXT: [[WRAP2:%.*]] = insertvalue { {}, { float }, [0 x i8] } poison, { float } [[UNWRAP1]], 1 ; CHECK-NEXT: [[WRAP2_FCA_1_0_EXTRACT:%.*]] = extractvalue { {}, { float }, [0 x i8] } [[WRAP2]], 1, 0 ; CHECK-NEXT: [[TMP1:%.*]] = bitcast float [[WRAP2_FCA_1_0_EXTRACT]] to <4 x i8> ; CHECK-NEXT: [[VALCAST1:%.*]] = bitcast <4 x i8> [[TMP1]] to i32 -; CHECK-NEXT: [[WRAP3:%.*]] = insertvalue [1 x [1 x i32]] undef, i32 [[VALCAST1]], 0, 0 -; CHECK-NEXT: [[WRAP4:%.*]] = insertvalue { [1 x [1 x i32]], {} } undef, [1 x [1 x i32]] [[WRAP3]], 0 +; CHECK-NEXT: [[WRAP3:%.*]] = insertvalue [1 x [1 x i32]] poison, i32 [[VALCAST1]], 0, 0 +; CHECK-NEXT: [[WRAP4:%.*]] = insertvalue { [1 x [1 x i32]], {} } poison, [1 x [1 x i32]] [[WRAP3]], 0 ; CHECK-NEXT: [[WRAP4_FCA_0_0_0_EXTRACT:%.*]] = extractvalue { [1 x [1 x i32]], {} } [[WRAP4]], 0, 0, 0 ; CHECK-NEXT: [[TMP2:%.*]] = bitcast i32 [[WRAP4_FCA_0_0_0_EXTRACT]] to <4 x i8> ; CHECK-NEXT: [[TMP3:%.*]] = bitcast <4 x i8> [[TMP2]] to float @@ -1128,7 +1128,7 @@ entry: %a2 = alloca { {}, { float }, [0 x i8] } %a3 = alloca { [0 x i8], { [0 x double], [1 x [1 x <4 x i8>]], {} }, { { {} } } } - %wrap1 = insertvalue [1 x { i32 }] undef, i32 %x, 0, 0 + %wrap1 = insertvalue [1 x { i32 }] poison, i32 %x, 0, 0 %gep1 = getelementptr { { [1 x { i32 }] } }, { { [1 x { i32 }] } }* %a1, i32 0, i32 0, i32 0 store [1 x { i32 }] %wrap1, [1 x { i32 }]* %gep1 @@ -1137,7 +1137,7 @@ entry: %load1 = load { [1 x { float }] }, { [1 x { float }] }* %ptrcast1 %unwrap1 = extractvalue { [1 x { float }] } %load1, 0, 0 - %wrap2 = insertvalue { {}, { float }, [0 x i8] } undef, { float } %unwrap1, 1 + %wrap2 = insertvalue { {}, { float }, [0 x i8] } poison, { float } %unwrap1, 1 store { {}, { float }, [0 x i8] } %wrap2, { {}, { float }, [0 x i8] }* %a2 %gep3 = getelementptr { {}, { float }, [0 x i8] }, { {}, { float }, [0 x i8] }* %a2, i32 0, i32 1, i32 0 @@ -1145,8 +1145,8 @@ entry: %load3 = load <4 x i8>, <4 x i8>* %ptrcast2 %valcast1 = bitcast <4 x i8> %load3 to i32 - %wrap3 = insertvalue [1 x [1 x i32]] undef, i32 %valcast1, 0, 0 - %wrap4 = insertvalue { [1 x [1 x i32]], {} } undef, [1 x [1 x i32]] %wrap3, 0 + %wrap3 = insertvalue [1 x [1 x i32]] poison, i32 %valcast1, 0, 0 + %wrap4 = insertvalue { [1 x [1 x i32]], {} } poison, [1 x [1 x i32]] %wrap3, 0 %gep4 = getelementptr { [0 x i8], { [0 x double], [1 x [1 x <4 x i8>]], {} }, { { {} } } }, { [0 x i8], { [0 x double], [1 x [1 x <4 x i8>]], {} }, { { {} } } }* %a3, i32 0, i32 1 %ptrcast3 = bitcast { [0 x double], [1 x [1 x <4 x i8>]], {} }* %gep4 to { [1 x [1 x i32]], {} }* store { [1 x [1 x i32]], {} } %wrap4, { [1 x [1 x i32]], {} }* %ptrcast3 @@ -1531,20 +1531,20 @@ end: ret void } -define void @PR15805(i1 %a, i1 %b) { +define i64 @PR15805(i1 %a, i1 %b) { ; CHECK-LABEL: @PR15805( -; CHECK-NEXT: [[COND_SROA_SPECULATED:%.*]] = select i1 undef, i64 undef, i64 undef -; CHECK-NEXT: ret void +; CHECK-NEXT: [[COND_SROA_SPECULATED:%.*]] = select i1 [[B:%.*]], i64 undef, i64 undef +; CHECK-NEXT: ret i64 [[COND_SROA_SPECULATED]] ; %c = alloca i64, align 8 - %p.0.c = select i1 undef, i64* %c, i64* %c - %cond.in = select i1 undef, i64* %p.0.c, i64* %c + %p.0.c = select i1 %a, i64* %c, i64* %c + %cond.in = select i1 %b, i64* %p.0.c, i64* %c %cond = load i64, i64* %cond.in, align 8 - ret void + ret i64 %cond } -define void @PR15805.1(i1 %a, i1 %b) { +define void @PR15805.1(i1 %a, i1 %b, i1 %c1) { ; Same as the normal PR15805, but rigged to place the use before the def inside ; of looping unreachable code. This helps ensure that we aren't sensitive to the ; order in which the uses of the alloca are visited. @@ -1552,8 +1552,8 @@ define void @PR15805.1(i1 %a, i1 %b) { ; CHECK-LABEL: @PR15805.1( ; CHECK-NEXT: br label [[EXIT:%.*]] ; CHECK: loop: -; CHECK-NEXT: [[COND_SROA_SPECULATED:%.*]] = select i1 undef, i64 undef, i64 undef -; CHECK-NEXT: br i1 undef, label [[LOOP:%.*]], label [[EXIT]] +; CHECK-NEXT: [[COND_SROA_SPECULATED:%.*]] = select i1 [[A:%.*]], i64 undef, i64 undef +; CHECK-NEXT: br i1 [[C1:%.*]], label [[LOOP:%.*]], label [[EXIT]] ; CHECK: exit: ; CHECK-NEXT: ret void ; @@ -1562,16 +1562,16 @@ define void @PR15805.1(i1 %a, i1 %b) { br label %exit loop: - %cond.in = select i1 undef, i64* %c, i64* %p.0.c - %p.0.c = select i1 undef, i64* %c, i64* %c + %cond.in = select i1 %a, i64* %c, i64* %p.0.c + %p.0.c = select i1 %b, i64* %c, i64* %c %cond = load i64, i64* %cond.in, align 8 - br i1 undef, label %loop, label %exit + br i1 %c1, label %loop, label %exit exit: ret void } -define void @PR16651.1(i8* %a) { +define i8 @PR16651.1(i8* %a) { ; This test case caused a crash due to the volatile memcpy in combination with ; lowering to integer loads and stores of a width other than that of the original ; memcpy. @@ -1589,8 +1589,8 @@ define void @PR16651.1(i8* %a) { ; CHECK-NEXT: [[B_SROA_2_0_A_SROA_IDX:%.*]] = getelementptr inbounds i8, ptr [[A]], i64 3 ; CHECK-NEXT: [[B_SROA_2_0_COPYLOAD:%.*]] = load volatile i8, ptr [[B_SROA_2_0_A_SROA_IDX]], align 1 ; CHECK-NEXT: store volatile i8 [[B_SROA_2_0_COPYLOAD]], ptr [[B_SROA_2]], align 1 -; CHECK-NEXT: [[B_SROA_1_0_B_SROA_1_2_:%.*]] = load i8, ptr [[B_SROA_1]], align 2 -; CHECK-NEXT: unreachable +; CHECK-NEXT: [[B_SROA_1_0_B_SROA_1_2_V:%.*]] = load i8, ptr [[B_SROA_1]], align 2 +; CHECK-NEXT: ret i8 [[B_SROA_1_0_B_SROA_1_2_V]] ; entry: @@ -1598,11 +1598,11 @@ entry: %b.cast = bitcast i32* %b to i8* call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %b.cast, i8* align 4 %a, i32 4, i1 true) %b.gep = getelementptr inbounds i8, i8* %b.cast, i32 2 - load i8, i8* %b.gep, align 2 - unreachable + %v = load i8, i8* %b.gep, align 2 + ret i8 %v } -define void @PR16651.2() { +define float @PR16651.2(<2 x float> %val, i1 %c1) { ; This test case caused a crash due to failing to promote given a select that ; can't be speculated. It shouldn't be promoted, but we missed that fact when ; analyzing whether we could form a vector promotion because that code didn't @@ -1611,20 +1611,20 @@ define void @PR16651.2() { ; CHECK-LABEL: @PR16651.2( ; CHECK-NEXT: entry: ; CHECK-NEXT: [[TV1_SROA_0:%.*]] = alloca <2 x float>, align 8 -; CHECK-NEXT: store <2 x float> undef, ptr [[TV1_SROA_0]], align 8 -; CHECK-NEXT: [[COND105_IN_I_I:%.*]] = select i1 undef, ptr null, ptr [[TV1_SROA_0]] +; CHECK-NEXT: store <2 x float> [[VAL:%.*]], ptr [[TV1_SROA_0]], align 8 +; CHECK-NEXT: [[COND105_IN_I_I:%.*]] = select i1 [[C1:%.*]], ptr null, ptr [[TV1_SROA_0]] ; CHECK-NEXT: [[COND105_I_I:%.*]] = load float, ptr [[COND105_IN_I_I]], align 8 -; CHECK-NEXT: ret void +; CHECK-NEXT: ret float [[COND105_I_I]] ; entry: %tv1 = alloca { <2 x float>, <2 x float> }, align 8 %0 = getelementptr { <2 x float>, <2 x float> }, { <2 x float>, <2 x float> }* %tv1, i64 0, i32 1 - store <2 x float> undef, <2 x float>* %0, align 8 + store <2 x float> %val, <2 x float>* %0, align 8 %1 = getelementptr inbounds { <2 x float>, <2 x float> }, { <2 x float>, <2 x float> }* %tv1, i64 0, i32 1, i64 0 - %cond105.in.i.i = select i1 undef, float* null, float* %1 + %cond105.in.i.i = select i1 %c1, float* null, float* %1 %cond105.i.i = load float, float* %cond105.in.i.i, align 8 - ret void + ret float %cond105.i.i } define void @test23(i32 %x) { @@ -1643,7 +1643,7 @@ entry: ret void } -define void @PR18615() { +define void @PR18615(i8* %ptr) { ; CHECK-LABEL: @PR18615( ; CHECK-NEXT: entry: ; CHECK-NEXT: ret void @@ -1651,7 +1651,7 @@ define void @PR18615() { entry: %f = alloca i8 %gep = getelementptr i8, i8* %f, i64 -1 - call void @llvm.memcpy.p0i8.p0i8.i32(i8* undef, i8* %gep, i32 1, i1 false) + call void @llvm.memcpy.p0i8.p0i8.i32(i8* %ptr, i8* %gep, i32 1, i1 false) ret void } @@ -2025,7 +2025,7 @@ entry: declare void @llvm.lifetime.start.isVoid.i64.p0i8(i64, [10 x float]* nocapture) declare void @llvm.lifetime.end.isVoid.i64.p0i8(i64, [10 x float]* nocapture) -@array = dso_local global [10 x float] undef, align 4 +@array = dso_local global [10 x float] zeroinitializer, align 4 define void @test29(i32 %num, i32 %tid) { ; CHECK-LABEL: @test29( diff --git a/llvm/test/Transforms/SROA/basictest.ll b/llvm/test/Transforms/SROA/basictest.ll index 66443c1..82221b4 100644 --- a/llvm/test/Transforms/SROA/basictest.ll +++ b/llvm/test/Transforms/SROA/basictest.ll @@ -580,7 +580,7 @@ define %S2 @test8(%S2* %arg) { ; CHECK-NEXT: [[S2_NEXT_S1:%.*]] = load %S1*, %S1** [[S2_NEXT_S1_PTR]], align 8, !tbaa [[TBAA3]] ; CHECK-NEXT: [[S2_NEXT_NEXT_PTR:%.*]] = getelementptr [[S2]], %S2* [[S2_NEXT]], i64 0, i32 1 ; CHECK-NEXT: [[S2_NEXT_NEXT:%.*]] = load %S2*, %S2** [[S2_NEXT_NEXT_PTR]], align 8, !tbaa [[TBAA7]] -; CHECK-NEXT: [[RESULT1:%.*]] = insertvalue [[S2]] undef, %S1* [[S2_NEXT_S1]], 0 +; CHECK-NEXT: [[RESULT1:%.*]] = insertvalue [[S2]] poison, %S1* [[S2_NEXT_S1]], 0 ; CHECK-NEXT: [[RESULT2:%.*]] = insertvalue [[S2]] [[RESULT1]], %S2* [[S2_NEXT_NEXT]], 1 ; CHECK-NEXT: ret [[S2]] [[RESULT2]] ; @@ -600,7 +600,7 @@ entry: store %S2* %s2.next.next, %S2** %new.next.ptr, !tbaa !9 %new.s1 = load %S1*, %S1** %new.s1.ptr - %result1 = insertvalue %S2 undef, %S1* %new.s1, 0 + %result1 = insertvalue %S2 poison, %S1* %new.s1, 0 %new.next = load %S2*, %S2** %new.next.ptr %result2 = insertvalue %S2 %result1, %S2* %new.next, 1 ret %S2 %result2 @@ -659,10 +659,10 @@ entry: ret %S2* %s2ptr } -define i32 @test11() { +define i32 @test11(i1 %c1) { ; CHECK-LABEL: @test11( ; CHECK-NEXT: entry: -; CHECK-NEXT: br i1 undef, label [[GOOD:%.*]], label [[BAD:%.*]] +; CHECK-NEXT: br i1 [[C1:%.*]], label [[GOOD:%.*]], label [[BAD:%.*]] ; CHECK: good: ; CHECK-NEXT: ret i32 0 ; CHECK: bad: @@ -671,7 +671,7 @@ define i32 @test11() { entry: %X = alloca i32 - br i1 undef, label %good, label %bad + br i1 %c1, label %good, label %bad good: %Y = getelementptr i32, i32* %X, i64 0 @@ -929,7 +929,7 @@ entry: %opaque = type opaque -define i32 @test19(%opaque* %x) { +define i64 @test19(%opaque* %x) { ; This input will cause us to try to compute a natural GEP when rewriting ; pointers in such a way that we try to GEP through the opaque type. Previously, ; a check for an unsized type was missing and this crashed. Ensure it behaves @@ -942,7 +942,7 @@ define i32 @test19(%opaque* %x) { ; CHECK-NEXT: [[A_SROA_2_0_CAST1_SROA_IDX:%.*]] = getelementptr inbounds i8, i8* [[CAST1]], i64 8 ; CHECK-NEXT: [[A_SROA_2_0_CAST1_SROA_CAST:%.*]] = bitcast i8* [[A_SROA_2_0_CAST1_SROA_IDX]] to i8** ; CHECK-NEXT: [[A_SROA_2_0_COPYLOAD:%.*]] = load i8*, i8** [[A_SROA_2_0_CAST1_SROA_CAST]], align 1 -; CHECK-NEXT: ret i32 undef +; CHECK-NEXT: ret i64 [[A_SROA_0_0_COPYLOAD]] ; entry: @@ -952,12 +952,12 @@ entry: call void @llvm.memcpy.p0i8.p0i8.i32(i8* %cast2, i8* %cast1, i32 16, i1 false) %gep = getelementptr inbounds { i64, i8* }, { i64, i8* }* %a, i32 0, i32 0 %val = load i64, i64* %gep - ret i32 undef + ret i64 %val } declare void @llvm.memcpy.p0i8.p1i8.i32(i8* nocapture, i8 addrspace(1)* nocapture, i32, i32, i1) nounwind -define i32 @test19_addrspacecast(%opaque* %x) { +define i64 @test19_addrspacecast(%opaque* %x) { ; This input will cause us to try to compute a natural GEP when rewriting ; pointers in such a way that we try to GEP through the opaque type. Previously, ; a check for an unsized type was missing and this crashed. Ensure it behaves @@ -970,7 +970,7 @@ define i32 @test19_addrspacecast(%opaque* %x) { ; CHECK-NEXT: [[A_SROA_2_0_CAST1_SROA_IDX:%.*]] = getelementptr inbounds i8, i8 addrspace(1)* [[CAST1]], i16 8 ; CHECK-NEXT: [[A_SROA_2_0_CAST1_SROA_CAST:%.*]] = bitcast i8 addrspace(1)* [[A_SROA_2_0_CAST1_SROA_IDX]] to i8* addrspace(1)* ; CHECK-NEXT: [[A_SROA_2_0_COPYLOAD:%.*]] = load i8*, i8* addrspace(1)* [[A_SROA_2_0_CAST1_SROA_CAST]], align 1 -; CHECK-NEXT: ret i32 undef +; CHECK-NEXT: ret i64 [[A_SROA_0_0_COPYLOAD]] ; entry: @@ -980,7 +980,7 @@ entry: call void @llvm.memcpy.p0i8.p1i8.i32(i8* %cast2, i8 addrspace(1)* %cast1, i32 16, i32 1, i1 false) %gep = getelementptr inbounds { i64, i8* }, { i64, i8* }* %a, i32 0, i32 0 %val = load i64, i64* %gep - ret i32 undef + ret i64 %val } define i32 @test20() { @@ -1061,13 +1061,13 @@ entry: ret void } -define void @PR13916.2() { +define void @PR13916.2(i1 %c1) { ; Check whether we continue to handle them correctly when they start off with ; different pointer value chains, but during rewriting we coalesce them into the ; same value. ; CHECK-LABEL: @PR13916.2( ; CHECK-NEXT: entry: -; CHECK-NEXT: br i1 undef, label [[IF_THEN:%.*]], label [[IF_END:%.*]] +; CHECK-NEXT: br i1 [[C1:%.*]], label [[IF_THEN:%.*]], label [[IF_END:%.*]] ; CHECK: if.then: ; CHECK-NEXT: br label [[IF_END]] ; CHECK: if.end: @@ -1076,7 +1076,7 @@ define void @PR13916.2() { entry: %a = alloca %PR13916.struct, align 1 - br i1 undef, label %if.then, label %if.end + br i1 %c1, label %if.then, label %if.end if.then: %tmp0 = bitcast %PR13916.struct* %a to i8* @@ -1090,17 +1090,17 @@ if.end: ret void } -define void @PR13990() { +define void @PR13990(i1 %c1, i1 %c2, i1 %c3, i1 %c4, i8* %ptr) { ; Ensure we can handle cases where processing one alloca causes the other ; alloca to become dead and get deleted. This might crash or fail under ; Valgrind if we regress. ; CHECK-LABEL: @PR13990( ; CHECK-NEXT: entry: -; CHECK-NEXT: br i1 undef, label [[BB1:%.*]], label [[BB2:%.*]] +; CHECK-NEXT: br i1 [[C1:%.*]], label [[BB1:%.*]], label [[BB2:%.*]] ; CHECK: bb1: -; CHECK-NEXT: br i1 undef, label [[BB2]], label [[BB3:%.*]] +; CHECK-NEXT: br i1 [[C2:%.*]], label [[BB2]], label [[BB3:%.*]] ; CHECK: bb2: -; CHECK-NEXT: br i1 undef, label [[BB3]], label [[BB4:%.*]] +; CHECK-NEXT: br i1 [[C4:%.*]], label [[BB3]], label [[BB4:%.*]] ; CHECK: bb3: ; CHECK-NEXT: unreachable ; CHECK: bb4: @@ -1110,15 +1110,15 @@ define void @PR13990() { entry: %tmp1 = alloca i8* %tmp2 = alloca i8* - br i1 undef, label %bb1, label %bb2 + br i1 %c1, label %bb1, label %bb2 bb1: - store i8* undef, i8** %tmp2 - br i1 undef, label %bb2, label %bb3 + store i8* %ptr, i8** %tmp2 + br i1 %c2, label %bb2, label %bb3 bb2: - %tmp50 = select i1 undef, i8** %tmp2, i8** %tmp1 - br i1 undef, label %bb3, label %bb4 + %tmp50 = select i1 %c3, i8** %tmp2, i8** %tmp1 + br i1 %c4, label %bb3, label %bb4 bb3: unreachable @@ -1153,15 +1153,16 @@ entry: %PR14034.struct = type { { {} }, i32, %PR14034.list } %PR14034.list = type { %PR14034.list*, %PR14034.list* } -define void @PR14034() { +define void @PR14034(%PR14034.list* %ptr, %PR14034.struct* %ptr2) { ; This test case tries to form GEPs into the empty leading struct members, and ; subsequently crashed (under valgrind) before we fixed the PR. The important ; thing is to handle empty structs gracefully. ; CHECK-LABEL: @PR14034( ; CHECK-NEXT: entry: ; CHECK-NEXT: [[A_SROA_0:%.*]] = alloca [12 x i8], align 8 +; CHECK-NEXT: [[A_SROA_0_0_CAST0_SROA_CAST:%.*]] = bitcast %PR14034.struct* [[PTR2:%.*]] to i8* ; CHECK-NEXT: [[A_SROA_0_0_CAST1_SROA_IDX:%.*]] = getelementptr inbounds [12 x i8], [12 x i8]* [[A_SROA_0]], i64 0, i64 0 -; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 undef, i8* align 8 [[A_SROA_0_0_CAST1_SROA_IDX]], i32 12, i1 false) +; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 [[A_SROA_0_0_CAST0_SROA_CAST]], i8* align 8 [[A_SROA_0_0_CAST1_SROA_IDX]], i32 12, i1 false) ; CHECK-NEXT: ret void ; @@ -1169,8 +1170,8 @@ entry: %a = alloca %PR14034.struct %list = getelementptr %PR14034.struct, %PR14034.struct* %a, i32 0, i32 2 %prev = getelementptr %PR14034.list, %PR14034.list* %list, i32 0, i32 1 - store %PR14034.list* undef, %PR14034.list** %prev - %cast0 = bitcast %PR14034.struct* undef to i8* + store %PR14034.list* %ptr, %PR14034.list** %prev + %cast0 = bitcast %PR14034.struct* %ptr2 to i8* %cast1 = bitcast %PR14034.struct* %a to i8* call void @llvm.memcpy.p0i8.p0i8.i32(i8* %cast0, i8* %cast1, i32 12, i1 false) ret void @@ -1181,17 +1182,17 @@ define i32 @test22(i32 %x) { ; types involving wrapper aggregates and zero-length aggregate members. ; CHECK-LABEL: @test22( ; CHECK-NEXT: entry: -; CHECK-NEXT: [[WRAP1:%.*]] = insertvalue [1 x { i32 }] undef, i32 [[X:%.*]], 0, 0 +; CHECK-NEXT: [[WRAP1:%.*]] = insertvalue [1 x { i32 }] poison, i32 [[X:%.*]], 0, 0 ; CHECK-NEXT: [[WRAP1_FCA_0_0_EXTRACT:%.*]] = extractvalue [1 x { i32 }] [[WRAP1]], 0, 0 ; CHECK-NEXT: [[TMP0:%.*]] = bitcast i32 [[WRAP1_FCA_0_0_EXTRACT]] to float ; CHECK-NEXT: [[LOAD1_FCA_0_0_0_INSERT:%.*]] = insertvalue { [1 x { float }] } poison, float [[TMP0]], 0, 0, 0 ; CHECK-NEXT: [[UNWRAP1:%.*]] = extractvalue { [1 x { float }] } [[LOAD1_FCA_0_0_0_INSERT]], 0, 0 -; CHECK-NEXT: [[WRAP2:%.*]] = insertvalue { {}, { float }, [0 x i8] } undef, { float } [[UNWRAP1]], 1 +; CHECK-NEXT: [[WRAP2:%.*]] = insertvalue { {}, { float }, [0 x i8] } poison, { float } [[UNWRAP1]], 1 ; CHECK-NEXT: [[WRAP2_FCA_1_0_EXTRACT:%.*]] = extractvalue { {}, { float }, [0 x i8] } [[WRAP2]], 1, 0 ; CHECK-NEXT: [[TMP1:%.*]] = bitcast float [[WRAP2_FCA_1_0_EXTRACT]] to <4 x i8> ; CHECK-NEXT: [[VALCAST1:%.*]] = bitcast <4 x i8> [[TMP1]] to i32 -; CHECK-NEXT: [[WRAP3:%.*]] = insertvalue [1 x [1 x i32]] undef, i32 [[VALCAST1]], 0, 0 -; CHECK-NEXT: [[WRAP4:%.*]] = insertvalue { [1 x [1 x i32]], {} } undef, [1 x [1 x i32]] [[WRAP3]], 0 +; CHECK-NEXT: [[WRAP3:%.*]] = insertvalue [1 x [1 x i32]] poison, i32 [[VALCAST1]], 0, 0 +; CHECK-NEXT: [[WRAP4:%.*]] = insertvalue { [1 x [1 x i32]], {} } poison, [1 x [1 x i32]] [[WRAP3]], 0 ; CHECK-NEXT: [[WRAP4_FCA_0_0_0_EXTRACT:%.*]] = extractvalue { [1 x [1 x i32]], {} } [[WRAP4]], 0, 0, 0 ; CHECK-NEXT: [[TMP2:%.*]] = bitcast i32 [[WRAP4_FCA_0_0_0_EXTRACT]] to <4 x i8> ; CHECK-NEXT: [[TMP3:%.*]] = bitcast <4 x i8> [[TMP2]] to float @@ -1206,7 +1207,7 @@ entry: %a2 = alloca { {}, { float }, [0 x i8] } %a3 = alloca { [0 x i8], { [0 x double], [1 x [1 x <4 x i8>]], {} }, { { {} } } } - %wrap1 = insertvalue [1 x { i32 }] undef, i32 %x, 0, 0 + %wrap1 = insertvalue [1 x { i32 }] poison, i32 %x, 0, 0 %gep1 = getelementptr { { [1 x { i32 }] } }, { { [1 x { i32 }] } }* %a1, i32 0, i32 0, i32 0 store [1 x { i32 }] %wrap1, [1 x { i32 }]* %gep1 @@ -1215,7 +1216,7 @@ entry: %load1 = load { [1 x { float }] }, { [1 x { float }] }* %ptrcast1 %unwrap1 = extractvalue { [1 x { float }] } %load1, 0, 0 - %wrap2 = insertvalue { {}, { float }, [0 x i8] } undef, { float } %unwrap1, 1 + %wrap2 = insertvalue { {}, { float }, [0 x i8] } poison, { float } %unwrap1, 1 store { {}, { float }, [0 x i8] } %wrap2, { {}, { float }, [0 x i8] }* %a2 %gep3 = getelementptr { {}, { float }, [0 x i8] }, { {}, { float }, [0 x i8] }* %a2, i32 0, i32 1, i32 0 @@ -1223,8 +1224,8 @@ entry: %load3 = load <4 x i8>, <4 x i8>* %ptrcast2 %valcast1 = bitcast <4 x i8> %load3 to i32 - %wrap3 = insertvalue [1 x [1 x i32]] undef, i32 %valcast1, 0, 0 - %wrap4 = insertvalue { [1 x [1 x i32]], {} } undef, [1 x [1 x i32]] %wrap3, 0 + %wrap3 = insertvalue [1 x [1 x i32]] poison, i32 %valcast1, 0, 0 + %wrap4 = insertvalue { [1 x [1 x i32]], {} } poison, [1 x [1 x i32]] %wrap3, 0 %gep4 = getelementptr { [0 x i8], { [0 x double], [1 x [1 x <4 x i8>]], {} }, { { {} } } }, { [0 x i8], { [0 x double], [1 x [1 x <4 x i8>]], {} }, { { {} } } }* %a3, i32 0, i32 1 %ptrcast3 = bitcast { [0 x double], [1 x [1 x <4 x i8>]], {} }* %gep4 to { [1 x [1 x i32]], {} }* store { [1 x [1 x i32]], {} } %wrap4, { [1 x [1 x i32]], {} }* %ptrcast3 @@ -1620,18 +1621,18 @@ end: define void @PR15805(i1 %a, i1 %b) { ; CHECK-LABEL: @PR15805( -; CHECK-NEXT: [[COND_SROA_SPECULATED:%.*]] = select i1 undef, i64 undef, i64 undef +; CHECK-NEXT: [[COND_SROA_SPECULATED:%.*]] = select i1 [[B:%.*]], i64 undef, i64 undef ; CHECK-NEXT: ret void ; %c = alloca i64, align 8 - %p.0.c = select i1 undef, i64* %c, i64* %c - %cond.in = select i1 undef, i64* %p.0.c, i64* %c + %p.0.c = select i1 %a, i64* %c, i64* %c + %cond.in = select i1 %b, i64* %p.0.c, i64* %c %cond = load i64, i64* %cond.in, align 8 ret void } -define void @PR15805.1(i1 %a, i1 %b) { +define void @PR15805.1(i1 %a, i1 %b, i1 %c2) { ; Same as the normal PR15805, but rigged to place the use before the def inside ; of looping unreachable code. This helps ensure that we aren't sensitive to the ; order in which the uses of the alloca are visited. @@ -1639,8 +1640,8 @@ define void @PR15805.1(i1 %a, i1 %b) { ; CHECK-LABEL: @PR15805.1( ; CHECK-NEXT: br label [[EXIT:%.*]] ; CHECK: loop: -; CHECK-NEXT: [[COND_SROA_SPECULATED:%.*]] = select i1 undef, i64 undef, i64 undef -; CHECK-NEXT: br i1 undef, label [[LOOP:%.*]], label [[EXIT]] +; CHECK-NEXT: [[COND_SROA_SPECULATED:%.*]] = select i1 [[A:%.*]], i64 undef, i64 undef +; CHECK-NEXT: br i1 [[C2:%.*]], label [[LOOP:%.*]], label [[EXIT]] ; CHECK: exit: ; CHECK-NEXT: ret void ; @@ -1649,10 +1650,10 @@ define void @PR15805.1(i1 %a, i1 %b) { br label %exit loop: - %cond.in = select i1 undef, i64* %c, i64* %p.0.c - %p.0.c = select i1 undef, i64* %c, i64* %c + %cond.in = select i1 %a, i64* %c, i64* %p.0.c + %p.0.c = select i1 %b, i64* %c, i64* %c %cond = load i64, i64* %cond.in, align 8 - br i1 undef, label %loop, label %exit + br i1 %c2, label %loop, label %exit exit: ret void @@ -1690,7 +1691,7 @@ entry: unreachable } -define void @PR16651.2() { +define void @PR16651.2(<2 x float> %val, i1 %c1) { ; This test case caused a crash due to failing to promote given a select that ; can't be speculated. It shouldn't be promoted, but we missed that fact when ; analyzing whether we could form a vector promotion because that code didn't @@ -1699,9 +1700,9 @@ define void @PR16651.2() { ; CHECK-LABEL: @PR16651.2( ; CHECK-NEXT: entry: ; CHECK-NEXT: [[TV1_SROA_0:%.*]] = alloca <2 x float>, align 8 -; CHECK-NEXT: store <2 x float> undef, <2 x float>* [[TV1_SROA_0]], align 8 +; CHECK-NEXT: store <2 x float> [[VAL:%.*]], <2 x float>* [[TV1_SROA_0]], align 8 ; CHECK-NEXT: [[TV1_SROA_0_0__SROA_IDX:%.*]] = getelementptr inbounds <2 x float>, <2 x float>* [[TV1_SROA_0]], i64 0, i32 0 -; CHECK-NEXT: [[COND105_IN_I_I:%.*]] = select i1 undef, float* null, float* [[TV1_SROA_0_0__SROA_IDX]] +; CHECK-NEXT: [[COND105_IN_I_I:%.*]] = select i1 [[C1:%.*]], float* null, float* [[TV1_SROA_0_0__SROA_IDX]] ; CHECK-NEXT: [[COND105_I_I:%.*]] = load float, float* [[COND105_IN_I_I]], align 8 ; CHECK-NEXT: ret void ; @@ -1709,9 +1710,9 @@ define void @PR16651.2() { entry: %tv1 = alloca { <2 x float>, <2 x float> }, align 8 %0 = getelementptr { <2 x float>, <2 x float> }, { <2 x float>, <2 x float> }* %tv1, i64 0, i32 1 - store <2 x float> undef, <2 x float>* %0, align 8 + store <2 x float> %val, <2 x float>* %0, align 8 %1 = getelementptr inbounds { <2 x float>, <2 x float> }, { <2 x float>, <2 x float> }* %tv1, i64 0, i32 1, i64 0 - %cond105.in.i.i = select i1 undef, float* null, float* %1 + %cond105.in.i.i = select i1 %c1, float* null, float* %1 %cond105.i.i = load float, float* %cond105.in.i.i, align 8 ret void } @@ -1732,7 +1733,7 @@ entry: ret void } -define void @PR18615() { +define void @PR18615(i8* %ptr) { ; CHECK-LABEL: @PR18615( ; CHECK-NEXT: entry: ; CHECK-NEXT: ret void @@ -1740,7 +1741,7 @@ define void @PR18615() { entry: %f = alloca i8 %gep = getelementptr i8, i8* %f, i64 -1 - call void @llvm.memcpy.p0i8.p0i8.i32(i8* undef, i8* %gep, i32 1, i1 false) + call void @llvm.memcpy.p0i8.p0i8.i32(i8* %ptr, i8* %gep, i32 1, i1 false) ret void } @@ -2118,7 +2119,7 @@ entry: declare void @llvm.lifetime.start.isVoid.i64.p0i8(i64, [10 x float]* nocapture) declare void @llvm.lifetime.end.isVoid.i64.p0i8(i64, [10 x float]* nocapture) -@array = dso_local global [10 x float] undef, align 4 +@array = dso_local global [10 x float] zeroinitializer, align 4 define void @test29(i32 %num, i32 %tid) { ; CHECK-LABEL: @test29( diff --git a/llvm/test/Transforms/SROA/dbg-single-piece.ll b/llvm/test/Transforms/SROA/dbg-single-piece.ll index d9eb41b..ba5b609 100644 --- a/llvm/test/Transforms/SROA/dbg-single-piece.ll +++ b/llvm/test/Transforms/SROA/dbg-single-piece.ll @@ -1,3 +1,4 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py ; RUN: opt -passes=sroa %s -S | FileCheck %s target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" @@ -5,18 +6,20 @@ target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" declare void @llvm.dbg.declare(metadata, metadata, metadata) #0 define void @_ZL18findInsertLocationPN4llvm17MachineBasicBlockENS_9SlotIndexERNS_13LiveIntervalsE() { +; CHECK-LABEL: @_ZL18findInsertLocationPN4llvm17MachineBasicBlockENS_9SlotIndexERNS_13LiveIntervalsE( +; CHECK-NEXT: entry: +; CHECK-NEXT: call void @llvm.dbg.value(metadata %foo* poison, metadata [[META3:![0-9]+]], metadata !DIExpression(DW_OP_LLVM_fragment, 64, 64)), !dbg [[DBG8:![0-9]+]] +; CHECK-NEXT: ret void +; entry: %retval = alloca %foo, align 8 call void @llvm.dbg.declare(metadata %foo* %retval, metadata !1, metadata !7), !dbg !8 ; Checks that SROA still inserts a bit_piece expression, even if it produces only one piece ; (as long as that piece is smaller than the whole thing) -; CHECK-NOT: call void @llvm.dbg.value -; CHECK: call void @llvm.dbg.value(metadata %foo* undef, {{.*}}, metadata !DIExpression(DW_OP_LLVM_fragment, 64, 64)), !dbg -; CHECK-NOT: call void @llvm.dbg.value %0 = bitcast %foo* %retval to i8* %1 = getelementptr inbounds i8, i8* %0, i64 8 %2 = bitcast i8* %1 to %foo** - store %foo* undef, %foo** %2, align 8 + store %foo* poison, %foo** %2, align 8 ret void } diff --git a/llvm/test/Transforms/SROA/dead-inst.ll b/llvm/test/Transforms/SROA/dead-inst.ll index 083c8a6..7f77f90 100644 --- a/llvm/test/Transforms/SROA/dead-inst.ll +++ b/llvm/test/Transforms/SROA/dead-inst.ll @@ -1,3 +1,4 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py ; SROA fails to rewrite allocs but does rewrite some phis and delete ; dead instructions. Ensure that this invalidates analyses required ; for other passes. @@ -17,14 +18,14 @@ target triple = "powerpc64le-grtev4-linux-gnu" declare void @D(%class.b* sret(%class.b), %class.b* dereferenceable(32)) local_unnamed_addr ; Function Attrs: nounwind -define hidden fastcc void @H(%class.b* noalias nocapture readnone, [2 x i64]) unnamed_addr { +define void @H(%class.b* noalias nocapture readnone, [2 x i64], i8* %ptr, i32 signext %v, i64 %l, i64 %idx, %class.b* nonnull dereferenceable(32) %ptr2) { %3 = alloca %class.b, align 8 %.sroa.0 = alloca i64, align 8 store i64 0, i64* %.sroa.0, align 8 %4 = extractvalue [2 x i64] %1, 1 switch i64 %4, label %6 [ - i64 4, label %foo - i64 5, label %5 + i64 4, label %foo + i64 5, label %5 ] ;