[cfe-commits] r57769 - in /cfe/trunk/lib/CodeGen: CGDebugInfo.cpp CGDebugInfo.h CGObjC.cpp CodeGenFunction.cpp CodeGenFunction.h
Daniel Dunbar
daniel at zuster.org
Sat Oct 18 11:22:23 PDT 2008
Author: ddunbar
Date: Sat Oct 18 13:22:23 2008
New Revision: 57769
URL: http://llvm.org/viewvc/llvm-project?rev=57769&view=rev
Log:
Debug info bug fix, function start wasn't getting generated correctly
for Obj-C methods.
Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h
cfe/trunk/lib/CodeGen/CGObjC.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=57769&r1=57768&r2=57769&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Sat Oct 18 13:22:23 2008
@@ -598,7 +598,8 @@
/// EmitFunctionStart - Constructs the debug code for entering a function -
/// "llvm.dbg.func.start.".
-void CGDebugInfo::EmitFunctionStart(const FunctionDecl *FnDecl,
+void CGDebugInfo::EmitFunctionStart(const char *Name,
+ QualType ReturnType,
llvm::Function *Fn,
llvm::IRBuilder<> &Builder)
{
@@ -611,8 +612,8 @@
}
// Get name information.
- Subprogram->setName(FnDecl->getName());
- Subprogram->setFullName(FnDecl->getName());
+ Subprogram->setName(Name);
+ Subprogram->setFullName(Name);
// Gather location information.
llvm::CompileUnitDesc *Unit = getOrCreateCompileUnit(CurLoc);
@@ -620,8 +621,7 @@
uint64_t Loc = SM.getLogicalLineNumber(CurLoc);
// Get Function Type.
- QualType type = FnDecl->getResultType();
- llvm::TypeDesc *SPTy = getOrCreateType(type, Unit);
+ llvm::TypeDesc *SPTy = getOrCreateType(ReturnType, Unit);
Subprogram->setAnchor(SubprogramAnchor);
Subprogram->setContext(Unit);
Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=57769&r1=57768&r2=57769&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Sat Oct 18 13:22:23 2008
@@ -110,9 +110,9 @@
void EmitStopPoint(llvm::Function *Fn, BuilderType &Builder);
/// EmitFunctionStart - Emit a call to llvm.dbg.function.start to indicate
- /// start of a new function
- void EmitFunctionStart(const FunctionDecl *FnDecl, llvm::Function *Fn,
- BuilderType &Builder);
+ /// start of a new function.
+ void EmitFunctionStart(const char *Name, QualType ReturnType,
+ llvm::Function *Fn, BuilderType &Builder);
/// EmitRegionStart - Emit a call to llvm.dbg.region.start to indicate start
/// of a new block.
Modified: cfe/trunk/lib/CodeGen/CGObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjC.cpp?rev=57769&r1=57768&r2=57769&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjC.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjC.cpp Sat Oct 18 13:22:23 2008
@@ -119,7 +119,7 @@
Args.push_back(std::make_pair(IPD, IPD->getType()));
}
- StartFunction(OMD, OMD->getResultType(), Fn, Args);
+ StartFunction(OMD, OMD->getResultType(), Fn, Args, OMD->getLocEnd());
}
/// Generate an Objective-C method. An Objective-C method is a C function with
@@ -127,13 +127,7 @@
void CodeGenFunction::GenerateObjCMethod(const ObjCMethodDecl *OMD) {
StartObjCMethod(OMD);
EmitStmt(OMD->getBody());
-
- const CompoundStmt *S = dyn_cast<CompoundStmt>(OMD->getBody());
- if (S) {
- FinishFunction(S->getRBracLoc());
- } else {
- FinishFunction();
- }
+ FinishFunction(cast<CompoundStmt>(OMD->getBody())->getRBracLoc());
}
// FIXME: I wasn't sure about the synthesis approach. If we end up
Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=57769&r1=57768&r2=57769&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Sat Oct 18 13:22:23 2008
@@ -98,7 +98,8 @@
void CodeGenFunction::StartFunction(const Decl *D, QualType RetTy,
llvm::Function *Fn,
- const FunctionArgList &Args) {
+ const FunctionArgList &Args,
+ SourceLocation StartLoc) {
CurFuncDecl = D;
FnRetTy = RetTy;
CurFn = Fn;
@@ -122,11 +123,14 @@
// Emit subprogram debug descriptor.
// FIXME: The cast here is a huge hack.
- if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
- if (CGDebugInfo *DI = CGM.getDebugInfo()) {
- if (CompoundStmt* body = dyn_cast<CompoundStmt>(FD->getBody()))
- DI->setLocation(body->getLBracLoc());
- DI->EmitFunctionStart(FD, CurFn, Builder);
+ if (CGDebugInfo *DI = CGM.getDebugInfo()) {
+ DI->setLocation(StartLoc);
+ if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
+ DI->EmitFunctionStart(FD->getName(), RetTy, CurFn, Builder);
+ } else {
+ // Just use LLVM function name.
+ DI->EmitFunctionStart(Fn->getName().c_str(),
+ RetTy, CurFn, Builder);
}
}
@@ -145,7 +149,8 @@
FProto->getArgType(i)));
}
- StartFunction(FD, FD->getResultType(), Fn, Args);
+ StartFunction(FD, FD->getResultType(), Fn, Args,
+ cast<CompoundStmt>(FD->getBody())->getLBracLoc());
EmitStmt(FD->getBody());
Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=57769&r1=57768&r2=57769&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Sat Oct 18 13:22:23 2008
@@ -184,7 +184,8 @@
llvm::Function *Fn);
void StartFunction(const Decl *D, QualType RetTy,
llvm::Function *Fn,
- const FunctionArgList &Args);
+ const FunctionArgList &Args,
+ SourceLocation StartLoc);
void FinishFunction(SourceLocation EndLoc=SourceLocation());
/// EmitFunctionProlog - Emit the target specific LLVM code to load
More information about the cfe-commits
mailing list