[PATCH] D12875: Stripping invariant.group metadata in CodeGenPrepare

Piotr Padlewski via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 15 11:10:32 PDT 2015


Prazek updated this revision to Diff 34814.

http://reviews.llvm.org/D12875

Files:
  lib/CodeGen/CodeGenPrepare.cpp
  test/Transforms/CodeGenPrepare/invariant.group.ll

Index: test/Transforms/CodeGenPrepare/invariant.group.ll
===================================================================
--- /dev/null
+++ test/Transforms/CodeGenPrepare/invariant.group.ll
@@ -0,0 +1,23 @@
+; RUN: opt -codegenprepare -S < %s | FileCheck %s
+
+ at tmp = global i8 0
+
+; CHECK-LABEL: define void @foo() {
+define void @foo() {
+enter:
+  ; CHECK-NOT: !invariant.group
+  ; CHECK-NOT: @llvm.invariant.group.barrier(
+  ; CHECK: %val = load i8, i8* @tmp
+  %val = load i8, i8* @tmp, !invariant.group !0
+  %ptr = call i8* @llvm.invariant.group.barrier(i8* @tmp)
+  
+  ; CHECK: store i8 42, i8* @tmp
+  store i8 42, i8* %ptr, !invariant.group !0
+  
+  ret void
+}
+; CHECK-LABEL: }
+
+declare i8* @llvm.invariant.group.barrier(i8*)
+
+!0 = !{!"something"}
\ No newline at end of file
Index: lib/CodeGen/CodeGenPrepare.cpp
===================================================================
--- lib/CodeGen/CodeGenPrepare.cpp
+++ lib/CodeGen/CodeGenPrepare.cpp
@@ -187,6 +187,7 @@
                         unsigned CreatedInstCost);
     bool splitBranchCondition(Function &F);
     bool simplifyOffsetableRelocate(Instruction &I);
+    void stripInvariantGroupMetadata(Instruction &I);
   };
 }
 
@@ -4425,14 +4426,16 @@
       return OptimizeCmpExpression(CI);
 
   if (LoadInst *LI = dyn_cast<LoadInst>(I)) {
+    stripInvariantGroupMetadata(*LI);
     if (TLI) {
       unsigned AS = LI->getPointerAddressSpace();
       return OptimizeMemoryInst(I, I->getOperand(0), LI->getType(), AS);
     }
     return false;
   }
 
   if (StoreInst *SI = dyn_cast<StoreInst>(I)) {
+    stripInvariantGroupMetadata(*SI);
     if (TLI) {
       unsigned AS = SI->getPointerAddressSpace();
       return OptimizeMemoryInst(I, SI->getOperand(1),
@@ -4831,3 +4834,8 @@
   }
   return MadeChange;
 }
+
+void CodeGenPrepare::stripInvariantGroupMetadata(Instruction &I) {
+  if (auto *InvariantMD = I.getMetadata("invariant.group"))
+    I.dropUnknownNonDebugMetadata(InvariantMD->getMetadataID());
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D12875.34814.patch
Type: text/x-patch
Size: 2002 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150915/8645a1be/attachment.bin>


More information about the llvm-commits mailing list