Name the llvm methods using the debug symbol by default, instead of using the cryptic...
authorZoltan Varga <vargaz@gmail.com>
Sat, 18 Dec 2010 02:39:35 +0000 (03:39 +0100)
committerZoltan Varga <vargaz@gmail.com>
Sat, 18 Dec 2010 02:39:35 +0000 (03:39 +0100)
mono/mini/aot-compiler.c
mono/mini/mini-llvm.c
mono/mini/mini.h

index 8fe73c81e27b08b0c947380e5b79e770e5af20db..268f6cae1f81eed4814b828020b0b539144ec403 100644 (file)
@@ -493,6 +493,14 @@ arch_init (MonoAotCompile *acfg)
        acfg->llc_args = g_string_new ("");
        acfg->as_args = g_string_new ("");
 
+       /*
+        * The prefix LLVM likes to put in front of symbol names on darwin.
+        * The mach-os specs require this for globals, but LLVM puts them in front of all
+        * symbols. We need to handle this, since we need to refer to LLVM generated
+        * symbols.
+        */
+       acfg->llvm_label_prefix = "";
+
 #ifdef TARGET_ARM
        if (acfg->aot_opts.mtriple && strstr (acfg->aot_opts.mtriple, "darwin")) {
                g_string_append (acfg->llc_args, "-mattr=+v6");
@@ -3149,7 +3157,7 @@ get_debug_sym (MonoMethod *method, const char *prefix, GHashTable *cache)
 {
        char *name1, *name2, *cached;
        int i, j, len, count;
-               
+
        name1 = mono_method_full_name (method, TRUE);
        len = strlen (name1);
        name2 = malloc (strlen (prefix) + len + 16);
@@ -4743,14 +4751,6 @@ mono_aot_get_got_offset (MonoJumpInfo *ji)
 
 char*
 mono_aot_get_method_name (MonoCompile *cfg)
-{
-       guint32 method_index = get_method_index (llvm_acfg, cfg->orig_method);
-
-       return g_strdup_printf ("m_%x", method_index);
-}
-
-char*
-mono_aot_get_method_debug_name (MonoCompile *cfg)
 {
        return get_debug_sym (cfg->orig_method, "", llvm_acfg->method_label_hash);
 }
@@ -6361,6 +6361,10 @@ mono_compile_assembly (MonoAssembly *ass, guint32 opts, const char *aot_options)
 #endif
        acfg->num_trampolines [MONO_AOT_TRAMP_IMT_THUNK] = acfg->aot_opts.full_aot ? acfg->aot_opts.nimt_trampolines : 0;
 
+       acfg->temp_prefix = img_writer_get_temp_label_prefix (NULL);
+
+       arch_init (acfg);
+
        acfg->got_symbol_base = g_strdup_printf ("%smono_aot_%s_got", acfg->llvm_label_prefix, acfg->image->assembly->aname.name);
        acfg->plt_symbol = g_strdup_printf ("%smono_aot_%s_plt", acfg->llvm_label_prefix, acfg->image->assembly->aname.name);
 
@@ -6374,18 +6378,6 @@ mono_compile_assembly (MonoAssembly *ass, guint32 opts, const char *aot_options)
                        *p = '_';
        }
 
-       acfg->temp_prefix = img_writer_get_temp_label_prefix (NULL);
-
-       /*
-        * The prefix LLVM likes to put in front of symbol names on darwin.
-        * The mach-os specs require this for globals, but LLVM puts them in front of all
-        * symbols. We need to handle this, since we need to refer to LLVM generated
-        * symbols.
-        */
-       acfg->llvm_label_prefix = "";
-
-       arch_init (acfg);
-
        acfg->method_index = 1;
 
        collect_methods (acfg);
@@ -6501,7 +6493,10 @@ mono_compile_assembly (MonoAssembly *ass, guint32 opts, const char *aot_options)
                        MonoCompile *cfg = acfg->cfgs [i];
                        int method_index = get_method_index (acfg, cfg->orig_method);
 
-                       cfg->asm_symbol = g_strdup_printf ("%s%sm_%x", acfg->temp_prefix, acfg->llvm_label_prefix, method_index);
+                       if (COMPILE_LLVM (cfg))
+                               cfg->asm_symbol = g_strdup_printf ("%s%s", acfg->llvm_label_prefix, cfg->llvm_method_name);
+                       else
+                               cfg->asm_symbol = g_strdup_printf ("%s%sm_%x", acfg->temp_prefix, acfg->llvm_label_prefix, method_index);
                }
        }
 
