[llvm-commits] [llvm-gcc-4.2] r50984 - /llvm-gcc-4.2/branches/release_23/gcc/llvm-convert.cpp

Tanya Lattner tonic at nondot.org
Mon May 12 11:49:39 PDT 2008


Author: tbrethou
Date: Mon May 12 13:49:37 2008
New Revision: 50984

URL: http://llvm.org/viewvc/llvm-project?rev=50984&view=rev
Log:
Merge from mainline.
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/branches/release_23/gcc/llvm-convert.cpp

Modified: llvm-gcc-4.2/branches/release_23/gcc/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/release_23/gcc/llvm-convert.cpp?rev=50984&r1=50983&r2=50984&view=diff

==============================================================================
--- llvm-gcc-4.2/branches/release_23/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.2/branches/release_23/gcc/llvm-convert.cpp Mon May 12 13:49:37 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