[cfe-commits] r75589 - in /cfe/trunk: lib/CodeGen/CGDebugInfo.cpp lib/CodeGen/CGDebugInfo.h lib/CodeGen/CodeGenModule.cpp test/CodeGenObjC/debug-info-linkagename.m test/CodeGenObjC/debug-info.m
Devang Patel
dpatel at apple.com
Mon Jul 13 19:47:58 PDT 2009
Author: dpatel
Date: Mon Jul 13 21:47:58 2009
New Revision: 75589
URL: http://llvm.org/viewvc/llvm-project?rev=75589&view=rev
Log:
Use LLVM mangler to get mangled name for debug info entry.
Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/test/CodeGenObjC/debug-info-linkagename.m
cfe/trunk/test/CodeGenObjC/debug-info.m
Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=75589&r1=75588&r2=75589&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Jul 13 21:47:58 2009
@@ -19,6 +19,7 @@
#include "clang/AST/RecordLayout.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/FileManager.h"
+#include "clang/Basic/TargetInfo.h"
#include "clang/Frontend/CompileOptions.h"
#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
@@ -33,12 +34,22 @@
using namespace clang;
using namespace clang::CodeGen;
-CGDebugInfo::CGDebugInfo(CodeGenModule *m)
+CGDebugInfo::CGDebugInfo(CodeGenModule *m, TargetInfo *t)
: M(m), isMainCompileUnitCreated(false), DebugFactory(M->getModule()),
BlockLiteralGenericSet(false) {
+ LLVMMangler = new llvm::Mangler(m->getModule(), t->getUserLabelPrefix(), ".");
+ // add chars used in ObjC method names so method names aren't mangled
+ LLVMMangler->markCharAcceptable('[');
+ LLVMMangler->markCharAcceptable(']');
+ LLVMMangler->markCharAcceptable('(');
+ LLVMMangler->markCharAcceptable(')');
+ LLVMMangler->markCharAcceptable('-');
+ LLVMMangler->markCharAcceptable('+');
+ LLVMMangler->markCharAcceptable(' ');
}
CGDebugInfo::~CGDebugInfo() {
+ delete LLVMMangler;
assert(RegionStack.empty() && "Region stack mismatch, stack not empty!");
}
@@ -820,8 +831,6 @@
void CGDebugInfo::EmitFunctionStart(const char *Name, QualType ReturnType,
llvm::Function *Fn,
CGBuilderTy &Builder) {
- const char *LinkageName = Name;
-
// Skip the asm prefix if it exists.
//
// FIXME: This should probably be the unmangled name?
@@ -834,7 +843,8 @@
unsigned LineNo = SM.getPresumedLoc(CurLoc).getLine();
llvm::DISubprogram SP =
- DebugFactory.CreateSubprogram(Unit, Name, Name, LinkageName, Unit, LineNo,
+ DebugFactory.CreateSubprogram(Unit, Name, Name, LLVMMangler->getValueName(Fn),
+ Unit, LineNo,
getOrCreateType(ReturnType, Unit),
Fn->hasInternalLinkage(), true/*definition*/);
@@ -969,7 +979,9 @@
ArrayType::Normal, 0);
}
- DebugFactory.CreateGlobalVariable(Unit, Name, Name, "", Unit, LineNo,
+ DebugFactory.CreateGlobalVariable(Unit, Name, Name,
+ LLVMMangler->getValueName(Var),
+ Unit, LineNo,
getOrCreateType(T, Unit),
Var->hasInternalLinkage(),
true/*definition*/, Var);
@@ -999,7 +1011,9 @@
ArrayType::Normal, 0);
}
- DebugFactory.CreateGlobalVariable(Unit, Name, Name, "", Unit, LineNo,
+ DebugFactory.CreateGlobalVariable(Unit, Name, Name,
+ LLVMMangler->getValueName(Var),
+ Unit, LineNo,
getOrCreateType(T, Unit),
Var->hasInternalLinkage(),
true/*definition*/, Var);
Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=75589&r1=75588&r2=75589&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Mon Jul 13 21:47:58 2009
@@ -16,6 +16,7 @@
#include "clang/AST/Type.h"
#include "clang/Basic/SourceLocation.h"
+#include "llvm/Support/Mangler.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/Analysis/DebugInfo.h"
#include <map>
@@ -25,6 +26,7 @@
namespace clang {
class VarDecl;
class ObjCInterfaceDecl;
+ class TargetInfo;
namespace CodeGen {
class CodeGenModule;
@@ -34,6 +36,7 @@
/// the backend.
class CGDebugInfo {
CodeGenModule *M;
+ llvm::Mangler *LLVMMangler;
bool isMainCompileUnitCreated;
llvm::DIFactory DebugFactory;
@@ -68,7 +71,7 @@
llvm::DIType CreateType(const ArrayType *Ty, llvm::DICompileUnit U);
public:
- CGDebugInfo(CodeGenModule *m);
+ CGDebugInfo(CodeGenModule *m, TargetInfo *t);
~CGDebugInfo();
/// setLocation - Update the current source location. If \arg loc is
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=75589&r1=75588&r2=75589&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Mon Jul 13 21:47:58 2009
@@ -52,7 +52,9 @@
Runtime = CreateMacObjCRuntime(*this);
// If debug info generation is enabled, create the CGDebugInfo object.
- DebugInfo = CompileOpts.DebugInfo ? new CGDebugInfo(this) : 0;
+ DebugInfo = 0;
+ if (CompileOpts.DebugInfo)
+ DebugInfo = new CGDebugInfo(this, &Context.Target);
}
CodeGenModule::~CodeGenModule() {
Modified: cfe/trunk/test/CodeGenObjC/debug-info-linkagename.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/debug-info-linkagename.m?rev=75589&r1=75588&r2=75589&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenObjC/debug-info-linkagename.m (original)
+++ cfe/trunk/test/CodeGenObjC/debug-info-linkagename.m Mon Jul 13 21:47:58 2009
@@ -1,7 +1,5 @@
// RUN: clang-cc -g -S -o %t %s
// RUN: not grep 001 %t
-// XFAIL
-
@interface F
-(int) bar;
Modified: cfe/trunk/test/CodeGenObjC/debug-info.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/debug-info.m?rev=75589&r1=75588&r2=75589&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenObjC/debug-info.m (original)
+++ cfe/trunk/test/CodeGenObjC/debug-info.m Mon Jul 13 21:47:58 2009
@@ -1,7 +1,7 @@
// RUN: clang-cc -triple i386-apple-darwin9 -g -emit-llvm -o %t %s &&
// RUN: grep '@.str3 = internal constant \[8 x i8\] c"-\[A m0\]\\00"' %t &&
-// RUN: grep '@.str4 = internal constant \[9 x i8\] c"\\01-\[A m0\]\\00"' %t &&
-// RUN: grep '@llvm.dbg.subprogram = .* @.str3, .* @.str3, .* @.str4,' %t &&
+// RUN: grep '@.str4 = internal constant \[2 x i8\] c"A\\00"' %t &&
+// RUN: grep '@llvm.dbg.subprogram = .* @.str3, .* @.str3, .* @.str3,' %t &&
// RUN: grep '@llvm.dbg.composite.* = .* i32 15, i64 0, i64 8, .* i32 16' %t &&
// RUN: true
More information about the cfe-commits
mailing list