[cfe-commits] r64445 - in /cfe/trunk: lib/CodeGen/CGDecl.cpp lib/CodeGen/CGStmt.cpp lib/CodeGen/CodeGenFunction.cpp lib/CodeGen/CodeGenFunction.h lib/Sema/SemaDeclAttr.cpp test/CodeGen/attr-nodebug.c

Anders Carlsson andersca at mac.com
Fri Feb 13 00:11:52 PST 2009


Author: andersca
Date: Fri Feb 13 02:11:52 2009
New Revision: 64445

URL: http://llvm.org/viewvc/llvm-project?rev=64445&view=rev
Log:
Add CodeGen support for the nodebug attribute.

Added:
    cfe/trunk/test/CodeGen/attr-nodebug.c
Modified:
    cfe/trunk/lib/CodeGen/CGDecl.cpp
    cfe/trunk/lib/CodeGen/CGStmt.cpp
    cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
    cfe/trunk/lib/CodeGen/CodeGenFunction.h
    cfe/trunk/lib/Sema/SemaDeclAttr.cpp

Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=64445&r1=64444&r2=64445&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Fri Feb 13 02:11:52 2009
@@ -144,7 +144,7 @@
   DMEntry = llvm::ConstantExpr::getBitCast(GV, LPtrTy);
 
   // Emit global variable debug descriptor for static vars.
-  CGDebugInfo *DI = CGM.getDebugInfo();
+  CGDebugInfo *DI = getDebugInfo();
   if(DI) {
     DI->setLocation(D.getLocation());
     DI->EmitGlobalVariable(static_cast<llvm::GlobalVariable *>(GV), &D);
@@ -224,7 +224,7 @@
   DMEntry = DeclPtr;
 
   // Emit debug info for local var declaration.
-  if (CGDebugInfo *DI = CGM.getDebugInfo()) {
+  if (CGDebugInfo *DI = getDebugInfo()) {
     DI->setLocation(D.getLocation());
     DI->EmitDeclareOfAutoVariable(&D, DeclPtr, Builder);
   }
@@ -299,7 +299,7 @@
   DMEntry = DeclPtr;
 
   // Emit debug info for param declaration.
-  if (CGDebugInfo *DI = CGM.getDebugInfo()) {
+  if (CGDebugInfo *DI = getDebugInfo()) {
     DI->setLocation(D.getLocation());
     DI->EmitDeclareOfArgVariable(&D, DeclPtr, Builder);
   }

Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=64445&r1=64444&r2=64445&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGStmt.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmt.cpp Fri Feb 13 02:11:52 2009
@@ -28,7 +28,7 @@
 //===----------------------------------------------------------------------===//
 
 void CodeGenFunction::EmitStopPoint(const Stmt *S) {
-  if (CGDebugInfo *DI = CGM.getDebugInfo()) {
+  if (CGDebugInfo *DI = getDebugInfo()) {
     DI->setLocation(S->getLocStart());
     DI->EmitStopPoint(CurFn, Builder);
   }
@@ -124,7 +124,7 @@
 RValue CodeGenFunction::EmitCompoundStmt(const CompoundStmt &S, bool GetLast,
                                          llvm::Value *AggLoc, bool isAggVol) {
 
-  CGDebugInfo *DI = CGM.getDebugInfo();
+  CGDebugInfo *DI = getDebugInfo();
   if (DI) {
     EnsureInsertPoint();
     DI->setLocation(S.getLBracLoc());

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=64445&r1=64444&r2=64445&view=diff

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

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=64445&r1=64444&r2=64445&view=diff

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

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=64445&r1=64444&r2=64445&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Fri Feb 13 02:11:52 2009
@@ -1310,8 +1310,8 @@
     S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 0;
     return;
   }
-  FunctionDecl *Fn = dyn_cast<FunctionDecl>(d);
-  if (!Fn) {
+
+  if (!isa<FunctionDecl>(d)) {
     S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type)
       << "nodebug" << "function";
     return;

Added: cfe/trunk/test/CodeGen/attr-nodebug.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/attr-nodebug.c?rev=64445&view=auto

==============================================================================
--- cfe/trunk/test/CodeGen/attr-nodebug.c (added)
+++ cfe/trunk/test/CodeGen/attr-nodebug.c Fri Feb 13 02:11:52 2009
@@ -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++;
+}
+





More information about the cfe-commits mailing list