Pull r62889 into Dib:
Set DW_AT_APPLE_optimized and DW_AT_APPLE_flags attribute while building
DICompileUnit.
Right now, llvm-gcc does not emit debug info when optimization is ON. However,
emit llvm.dbg.compile_unit and preserve it even when optimization is ON. This
allows DW_AT_APPLE_flags to find its way in final binary.
llvm-svn: 62890
diff --git a/llvm-gcc-4.2/gcc/llvm-backend.cpp b/llvm-gcc-4.2/gcc/llvm-backend.cpp
index a2ead60..f920d6e 100644
--- a/llvm-gcc-4.2/gcc/llvm-backend.cpp
+++ b/llvm-gcc-4.2/gcc/llvm-backend.cpp
@@ -592,6 +592,13 @@
writeLLVMValues();
}
+ if (!flag_pch_file
+ && optimize && debug_info_level > DINFO_LEVEL_NONE && !TheDebugInfo) {
+ DebugInfo DI(TheModule);
+ DICompileUnit CU = DI.createCompileUnit(main_input_filename);
+ AttributeUsedGlobals.insert(CU.getGV());
+ }
+
// Add an llvm.global_ctors global if needed.
if (!StaticCtors.empty())
CreateStructorsList(StaticCtors, "llvm.global_ctors");
diff --git a/llvm-gcc-4.2/gcc/llvm-debug.cpp b/llvm-gcc-4.2/gcc/llvm-debug.cpp
index 2764b65..8ccc298 100644
--- a/llvm-gcc-4.2/gcc/llvm-debug.cpp
+++ b/llvm-gcc-4.2/gcc/llvm-debug.cpp
@@ -813,8 +813,15 @@
else
LangTag = DW_LANG_C89;
+ const char *Flags = "";
+ // Do this only when RC_DEBUG_OPTIONS environment variable is set to
+ // a nonempty string. This is intended only for internal Apple use.
+ char * debugopt = getenv("RC_DEBUG_OPTIONS");
+ if (debugopt && debugopt[0])
+ Flags = get_arguments();
+
return DebugFactory.CreateCompileUnit(LangTag, FileName, Directory,
- version_string);
+ version_string, optimize, Flags);
}
/* LLVM LOCAL end (ENTIRE FILE!) */