diff options
author | Chris Lattner <sabre@nondot.org> | 2002-03-15 20:35:21 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-03-15 20:35:21 +0000 |
commit | f09733a8766aaa331d7e5196ea36cd9c6bb82100 (patch) | |
tree | 7ec4472d215ff89a7a14976a5cbde55858e26e66 /lib/Transforms | |
parent | acd3caec0d5419f454cfc4e15afe7945de46547f (diff) |
Remove code designed to compensate for a bug in GCC. The bug has since
been fixed.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1881 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r-- | lib/Transforms/IPO/DeadTypeElimination.cpp | 62 |
1 files changed, 5 insertions, 57 deletions
diff --git a/lib/Transforms/IPO/DeadTypeElimination.cpp b/lib/Transforms/IPO/DeadTypeElimination.cpp index 801cdffb7e..f8a9b6e1dd 100644 --- a/lib/Transforms/IPO/DeadTypeElimination.cpp +++ b/lib/Transforms/IPO/DeadTypeElimination.cpp @@ -393,7 +393,6 @@ static inline bool FixCastsAndPHIs(BasicBlock *BB) { } } - return Changed; } @@ -436,33 +435,10 @@ static inline void RefactorPredecessor(BasicBlock *BB, BasicBlock *Pred) { } -// CheckIncomingValueFor - Make sure that the specified PHI node has an entry -// for the provided basic block. If it doesn't, add one and return true. -// -static inline void CheckIncomingValueFor(PHINode *PN, BasicBlock *BB) { - if (PN->getBasicBlockIndex(BB) != -1) return; // Already has value - - Value *NewVal = 0; - const Type *Ty = PN->getType(); - - if (const PointerType *PT = dyn_cast<PointerType>(Ty)) - NewVal = ConstantPointerNull::get(PT); - else if (Ty == Type::BoolTy) - NewVal = ConstantBool::True; - else if (Ty == Type::FloatTy || Ty == Type::DoubleTy) - NewVal = ConstantFP::get(Ty, 42); - else if (Ty->isIntegral()) - NewVal = ConstantInt::get(Ty, 42); - - assert(NewVal && "Unknown PHI node type!"); - PN->addIncoming(NewVal, BB); -} - // fixLocalProblems - Loop through the method and fix problems with the PHI -// nodes in the current method. The two problems that are handled are: -// -// 1. PHI nodes with multiple entries for the same predecessor. GCC sometimes -// generates code that looks like this: +// nodes in the current method. The problem is that PHI nodes might exist with +// multiple entries for the same predecessor. GCC sometimes generates code +// that looks like this: // // bb7: br bool %cond1004, label %bb8, label %bb8 // bb8: %reg119 = phi uint [ 0, %bb7 ], [ 1, %bb7 ] @@ -475,18 +451,6 @@ static inline void CheckIncomingValueFor(PHINode *PN, BasicBlock *BB) { // bb8: %reg119 = phi uint [ 0, %bbX ], [ 1, %bb7 ] // // -// 2. PHI nodes with fewer arguments than predecessors. -// These can be generated by GCC if a variable is uninitalized over a path -// in the CFG. We fix this by adding an entry for the missing predecessors -// that is initialized to either 42 for a numeric/FP value, or null if it's -// a pointer value. This problem can be generated by code that looks like -// this: -// int foo(int y) { -// int X; -// if (y) X = 1; -// return X; -// } -// static bool fixLocalProblems(Method *M) { bool Changed = false; // Don't use iterators because invalidation gets messy... @@ -498,8 +462,8 @@ static bool fixLocalProblems(Method *M) { if (isa<PHINode>(BB->front())) { const vector<BasicBlock*> Preds(pred_begin(BB), pred_end(BB)); - // Handle Problem #1. Sort the list of predecessors so that it is easy to - // decide whether or not duplicate predecessors exist. + // Handle the problem. Sort the list of predecessors so that it is easy + // to decide whether or not duplicate predecessors exist. vector<BasicBlock*> SortedPreds(Preds); sort(SortedPreds.begin(), SortedPreds.end()); @@ -512,22 +476,6 @@ static bool fixLocalProblems(Method *M) { } LastOne = SortedPreds[i]; } - - // Loop over all of the PHI nodes in the current BB. These PHI nodes are - // guaranteed to be at the beginning of the basic block. - // - for (BasicBlock::iterator I = BB->begin(); - PHINode *PN = dyn_cast<PHINode>(*I); ++I) { - - // Handle problem #2. - if (PN->getNumIncomingValues() != Preds.size()) { - assert(PN->getNumIncomingValues() <= Preds.size() && - "Can't handle extra arguments to PHI nodes!"); - for (unsigned i = 0; i < Preds.size(); ++i) - CheckIncomingValueFor(PN, Preds[i]); - Changed = true; - } - } } } return Changed; |