[cfe-commits] r110694 - in /cfe/trunk/lib/CodeGen: CGDebugInfo.cpp CGDebugInfo.h CGExprScalar.cpp CodeGenFunction.cpp CodeGenFunction.h

Devang Patel dpatel at apple.com
Tue Aug 10 10:53:33 PDT 2010


Author: dpatel
Date: Tue Aug 10 12:53:33 2010
New Revision: 110694

URL: http://llvm.org/viewvc/llvm-project?rev=110694&view=rev
Log:
Simplify code and add comments, in code that generate debug info for constant integer globals, based on Chris's feedback.


Modified:
    cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
    cfe/trunk/lib/CodeGen/CGDebugInfo.h
    cfe/trunk/lib/CodeGen/CGExprScalar.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=110694&r1=110693&r2=110694&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Tue Aug 10 12:53:33 2010
@@ -1801,7 +1801,9 @@
                                     true/*definition*/, Var);
 }
 
-void CGDebugInfo::EmitGlobalVariable(llvm::Constant *C, const ValueDecl *VD,
+/// EmitGlobalVariable - Emit global variable's debug info.
+void CGDebugInfo::EmitGlobalVariable(const ValueDecl *VD, 
+                                     llvm::ConstantInt *Init,
                                      CGBuilderTy &Builder) {
   // Create the descriptor for the variable.
   llvm::DIFile Unit = getOrCreateFile(VD->getLocation());
@@ -1809,7 +1811,7 @@
   DebugFactory.CreateGlobalVariable(Unit, Name, Name, Name, Unit,
                                     getLineNumber(VD->getLocation()),
                                     getOrCreateType(VD->getType(), Unit),
-                                    true, true, C);
+                                    true, true, Init);
 }
 
 /// getOrCreateNamesSpace - Return namespace descriptor for the given

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=110694&r1=110693&r2=110694&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Tue Aug 10 12:53:33 2010
@@ -181,8 +181,8 @@
   /// EmitGlobalVariable - Emit information about an objective-c interface.
   void EmitGlobalVariable(llvm::GlobalVariable *GV, ObjCInterfaceDecl *Decl);
 
-  /// EmitGlobalVariable - Emit information about a constant.
-  void EmitGlobalVariable(llvm::Constant *C, const ValueDecl *VD, 
+  /// EmitGlobalVariable - Emit global variable's debug info.
+  void EmitGlobalVariable(const ValueDecl *VD, llvm::ConstantInt *Init, 
                           CGBuilderTy &Builder);
 
 private:

Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=110694&r1=110693&r2=110694&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Tue Aug 10 12:53:33 2010
@@ -149,8 +149,10 @@
     Expr::EvalResult Result;
     if (E->Evaluate(Result, CGF.getContext()) && Result.Val.isInt()) {
       assert(!Result.HasSideEffects && "Constant declref with side-effect?!");
-      CGF.EmitDeclRefExprDbgValue(E, Result.Val);
-      return llvm::ConstantInt::get(VMContext, Result.Val.getInt());
+      llvm::ConstantInt *CI 
+        = llvm::ConstantInt::get(VMContext, Result.Val.getInt());
+      CGF.EmitDeclRefExprDbgValue(E, CI);
+      return CI;
     }
     return EmitLoadOfLValue(E);
   }

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=110694&r1=110693&r2=110694&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Tue Aug 10 12:53:33 2010
@@ -1286,15 +1286,8 @@
 }
 
 void CodeGenFunction::EmitDeclRefExprDbgValue(const DeclRefExpr *E, 
-                                              const APValue &AV) {
-  CGDebugInfo *Dbg = getDebugInfo();
-  if (!Dbg) return;
-
-  llvm::Constant *C = NULL;
-  if (AV.isInt())
-    C = llvm::ConstantInt::get(getLLVMContext(), AV.getInt());
-  else if (AV.isFloat())
-    C = llvm::ConstantFP::get(getLLVMContext(), AV.getFloat());
-  if (C)
-    Dbg->EmitGlobalVariable(C, E->getDecl(), Builder);
+                                              llvm::ConstantInt *Init) {
+  assert (Init && "Invalid DeclRefExpr initializer!");
+  if (CGDebugInfo *Dbg = getDebugInfo())
+    Dbg->EmitGlobalVariable(E->getDecl(), Init, Builder);
 }

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=110694&r1=110693&r2=110694&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Tue Aug 10 12:53:33 2010
@@ -1373,7 +1373,7 @@
   LValue EmitStmtExprLValue(const StmtExpr *E);
   LValue EmitPointerToDataMemberBinaryExpr(const BinaryOperator *E);
   LValue EmitObjCSelectorLValue(const ObjCSelectorExpr *E);
-  void   EmitDeclRefExprDbgValue(const DeclRefExpr *E, const APValue &AV);
+  void   EmitDeclRefExprDbgValue(const DeclRefExpr *E, llvm::ConstantInt *Init);
   //===--------------------------------------------------------------------===//
   //                         Scalar Expression Emission
   //===--------------------------------------------------------------------===//





More information about the cfe-commits mailing list