[PATCH] D13233: Combining invariant.group metadata bugfix

Piotr Padlewski via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 29 10:40:21 PDT 2015


Prazek updated this revision to Diff 36004.

http://reviews.llvm.org/D13233

Files:
  lib/Transforms/Utils/Local.cpp

Index: lib/Transforms/Utils/Local.cpp
===================================================================
--- lib/Transforms/Utils/Local.cpp
+++ lib/Transforms/Utils/Local.cpp
@@ -1424,10 +1424,13 @@
   }
   // Set !invariant.group from J if J has it. If both instructions have it
   // then we will just pick it from J - even when they are different.
+  // Also make sure that K is load or store - f.e. combining bitcast with load
+  // could produce bitcast with invariant.group metadata, which is invalid.
   // FIXME: we should try to preserve both invariant.group md if they are
   // different, but right now instruction can only have one invariant.group.
   if (auto *JMD = J->getMetadata(LLVMContext::MD_invariant_group))
-    K->setMetadata(LLVMContext::MD_invariant_group, JMD);
+    if (isa<LoadInst>(K) || isa<StoreInst>(K))
+      K->setMetadata(LLVMContext::MD_invariant_group, JMD);
 
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13233.36004.patch
Type: text/x-patch
Size: 905 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150929/3723a9f7/attachment.bin>


More information about the llvm-commits mailing list