[llvm] Fix an enable debug info generation for llvm master.
authorZoltan Varga <vargaz@gmail.com>
Thu, 14 Jul 2016 20:49:28 +0000 (16:49 -0400)
committerZoltan Varga <vargaz@gmail.com>
Thu, 14 Jul 2016 20:49:28 +0000 (16:49 -0400)
mono/mini/mini-llvm-cpp.cpp
mono/mini/mini-llvm-cpp.h
mono/mini/mini-llvm.c

index 425eea95ed81854b1d84e0637c7a0929dc3dbbc7..4753f66ca6d882ec24a1110495a0ee5cbc5c5589 100644 (file)
@@ -246,16 +246,21 @@ mono_llvm_di_create_compile_unit (void *di_builder, const char *cu_name, const c
 }
 
 void*
-mono_llvm_di_create_function (void *di_builder, void *cu, const char *name, const char *mangled_name, const char *dir, const char *file, int line)
+mono_llvm_di_create_function (void *di_builder, void *cu, LLVMValueRef func, const char *name, const char *mangled_name, const char *dir, const char *file, int line)
 {
        DIBuilder *builder = (DIBuilder*)di_builder;
        DIFile *di_file;
        DISubroutineType *type;
+       DISubprogram *di_func;
 
        // FIXME: Share DIFile
        di_file = builder->createFile (file, dir);
        type = builder->createSubroutineType (builder->getOrCreateTypeArray (ArrayRef<Metadata*> ()));
-       return builder->createFunction (di_file, name, mangled_name, di_file, line, type, true, true, 0);
+       di_func = builder->createFunction (di_file, name, mangled_name, di_file, line, type, true, true, 0);
+
+       unwrap<Function>(func)->setMetadata ("dbg", di_func);
+
+       return di_func;
 }
 
 void*
index 064c587ce54d5773cf59881f420947ea1d302d81..50e89e858eac7599384ee9a87b9561f61c354884 100644 (file)
@@ -100,7 +100,7 @@ void*
 mono_llvm_create_di_builder (LLVMModuleRef module);
 
 void*
-mono_llvm_di_create_function (void *di_builder, void *cu, const char *name, const char *mangled_name, const char *dir, const char *file, int line);
+mono_llvm_di_create_function (void *di_builder, void *cu, LLVMValueRef func, const char *name, const char *mangled_name, const char *dir, const char *file, int line);
 
 void*
 mono_llvm_di_create_compile_unit (void *di_builder, const char *cu_name, const char *dir, const char *producer);
index ce9cedebbb4c033b50f835db1ddf7880a1e00484..7665b6a56b515df24e7e73800e5c8b2bf0d78783 100644 (file)
@@ -8298,10 +8298,6 @@ mono_llvm_create_aot_module (MonoAssembly *assembly, const char *global_prefix,
                /* clang ignores our debug info because it has an invalid version */
                module->emit_dwarf = FALSE;
 
-#if LLVM_API_VERSION > 100
-       module->emit_dwarf = FALSE;
-#endif
-
        add_intrinsics (module->lmodule);
        add_types (module);
 
@@ -8879,7 +8875,7 @@ emit_dbg_subprogram (EmitContext *ctx, MonoCompile *cfg, LLVMValueRef method, co
        filename = g_path_get_basename (source_file);
 
 #if LLVM_API_VERSION > 100
-       return mono_llvm_di_create_function (module->di_builder, module->cu, cfg->method->name, name, dir, filename, n_seq_points ? sym_seq_points [0].line : 1);
+       return mono_llvm_di_create_function (module->di_builder, module->cu, method, cfg->method->name, name, dir, filename, n_seq_points ? sym_seq_points [0].line : 1);
 #endif
 
        ctx_args [0] = LLVMConstInt (LLVMInt32Type (), 0x29, FALSE);