-
-
Save anonymous/7219541341dd9029d0c038ec59246f8b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/include/llvm/Analysis/VectorUtils.h b/include/llvm/Analysis/VectorUtils.h | |
index a73f9fc..6bd11aa 100644 | |
--- a/include/llvm/Analysis/VectorUtils.h | |
+++ b/include/llvm/Analysis/VectorUtils.h | |
@@ -115,6 +115,14 @@ computeMinimumValueSizes(ArrayRef<BasicBlock*> Blocks, | |
const TargetTransformInfo *TTI=nullptr); | |
/// \returns \p I after propagating metadata from \p VL. | |
+/// | |
+/// Specifically, let Kinds = [MD_tbaa, MD_alias_scope, MD_noalias, MD_fpmath, | |
+/// MD_nontemporal]. For K in Kinds, we get the MDNode for K from each of the | |
+/// elements of VL, compute their "intersection" (i.e., the most generic | |
+/// metadata value that covers all of the individual values), and set I's | |
+/// metadata for M equal to the intersection value. | |
+/// | |
+/// This function always sets a (possibly null) value for each K in Kinds. | |
Instruction *propagateMetadata(Instruction *I, ArrayRef<Value *> VL); | |
} // llvm namespace | |
diff --git a/lib/Analysis/VectorUtils.cpp b/lib/Analysis/VectorUtils.cpp | |
index 55cc538..e0f968d 100644 | |
--- a/lib/Analysis/VectorUtils.cpp | |
+++ b/lib/Analysis/VectorUtils.cpp | |
@@ -454,14 +454,12 @@ Instruction *llvm::propagateMetadata(Instruction *Inst, ArrayRef<Value *> VL) { | |
SmallVector<std::pair<unsigned, MDNode *>, 4> Metadata; | |
I0->getAllMetadataOtherThanDebugLoc(Metadata); | |
- for (unsigned I = 0, N = Metadata.size(); I != N; ++I) { | |
- unsigned Kind = Metadata[I].first; | |
- MDNode *MD = Metadata[I].second; | |
- | |
- for (int J = 1, E = VL.size(); MD && J != E; ++J) { | |
- const Instruction *IJ = cast<Instruction>(VL[J]); | |
- MDNode *IMD = IJ->getMetadata(Kind); | |
- | |
+ for (auto Kind : {LLVMContext::MD_tbaa, LLVMContext::MD_alias_scope, | |
+ LLVMContext::MD_noalias, LLVMContext::MD_fpmath, | |
+ LLVMContext::MD_nontemporal}) { | |
+ MDNode *MD = I0->getMetadata(Kind); | |
+ for (int I = 1, N = VL.size(); I != N; ++I) { | |
+ MDNode *IMD = cast<Instruction>(VL[I])->getMetadata(Kind); | |
switch (Kind) { | |
case LLVMContext::MD_tbaa: | |
MD = MDNode::getMostGenericTBAA(MD, IMD); | |
@@ -479,11 +477,9 @@ Instruction *llvm::propagateMetadata(Instruction *Inst, ArrayRef<Value *> VL) { | |
MD = MDNode::intersect(MD, IMD); | |
break; | |
default: | |
- MD = nullptr; // Remove unknown metadata. | |
- break; | |
+ assert(false && "Unreachable"); | |
} | |
} | |
- | |
Inst->setMetadata(Kind, MD); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment