Skip to content

Backport 2131242 #44

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
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