[llvm-commits] [llvm-gcc-4.2] r104048 - in /llvm-gcc-4.2/trunk/gcc: llvm-backend.cpp llvm-debug.cpp llvm-debug.h testsuite/gcc.dg/pch/valid-1.c
Devang Patel
dpatel at apple.com
Tue May 18 12:35:46 PDT 2010
Author: dpatel
Date: Tue May 18 14:35:46 2010
New Revision: 104048
URL: http://llvm.org/viewvc/llvm-project?rev=104048&view=rev
Log:
Update debug info read from PCH file to match current source file info.
This fixes many failures in llvmgcc's pch test suite.
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
llvm-gcc-4.2/trunk/gcc/testsuite/gcc.dg/pch/valid-1.c
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=104048&r1=104047&r2=104048&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Tue May 18 14:35:46 2010
@@ -265,6 +265,17 @@
// Now, llvm.pch.values is not required so remove it from the symbol table.
GV->eraseFromParent();
+
+ if (TheDebugInfo) {
+ // Replace compile unit received from the PCH file.
+ NamedMDNode *NMD = TheModule->getOrInsertNamedMetadata("llvm.dbg.pch.cu");
+ if (NMD->getNumOperands() == 1) {
+ MDNode *HeaderCUNode = NMD->getOperand(0);
+ Value *CUNode = TheDebugInfo->getCU();
+ HeaderCUNode->replaceAllUsesWith(CUNode);
+ }
+ TheDebugInfo->replaceBasicTypesFromPCH();
+ }
}
/// writeLLVMValues - GCC tree's uses LLVMValues vector's index to reach LLVM
@@ -295,6 +306,11 @@
GlobalValue::ExternalLinkage,
LLVMValuesTable,
"llvm.pch.values");
+
+ if (TheDebugInfo && TheDebugInfo->getCU().Verify()) {
+ NamedMDNode *NMD = TheModule->getOrInsertNamedMetadata("llvm.dbg.pch.cu");
+ NMD->addOperand(TheDebugInfo->getCU());
+ }
}
/// eraseLocalLLVMValues - drop all non-global values from the LLVM values map.
@@ -513,9 +529,7 @@
else
RegisterRegAlloc::setDefault(createLocalRegisterAllocator);
- // FIXME - Do not disable debug info while writing pch.
- if (!flag_pch_file &&
- debug_info_level > DINFO_LEVEL_NONE)
+ if (debug_info_level > DINFO_LEVEL_NONE)
TheDebugInfo = new DebugInfo(TheModule);
}
@@ -560,8 +574,7 @@
TheModule = ParseBitcodeFile(MB, getGlobalContext(), &ErrMsg);
delete MB;
- // FIXME - Do not disable debug info while writing pch.
- if (!flag_pch_file && debug_info_level > DINFO_LEVEL_NONE) {
+ if (debug_info_level > DINFO_LEVEL_NONE) {
TheDebugInfo = new DebugInfo(TheModule);
TheDebugInfo->Initialize();
}
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=104048&r1=104047&r2=104048&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp Tue May 18 14:35:46 2010
@@ -41,6 +41,7 @@
extern "C" {
#include "langhooks.h"
#include "toplev.h"
+#include "flags.h"
#include "tree.h"
#include "version.h"
#include "function.h"
@@ -540,7 +541,12 @@
if (DECL_CONTEXT (decl))
if (TREE_CODE (DECL_CONTEXT (decl)) != FUNCTION_DECL)
LinkageName = GV->getName();
- DebugFactory.CreateGlobalVariable(findRegion(DECL_CONTEXT(decl)),
+ DIDescriptor Context;
+ if (DECL_CONTEXT(decl))
+ Context = findRegion(DECL_CONTEXT(decl));
+ else
+ Context = getOrCreateFile(Loc.file);
+ DebugFactory.CreateGlobalVariable(Context,
DispName, DispName, LinkageName,
getOrCreateFile(Loc.file), Loc.line,
TyD, GV->hasInternalLinkage(),
@@ -588,12 +594,37 @@
}
}
- return
+ DIBasicType BTy =
DebugFactory.CreateBasicType(getOrCreateFile(main_input_filename),
TypeName,
getOrCreateFile(main_input_filename),
0, Size, Align,
0, 0, Encoding);
+
+ if (TheDebugInfo && flag_pch_file) {
+ NamedMDNode *NMD = TheModule->getOrInsertNamedMetadata("llvm.dbg.pch.bt");
+ NMD->addOperand(BTy);
+ }
+
+ return BTy;
+}
+
+/// replaceBasicTypesFromPCH - Replace basic type debug info received
+/// from PCH file.
+void DebugInfo::replaceBasicTypesFromPCH() {
+ NamedMDNode *NMD = TheModule->getOrInsertNamedMetadata("llvm.dbg.pch.bt");
+ for (int i = 0, e = NMD->getNumOperands(); i != e; ++i) {
+ DIBasicType HeaderBTy(NMD->getOperand(i));
+ MDNode *NewBTy = NULL;
+ NewBTy = DebugFactory.CreateBasicType(getOrCreateFile(main_input_filename),
+ HeaderBTy.getName(),
+ getOrCreateFile(main_input_filename),
+ 0, HeaderBTy.getSizeInBits(),
+ HeaderBTy.getAlignInBits(),
+ 0, 0, HeaderBTy.getEncoding());
+ MDNode *HBTyNode = HeaderBTy;
+ HBTyNode->replaceAllUsesWith(NewBTy);
+ }
}
/// isArtificialArgumentType - Return true if arg_type represents artificial,
@@ -1063,8 +1094,13 @@
return DIType(cast<MDNode>(M));
if (TREE_CODE(TyDef) == TYPE_DECL && DECL_ORIGINAL_TYPE(TyDef)) {
expanded_location TypeDefLoc = GetNodeLocation(TyDef);
+ DIDescriptor Context;
+ if (DECL_CONTEXT(TyDef))
+ Context = findRegion(DECL_CONTEXT(TyDef));
+ else
+ Context = getOrCreateFile(TypeDefLoc.file);
Ty = DebugFactory.CreateDerivedType(DW_TAG_typedef,
- findRegion(DECL_CONTEXT(TyDef)),
+ Context,
GetNodeName(TyDef),
getOrCreateFile(TypeDefLoc.file),
TypeDefLoc.line,
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=104048&r1=104047&r2=104048&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-debug.h (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-debug.h Tue May 18 14:35:46 2010
@@ -181,6 +181,13 @@
/// name is constructred on demand (e.g. C++ destructor) then the name
/// is stored on the side.
StringRef getFunctionName(tree_node *FnDecl);
+
+ /// getCU - Get Compile Unit.
+ DICompileUnit getCU() { return TheCU;}
+
+ /// replaceBasicTypesFromPCH - Replace basic type debug info received
+ /// from PCH file.
+ void replaceBasicTypesFromPCH();
};
} // end namespace llvm
Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.dg/pch/valid-1.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.dg/pch/valid-1.c?rev=104048&r1=104047&r2=104048&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.dg/pch/valid-1.c (original)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.dg/pch/valid-1.c Tue May 18 14:35:46 2010
@@ -1,5 +1,6 @@
/* { dg-options "-I. -Winvalid-pch -g" } */
-#include "valid-1.h"/* { dg-error "created with -gnone, but used with -g|No such file|they were invalid" } */
+/* LLVM LOCAL - Ignore -g mismatch. */
+#include "valid-1.h"
int x;
More information about the llvm-commits
mailing list