[llvm-commits] [dragonegg] r90345 - /dragonegg/trunk/llvm-convert.cpp
Duncan Sands
baldrick at free.fr
Wed Dec 2 12:38:46 PST 2009
Author: baldrick
Date: Wed Dec 2 14:38:46 2009
New Revision: 90345
URL: http://llvm.org/viewvc/llvm-project?rev=90345&view=rev
Log:
Due to exception handling not being wired up, an LLVM basic block can
have no predecessors even though the GCC basic block does. This can
result in phi nodes with no operands, which is not allowed. For the
moment, just nuke the phi node in this case.
Modified:
dragonegg/trunk/llvm-convert.cpp
Modified: dragonegg/trunk/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-convert.cpp?rev=90345&r1=90344&r2=90345&view=diff
==============================================================================
--- dragonegg/trunk/llvm-convert.cpp (original)
+++ dragonegg/trunk/llvm-convert.cpp Wed Dec 2 14:38:46 2009
@@ -812,8 +812,7 @@
// The incoming GCC basic block.
basic_block bb = gimple_phi_arg_edge(P.gcc_phi, i)->src;
- // If there is no corresponding LLVM basic block then the GCC basic block
- // was unreachable - skip this phi argument.
+ // The corresponding LLVM basic block.
DenseMap<basic_block, BasicBlock*>::iterator BI = BasicBlocks.find(bb);
assert(BI != BasicBlocks.end() && "GCC basic block not output?");
@@ -849,6 +848,17 @@
++PI, ++Index)
Predecessors.push_back(std::make_pair(*PI, Index));
+ if (Predecessors.empty()) {
+ // FIXME: If this happens then GCC has a control flow edge where LLVM has
+ // none - something has gone wrong. For the moment be laid back about it
+ // because the fact we don't yet wire up exception handling code means it
+ // happens all the time in Ada and C++.
+ P.PHI->replaceAllUsesWith(UndefValue::get(P.PHI->getType()));
+ P.PHI->eraseFromParent();
+ IncomingValues.clear();
+ continue;
+ }
+
// Sort the predecessors by basic block. In GCC, each predecessor occurs
// exactly once. However in LLVM a predecessor can occur several times,
// and then every copy of the predecessor must be associated with exactly
More information about the llvm-commits
mailing list