[llvm-commits] [llvm-gcc-4.2] r50964 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
Duncan Sands
baldrick at free.fr
Mon May 12 05:57:21 PDT 2008
Author: baldrick
Date: Mon May 12 07:57:19 2008
New Revision: 50964
URL: http://llvm.org/viewvc/llvm-project?rev=50964&view=rev
Log:
Since the order that basic blocks are output is
not related to the cfg in general, it is possible
to encounter a use of a gimple temporary before
it is defined even though the definition dominates
all uses. Handle this rare case by demoting the
temporary to an ordinary variable. This fixes
PR2264.
Modified:
llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=50964&r1=50963&r2=50964&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Mon May 12 07:57:19 2008
@@ -2164,8 +2164,16 @@
Value *TreeToLLVM::EmitLoadOfLValue(tree exp, const MemRef *DestLoc) {
// If this is a gimple temporary, don't emit a load, just use the result.
if (isGimpleTemporary(exp)) {
- assert(DECL_LLVM_SET_P(exp) && "Definition not found before use!");
- return DECL_LLVM(exp);
+ if (DECL_LLVM_SET_P(exp))
+ return DECL_LLVM(exp);
+ // Since basic blocks are output in no particular order, it is perfectly
+ // possible to encounter a use of a gimple temporary before encountering
+ // its definition, which is what has happened here. This happens rarely
+ // in practice, so there's no point in trying to do anything clever: just
+ // demote to an ordinary variable and create an alloca to hold its value.
+ DECL_GIMPLE_FORMAL_TEMP_P(exp) = 0;
+ EmitAutomaticVariableDecl(exp);
+ // Fall through.
} else if (TREE_CODE(exp) == VAR_DECL && DECL_REGISTER(exp) &&
TREE_STATIC(exp)) {
// If this is a register variable, EmitLV can't handle it (there is no
More information about the llvm-commits
mailing list