mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-10-30 16:17:05 +00:00
DeadStoreElimination can treat byval parameters as if there were alloca's for the purpose of removing end-of-function stores.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46351 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -261,9 +261,6 @@ bool DSE::handleEndBlock(BasicBlock& BB,
|
|||||||
for (BasicBlock::iterator BBI = BB.end(); BBI != BB.begin(); ){
|
for (BasicBlock::iterator BBI = BB.end(); BBI != BB.begin(); ){
|
||||||
--BBI;
|
--BBI;
|
||||||
|
|
||||||
if (deadPointers.empty())
|
|
||||||
break;
|
|
||||||
|
|
||||||
// If we find a store whose pointer is dead...
|
// If we find a store whose pointer is dead...
|
||||||
if (StoreInst* S = dyn_cast<StoreInst>(BBI)) {
|
if (StoreInst* S = dyn_cast<StoreInst>(BBI)) {
|
||||||
if (!S->isVolatile()) {
|
if (!S->isVolatile()) {
|
||||||
@@ -271,8 +268,12 @@ bool DSE::handleEndBlock(BasicBlock& BB,
|
|||||||
// See through pointer-to-pointer bitcasts
|
// See through pointer-to-pointer bitcasts
|
||||||
TranslatePointerBitCasts(pointerOperand);
|
TranslatePointerBitCasts(pointerOperand);
|
||||||
|
|
||||||
if (isa<AllocaInst>(pointerOperand) &&
|
// Alloca'd pointers or byval arguments (which are functionally like
|
||||||
deadPointers.count(cast<AllocaInst>(pointerOperand))) {
|
// alloca's) are valid candidates for removal.
|
||||||
|
if ( (isa<AllocaInst>(pointerOperand) &&
|
||||||
|
deadPointers.count(cast<AllocaInst>(pointerOperand))) ||
|
||||||
|
(isa<Argument>(pointerOperand) &&
|
||||||
|
cast<Argument>(pointerOperand)->hasByValAttr())) {
|
||||||
// Remove it!
|
// Remove it!
|
||||||
MD.removeInstruction(S);
|
MD.removeInstruction(S);
|
||||||
|
|
||||||
|
|||||||
10
test/Transforms/DeadStoreElimination/byval.ll
Normal file
10
test/Transforms/DeadStoreElimination/byval.ll
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
; RUN: llvm-as < %s | opt -dse | llvm-dis | not grep store
|
||||||
|
|
||||||
|
%struct.x = type { i32, i32, i32, i32 }
|
||||||
|
|
||||||
|
define i32 @foo(%struct.x* byval %a) nounwind {
|
||||||
|
entry:
|
||||||
|
%tmp2 = getelementptr %struct.x* %a, i32 0, i32 0
|
||||||
|
store i32 1, i32* %tmp2, align 4
|
||||||
|
ret i32 1
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user