[llvm-commits] CVS: llvm-gcc/gcc/llvm-expand.c llvm-out.h llvm-representation.c llvm-representation.h toplev.c
Jim Laskey
jlaskey at apple.com
Fri Dec 16 14:17:44 PST 2005
Changes in directory llvm-gcc/gcc:
llvm-expand.c updated: 1.121 -> 1.122
llvm-out.h updated: 1.6 -> 1.7
llvm-representation.c updated: 1.22 -> 1.23
llvm-representation.h updated: 1.21 -> 1.22
toplev.c updated: 1.6 -> 1.7
---
Log message:
http://llvm.cs.uiuc.edu/bugs/show_bug.cgi?id=676
Fixes a bug where all debug information showed the main compile unit and not
includes.
---
Diffs of the changes: (+112 -76)
llvm-expand.c | 136 +++++++++++++++++++++++++++++---------------------
llvm-out.h | 4 -
llvm-representation.c | 23 ++++++++
llvm-representation.h | 10 +++
toplev.c | 15 -----
5 files changed, 112 insertions(+), 76 deletions(-)
Index: llvm-gcc/gcc/llvm-expand.c
diff -u llvm-gcc/gcc/llvm-expand.c:1.121 llvm-gcc/gcc/llvm-expand.c:1.122
--- llvm-gcc/gcc/llvm-expand.c:1.121 Wed Dec 7 13:35:10 2005
+++ llvm-gcc/gcc/llvm-expand.c Fri Dec 16 16:17:32 2005
@@ -7834,7 +7834,6 @@
static llvm_type *emptyStructTy;
static llvm_type *ptrToEmptyStructTy;
-static llvm_global *dbCompileUnitGlobal;
static llvm_global *dbTranslationUnitsGlobal;
static llvm_global *dbGlobalsGlobal;
@@ -7881,62 +7880,85 @@
emits file level debug info as LLVM globals
*/
-void llvm_emit_debug_context_info(const char *fileName,
- const char *path,
- const char *producer){
- llvm_constant *CA = 0;
- llvm_global *pathStr = EmitGlobalString(fileName);
- llvm_global *fileNameStr = EmitGlobalString(path);
- llvm_global *producerStr = EmitGlobalString(producer);
- llvm_value **Elements = (llvm_value**) xcalloc(7, sizeof(llvm_value*));
- llvm_instruction *gep = 0;
-
- /* Infer language of file, stolen from dwarf2out.c */
- const char *language_string = lang_hooks.name;
- if (strcmp (language_string, "GNU C++") == 0)
- LLVM_DEBUG_LANG_CODE = 0x0004; /*DW_LANG_C_plus_plus;*/
- else if (strcmp (language_string, "GNU Ada") == 0)
- LLVM_DEBUG_LANG_CODE = 0x000d; /* DW_LANG_Ada95; */
- else if (strcmp (language_string, "GNU F77") == 0)
- LLVM_DEBUG_LANG_CODE = 0x0007; /* DW_LANG_Fortran77; */
- else if (strcmp (language_string, "GNU Pascal") == 0)
- LLVM_DEBUG_LANG_CODE = 0x0009; /* DW_LANG_Pascal83; */
- else if (strcmp (language_string, "GNU Java") == 0)
- LLVM_DEBUG_LANG_CODE = 0x000b; /* DW_LANG_Java; */
- else
- LLVM_DEBUG_LANG_CODE = 0x0001; /* DW_LANG_C89; */
-
-
- /* The constant in Elements[0] is DW_TAG_COMPILE_UNIT */
- Elements[0] = llvm_constant_new_integral(UIntTy, 17);
- Elements[1] = llvm_constant_new_integral(UShortTy, LLVM_DEBUG_VERSION);
- Elements[2] = llvm_constant_new_integral(UShortTy, LLVM_DEBUG_LANG_CODE);
+llvm_global *llvm_emit_debug_context_info(const char *fullpath) {
+ llvm_global *dbCompileUnitGlobal = NULL;
- gep = create_gep3(G2V(fileNameStr),
- llvm_constant_intptr_0,
- llvm_constant_intptr_0);
- Elements[3] = G2V(llvm_constant_expr_new(gep));
-
- gep = create_gep3(G2V(pathStr),
- llvm_constant_intptr_0,
- llvm_constant_intptr_0);
- Elements[4] = G2V(llvm_constant_expr_new(gep));
-
- gep = create_gep3(G2V(producerStr),
- llvm_constant_intptr_0,
- llvm_constant_intptr_0);
- Elements[5] = G2V(llvm_constant_expr_new(gep));
-
- Elements[6] = G2V(dbTranslationUnitsGlobal);
- CA = G2C(llvm_constant_aggregate_new(dbCompileUnitTy, Elements));
-
- dbCompileUnitGlobal = llvm_global_new(dbCompileUnitTy, "d.compile_unit");
- dbCompileUnitGlobal->isConstant = 1;
- dbCompileUnitGlobal->Linkage = L_Internal;
- dbCompileUnitGlobal->Init = CA;
+ if (debug_info_level > DINFO_LEVEL_NONE) {
+ const char *globalName;
+ llvm_global *pathStr;
+ llvm_global *fileNameStr;
+ llvm_global *producerStr;
+ llvm_constant *CA = 0;
+ llvm_value **Elements = (llvm_value**) xcalloc(7, sizeof(llvm_value*));
+ llvm_instruction *gep = 0;
+ static compileUnitCount = 0;
+ char *buf = xstrdup(fullpath);
+ char *path = buf;
+ char *fileName = strrchr(buf, '/');
+
+ if(fileName){
+ *fileName = '\0';
+ fileName++;
+ } else {
+ path = ".";
+ fileName = buf;
+ }
- llvm_ilist_push_back(llvm_global, TheProgram.Globals, dbCompileUnitGlobal);
+ pathStr = EmitGlobalString(path);
+ fileNameStr = EmitGlobalString(fileName);
+ producerStr = EmitGlobalString("3.4.x");
+ free(buf);
+
+ /* Infer language of file, stolen from dwarf2out.c */
+ const char *language_string = lang_hooks.name;
+ if (strcmp (language_string, "GNU C++") == 0)
+ LLVM_DEBUG_LANG_CODE = 0x0004; /*DW_LANG_C_plus_plus;*/
+ else if (strcmp (language_string, "GNU Ada") == 0)
+ LLVM_DEBUG_LANG_CODE = 0x000d; /* DW_LANG_Ada95; */
+ else if (strcmp (language_string, "GNU F77") == 0)
+ LLVM_DEBUG_LANG_CODE = 0x0007; /* DW_LANG_Fortran77; */
+ else if (strcmp (language_string, "GNU Pascal") == 0)
+ LLVM_DEBUG_LANG_CODE = 0x0009; /* DW_LANG_Pascal83; */
+ else if (strcmp (language_string, "GNU Java") == 0)
+ LLVM_DEBUG_LANG_CODE = 0x000b; /* DW_LANG_Java; */
+ else
+ LLVM_DEBUG_LANG_CODE = 0x0001; /* DW_LANG_C89; */
+
+
+ /* The constant in Elements[0] is DW_TAG_COMPILE_UNIT */
+ Elements[0] = llvm_constant_new_integral(UIntTy, 17);
+ Elements[1] = llvm_constant_new_integral(UShortTy, LLVM_DEBUG_VERSION);
+ Elements[2] = llvm_constant_new_integral(UShortTy, LLVM_DEBUG_LANG_CODE);
+
+ gep = create_gep3(G2V(fileNameStr),
+ llvm_constant_intptr_0,
+ llvm_constant_intptr_0);
+ Elements[3] = G2V(llvm_constant_expr_new(gep));
+
+ gep = create_gep3(G2V(pathStr),
+ llvm_constant_intptr_0,
+ llvm_constant_intptr_0);
+ Elements[4] = G2V(llvm_constant_expr_new(gep));
+
+ gep = create_gep3(G2V(producerStr),
+ llvm_constant_intptr_0,
+ llvm_constant_intptr_0);
+ Elements[5] = G2V(llvm_constant_expr_new(gep));
+
+ Elements[6] = G2V(dbTranslationUnitsGlobal);
+ CA = G2C(llvm_constant_aggregate_new(dbCompileUnitTy, Elements));
+
+ asprintf(&globalName, "d.compile_unit.%d", ++compileUnitCount);
+
+ dbCompileUnitGlobal = llvm_global_new(dbCompileUnitTy, globalName);
+ dbCompileUnitGlobal->isConstant = 1;
+ dbCompileUnitGlobal->Linkage = L_Internal;
+ dbCompileUnitGlobal->Init = CA;
+ llvm_ilist_push_back(llvm_global, TheProgram.Globals, dbCompileUnitGlobal);
+ }
+
+ return dbCompileUnitGlobal;
}
/* llvm_emit_dbg_function_info emits a global of type lldb.global
@@ -7948,6 +7970,7 @@
static void llvm_emit_dbg_function_info(llvm_function *Fn) {
char *func_name = G2V(Fn)->Name;
char *gFuncName = 0;
+ const char *sourcePath = DECL_SOURCE_FILE(current_function_decl);
llvm_constant *CA = 0;
llvm_global *funcNameStr = 0;
@@ -7962,7 +7985,7 @@
funcNameStr = EmitGlobalString(func_name);
Elements = (llvm_value**) xcalloc(7, sizeof(llvm_value*));
Elements[0] = llvm_constant_new_integral(UIntTy, 46); /* DW_TAG_subprogram */
- Elements[1] = G2V(dbCompileUnitGlobal);
+ Elements[1] = G2V(llvm_register_source(sourcePath)->Global);
gep = create_gep3(G2V(funcNameStr),
llvm_constant_intptr_0,
@@ -8020,7 +8043,6 @@
* and global object anchors.
*/
void InitDebuggerTypeDecls(void){
-
llvm_type *ptrToSByteTy;
unsigned ptrTySz, uIntTySz, uShortTySz, boolTySz;
unsigned dbCompileUnitSz;
@@ -8203,7 +8225,7 @@
stoppoint_inst->Operands[2] = llvm_constant_new_integral(UIntTy, lineNo);
stoppoint_inst->Operands[3] = llvm_constant_new_integral(UIntTy, colNo);
- stoppoint_inst->Operands[4] = G2V(dbCompileUnitGlobal);
+ stoppoint_inst->Operands[4]=G2V(llvm_register_source(input_filename)->Global);
append_inst(Fn, load_dbg_inst);
append_inst(Fn, stoppoint_inst);
Index: llvm-gcc/gcc/llvm-out.h
diff -u llvm-gcc/gcc/llvm-out.h:1.6 llvm-gcc/gcc/llvm-out.h:1.7
--- llvm-gcc/gcc/llvm-out.h:1.6 Fri Jul 22 13:51:11 2005
+++ llvm-gcc/gcc/llvm-out.h Fri Dec 16 16:17:32 2005
@@ -44,10 +44,6 @@
the command line, possibly NULL. */
void llvm_init_asm_output(const char *Filename);
-/* emit global debug info for the file */
-void llvm_emit_debug_context_info(const char *fileName, const char *path,
- const char *producer);
-
/* llvm_assemble_external - This function is called once for each external
* function and variable as they are used.
*/
Index: llvm-gcc/gcc/llvm-representation.c
diff -u llvm-gcc/gcc/llvm-representation.c:1.22 llvm-gcc/gcc/llvm-representation.c:1.23
--- llvm-gcc/gcc/llvm-representation.c:1.22 Sun Dec 4 22:49:21 2005
+++ llvm-gcc/gcc/llvm-representation.c Fri Dec 16 16:17:32 2005
@@ -859,6 +859,29 @@
llvm_instruction_print, F);
}
+/* llvm_source_path implementation ********************************************
+ */
+llvm_source_path *llvm_register_source(const char *SourceStr) {
+ llvm_source_path *Entry;
+ static llvm_source_path *Registry = NULL;
+ static llvm_source_path *Cache = NULL;
+
+ if (Cache && strcmp(Cache->SourceStr, SourceStr) == 0) return Cache;
+
+ for (Entry = Registry; Entry; Entry = Entry->Next) {
+ if (strcmp(Entry->SourceStr, SourceStr) == 0) {
+ Cache = Entry;
+ return Cache;
+ }
+ }
+
+ Cache = (llvm_source_path*)xcalloc(sizeof(llvm_source_path), 1);
+ Cache->SourceStr = SourceStr;
+ Cache->Global = llvm_emit_debug_context_info(SourceStr);
+ Cache->Next = Registry;
+ Registry = Cache;
+ return Cache;
+}
/* llvm_function implementation ********************************************
*/
Index: llvm-gcc/gcc/llvm-representation.h
diff -u llvm-gcc/gcc/llvm-representation.h:1.21 llvm-gcc/gcc/llvm-representation.h:1.22
--- llvm-gcc/gcc/llvm-representation.h:1.21 Sun Dec 4 22:49:21 2005
+++ llvm-gcc/gcc/llvm-representation.h Fri Dec 16 16:17:33 2005
@@ -266,6 +266,16 @@
L_Internal /* Static function? */
};
+struct llvm_global;
+typedef struct llvm_source_path {
+ const char *SourceStr;
+ struct llvm_global *Global;
+ struct llvm_source_path *Next;
+} llvm_source_path;
+
+llvm_source_path *llvm_register_source(const char *SourceStr);
+struct llvm_global *llvm_emit_debug_context_info(const char *fullpath);
+
struct llvm_expand_info;
typedef struct llvm_function {
llvm_constant ConstantBase;
Index: llvm-gcc/gcc/toplev.c
diff -u llvm-gcc/gcc/toplev.c:1.6 llvm-gcc/gcc/toplev.c:1.7
--- llvm-gcc/gcc/toplev.c:1.6 Thu Nov 18 14:44:23 2004
+++ llvm-gcc/gcc/toplev.c Fri Dec 16 16:17:33 2005
@@ -4409,21 +4409,6 @@
if (EMIT_LLVM) {
llvm_init_codegen();
- if (debug_info_level > DINFO_LEVEL_NONE) {
- char *buf = xstrdup(name);
- char *path = buf;
- char *fileName = strrchr(buf, '/');
- if(fileName){
- *fileName = '\0';
- fileName++;
- }else{
- path = ".";
- fileName = buf;
- }
-
- llvm_emit_debug_context_info(path, fileName, "llvm 3.4.x");
- free(buf);
- }
}
/* Other front-end initialization. */
More information about the llvm-commits
mailing list