]> granicus.if.org Git - clang/commitdiff
Do not emit debug information for variables while generating optimized code. The...
authorDevang Patel <dpatel@apple.com>
Fri, 27 Mar 2009 23:16:32 +0000 (23:16 +0000)
committerDevang Patel <dpatel@apple.com>
Fri, 27 Mar 2009 23:16:32 +0000 (23:16 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67876 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGDebugInfo.cpp
lib/CodeGen/CodeGenModule.h

index b437f3dfbd61f04b0da1e6df14e3249ab3730f22..7233bbf8e2364fb90e09f2c544326b513c11b908 100644 (file)
@@ -19,6 +19,7 @@
 #include "clang/AST/RecordLayout.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/FileManager.h"
+#include "clang/Frontend/CompileOptions.h"
 #include "llvm/Constants.h"
 #include "llvm/DerivedTypes.h"
 #include "llvm/Instructions.h"
@@ -665,6 +666,13 @@ void CGDebugInfo::EmitDeclare(const VarDecl *Decl, unsigned Tag,
                               llvm::Value *Storage, CGBuilderTy &Builder) {
   assert(!RegionStack.empty() && "Region stack mismatch, stack empty!");
 
+  // Do not emit variable debug information while generating optimized code.
+  // The llvm optimizer and code generator are not yet ready to support
+  // optimized code debugging.
+  const CompileOptions &CO = M->getCompileOpts();
+  if (CO.OptimizationLevel)
+    return;
+
   // Get location information.
   SourceManager &SM = M->getContext().getSourceManager();
   unsigned Line = SM.getInstantiationLineNumber(Decl->getLocation());
@@ -697,6 +705,14 @@ void CGDebugInfo::EmitDeclareOfArgVariable(const VarDecl *Decl, llvm::Value *AI,
 /// EmitGlobalVariable - Emit information about a global variable.
 void CGDebugInfo::EmitGlobalVariable(llvm::GlobalVariable *Var, 
                                      const VarDecl *Decl) {
+
+  // Do not emit variable debug information while generating optimized code.
+  // The llvm optimizer and code generator are not yet ready to support
+  // optimized code debugging.
+  const CompileOptions &CO = M->getCompileOpts();
+  if (CO.OptimizationLevel)
+    return;
+
   // Create global variable debug descriptor.
   llvm::DICompileUnit Unit = getOrCreateCompileUnit(Decl->getLocation());
   SourceManager &SM = M->getContext().getSourceManager();
index 228020ca79cb6395bbfc73b101298a0e6b0a5ab2..dbfbf028af0983cbf2e96977df3a0386cb98f706 100644 (file)
@@ -159,6 +159,7 @@ public:
 
   CGDebugInfo *getDebugInfo() { return DebugInfo; }
   ASTContext &getContext() const { return Context; }
+  const CompileOptions &getCompileOpts() const { return CompileOpts; }
   const LangOptions &getLangOptions() const { return Features; }
   llvm::Module &getModule() const { return TheModule; }
   CodeGenTypes &getTypes() { return Types; }