<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Wed, Oct 11, 2017 at 3:27 AM George Rimar via Phabricator <<a href="mailto:reviews@reviews.llvm.org">reviews@reviews.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">grimar added inline comments.<br>
<br>
<br>
================<br>
Comment at: test/ELF/Inputs/conflict-debug-variable.s:1<br>
+# Used reduced output from following code and gcc 7.1.0<br>
+# to produce this input file:<br>
----------------<br>
ruiu wrote:<br>
> I don't think we want to have this machine-generated assembly in the test directory. It is hard to verify/edit. Can you do this with llvm-as?<br>
Problem to do that is next. There is a difference in debug information produced by gcc and clang.<br>
<br>
clang encodes variables names using `DW_FORM_strp` (represents an offset in `.debug_str`):<br>
<br>
```<br>
0x0000001e:   DW_TAG_variable [2]<br>
                DW_AT_name [DW_FORM_strp]       ( .debug_str[0x00000048] = "foo")<br>
                DW_AT_type [DW_FORM_ref4]       (cu + 0x0033 => {0x00000033})<br>
                DW_AT_external [DW_FORM_flag_present]   (true)<br>
                DW_AT_decl_file [DW_FORM_data1] ("/home/umb/tests/566_duplicatesym/1.c")<br>
                DW_AT_decl_line [DW_FORM_data1] (1)<br>
                DW_AT_location [DW_FORM_exprloc]        (DW_OP_addr 0x0)<br>
```<br>
<br>
gcc places string in place using DW_FORM_string:<br>
```<br>
0x0000001d:   DW_TAG_variable [2]<br>
                 DW_AT_name [DW_FORM_string]    ("foo")<br>
                 DW_AT_decl_file [DW_FORM_data1]        ("/home/umb/tests/566_duplicatesym/1.c")<br>
                 DW_AT_decl_line [DW_FORM_data1]        (1)<br>
                 DW_AT_type [DW_FORM_ref4]      (cu + 0x0032 => {0x00000032})<br>
                DW_AT_external [DW_FORM_flag_present]   (true)<br>
                 DW_AT_location [DW_FORM_exprloc]       (DW_OP_addr 0x0)<br>
```<br>
<br>
We want to support both ways, and this patch supports only first one, because our `LLDDwarfObj`<br>
does not provide `.debug_str` section for DWARF parsers yet.<br>
<br>
I tried to use llvm-as + llc and found no way to make output to use gcc way (`DW_FORM_string` for name attribute).<br>
(used clang -S -emit-llvm -g to produce IR). I am not sure is it possible ? Seems - not.<br>
I think clang has no flags to drop use of `.debug_str`.<br></blockquote><div><br>Yep, llvm uses FORM_strp for everything & has no fallback/other path/flag/etc to do otherwise.<br><br>GCC will likely also use FORM_strp for longer strings (once it's longer than the size of the relocation it costs to indirect through debug_str).<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
I am going to implement support for `DW_FORM_strp` (clang way) after this patch be landed, but we need testcases<br>
for both ways I believe. For following patch I can use llvm-as.<br>
<br>
I updated this testcase so it should be more readable. It also should be no need to edit it in future I think.<br>
<br>
<br>
<a href="https://reviews.llvm.org/D38721" rel="noreferrer" target="_blank">https://reviews.llvm.org/D38721</a><br>
<br>
<br>
<br>
</blockquote></div></div>