Please use GitHub pull requests for new patches. Avoid migrating existing patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
llvm/test/Transforms/DeadStoreElimination/non-escaping-ptr.ll
- This file was added.
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py | |||||
; RUN: opt %s -basicaa -dse -enable-dse-memoryssa -S | FileCheck %s | |||||
target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64" | |||||
declare i32* @return_first(i32* returned, i32*) | |||||
declare i32* @return_second(i32*, i32* returned) | |||||
declare noalias i8* @malloc(i32) | |||||
define void @test1() { | |||||
; CHECK-LABEL: @test1( | |||||
; CHECK-NEXT: ret void | |||||
; | |||||
%P = alloca i32, i32 1, align 1 | |||||
store i32 0, i32* %P | |||||
ret void | |||||
} | |||||
define void @test2() { | |||||
; CHECK-LABEL: @test2( | |||||
; CHECK-NEXT: ret void | |||||
; | |||||
%P = alloca i32, i32 1, align 1 | |||||
%P1 = bitcast i32* %P to i8* | |||||
store i8 0, i8* %P1 | |||||
ret void | |||||
} | |||||
define void @test3() { | |||||
; CHECK-LABEL: @test3( | |||||
; CHECK-NEXT: ret void | |||||
; | |||||
%P = alloca i32, i32 4, align 1 | |||||
%P1 = bitcast i32* %P to i8* | |||||
%P2 = bitcast i8* %P1 to i32* | |||||
%P2.gep = getelementptr i32, i32* %P2, i32 4 | |||||
%P3 = bitcast i32* %P2.gep to i8* | |||||
%P4 = bitcast i8* %P3 to i32* | |||||
%P5 = bitcast i32* %P4 to i8* | |||||
store i8 0, i8* %P5 | |||||
ret void | |||||
} | |||||
define void @test4() { | |||||
; CHECK-LABEL: @test4( | |||||
; CHECK-NEXT: br i1 true, label [[BB1:%.*]], label [[BB2:%.*]] | |||||
; CHECK: bb1: | |||||
; CHECK-NEXT: br label [[BB3:%.*]] | |||||
; CHECK: bb2: | |||||
; CHECK-NEXT: br label [[BB3]] | |||||
; CHECK: bb3: | |||||
; CHECK-NEXT: ret void | |||||
; | |||||
%P = alloca i32, i32 4, align 1 | |||||
%P1 = bitcast i32* %P to i8* | |||||
%P2 = bitcast i8* %P1 to i32* | |||||
%P2.gep = getelementptr i32, i32* %P2, i32 4 | |||||
br i1 true, label %bb1, label %bb2 | |||||
bb1: | |||||
%P3.1 = bitcast i32* %P2.gep to i8* | |||||
br label %bb3 | |||||
bb2: | |||||
%P3.2 = bitcast i32* %P2.gep to i8* | |||||
br label %bb3 | |||||
bb3: | |||||
%P3 = phi i8* [ %P3.1, %bb1 ], [%P3.2, %bb2 ] | |||||
%P4 = bitcast i8* %P3 to i32* | |||||
%P5 = bitcast i32* %P4 to i8* | |||||
store i8 0, i8* %P5 | |||||
ret void | |||||
} | |||||
define void @test5() { | |||||
; CHECK-LABEL: @test5( | |||||
; CHECK-NEXT: [[P:%.*]] = alloca i32, i32 4, align 1 | |||||
; CHECK-NEXT: [[P1:%.*]] = bitcast i32* [[P]] to i8* | |||||
; CHECK-NEXT: [[P2:%.*]] = bitcast i8* [[P1]] to i32* | |||||
; CHECK-NEXT: [[P2_GEP:%.*]] = getelementptr i32, i32* [[P2]], i32 4 | |||||
; CHECK-NEXT: br i1 true, label [[BB1:%.*]], label [[BB2:%.*]] | |||||
; CHECK: bb1: | |||||
; CHECK-NEXT: [[P3_3:%.*]] = call i32* @return_first(i32* [[P2_GEP]], i32* null) | |||||
; CHECK-NEXT: br label [[BB3:%.*]] | |||||
; CHECK: bb2: | |||||
; CHECK-NEXT: [[P3_3_I:%.*]] = call i32* @return_second(i32* null, i32* [[P2_GEP]]) | |||||
; CHECK-NEXT: br label [[BB3]] | |||||
; CHECK: bb3: | |||||
; CHECK-NEXT: ret void | |||||
; | |||||
%P = alloca i32, i32 4, align 1 | |||||
%P1 = bitcast i32* %P to i8* | |||||
%P2 = bitcast i8* %P1 to i32* | |||||
%P2.gep = getelementptr i32, i32* %P2, i32 4 | |||||
br i1 true, label %bb1, label %bb2 | |||||
bb1: | |||||
%P3.3 = call i32* @return_first(i32* %P2.gep, i32* null) | |||||
%P3.1 = bitcast i32* %P3.3 to i8* | |||||
br label %bb3 | |||||
bb2: | |||||
%P3.3.i = call i32* @return_second(i32* null, i32* %P2.gep) | |||||
%P3.1.i = bitcast i32* %P3.3.i to i8* | |||||
br label %bb3 | |||||
bb3: | |||||
%P3 = phi i8* [ %P3.1, %bb1 ], [%P3.1.i, %bb2 ] | |||||
%P4 = bitcast i8* %P3 to i32* | |||||
%P5 = bitcast i32* %P4 to i8* | |||||
store i8 0, i8* %P5 | |||||
ret void | |||||
} | |||||
define i8* @test28() { | |||||
; CHECK-LABEL: @test28( | |||||
; CHECK-NEXT: bb0: | |||||
; CHECK-NEXT: [[M:%.*]] = call noalias i8* @malloc(i32 10) | |||||
; CHECK-NEXT: [[MC0:%.*]] = bitcast i8* [[M]] to i8* | |||||
; CHECK-NEXT: [[MC1:%.*]] = bitcast i8* [[MC0]] to i8* | |||||
; CHECK-NEXT: [[MC2:%.*]] = bitcast i8* [[MC1]] to i8* | |||||
; CHECK-NEXT: [[MC3:%.*]] = bitcast i8* [[MC2]] to i8* | |||||
; CHECK-NEXT: [[MC4:%.*]] = bitcast i8* [[MC3]] to i8* | |||||
; CHECK-NEXT: [[MC5:%.*]] = bitcast i8* [[MC4]] to i8* | |||||
; CHECK-NEXT: [[MC6:%.*]] = bitcast i8* [[MC5]] to i8* | |||||
; CHECK-NEXT: [[M0:%.*]] = bitcast i8* [[MC6]] to i8* | |||||
; CHECK-NEXT: store i8 2, i8* [[M0]] | |||||
; CHECK-NEXT: ret i8* [[M0]] | |||||
; | |||||
bb0: | |||||
%m = call noalias i8* @malloc(i32 10) | |||||
%mc0 = bitcast i8* %m to i8* | |||||
%mc1 = bitcast i8* %mc0 to i8* | |||||
%mc2 = bitcast i8* %mc1 to i8* | |||||
%mc3 = bitcast i8* %mc2 to i8* | |||||
%mc4 = bitcast i8* %mc3 to i8* | |||||
%mc5 = bitcast i8* %mc4 to i8* | |||||
%mc6 = bitcast i8* %mc5 to i8* | |||||
%m0 = bitcast i8* %mc6 to i8* | |||||
store i8 2, i8* %m0 | |||||
ret i8* %m0 | |||||
} | |||||
define i8* @test28A() { | |||||
; CHECK-LABEL: @test28A( | |||||
; CHECK-NEXT: bb0: | |||||
; CHECK-NEXT: ret i8* null | |||||
; | |||||
bb0: | |||||
%m = call noalias i8* @malloc(i32 10) | |||||
%mc0 = bitcast i8* %m to i8* | |||||
%mc1 = bitcast i8* %mc0 to i8* | |||||
%mc2 = bitcast i8* %mc1 to i8* | |||||
%mc3 = bitcast i8* %mc2 to i8* | |||||
%mc4 = bitcast i8* %mc3 to i8* | |||||
%mc5 = bitcast i8* %mc4 to i8* | |||||
%mc6 = bitcast i8* %mc5 to i8* | |||||
%m0 = bitcast i8* %mc6 to i8* | |||||
store i8 2, i8* %m0 | |||||
ret i8* null | |||||
} | |||||
define void @test6() { | |||||
; CHECK-LABEL: @test6( | |||||
; CHECK-NEXT: [[P:%.*]] = alloca i32, i32 4, align 1 | |||||
; CHECK-NEXT: [[P1:%.*]] = bitcast i32* [[P]] to i8* | |||||
; CHECK-NEXT: [[P2:%.*]] = bitcast i8* [[P1]] to i32* | |||||
; CHECK-NEXT: [[P2_GEP:%.*]] = getelementptr i32, i32* [[P2]], i32 4 | |||||
; CHECK-NEXT: br i1 true, label [[BB1:%.*]], label [[BB2:%.*]] | |||||
; CHECK: bb1: | |||||
; CHECK-NEXT: [[P3_3:%.*]] = call i32* @return_first(i32* [[P2_GEP]], i32* null) | |||||
; CHECK-NEXT: [[P3_1:%.*]] = bitcast i32* [[P3_3]] to i8* | |||||
; CHECK-NEXT: br label [[BB3:%.*]] | |||||
; CHECK: bb2: | |||||
; CHECK-NEXT: [[P3_3_I:%.*]] = call i32* @return_second(i32* [[P2_GEP]], i32* null) | |||||
; CHECK-NEXT: [[P3_1_I:%.*]] = bitcast i32* [[P3_3_I]] to i8* | |||||
; CHECK-NEXT: br label [[BB3]] | |||||
; CHECK: bb3: | |||||
; CHECK-NEXT: [[P3:%.*]] = phi i8* [ [[P3_1]], [[BB1]] ], [ [[P3_1_I]], [[BB2]] ] | |||||
; CHECK-NEXT: [[P4:%.*]] = bitcast i8* [[P3]] to i32* | |||||
; CHECK-NEXT: [[P5:%.*]] = bitcast i32* [[P4]] to i8* | |||||
; CHECK-NEXT: store i8 0, i8* [[P5]] | |||||
; CHECK-NEXT: ret void | |||||
; | |||||
%P = alloca i32, i32 4, align 1 | |||||
%P1 = bitcast i32* %P to i8* | |||||
%P2 = bitcast i8* %P1 to i32* | |||||
%P2.gep = getelementptr i32, i32* %P2, i32 4 | |||||
br i1 true, label %bb1, label %bb2 | |||||
bb1: | |||||
%P3.3 = call i32* @return_first(i32* %P2.gep, i32* null) | |||||
%P3.1 = bitcast i32* %P3.3 to i8* | |||||
br label %bb3 | |||||
bb2: | |||||
%P3.3.i = call i32* @return_second(i32* %P2.gep, i32* null) | |||||
%P3.1.i = bitcast i32* %P3.3.i to i8* | |||||
br label %bb3 | |||||
bb3: | |||||
%P3 = phi i8* [ %P3.1, %bb1 ], [%P3.1.i, %bb2 ] | |||||
%P4 = bitcast i8* %P3 to i32* | |||||
%P5 = bitcast i32* %P4 to i8* | |||||
store i8 0, i8* %P5 | |||||
ret void | |||||
} | |||||
define void @testA1(i32* %P) { | |||||
; CHECK-LABEL: @testA1( | |||||
; CHECK-NEXT: store i32 0, i32* [[P:%.*]] | |||||
; CHECK-NEXT: ret void | |||||
; | |||||
store i32 0, i32* %P | |||||
ret void | |||||
} | |||||
define void @testA2(i32* %P) { | |||||
; CHECK-LABEL: @testA2( | |||||
; CHECK-NEXT: [[P1:%.*]] = bitcast i32* [[P:%.*]] to i8* | |||||
; CHECK-NEXT: store i8 0, i8* [[P1]] | |||||
; CHECK-NEXT: ret void | |||||
; | |||||
%P1 = bitcast i32* %P to i8* | |||||
store i8 0, i8* %P1 | |||||
ret void | |||||
} | |||||
define void @testA3(i32* %P) { | |||||
; CHECK-LABEL: @testA3( | |||||
; CHECK-NEXT: [[P1:%.*]] = bitcast i32* [[P:%.*]] to i8* | |||||
; CHECK-NEXT: [[P2:%.*]] = bitcast i8* [[P1]] to i32* | |||||
; CHECK-NEXT: [[P2_GEP:%.*]] = getelementptr i32, i32* [[P2]], i32 4 | |||||
; CHECK-NEXT: [[P3:%.*]] = bitcast i32* [[P2_GEP]] to i8* | |||||
; CHECK-NEXT: [[P4:%.*]] = bitcast i8* [[P3]] to i32* | |||||
; CHECK-NEXT: [[P5:%.*]] = bitcast i32* [[P4]] to i8* | |||||
; CHECK-NEXT: store i8 0, i8* [[P5]] | |||||
; CHECK-NEXT: ret void | |||||
; | |||||
%P1 = bitcast i32* %P to i8* | |||||
%P2 = bitcast i8* %P1 to i32* | |||||
%P2.gep = getelementptr i32, i32* %P2, i32 4 | |||||
%P3 = bitcast i32* %P2.gep to i8* | |||||
%P4 = bitcast i8* %P3 to i32* | |||||
%P5 = bitcast i32* %P4 to i8* | |||||
store i8 0, i8* %P5 | |||||
ret void | |||||
} | |||||
define void @testA4(i32* %P) { | |||||
; CHECK-LABEL: @testA4( | |||||
; CHECK-NEXT: [[P1:%.*]] = bitcast i32* [[P:%.*]] to i8* | |||||
; CHECK-NEXT: [[P2:%.*]] = bitcast i8* [[P1]] to i32* | |||||
; CHECK-NEXT: [[P2_GEP:%.*]] = getelementptr i32, i32* [[P2]], i32 4 | |||||
; CHECK-NEXT: br i1 true, label [[BB1:%.*]], label [[BB2:%.*]] | |||||
; CHECK: bb1: | |||||
; CHECK-NEXT: [[P3_1:%.*]] = bitcast i32* [[P2_GEP]] to i8* | |||||
; CHECK-NEXT: br label [[BB3:%.*]] | |||||
; CHECK: bb2: | |||||
; CHECK-NEXT: [[P3_2:%.*]] = bitcast i32* [[P2_GEP]] to i8* | |||||
; CHECK-NEXT: br label [[BB3]] | |||||
; CHECK: bb3: | |||||
; CHECK-NEXT: [[P3:%.*]] = phi i8* [ [[P3_1]], [[BB1]] ], [ [[P3_2]], [[BB2]] ] | |||||
; CHECK-NEXT: [[P4:%.*]] = bitcast i8* [[P3]] to i32* | |||||
; CHECK-NEXT: [[P5:%.*]] = bitcast i32* [[P4]] to i8* | |||||
; CHECK-NEXT: store i8 0, i8* [[P5]] | |||||
; CHECK-NEXT: ret void | |||||
; | |||||
%P1 = bitcast i32* %P to i8* | |||||
%P2 = bitcast i8* %P1 to i32* | |||||
%P2.gep = getelementptr i32, i32* %P2, i32 4 | |||||
br i1 true, label %bb1, label %bb2 | |||||
bb1: | |||||
%P3.1 = bitcast i32* %P2.gep to i8* | |||||
br label %bb3 | |||||
bb2: | |||||
%P3.2 = bitcast i32* %P2.gep to i8* | |||||
br label %bb3 | |||||
bb3: | |||||
%P3 = phi i8* [ %P3.1, %bb1 ], [%P3.2, %bb2 ] | |||||
%P4 = bitcast i8* %P3 to i32* | |||||
%P5 = bitcast i32* %P4 to i8* | |||||
store i8 0, i8* %P5 | |||||
ret void | |||||
} | |||||
define void @testA5(i32* %P) { | |||||
; CHECK-LABEL: @testA5( | |||||
; CHECK-NEXT: [[P1:%.*]] = bitcast i32* [[P:%.*]] to i8* | |||||
; CHECK-NEXT: [[P2:%.*]] = bitcast i8* [[P1]] to i32* | |||||
; CHECK-NEXT: [[P2_GEP:%.*]] = getelementptr i32, i32* [[P2]], i32 4 | |||||
; CHECK-NEXT: br i1 true, label [[BB1:%.*]], label [[BB2:%.*]] | |||||
; CHECK: bb1: | |||||
; CHECK-NEXT: [[P3_3:%.*]] = call i32* @return_first(i32* [[P2_GEP]], i32* null) | |||||
; CHECK-NEXT: [[P3_1:%.*]] = bitcast i32* [[P3_3]] to i8* | |||||
; CHECK-NEXT: br label [[BB3:%.*]] | |||||
; CHECK: bb2: | |||||
; CHECK-NEXT: [[P3_3_I:%.*]] = call i32* @return_second(i32* null, i32* [[P2_GEP]]) | |||||
; CHECK-NEXT: [[P3_1_I:%.*]] = bitcast i32* [[P3_3_I]] to i8* | |||||
; CHECK-NEXT: br label [[BB3]] | |||||
; CHECK: bb3: | |||||
; CHECK-NEXT: [[P3:%.*]] = phi i8* [ [[P3_1]], [[BB1]] ], [ [[P3_1_I]], [[BB2]] ] | |||||
; CHECK-NEXT: [[P4:%.*]] = bitcast i8* [[P3]] to i32* | |||||
; CHECK-NEXT: [[P5:%.*]] = bitcast i32* [[P4]] to i8* | |||||
; CHECK-NEXT: store i8 0, i8* [[P5]] | |||||
; CHECK-NEXT: ret void | |||||
; | |||||
%P1 = bitcast i32* %P to i8* | |||||
%P2 = bitcast i8* %P1 to i32* | |||||
%P2.gep = getelementptr i32, i32* %P2, i32 4 | |||||
br i1 true, label %bb1, label %bb2 | |||||
bb1: | |||||
%P3.3 = call i32* @return_first(i32* %P2.gep, i32* null) | |||||
%P3.1 = bitcast i32* %P3.3 to i8* | |||||
br label %bb3 | |||||
bb2: | |||||
%P3.3.i = call i32* @return_second(i32* null, i32* %P2.gep) | |||||
%P3.1.i = bitcast i32* %P3.3.i to i8* | |||||
br label %bb3 | |||||
bb3: | |||||
%P3 = phi i8* [ %P3.1, %bb1 ], [%P3.1.i, %bb2 ] | |||||
%P4 = bitcast i8* %P3 to i32* | |||||
%P5 = bitcast i32* %P4 to i8* | |||||
store i8 0, i8* %P5 | |||||
ret void | |||||
} |