diff options
author | Chris Lattner <sabre@nondot.org> | 2009-11-27 22:50:07 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-11-27 22:50:07 +0000 |
commit | 971fd57f7d8f6496c5170499ac40ddee538488b3 (patch) | |
tree | 3a789c680b86de96a2a3b693e2d53671e0bc6ef9 | |
parent | 6f7b210b2577fbc9247a9fc5223655390008ae89 (diff) |
disable value insertion for now, I need to figure out how
to inform GVN about the newly inserted values. This fixes
PR5631.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90022 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Transforms/Scalar/GVN.cpp | 8 | ||||
-rw-r--r-- | test/Transforms/GVN/crash.ll | 61 | ||||
-rw-r--r-- | test/Transforms/GVN/pre-load.ll | 24 |
3 files changed, 79 insertions, 14 deletions
diff --git a/lib/Transforms/Scalar/GVN.cpp b/lib/Transforms/Scalar/GVN.cpp index 18cfd2208d..cdc3a4efc1 100644 --- a/lib/Transforms/Scalar/GVN.cpp +++ b/lib/Transforms/Scalar/GVN.cpp @@ -1437,10 +1437,16 @@ bool GVN::processNonLocalLoad(LoadInst *LI, // // FIXME: This may insert a computation, but we don't tell scalar GVN // optimization stuff about it. How do we do this? +#if 0 Value *LoadPtr = MD->InsertPHITranslatedPointer(LI->getOperand(0), LoadBB, UnavailablePred, TD, *DT); - +#else + Value *LoadPtr = + MD->GetAvailablePHITranslatedValue(LI->getOperand(0), LoadBB, + UnavailablePred, TD, *DT); +#endif + // If we couldn't find or insert a computation of this phi translated value, // we fail PRE. if (LoadPtr == 0) { diff --git a/test/Transforms/GVN/crash.ll b/test/Transforms/GVN/crash.ll new file mode 100644 index 0000000000..7dd8454dd9 --- /dev/null +++ b/test/Transforms/GVN/crash.ll @@ -0,0 +1,61 @@ +; RUN: opt -gvn %s -disable-output + +; PR5631 + +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64" +target triple = "x86_64-apple-darwin10.0" + +define i32* @peel_to_type(i8* %name, i32 %namelen, i32* %o, i32 %expected_type) nounwind ssp { +entry: + br i1 undef, label %if.end13, label %while.body.preheader + + +if.end13: ; preds = %if.then6 + br label %while.body.preheader + +while.body.preheader: ; preds = %if.end13, %if.end + br label %while.body + +while.body: ; preds = %while.body.backedge, %while.body.preheader + %o.addr.0 = phi i32* [ undef, %while.body.preheader ], [ %o.addr.0.be, %while.body.backedge ] ; <i32*> [#uses=2] + br i1 false, label %return.loopexit, label %lor.lhs.false + +lor.lhs.false: ; preds = %while.body + %tmp20 = bitcast i32* %o.addr.0 to i32* ; <i32*> [#uses=1] + %tmp22 = load i32* %tmp20 ; <i32> [#uses=0] + br i1 undef, label %land.lhs.true24, label %if.end31 + +land.lhs.true24: ; preds = %lor.lhs.false + %call28 = call i32* @parse_object(i8* undef) nounwind ; <i32*> [#uses=0] + br i1 undef, label %return.loopexit, label %if.end31 + +if.end31: ; preds = %land.lhs.true24, %lor.lhs.false + br i1 undef, label %return.loopexit, label %if.end41 + +if.end41: ; preds = %if.end31 + %tmp43 = bitcast i32* %o.addr.0 to i32* ; <i32*> [#uses=1] + %tmp45 = load i32* %tmp43 ; <i32> [#uses=0] + br i1 undef, label %if.then50, label %if.else + +if.then50: ; preds = %if.end41 + %tmp53 = load i32** undef ; <i32*> [#uses=1] + br label %while.body.backedge + +if.else: ; preds = %if.end41 + br i1 undef, label %if.then62, label %if.else67 + +if.then62: ; preds = %if.else + br label %while.body.backedge + +while.body.backedge: ; preds = %if.then62, %if.then50 + %o.addr.0.be = phi i32* [ %tmp53, %if.then50 ], [ undef, %if.then62 ] ; <i32*> [#uses=1] + br label %while.body + +if.else67: ; preds = %if.else + ret i32* null + +return.loopexit: ; preds = %if.end31, %land.lhs.true24, %while.body + ret i32* undef +} + +declare i32* @parse_object(i8*) diff --git a/test/Transforms/GVN/pre-load.ll b/test/Transforms/GVN/pre-load.ll index 19ea8720d3..c055e86b42 100644 --- a/test/Transforms/GVN/pre-load.ll +++ b/test/Transforms/GVN/pre-load.ll @@ -86,9 +86,9 @@ block1: block2: br label %block4 -; CHECK: block2: -; CHECK: load i32* -; CHECK: br label %block4 +; HECK: block2: +; HECK: load i32* +; HECK: br label %block4 block3: %B = getelementptr i32* %q, i32 1 @@ -103,10 +103,10 @@ block4: %P3 = getelementptr i32* %P2, i32 1 %PRE = load i32* %P3 ret i32 %PRE -; CHECK: block4: -; CHECK-NEXT: phi i32 [ -; CHECK-NOT: load -; CHECK: ret i32 +; HECK: block4: +; HECK-NEXT: phi i32 [ +; HECK-NOT: load +; HECK: ret i32 } ;void test5(int N, double *G) { @@ -239,12 +239,10 @@ return: ret void } - -;;; --- todo - -;; Here the loaded address isn't available in 'block2' at all. -define i32 @testX(i32* %p, i32* %q, i32** %Hack, i1 %C) { -; CHECK: @testX +;; Here the loaded address isn't available in 'block2' at all, requiring a new +;; GEP to be inserted into it. +define i32 @test8(i32* %p, i32* %q, i32** %Hack, i1 %C) { +; CHECK: @test8 block1: br i1 %C, label %block2, label %block3 |