[PATCH] D53464: CGP: Clear data structures at the end of a loop iteration instead of the beginning.

Peter Collingbourne via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 19 17:40:12 PDT 2018


pcc created this revision.
pcc added a reviewer: efriedma.
Herald added subscribers: hiraditya, srhines.

Clearing LargeOffsetGEPMap at the end fixes a bug where if a large
offset GEP is in a dead basic block, we fail an assertion when trying
to delete the block due to the asserting VH in LargeOffsetGEPMap.


Repository:
  rL LLVM

https://reviews.llvm.org/D53464

Files:
  llvm/lib/CodeGen/CodeGenPrepare.cpp
  llvm/test/CodeGen/Thumb2/unreachable-large-offset-gep.ll


Index: llvm/test/CodeGen/Thumb2/unreachable-large-offset-gep.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/Thumb2/unreachable-large-offset-gep.ll
@@ -0,0 +1,22 @@
+; RUN: llc -o - %s | FileCheck %s
+
+; CHECK: .LBB0_1:
+; CHECK: b .LBB0_1
+
+target triple = "thumbv8m-unknown-linux-android"
+
+define void @d(i32* %c) {
+entry:
+  br i1 false, label %f.exit, label %i.d
+
+i.d:
+  br label %i.d
+
+f.exit:
+  %0 = getelementptr i32, i32* %c, i32 57
+  br label %if.g
+
+if.g:
+  store i32 0, i32* %0
+  ret void
+}
Index: llvm/lib/CodeGen/CodeGenPrepare.cpp
===================================================================
--- llvm/lib/CodeGen/CodeGenPrepare.cpp
+++ llvm/lib/CodeGen/CodeGenPrepare.cpp
@@ -436,11 +436,6 @@
   bool MadeChange = true;
   while (MadeChange) {
     MadeChange = false;
-    SeenChainsForSExt.clear();
-    ValToSExtendedUses.clear();
-    RemovedInsts.clear();
-    LargeOffsetGEPMap.clear();
-    LargeOffsetGEPID.clear();
     for (Function::iterator I = F.begin(); I != F.end(); ) {
       BasicBlock *BB = &*I++;
       bool ModifiedDTOnIteration = false;
@@ -460,6 +455,11 @@
       I->deleteValue();
 
     EverMadeChange |= MadeChange;
+    SeenChainsForSExt.clear();
+    ValToSExtendedUses.clear();
+    RemovedInsts.clear();
+    LargeOffsetGEPMap.clear();
+    LargeOffsetGEPID.clear();
   }
 
   SunkAddrs.clear();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53464.170286.patch
Type: text/x-patch
Size: 1422 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181020/fb2b0bb9/attachment.bin>


More information about the llvm-commits mailing list