[llvm-commits] [llvm-gcc-4.2] r52474 - in /llvm-gcc-4.2/trunk/gcc: llvm-backend.cpp llvm-debug.cpp llvm-debug.h

Bill Wendling isanbard at gmail.com
Wed Jun 18 16:55:07 PDT 2008


Author: void
Date: Wed Jun 18 18:55:07 2008
New Revision: 52474

URL: http://llvm.org/viewvc/llvm-project?rev=52474&view=rev
Log:
The module was being deleted before the debug info was finished with it. This
happened when PCH files are involved. Have the TheDebugInfo object take
possession of the TheModule object so that it won't get deleted accidentally.


Modified:
    llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp
    llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp
    llvm-gcc-4.2/trunk/gcc/llvm-debug.h

Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp?rev=52474&r1=52473&r2=52474&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Wed Jun 18 18:55:07 2008
@@ -203,6 +203,7 @@
     RegisterRegAlloc::setDefault(createLocalRegisterAllocator);
  
   if (!optimize && debug_info_level > DINFO_LEVEL_NONE)
+    // TheDebugInfo is taking ownership of TheModule.
     TheDebugInfo = new DebugInfo(TheModule);
 }
 
@@ -224,9 +225,10 @@
 /// Read bytecode from PCH file. Initialize TheModule and setup
 /// LTypes vector.
 void llvm_pch_read(const unsigned char *Buffer, unsigned Size) {
-
   std::string ModuleName = TheModule->getModuleIdentifier();
-  if (TheModule)
+
+  // Don't delete the module if the debug info isn't done with it yet.
+  if (!TheDebugInfo || TheDebugInfo->getModule() != TheModule)
     delete TheModule;
 
   clearTargetBuiltinCache();

Modified: llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp?rev=52474&r1=52473&r2=52474&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp Wed Jun 18 18:55:07 2008
@@ -225,6 +225,10 @@
   SR.setModule(M);
 }
 
+DebugInfo::~DebugInfo() {
+  delete M;
+}
+
 /// getValueFor - Return a llvm representation for a given debug information
 /// descriptor.
 Value *DebugInfo::getValueFor(DebugInfoDesc *DD) {

Modified: llvm-gcc-4.2/trunk/gcc/llvm-debug.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-debug.h?rev=52474&r1=52473&r2=52474&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-debug.h (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-debug.h Wed Jun 18 18:55:07 2008
@@ -77,10 +77,12 @@
   
 public:
   DebugInfo(Module *m);
-  
+  ~DebugInfo();
+
   // Accessors.
   void setLocationFile(const char *FullPath) { CurFullPath = FullPath; }
   void setLocationLine(int LineNo)           { CurLineNo = LineNo; }
+  const Module *getModule() const            { return M; }
   
   /// getValueFor - Return a llvm representation for a given debug information
   /// descriptor.





More information about the llvm-commits mailing list