mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-16 12:24:03 +00:00
Introduce a helper to combine instruction metadata.
Replace the old code in GVN and BBVectorize with it. Update SimplifyCFG to use it. Patch by Björn Steinbrink! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215723 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -1305,3 +1305,39 @@ bool llvm::removeUnreachableBlocks(Function &F) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void llvm::combineMetadata(Instruction *K, const Instruction *J, ArrayRef<unsigned> KnownIDs) {
|
||||
SmallVector<std::pair<unsigned, MDNode*>, 4> Metadata;
|
||||
K->dropUnknownMetadata(KnownIDs);
|
||||
K->getAllMetadataOtherThanDebugLoc(Metadata);
|
||||
for (unsigned i = 0, n = Metadata.size(); i < n; ++i) {
|
||||
unsigned Kind = Metadata[i].first;
|
||||
MDNode *JMD = J->getMetadata(Kind);
|
||||
MDNode *KMD = Metadata[i].second;
|
||||
|
||||
switch (Kind) {
|
||||
default:
|
||||
K->setMetadata(Kind, nullptr); // Remove unknown metadata
|
||||
break;
|
||||
case LLVMContext::MD_dbg:
|
||||
llvm_unreachable("getAllMetadataOtherThanDebugLoc returned a MD_dbg");
|
||||
case LLVMContext::MD_tbaa:
|
||||
K->setMetadata(Kind, MDNode::getMostGenericTBAA(JMD, KMD));
|
||||
break;
|
||||
case LLVMContext::MD_alias_scope:
|
||||
case LLVMContext::MD_noalias:
|
||||
K->setMetadata(Kind, MDNode::intersect(JMD, KMD));
|
||||
break;
|
||||
case LLVMContext::MD_range:
|
||||
K->setMetadata(Kind, MDNode::getMostGenericRange(JMD, KMD));
|
||||
break;
|
||||
case LLVMContext::MD_fpmath:
|
||||
K->setMetadata(Kind, MDNode::getMostGenericFPMath(JMD, KMD));
|
||||
break;
|
||||
case LLVMContext::MD_invariant_load:
|
||||
// Only set the !invariant.load if it is present in both instructions.
|
||||
K->setMetadata(Kind, JMD);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user