Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1466,7 +1466,7 @@ bool MemCpyOptPass::performStackMoveOptzn(Instruction *Load, Instruction *Store,
// to remove them.

SmallVector<Instruction *, 4> LifetimeMarkers;
SmallSet<Instruction *, 4> NoAliasInstrs;
SmallSet<Instruction *, 4> AAMetadataInstrs;
bool SrcNotDom = false;

// Recursively track the user and check whether modified alias exist.
Expand Down Expand Up @@ -1521,8 +1521,7 @@ bool MemCpyOptPass::performStackMoveOptzn(Instruction *Load, Instruction *Store,
continue;
}
}
if (UI->hasMetadata(LLVMContext::MD_noalias))
NoAliasInstrs.insert(UI);
AAMetadataInstrs.insert(UI);
if (!ModRefCallback(UI))
return false;
}
Expand Down Expand Up @@ -1630,9 +1629,22 @@ bool MemCpyOptPass::performStackMoveOptzn(Instruction *Load, Instruction *Store,
// alias to begin to alias one another, we remove !noalias metadata from any
// uses of either alloca. This is conservative, but more precision doesn't
// seem worthwhile right now.
for (Instruction *I : NoAliasInstrs)
for (Instruction *I : AAMetadataInstrs) {


I->setMetadata(LLVMContext::MD_alias_scope, nullptr);

I->setMetadata(LLVMContext::MD_noalias, nullptr);


I->setMetadata(LLVMContext::MD_tbaa, nullptr);


I->setMetadata(LLVMContext::MD_tbaa_struct, nullptr);


}

LLVM_DEBUG(dbgs() << "Stack Move: Performed staack-move optimization\n");
NumStackMove++;
return true;
Expand Down