[llvm-commits] [llvm-gcc-4.2] r44448 - in /llvm-gcc-4.2/trunk/gcc: llvm-backend.cpp llvm-debug.cpp llvm-debug.h testsuite/gcc.dg/pch/dwarf-1.c testsuite/gcc.dg/pch/dwarf-1.hs
Devang Patel
dpatel at apple.com
Thu Nov 29 17:05:59 PST 2007
Author: dpatel
Date: Thu Nov 29 19:05:58 2007
New Revision: 44448
URL: http://llvm.org/viewvc/llvm-project?rev=44448&view=rev
Log:
Restore debug info after reading PCH.
Added:
llvm-gcc-4.2/trunk/gcc/testsuite/gcc.dg/pch/dwarf-1.c
llvm-gcc-4.2/trunk/gcc/testsuite/gcc.dg/pch/dwarf-1.hs
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=44448&r1=44447&r2=44448&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Thu Nov 29 19:05:58 2007
@@ -243,6 +243,9 @@
readLLVMTypesStringTable();
readLLVMValues();
+ if (TheDebugInfo)
+ TheDebugInfo->readLLVMDebugInfo();
+
flag_llvm_pch_read = 1;
}
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=44448&r1=44447&r2=44448&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp Thu Nov 29 19:05:58 2007
@@ -878,6 +878,36 @@
return Unit;
}
+/// readLLVMDebugInfo - Read debug info from PCH file. TheModule already
+/// represents module read from PCH file. Restore AnchorDesc from PCH file.
+void DebugInfo::readLLVMDebugInfo() {
+ MachineModuleInfo MMI;
+ MMI.AnalyzeModule(*TheModule);
+ std::vector<SubprogramDesc *> Subprograms =
+ MMI.getAnchoredDescriptors<SubprogramDesc>(*TheModule);
+
+ if (!Subprograms.empty())
+ SubprogramAnchor = Subprograms[0]->getAnchor();
+
+ std::vector<CompileUnitDesc *> CUs =
+ MMI.getAnchoredDescriptors<CompileUnitDesc>(*TheModule);
+
+ if (!CUs.empty())
+ CompileUnitAnchor = CUs[0]->getAnchor();
+
+ std::vector<GlobalVariableDesc *> GVs =
+ MMI.getAnchoredDescriptors<GlobalVariableDesc>(*TheModule);
+
+ if (!GVs.empty())
+ GlobalVariableAnchor = GVs[0]->getAnchor();
+
+ const std::map<GlobalVariable *, DebugInfoDesc *> &GlobalDescs
+ = MMI.getDIDeserializer()->getGlobalDescs();
+ for (std::map<GlobalVariable *, DebugInfoDesc *>::const_iterator
+ I = GlobalDescs.begin(), E = GlobalDescs.end(); I != E; ++I)
+ SR.addDescriptor(I->second, I->first);
+}
+
/* LLVM LOCAL end (ENTIRE FILE!) */
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=44448&r1=44447&r2=44448&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-debug.h (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-debug.h Thu Nov 29 19:05:58 2007
@@ -123,7 +123,9 @@
/// getOrCreateCompileUnit - Get the compile unit from the cache or create a
/// new one if necessary.
CompileUnitDesc *getOrCreateCompileUnit(const std::string &FullPath);
-
+
+ /// readLLVMDebugInfo - Read debug info from PCH file.
+ void readLLVMDebugInfo();
};
} // end namespace llvm
Added: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.dg/pch/dwarf-1.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.dg/pch/dwarf-1.c?rev=44448&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.dg/pch/dwarf-1.c (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.dg/pch/dwarf-1.c Thu Nov 29 19:05:58 2007
@@ -0,0 +1,6 @@
+#include "dwarf-1.h"
+
+int main() {
+ foo();
+ return 0;
+}
Added: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.dg/pch/dwarf-1.hs
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.dg/pch/dwarf-1.hs?rev=44448&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.dg/pch/dwarf-1.hs (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.dg/pch/dwarf-1.hs Thu Nov 29 19:05:58 2007
@@ -0,0 +1,3 @@
+int foo() {
+ return 42;
+}
More information about the llvm-commits
mailing list