[PATCH] D66495: [MemorySSA] Fix existing phis when inserting defs.
Alina Sbirlea via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 20 15:28:41 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL369464: [MemorySSA] Fix existing phis when inserting defs. (authored by asbirlea, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D66495?vs=216236&id=216269#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D66495/new/
https://reviews.llvm.org/D66495
Files:
llvm/trunk/lib/Analysis/MemorySSAUpdater.cpp
llvm/trunk/test/Analysis/MemorySSA/PR43044.ll
Index: llvm/trunk/test/Analysis/MemorySSA/PR43044.ll
===================================================================
--- llvm/trunk/test/Analysis/MemorySSA/PR43044.ll
+++ llvm/trunk/test/Analysis/MemorySSA/PR43044.ll
@@ -0,0 +1,52 @@
+; RUN: opt -loop-rotate -licm -enable-mssa-loop-dependency -verify-memoryssa %s -S | FileCheck %s
+; REQUIRES: asserts
+
+target datalayout = "E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-v128:64-a:8:16-n32:64"
+target triple = "s390x-ibm-linux"
+
+declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture)
+
+; CHECK-LABEL: @func_42()
+define void @func_42() {
+entry:
+ br label %for.cond1050
+
+for.cond1050.loopexit: ; preds = %for.cond1373
+ br label %for.cond1050
+
+for.cond1050: ; preds = %for.cond1050.loopexit, %entry
+ %storemerge6 = phi i32 [ 2, %entry ], [ 0, %for.cond1050.loopexit ]
+ %cmp1051 = icmp sgt i32 %storemerge6, -1
+ br i1 %cmp1051, label %for.cond1055.preheader, label %cleanup1400.loopexit1
+
+for.cond1055.preheader: ; preds = %for.cond1050
+ store i64 0, i64* null, align 8
+ %0 = load i64, i64* null, align 8
+ %tobool1383 = icmp eq i64 %0, 0
+ br i1 %tobool1383, label %for.cond1055.preheader.cleanup1400.loopexit.split_crit_edge, label %for.cond1055.preheader.for.cond1055.preheader.split_crit_edge
+
+for.cond1055.preheader.for.cond1055.preheader.split_crit_edge: ; preds = %for.cond1055.preheader
+ br label %for.body1376
+
+for.cond1055.preheader.cleanup1400.loopexit.split_crit_edge: ; preds = %for.cond1055.preheader
+ br label %cleanup1400.loopexit.split
+
+for.cond1373: ; preds = %for.body1376
+ br i1 true, label %for.body1376, label %for.cond1050.loopexit
+
+for.body1376: ; preds = %for.cond1373, %for.cond1055.preheader.for.cond1055.preheader.split_crit_edge
+ br i1 false, label %cleanup1400.loopexit, label %for.cond1373
+
+cleanup1400.loopexit: ; preds = %for.body1376
+ br label %cleanup1400.loopexit.split
+
+cleanup1400.loopexit.split: ; preds = %cleanup1400.loopexit, %for.cond1055.preheader.cleanup1400.loopexit.split_crit_edge
+ br label %cleanup1400
+
+cleanup1400.loopexit1: ; preds = %for.cond1050
+ br label %cleanup1400
+
+cleanup1400: ; preds = %cleanup1400.loopexit1, %cleanup1400.loopexit.split
+ call void @llvm.lifetime.end.p0i8(i64 4, i8* nonnull undef)
+ unreachable
+}
Index: llvm/trunk/lib/Analysis/MemorySSAUpdater.cpp
===================================================================
--- llvm/trunk/lib/Analysis/MemorySSAUpdater.cpp
+++ llvm/trunk/lib/Analysis/MemorySSAUpdater.cpp
@@ -341,16 +341,20 @@
IDFs.setDefiningBlocks(DefiningBlocks);
IDFs.calculate(IDFBlocks);
SmallVector<AssertingVH<MemoryPhi>, 4> NewInsertedPHIs;
- for (auto *BBIDF : IDFBlocks)
- if (!MSSA->getMemoryAccess(BBIDF)) {
- auto *MPhi = MSSA->createMemoryPhi(BBIDF);
+ for (auto *BBIDF : IDFBlocks) {
+ auto *MPhi = MSSA->getMemoryAccess(BBIDF);
+ if (!MPhi) {
+ MPhi = MSSA->createMemoryPhi(BBIDF);
NewInsertedPHIs.push_back(MPhi);
- // Add the phis created into the IDF blocks to NonOptPhis, so they are
- // not optimized out as trivial by the call to getPreviousDefFromEnd
- // below. Once they are complete, all these Phis are added to the
- // FixupList, and removed from NonOptPhis inside fixupDefs().
- NonOptPhis.insert(MPhi);
}
+ // Add the phis created into the IDF blocks to NonOptPhis, so they are
+ // not optimized out as trivial by the call to getPreviousDefFromEnd
+ // below. Once they are complete, all these Phis are added to the
+ // FixupList, and removed from NonOptPhis inside fixupDefs().
+ // Existing Phis in IDF may need fixing as well, and potentially be
+ // trivial before this insertion, hence add all IDF Phis. See PR43044.
+ NonOptPhis.insert(MPhi);
+ }
for (auto &MPhi : NewInsertedPHIs) {
auto *BBIDF = MPhi->getBlock();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D66495.216269.patch
Type: text/x-patch
Size: 4242 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190820/a615e749/attachment.bin>
More information about the llvm-commits
mailing list