Add CodeGen support for the nodebug attribute.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64445 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Anders Carlsson 2009-02-13 08:11:52 +00:00
Родитель d87df37e0a
Коммит e896d98548
6 изменённых файлов: 31 добавлений и 11 удалений

Просмотреть файл

@ -144,7 +144,7 @@ void CodeGenFunction::EmitStaticBlockVarDecl(const VarDecl &D) {
DMEntry = llvm::ConstantExpr::getBitCast(GV, LPtrTy); DMEntry = llvm::ConstantExpr::getBitCast(GV, LPtrTy);
// Emit global variable debug descriptor for static vars. // Emit global variable debug descriptor for static vars.
CGDebugInfo *DI = CGM.getDebugInfo(); CGDebugInfo *DI = getDebugInfo();
if(DI) { if(DI) {
DI->setLocation(D.getLocation()); DI->setLocation(D.getLocation());
DI->EmitGlobalVariable(static_cast<llvm::GlobalVariable *>(GV), &D); DI->EmitGlobalVariable(static_cast<llvm::GlobalVariable *>(GV), &D);
@ -224,7 +224,7 @@ void CodeGenFunction::EmitLocalBlockVarDecl(const VarDecl &D) {
DMEntry = DeclPtr; DMEntry = DeclPtr;
// Emit debug info for local var declaration. // Emit debug info for local var declaration.
if (CGDebugInfo *DI = CGM.getDebugInfo()) { if (CGDebugInfo *DI = getDebugInfo()) {
DI->setLocation(D.getLocation()); DI->setLocation(D.getLocation());
DI->EmitDeclareOfAutoVariable(&D, DeclPtr, Builder); DI->EmitDeclareOfAutoVariable(&D, DeclPtr, Builder);
} }
@ -299,7 +299,7 @@ void CodeGenFunction::EmitParmDecl(const VarDecl &D, llvm::Value *Arg) {
DMEntry = DeclPtr; DMEntry = DeclPtr;
// Emit debug info for param declaration. // Emit debug info for param declaration.
if (CGDebugInfo *DI = CGM.getDebugInfo()) { if (CGDebugInfo *DI = getDebugInfo()) {
DI->setLocation(D.getLocation()); DI->setLocation(D.getLocation());
DI->EmitDeclareOfArgVariable(&D, DeclPtr, Builder); DI->EmitDeclareOfArgVariable(&D, DeclPtr, Builder);
} }

Просмотреть файл

@ -28,7 +28,7 @@ using namespace CodeGen;
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
void CodeGenFunction::EmitStopPoint(const Stmt *S) { void CodeGenFunction::EmitStopPoint(const Stmt *S) {
if (CGDebugInfo *DI = CGM.getDebugInfo()) { if (CGDebugInfo *DI = getDebugInfo()) {
DI->setLocation(S->getLocStart()); DI->setLocation(S->getLocStart());
DI->EmitStopPoint(CurFn, Builder); DI->EmitStopPoint(CurFn, Builder);
} }
@ -124,7 +124,7 @@ bool CodeGenFunction::EmitSimpleStmt(const Stmt *S) {
RValue CodeGenFunction::EmitCompoundStmt(const CompoundStmt &S, bool GetLast, RValue CodeGenFunction::EmitCompoundStmt(const CompoundStmt &S, bool GetLast,
llvm::Value *AggLoc, bool isAggVol) { llvm::Value *AggLoc, bool isAggVol) {
CGDebugInfo *DI = CGM.getDebugInfo(); CGDebugInfo *DI = getDebugInfo();
if (DI) { if (DI) {
EnsureInsertPoint(); EnsureInsertPoint();
DI->setLocation(S.getLBracLoc()); DI->setLocation(S.getLBracLoc());

Просмотреть файл

@ -23,8 +23,8 @@ using namespace clang;
using namespace CodeGen; using namespace CodeGen;
CodeGenFunction::CodeGenFunction(CodeGenModule &cgm) CodeGenFunction::CodeGenFunction(CodeGenModule &cgm)
: CGM(cgm), Target(CGM.getContext().Target), SwitchInsn(NULL), : CGM(cgm), Target(CGM.getContext().Target), DebugInfo(0), SwitchInsn(0),
CaseRangeBlock(NULL) { CaseRangeBlock(0) {
LLVMIntTy = ConvertType(getContext().IntTy); LLVMIntTy = ConvertType(getContext().IntTy);
LLVMPointerWidth = Target.getPointerWidth(0); LLVMPointerWidth = Target.getPointerWidth(0);
} }
@ -128,7 +128,7 @@ void CodeGenFunction::FinishFunction(SourceLocation EndLoc) {
EmitReturnBlock(); EmitReturnBlock();
// Emit debug descriptor for function end. // Emit debug descriptor for function end.
if (CGDebugInfo *DI = CGM.getDebugInfo()) { if (CGDebugInfo *DI = getDebugInfo()) {
DI->setLocation(EndLoc); DI->setLocation(EndLoc);
DI->EmitRegionEnd(CurFn, Builder); DI->EmitRegionEnd(CurFn, Builder);
} }
@ -168,7 +168,7 @@ void CodeGenFunction::StartFunction(const Decl *D, QualType RetTy,
// Emit subprogram debug descriptor. // Emit subprogram debug descriptor.
// FIXME: The cast here is a huge hack. // FIXME: The cast here is a huge hack.
if (CGDebugInfo *DI = CGM.getDebugInfo()) { if (CGDebugInfo *DI = getDebugInfo()) {
DI->setLocation(StartLoc); DI->setLocation(StartLoc);
if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) { if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
DI->EmitFunctionStart(CGM.getMangledName(FD)->getName(), DI->EmitFunctionStart(CGM.getMangledName(FD)->getName(),
@ -197,6 +197,10 @@ void CodeGenFunction::StartFunction(const Decl *D, QualType RetTy,
void CodeGenFunction::GenerateCode(const FunctionDecl *FD, void CodeGenFunction::GenerateCode(const FunctionDecl *FD,
llvm::Function *Fn) { llvm::Function *Fn) {
// Check if we should generate debug info for this function.
if (CGM.getDebugInfo() && !FD->getAttr<NodebugAttr>())
DebugInfo = CGM.getDebugInfo();
FunctionArgList Args; FunctionArgList Args;
if (FD->getNumParams()) { if (FD->getNumParams()) {
const FunctionTypeProto* FProto = FD->getType()->getAsFunctionTypeProto(); const FunctionTypeProto* FProto = FD->getType()->getAsFunctionTypeProto();

Просмотреть файл

@ -55,6 +55,7 @@ namespace clang {
namespace CodeGen { namespace CodeGen {
class CodeGenModule; class CodeGenModule;
class CodeGenTypes; class CodeGenTypes;
class CGDebugInfo;
class CGFunctionInfo; class CGFunctionInfo;
class CGRecordLayout; class CGRecordLayout;
@ -151,6 +152,8 @@ public:
void EmitBranchThroughCleanup(llvm::BasicBlock *Dest); void EmitBranchThroughCleanup(llvm::BasicBlock *Dest);
private: private:
CGDebugInfo* DebugInfo;
/// LabelIDs - Track arbitrary ids assigned to labels for use in implementing /// LabelIDs - Track arbitrary ids assigned to labels for use in implementing
/// the GCC address-of-label extension and indirect goto. IDs are assigned to /// the GCC address-of-label extension and indirect goto. IDs are assigned to
/// labels inside getIDForAddrOfLabel(). /// labels inside getIDForAddrOfLabel().
@ -228,6 +231,7 @@ public:
CodeGenFunction(CodeGenModule &cgm); CodeGenFunction(CodeGenModule &cgm);
ASTContext &getContext() const; ASTContext &getContext() const;
CGDebugInfo *getDebugInfo() { return DebugInfo; }
void GenerateObjCMethod(const ObjCMethodDecl *OMD); void GenerateObjCMethod(const ObjCMethodDecl *OMD);

Просмотреть файл

@ -1310,8 +1310,8 @@ static void HandleNodebugAttr(Decl *d, const AttributeList &Attr, Sema &S) {
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 0; S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 0;
return; return;
} }
FunctionDecl *Fn = dyn_cast<FunctionDecl>(d);
if (!Fn) { if (!isa<FunctionDecl>(d)) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type) S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type)
<< "nodebug" << "function"; << "nodebug" << "function";
return; return;

Просмотреть файл

@ -0,0 +1,12 @@
// RUN: clang -g -emit-llvm -o %t %s &&
// RUN: not grep 'call void @llvm.dbg.func.start' %t
void t1() __attribute__((nodebug));
void t1()
{
int a = 10;
a++;
}