[llvm] 50cf0a1 - Allow empty value list in propagateMetadata(Inst, ArrayOf...)

Krzysztof Parzyszek via llvm-commits llvm-commits at lists.llvm.org
Fri May 7 11:27:39 PDT 2021


Author: Krzysztof Parzyszek
Date: 2021-05-07T13:20:50-05:00
New Revision: 50cf0a1d1ae48bd0397b41a400e01c62975b6706

URL: https://github.com/llvm/llvm-project/commit/50cf0a1d1ae48bd0397b41a400e01c62975b6706
DIFF: https://github.com/llvm/llvm-project/commit/50cf0a1d1ae48bd0397b41a400e01c62975b6706.diff

LOG: Allow empty value list in propagateMetadata(Inst, ArrayOf...)

This will allow writing
  propagateMetadata(Inst, collectInterestingValues(...))
without concern about empty lists. In case of an empty list,
Inst is returned without any changes.

Added: 
    

Modified: 
    llvm/lib/Analysis/VectorUtils.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/VectorUtils.cpp b/llvm/lib/Analysis/VectorUtils.cpp
index aeec4390ffc1..f7c392961fa4 100644
--- a/llvm/lib/Analysis/VectorUtils.cpp
+++ b/llvm/lib/Analysis/VectorUtils.cpp
@@ -708,6 +708,8 @@ MDNode *llvm::intersectAccessGroups(const Instruction *Inst1,
 
 /// \returns \p I after propagating metadata from \p VL.
 Instruction *llvm::propagateMetadata(Instruction *Inst, ArrayRef<Value *> VL) {
+  if (VL.empty())
+    return Inst;
   Instruction *I0 = cast<Instruction>(VL[0]);
   SmallVector<std::pair<unsigned, MDNode *>, 4> Metadata;
   I0->getAllMetadataOtherThanDebugLoc(Metadata);


        


More information about the llvm-commits mailing list