llvm.org GIT mirror llvm / 741c0ae
dead calls to llvm.stacksave can be deleted, even though they have potential side-effects. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45392 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 11 years ago
2 changed file(s) with 21 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
1616 #include "llvm/DerivedTypes.h"
1717 #include "llvm/Instructions.h"
1818 #include "llvm/Intrinsics.h"
19 #include "llvm/IntrinsicInst.h"
1920 #include "llvm/Analysis/ConstantFolding.h"
2021 #include "llvm/Target/TargetData.h"
2122 #include "llvm/Support/GetElementPtrTypeIterator.h"
172173 bool llvm::isInstructionTriviallyDead(Instruction *I) {
173174 if (!I->use_empty() || isa(I)) return false;
174175
175 if (!I->mayWriteToMemory()) return true;
176
176 if (!I->mayWriteToMemory())
177 return true;
178
179 // Special case intrinsics that "may write to memory" but can be deleted when
180 // dead.
181 if (IntrinsicInst *II = dyn_cast(I))
182 // Safe to delete llvm.stacksave if dead.
183 if (II->getIntrinsicID() == Intrinsic::stacksave)
184 return true;
185
177186 return false;
178187 }
179188
0 ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep {ret i32 %A}
1 ; RUN: llvm-as < %s | opt -die | llvm-dis | not grep call.*llvm.stacksave
12
23 define i32 @test(i32 %A) {
34 %X = or i1 false, false
1112 %C.upgrd.1 = phi i32 [ %B, %T ], [ %A, %0 ]
1213 ret i32 %C.upgrd.1
1314 }
15
16 define i32* @test2(i32 %width) {
17 %tmp = call i8* @llvm.stacksave( )
18 %tmp14 = alloca i32, i32 %width
19 ret i32* %tmp14
20 }
21
22 declare i8* @llvm.stacksave()
23