index c459b388e1b0a424e0c605266d8d8cae7cb1acf2..173fe550da2fec44743a064907045a4dda904476 100644 (file)
@@ -3738,8 +3738,8 @@ mono_llvm_emit_method (MonoCompile *cfg)
        MonoMethodSignature *sig;
        MonoBasicBlock *bb;
        LLVMTypeRef method_type;
-       LLVMValueRef method = NULL, debug_alias = NULL;
-       char *method_name, *debug_name = NULL;
+       LLVMValueRef method = NULL;
+       char *method_name;
        LLVMValueRef *values;
        int i, max_block_num, bb_index;
        gboolean last = FALSE;
@@ -3792,12 +3792,11 @@ mono_llvm_emit_method (MonoCompile *cfg)
        if (cfg->compile_aot) {
                ctx->lmodule = &aot_module;
                method_name = mono_aot_get_method_name (cfg);
-               debug_name = mono_aot_get_method_debug_name (cfg);
+               cfg->llvm_method_name = g_strdup (method_name);
        } else {
                init_jit_module ();
                ctx->lmodule = &jit_module;
                method_name = mono_method_full_name (cfg->method, TRUE);
-               debug_name = NULL;
        }
        
        module = ctx->module = ctx->lmodule->module;
@@ -3849,6 +3848,13 @@ mono_llvm_emit_method (MonoCompile *cfg)
 #endif
        LLVMSetLinkage (method, LLVMPrivateLinkage);
 
+       if (cfg->compile_aot) {
+               LLVMSetLinkage (method, LLVMInternalLinkage);
+               LLVMSetVisibility (method, LLVMHiddenVisibility);
+       } else {
+               LLVMSetLinkage (method, LLVMPrivateLinkage);
+       }
+
        if (cfg->method->save_lmf)
                LLVM_FAILURE (ctx, "lmf");
 
@@ -4072,14 +4078,6 @@ mono_llvm_emit_method (MonoCompile *cfg)
 
        if (cfg->compile_aot) {
                /* Don't generate native code, keep the LLVM IR */
-
-               /* Can't delete the method if it has an alias, so only add it if successful */
-               if (debug_name) {
-                       debug_alias = LLVMAddAlias (module, LLVMTypeOf (method), method, debug_name);
-                       LLVMSetLinkage (debug_alias, LLVMInternalLinkage);
-                       LLVMSetVisibility (debug_alias, LLVMHiddenVisibility);
-               }
-
                if (cfg->compile_aot && cfg->verbose_level)
                        printf ("%s emitted as %s\n", mono_method_full_name (cfg->method, TRUE), method_name);
 
@@ -4127,7 +4125,6 @@ mono_llvm_emit_method (MonoCompile *cfg)
        g_free (ctx->pindexes);
        g_free (ctx->is_dead);
        g_free (ctx->unreachable);
-       g_free (debug_name);
        g_ptr_array_free (phi_values, TRUE);
        g_free (ctx->bblocks);
        g_hash_table_destroy (ctx->region_to_handler);
index de5105f736eb1e10d41c13abeff5d77c498bd45b..e2880824a70fa35b98ef7b653b1db6b7d658fb45 100644 (file)
@@ -1230,6 +1230,7 @@ typedef struct {
        guint32 got_offset, ex_info_offset, method_info_offset;
        /* Symbol used to refer to this method in generated assembly */
        char *asm_symbol;
+       char *llvm_method_name;
 
        MonoJitExceptionInfo *llvm_ex_info;
        guint32 llvm_ex_info_len;
@@ -1670,7 +1671,6 @@ MonoMethod* mono_aot_get_array_helper_from_wrapper (MonoMethod *method) MONO_INT
 guint32  mono_aot_get_got_offset            (MonoJumpInfo *ji) MONO_LLVM_INTERNAL;
 char*    mono_aot_get_method_name           (MonoCompile *cfg) MONO_LLVM_INTERNAL;
 char*    mono_aot_get_plt_symbol            (MonoJumpInfoType type, gconstpointer data) MONO_LLVM_INTERNAL;
-char*    mono_aot_get_method_debug_name     (MonoCompile *cfg) MONO_LLVM_INTERNAL;
 MonoJumpInfo* mono_aot_patch_info_dup       (MonoJumpInfo* ji) MONO_LLVM_INTERNAL;
 void     mono_aot_set_make_unreadable       (gboolean unreadable) MONO_INTERNAL;
 gboolean mono_aot_is_pagefault              (void *ptr) MONO_INTERNAL;