[PATCH] D61089: [Reassociation] Place moved instructions after landing pads
David Greene via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 24 13:37:47 PDT 2019
greened created this revision.
greened added reviewers: dsanders, spatel, davide, uabelho, mcrosier.
greened added a project: LLVM.
Herald added subscribers: llvm-commits, hiraditya.
Reassociation's NegateValue moved instructions to the beginning of
blocks (after PHIs) without checking for landingpad instructions.
It's possible for reassociation to happen within a landingpad block so
we need to make sure we don't move things too early in the block.
This change advances the insertion point past any landingpad.
Repository:
rL LLVM
https://reviews.llvm.org/D61089
Files:
llvm/lib/Transforms/Scalar/Reassociate.cpp
llvm/test/Transforms/Reassociate/reassociate-landndingpad.ll
Index: llvm/test/Transforms/Reassociate/reassociate-landndingpad.ll
===================================================================
--- /dev/null
+++ llvm/test/Transforms/Reassociate/reassociate-landndingpad.ll
@@ -0,0 +1,54 @@
+; Reassociate used to move the negation of $time_1_P14.0 above the
+; landingpad.
+;
+; RUN: opt -reassociate -disable-output < %s
+;
+; ModuleID = 'bugpoint-reduced-simplified.bc'
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+%"lp.2234.4378.7378.12512.15079.17646.20213.22780.25347.27914.40747.53580.74113.76680.86947.89514.92081.94648.115163.130561" = type { i8*, i32 }
+%__type_info.2235.4379.7379.12513.15080.17647.20214.22781.25348.27915.40748.53581.74114.76681.86948.89515.92082.94649.115162.130560 = type { i64*, i8* }
+
+declare i32 @__gxx_personality_v0(...)
+
+declare void @b() #0
+
+define void @a() #0 personality i32 (...)* @__gxx_personality_v0 {
+", bb1":
+ invoke void @b()
+ to label %invoke.cont unwind label %"bb22"
+
+", bb8": ; preds = %invoke.cont
+ invoke void @c()
+ to label %invoke.cont25 unwind label %"bb22"
+
+", bb15": ; preds = %invoke.cont
+ ret void
+
+"bb22": ; preds = %", bb8", %", bb1"
+ %"$time_1_P14.0" = phi i64 [ undef, %", bb8" ], [ undef, %", bb1" ]
+ %0 = landingpad %"lp.2234.4378.7378.12512.15079.17646.20213.22780.25347.27914.40747.53580.74113.76680.86947.89514.92081.94648.115163.130561"
+ cleanup
+ catch %__type_info.2235.4379.7379.12513.15080.17647.20214.22781.25348.27915.40748.53581.74114.76681.86948.89515.92082.94649.115162.130560* null
+ %r79 = sub i64 0, %"$time_1_P14.0"
+ %r81 = add i64 %r79, undef
+ %r93 = add i64 %r81, undef
+ %r95 = sub i64 %r93, %"$time_1_P14.0"
+ %r98 = icmp ult i64 %r95, undef
+ unreachable
+
+invoke.cont: ; preds = %", bb1"
+ br i1 undef, label %", bb15", label %", bb8"
+
+invoke.cont25: ; preds = %", bb8"
+ unreachable
+}
+
+declare void @c() #0
+
+attributes #0 = { "no-frame-pointer-elim-non-leaf" }
+
+!llvm.module.flags = !{!0}
+
+!0 = !{i32 1, !"Debug Info Version", i32 3}
Index: llvm/lib/Transforms/Scalar/Reassociate.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/Reassociate.cpp
+++ llvm/lib/Transforms/Scalar/Reassociate.cpp
@@ -868,7 +868,11 @@
} else {
InsertPt = ++InstInput->getIterator();
}
- while (isa<PHINode>(InsertPt)) ++InsertPt;
+ // It's possible that we happen to reassociate within a
+ // landingpad block, so make sure we don't move anything before
+ // the landingpad.
+ while (isa<PHINode>(InsertPt) || isa<LandingPadInst>(InsertPt))
+ ++InsertPt;
} else {
InsertPt = TheNeg->getParent()->getParent()->getEntryBlock().begin();
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D61089.196512.patch
Type: text/x-patch
Size: 2976 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190424/0a919266/attachment.bin>
More information about the llvm-commits
mailing list