[llvm-commits] [llvm] r62506 - in /llvm/trunk: lib/Transforms/Utils/SimplifyCFG.cpp test/Transforms/SimplifyCFG/2009-01-18-PHIPropCrash.ll
Bill Wendling
isanbard at gmail.com
Mon Jan 19 00:46:21 PST 2009
Author: void
Date: Mon Jan 19 02:46:20 2009
New Revision: 62506
URL: http://llvm.org/viewvc/llvm-project?rev=62506&view=rev
Log:
Temporarily revert r62487. It's causing this error during a release bootstrap of
llvm-gcc. Most likely, it's miscompiling one of the "gen*" programs:
/Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvm-gcc.obj/./prev-gcc/xgcc -B/Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvm-gcc.obj/./prev-gcc/ -B/Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvm-gcc.install/i386-apple-darwin9.6.0/bin/ -c -g -O2 -mdynamic-no-pic -DIN_GCC -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -mdynamic-no-pic -DHAVE_CONFIG_H -DGENERATOR_FILE -I. -Ibuild -I../../llvm-gcc.src/gcc -I../../llvm-gcc.src/gcc/build -I../../llvm-gcc.src/gcc/../include -I./../intl -I../../llvm-gcc.src/gcc/../libcpp/include -I../../llvm-gcc.src/gcc/../libdecnumber -I../libdecnumber -I/Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvm.obj/include -I/Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvm.src/include -DENABLE_LLVM -I/Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvm.obj/../llvm.src/include -D_DEBUG -D_GNU_SOURCE -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -o build/gencondmd.o build/gencondmd.c
./../llvm-gcc.src/gcc/config/i386/mmx.md:926: error: expected '}' before ')' token
./../llvm-gcc.src/gcc/config/i386/mmx.md:926: warning: excess elements in struct initializer
./../llvm-gcc.src/gcc/config/i386/mmx.md:926: warning: (near initialization for 'insn_conditions[4]')
./../llvm-gcc.src/gcc/config/i386/mmx.md:926: error: expected '}' before ')' token
./../llvm-gcc.src/gcc/config/i386/mmx.md:926: error: expected ',' or ';' before ')' token
./../llvm-gcc.src/gcc/config/i386/mmx.md:927: error: expected identifier or '(' before ',' token
./../llvm-gcc.src/gcc/config/i386/sse.md:3458: error: expected identifier or '(' before ',' token
..
Modified:
llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
llvm/trunk/test/Transforms/SimplifyCFG/2009-01-18-PHIPropCrash.ll
Modified: llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp?rev=62506&r1=62505&r2=62506&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp Mon Jan 19 02:46:20 2009
@@ -21,7 +21,6 @@
#include "llvm/Support/Debug.h"
#include "llvm/Analysis/ConstantFolding.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
-#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/Statistic.h"
@@ -173,74 +172,6 @@
return true;
}
-/// BlockIsReachableFrom - Return true if there is a path from StartBB to
-/// DestBB. We do this by recursively walking the CFG from DestBB up to StartBB
-/// unwind we either reach StartBB or find an unreachable chunk of the CFG.
-///
-/// Each entry in VisitedBlocks is either 0 -> not visited, 1 -> known reachable
-/// 2 -> known unreachable, 3 -> visitation in progress.
-static bool BlockIsReachableFrom(BasicBlock *StartBB, BasicBlock *DestBB,
- DenseMap<BasicBlock*, unsigned> &VisitedBlocks) {
- if (StartBB == DestBB) return true;
-
- unsigned &BlockEntry = VisitedBlocks[DestBB];
- if (BlockEntry == 1) return true; // Known reachable!
- if (BlockEntry == 2 || // Known unreachable.
- BlockEntry == 3) // Found a loop.
- return false;
-
- // If BlockEntry is 0, this is the first time we've seen this block. Mark it
- // as being visited and recurse up predecessors.
- BlockEntry = 3;
-
- for (pred_iterator PI = pred_begin(DestBB), E = pred_end(DestBB); PI != E;
- ++PI) {
- if (BlockIsReachableFrom(StartBB, *PI, VisitedBlocks)) {
- VisitedBlocks[DestBB] = 1;
- return true;
- }
- }
-
- // If we scanned all of our predecessors and we couldn't find a path to
- // StartBB, then this block must be unreachable for sure. Record this to
- // prevent visitation of this block in the future.
- VisitedBlocks[DestBB] = 2;
- return false;
-}
-
-/// RemoveUnreachableUsersOf - For each user of Inst, scan up the CFG until we
-/// find Inst. If Inst is found, then the user is live, otherwise it is dead.
-/// Remove dead users. This is basically a poor-man's dominance query, and is
-/// worst-case linear time in the number of blocks in the function.
-static void RemoveUnreachableUsersOf(Instruction *Inst) {
- DenseMap<BasicBlock*, unsigned> VisitedBlocks;
-
- BasicBlock *InstBB = Inst->getParent();
- for (Instruction::use_iterator UI = Inst->use_begin(), E = Inst->use_end();
- UI != E;) {
- Instruction *User = cast<Instruction>(*UI);
- Use &TheUse = UI.getUse();
-
- if (PHINode *PN = dyn_cast<PHINode>(User)) {
- unsigned UseOp = UI.getOperandNo();
- ++UI;
-
- if (BlockIsReachableFrom(InstBB, PN->getIncomingBlock(UseOp/2),
- VisitedBlocks))
- continue;
- } else {
- ++UI;
- if (BlockIsReachableFrom(InstBB, User->getParent(),
- VisitedBlocks))
- continue;
- }
- // If there is no path from Inst to this User, then this user is in dead
- // code. Just replace uses of Inst with undef.
- TheUse = UndefValue::get(Inst->getType());
- }
-}
-
-
/// TryToSimplifyUncondBranchFromEmptyBlock - BB contains an unconditional
/// branch to Succ, and contains no instructions other than PHI nodes and the
/// branch. If possible, eliminate BB.
@@ -285,18 +216,12 @@
}
if (isa<PHINode>(&BB->front())) {
- SmallVector<BasicBlock*, 16> OldSuccPreds(pred_begin(Succ),
- pred_end(Succ));
+ SmallVector<BasicBlock*, 16>
+ OldSuccPreds(pred_begin(Succ), pred_end(Succ));
// Move all PHI nodes in BB to Succ if they are alive, otherwise
// delete them.
while (PHINode *PN = dyn_cast<PHINode>(&BB->front())) {
- // The algorithm below will not work if there are users of PN that are in
- // unreachable blocks. These users will not be properly dominated by the
- // instruction, but the IR is valid because dead code does not need to
- // obey dominance properties.
- RemoveUnreachableUsersOf(PN);
-
if (PN->use_empty()) {
// Just remove the dead phi. This happens if Succ's PHIs were the only
// users of the PHI nodes.
Modified: llvm/trunk/test/Transforms/SimplifyCFG/2009-01-18-PHIPropCrash.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SimplifyCFG/2009-01-18-PHIPropCrash.ll?rev=62506&r1=62505&r2=62506&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/SimplifyCFG/2009-01-18-PHIPropCrash.ll (original)
+++ llvm/trunk/test/Transforms/SimplifyCFG/2009-01-18-PHIPropCrash.ll Mon Jan 19 02:46:20 2009
@@ -1,4 +1,5 @@
; RUN: llvm-as < %s | opt -simplifycfg | llvm-dis
+; XFAIL: *
; PR3016
; Dead use caused invariant violation.
More information about the llvm-commits
mailing list