[PATCH] D63680: [LoopRotate + MemorySSA] Keep an <instruction-cloned instruction> map.

Alina Sbirlea via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 10 10:38:18 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL365672: [LoopRotate + MemorySSA] Keep an <instruction-cloned instruction> map. (authored by asbirlea, committed by ).

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63680/new/

https://reviews.llvm.org/D63680

Files:
  llvm/trunk/lib/Transforms/Utils/LoopRotationUtils.cpp
  llvm/trunk/test/Analysis/MemorySSA/loop-rotate-valuemap.ll


Index: llvm/trunk/test/Analysis/MemorySSA/loop-rotate-valuemap.ll
===================================================================
--- llvm/trunk/test/Analysis/MemorySSA/loop-rotate-valuemap.ll
+++ llvm/trunk/test/Analysis/MemorySSA/loop-rotate-valuemap.ll
@@ -0,0 +1,26 @@
+; RUN: opt -loop-rotate -enable-mssa-loop-dependency %s -S | FileCheck %s
+; REQUIRES: asserts
+
+; Check that loop rotate keeps proper mapping between cloned instructions,
+; otherwise, MemorySSA will assert.
+
+; CHECK-LABEL: @f
+define void @f() {
+entry:
+  br label %for.body16
+
+for.cond.cleanup15:                               ; preds = %for.body16
+  ret void
+
+for.body16:                                       ; preds = %for.body16.for.body16_crit_edge, %entry
+  %call.i = tail call float @expf(float 0.000000e+00) #1
+  %0 = load float*, float** undef, align 8
+  br i1 undef, label %for.cond.cleanup15, label %for.body16.for.body16_crit_edge
+
+for.body16.for.body16_crit_edge:                  ; preds = %for.body16
+  %.pre = load float, float* undef, align 8
+  br label %for.body16
+}
+
+declare float @expf(float)
+
Index: llvm/trunk/lib/Transforms/Utils/LoopRotationUtils.cpp
===================================================================
--- llvm/trunk/lib/Transforms/Utils/LoopRotationUtils.cpp
+++ llvm/trunk/lib/Transforms/Utils/LoopRotationUtils.cpp
@@ -295,7 +295,7 @@
   // Begin by walking OrigHeader and populating ValueMap with an entry for
   // each Instruction.
   BasicBlock::iterator I = OrigHeader->begin(), E = OrigHeader->end();
-  ValueToValueMapTy ValueMap;
+  ValueToValueMapTy ValueMap, ValueMapMSSA;
 
   // For PHI nodes, the value available in OldPreHeader is just the
   // incoming value from OldPreHeader.
@@ -374,6 +374,9 @@
       if (auto *II = dyn_cast<IntrinsicInst>(C))
         if (II->getIntrinsicID() == Intrinsic::assume)
           AC->registerAssumption(II);
+      // MemorySSA cares whether the cloned instruction was inserted or not, and
+      // not whether it can be remapped to a simplified value.
+      ValueMapMSSA[Inst] = C;
     }
   }
 
@@ -391,10 +394,11 @@
   LoopEntryBranch->eraseFromParent();
 
   // Update MemorySSA before the rewrite call below changes the 1:1
-  // instruction:cloned_instruction_or_value mapping in ValueMap.
+  // instruction:cloned_instruction_or_value mapping.
   if (MSSAU) {
-    ValueMap[OrigHeader] = OrigPreheader;
-    MSSAU->updateForClonedBlockIntoPred(OrigHeader, OrigPreheader, ValueMap);
+    ValueMapMSSA[OrigHeader] = OrigPreheader;
+    MSSAU->updateForClonedBlockIntoPred(OrigHeader, OrigPreheader,
+                                        ValueMapMSSA);
   }
 
   SmallVector<PHINode*, 2> InsertedPHIs;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63680.209014.patch
Type: text/x-patch
Size: 2707 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190710/ac4740e8/attachment.bin>


More information about the llvm-commits mailing list