[llvm-commits] [124439] Fix PR1235, an ICE on invalid code.

clattner at apple.com clattner at apple.com
Thu Mar 1 22:49:44 PST 2007


Revision: 124439
Author:   clattner
Date:     2007-03-01 22:49:42 -0800 (Thu, 01 Mar 2007)

Log Message:
-----------
Fix PR1235, an ICE on invalid code.

Modified Paths:
--------------
    apple-local/branches/llvm/gcc/llvm-backend.cpp
    apple-local/branches/llvm/gcc/llvm-convert.cpp

Modified: apple-local/branches/llvm/gcc/llvm-backend.cpp
===================================================================
--- apple-local/branches/llvm/gcc/llvm-backend.cpp	2007-03-01 23:11:13 UTC (rev 124438)
+++ apple-local/branches/llvm/gcc/llvm-backend.cpp	2007-03-02 06:49:42 UTC (rev 124439)
@@ -713,6 +713,10 @@
   // same DECL node.  Don't discard the LLVM already made.
   if (DECL_LLVM_SET_P(decl)) return;
 
+  if (errorcount || sorrycount)
+    return;  // Do not process broken code.
+  
+  
   // Global register variable with asm name, e.g.:
   // register unsigned long esp __asm__("ebp");
   if (TREE_CODE(decl) != FUNCTION_DECL && DECL_REGISTER(decl)) {
@@ -862,6 +866,7 @@
 /// llvm_get_decl_name - Used by varasm.c, returns the specified declaration's
 /// name.
 const char *llvm_get_decl_name(void *LLVM) {
+  if (LLVM == 0) return "";
   return ((Value*)LLVM)->getValueName()->getKeyData();
 }
 

Modified: apple-local/branches/llvm/gcc/llvm-convert.cpp
===================================================================
--- apple-local/branches/llvm/gcc/llvm-convert.cpp	2007-03-01 23:11:13 UTC (rev 124438)
+++ apple-local/branches/llvm/gcc/llvm-convert.cpp	2007-03-02 06:49:42 UTC (rev 124439)
@@ -124,6 +124,9 @@
   if (Index == 0) {
     make_decl_llvm(Tr);
     Index = GET_DECL_LLVM_INDEX(Tr);
+    
+    // If there was an error, we may have disabled creating LLVM values.
+    if (Index == 0) return 0;
   }
   assert ((Index - 1) < LLVMValues.size() && "Invalid LLVM Value index");
 





More information about the llvm-commits mailing list