From c01054cc4722978d2585516c69264bcd9fddde97 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Thu, 22 Jun 2023 12:23:46 +0200 Subject: [PATCH] [InstCombine] Use CreateNonTerminatorUnreachable() helper Create the standard non-terminator unreachable, rather than a slight variation on it. --- llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp | 7 +------ llvm/test/Transforms/InstCombine/atomic.ll | 2 +- llvm/test/Transforms/InstCombine/getelementptr.ll | 4 ++-- llvm/test/Transforms/InstCombine/load.ll | 4 ++-- llvm/test/Transforms/InstCombine/pr44245.ll | 2 +- llvm/test/Transforms/InstCombine/struct-assign-tbaa-new.ll | 2 +- llvm/test/Transforms/InstCombine/struct-assign-tbaa.ll | 2 +- 7 files changed, 9 insertions(+), 14 deletions(-) diff --git a/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp b/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp index 376b7e5..b7d1074 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp @@ -1097,12 +1097,7 @@ Instruction *InstCombinerImpl::visitLoadInst(LoadInst &LI) { // load null/undef -> unreachable // TODO: Consider a target hook for valid address spaces for this xforms. if (canSimplifyNullLoadOrGEP(LI, Op)) { - // Insert a new store to null instruction before the load to indicate - // that this code is not reachable. We do this instead of inserting - // an unreachable instruction directly because we cannot modify the - // CFG. - Builder.CreateStore(PoisonValue::get(LI.getType()), - Constant::getNullValue(Op->getType())); + CreateNonTerminatorUnreachable(&LI); return replaceInstUsesWith(LI, PoisonValue::get(LI.getType())); } diff --git a/llvm/test/Transforms/InstCombine/atomic.ll b/llvm/test/Transforms/InstCombine/atomic.ll index 7842fdf..e4a3d0f 100644 --- a/llvm/test/Transforms/InstCombine/atomic.ll +++ b/llvm/test/Transforms/InstCombine/atomic.ll @@ -119,7 +119,7 @@ define i32 @test8(ptr %p) { ; ordering imposed. define i32 @test9() { ; CHECK-LABEL: @test9( -; CHECK-NEXT: store i32 poison, ptr null, align 4294967296 +; CHECK-NEXT: store i1 true, ptr poison, align 1 ; CHECK-NEXT: ret i32 poison ; %x = load atomic i32, ptr null unordered, align 4 diff --git a/llvm/test/Transforms/InstCombine/getelementptr.ll b/llvm/test/Transforms/InstCombine/getelementptr.ll index 5a3343e..bc39498 100644 --- a/llvm/test/Transforms/InstCombine/getelementptr.ll +++ b/llvm/test/Transforms/InstCombine/getelementptr.ll @@ -495,7 +495,7 @@ define i1 @test23() { define void @test25() { ; CHECK-LABEL: @test25( ; CHECK-NEXT: entry: -; CHECK-NEXT: store i64 poison, ptr null, align 4294967296 +; CHECK-NEXT: store i1 true, ptr poison, align 1 ; CHECK-NEXT: tail call void @foo25(i32 0, i64 poison) ; CHECK-NEXT: unreachable ; @@ -607,7 +607,7 @@ declare i32 @printf(ptr, ...) define i32 @test29(ptr %start, i32 %X) nounwind { ; CHECK-LABEL: @test29( ; CHECK-NEXT: entry: -; CHECK-NEXT: store i64 poison, ptr null, align 4294967296 +; CHECK-NEXT: store i1 true, ptr poison, align 1 ; CHECK-NEXT: br i1 poison, label [[IF_THEN216:%.*]], label [[IF_END363:%.*]] ; CHECK: if.then216: ; CHECK-NEXT: ret i32 1 diff --git a/llvm/test/Transforms/InstCombine/load.ll b/llvm/test/Transforms/InstCombine/load.ll index cd00ac7..0da1918 100644 --- a/llvm/test/Transforms/InstCombine/load.ll +++ b/llvm/test/Transforms/InstCombine/load.ll @@ -58,7 +58,7 @@ define i32 @test5(i1 %C) { define i32 @load_gep_null_inbounds(i64 %X) { ; CHECK-LABEL: @load_gep_null_inbounds( -; CHECK-NEXT: store i32 poison, ptr null, align 4294967296 +; CHECK-NEXT: store i1 true, ptr poison, align 1 ; CHECK-NEXT: ret i32 poison ; %V = getelementptr inbounds i32, ptr null, i64 %X @@ -68,7 +68,7 @@ define i32 @load_gep_null_inbounds(i64 %X) { define i32 @load_gep_null_not_inbounds(i64 %X) { ; CHECK-LABEL: @load_gep_null_not_inbounds( -; CHECK-NEXT: store i32 poison, ptr null, align 4294967296 +; CHECK-NEXT: store i1 true, ptr poison, align 1 ; CHECK-NEXT: ret i32 poison ; %V = getelementptr i32, ptr null, i64 %X diff --git a/llvm/test/Transforms/InstCombine/pr44245.ll b/llvm/test/Transforms/InstCombine/pr44245.ll index 197234b..a0896fa 100644 --- a/llvm/test/Transforms/InstCombine/pr44245.ll +++ b/llvm/test/Transforms/InstCombine/pr44245.ll @@ -158,7 +158,7 @@ define void @test_2(i1 %c) local_unnamed_addr { ; CHECK: cond.true133: ; CHECK-NEXT: br label [[COND_END144:%.*]] ; CHECK: cond.false138: -; CHECK-NEXT: store ptr poison, ptr null, align 4294967296 +; CHECK-NEXT: store i1 true, ptr poison, align 1 ; CHECK-NEXT: br label [[COND_END144]] ; CHECK: cond.end144: ; CHECK-NEXT: br label [[WHILE_COND]] diff --git a/llvm/test/Transforms/InstCombine/struct-assign-tbaa-new.ll b/llvm/test/Transforms/InstCombine/struct-assign-tbaa-new.ll index 04eb601..622b558 100644 --- a/llvm/test/Transforms/InstCombine/struct-assign-tbaa-new.ll +++ b/llvm/test/Transforms/InstCombine/struct-assign-tbaa-new.ll @@ -27,7 +27,7 @@ entry: define ptr @test2() { ; CHECK-LABEL: @test2( ; CHECK-NEXT: [[TMP:%.*]] = alloca [[B:%.*]], align 8 -; CHECK-NEXT: store i64 poison, ptr null, align 4294967296 +; CHECK-NEXT: store i1 true, ptr poison, align 1 ; CHECK-NEXT: ret ptr [[TMP]] ; %tmp = alloca %B, align 8 diff --git a/llvm/test/Transforms/InstCombine/struct-assign-tbaa.ll b/llvm/test/Transforms/InstCombine/struct-assign-tbaa.ll index d59bff2..97eeea8 100644 --- a/llvm/test/Transforms/InstCombine/struct-assign-tbaa.ll +++ b/llvm/test/Transforms/InstCombine/struct-assign-tbaa.ll @@ -27,7 +27,7 @@ entry: define ptr @test2() { ; CHECK-LABEL: @test2( ; CHECK-NEXT: [[TMP:%.*]] = alloca [[STRUCT_TEST2:%.*]], align 8 -; CHECK-NEXT: store i64 poison, ptr null, align 4294967296 +; CHECK-NEXT: store i1 true, ptr poison, align 1 ; CHECK-NEXT: ret ptr [[TMP]] ; %tmp = alloca %struct.test2, align 8 -- 2.7.4