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

Piotr Padlewski via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 14 23:24:56 PDT 2015


Prazek created this revision.
Prazek added reviewers: nlewycky, rsmith, majnemer.
Prazek added a subscriber: llvm-commits.

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() {
+; CHECK-NOT: !invariant.group
+; CHECK-NOT: @llvm.invariant.group.barrier(
+; CHECK: %val = load i8, i8* @tmp
+; CHECK: store i8 42, i8* @tmp
+; CHECK-LABEL: }
+
+define void @foo() {
+enter:
+  %val = load i8, i8* @tmp, !invariant.group !0
+  %ptr = call i8* @llvm.invariant.group.barrier(i8* @tmp)
+  store i8 42, i8* %ptr, !invariant.group !0
+  
+  ret void
+}
+
+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.34784.patch
Type: text/x-patch
Size: 1992 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150915/7bbac933/attachment.bin>


More information about the llvm-commits mailing list