<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Mar 17, 2015 at 10:45 AM, James Brock <span dir="ltr"><<a href="mailto:james@cognitive-electronics.com" target="_blank">james@cognitive-electronics.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div style="word-wrap:break-word"><div>I’m getting some weird results in the text of my LLVM-IR when compiling using version 3.6 with the -g option. For a simple c function (in a file func.c, shown below)</div><div><br></div><div><div>void test_func(unsigned int * dIn, unsigned int * dOut) {</div><div>   unsigned int idx = 0;</div><div>   for (idx = 0; idx < 100; idx++) {</div><div>      dOut[idx] = dIn[idx];</div><div>   }</div><div>   return;</div><div>}</div></div><div><br></div><div>and the compile command shown below</div><div><br></div><div>/path/to/clang -target x86_64 -v -g -S -emit-llvm -o func.ll func.c</div><div><br></div><div>The LLVM IR in the resultant .ll file (in part included below) contains strings with a lot of unusual and unnecessary characters, including a lot of null characters ‘\000’. This seams to be in the part of the LLVM IR related to the Dwarf information, and goes away with the removal of the -g option from the command line. I’ve tried this with a number of different optimization levels and target architectures with the same results. Any help or explanation for the odd strings is greatly appreciated. </div></div></blockquote><div><br>That's by design:<br><br><a href="http://llvm.org/docs/SourceLevelDebugging.html#id10">http://llvm.org/docs/SourceLevelDebugging.html#id10</a><br><br>"<span style="color:rgb(0,0,0);font-family:'Lucida Grande','Lucida Sans Unicode',Geneva,Verdana,sans-serif;font-size:14px;line-height:21px">Most of the string and integer fields in descriptors are packed into a single, null-separated </span><tt class="" style="font-family:Consolas,'Deja Vu Sans Mono','Bitstream Vera Sans Mono',monospace;font-size:0.95em;color:rgb(0,0,0);line-height:21px"><span class="">mdstring</span></tt><span style="color:rgb(0,0,0);font-family:'Lucida Grande','Lucida Sans Unicode',Geneva,Verdana,sans-serif;font-size:14px;line-height:21px">. "</span><br> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div style="word-wrap:break-word"><div><br></div><div><div><br></div><div>; Function Attrs: nounwind readnone</div><div>declare void @llvm.dbg.declare(metadata, metadata, metadata) #1</div><div><br></div><div>attributes #0 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }</div><div>attributes #1 = { nounwind readnone }</div><div><br></div><div>!<a href="http://llvm.dbg.cu" target="_blank">llvm.dbg.cu</a> = !{!0}</div><div>!llvm.module.flags = !{!10, !11}</div><div>!llvm.ident = !{!12}</div><div><br></div><div>!0 = !{!"0x11\0012\00clang version 3.6.0 (tags/RELEASE_360/final)\000\00\000\00\001", !1, !2, !2, !3, !2, !2} ; [ DW_TAG_compile_unit ] [/home/james/workspace/Libraries/opencl/coge_ocl/trunk/test/dat/ocl_kern1.c] [DW_LANG_C99]</div><div>!1 = !{!"ocl_kern1.c", !"/home/james/workspace/Libraries/opencl/coge_ocl/trunk/test/dat"}</div><div>!2 = !{}</div><div>!3 = !{!4}</div><div>!4 = !{!"0x2e\00test_func\00test_func\00\002\000\001\000\000\00256\000\002", !1, !5, !6, null, void (i32*, i32*)* @test_func, null, null, !2} ; [ DW_TAG_subprogram ] [line 2] [def] [test_func]</div><div>!5 = !{!"0x29", !1}                               ; [ DW_TAG_file_type ] [/home/james/workspace/Libraries/opencl/coge_ocl/trunk/test/dat/ocl_kern1.c]</div><div>!6 = !{!"0x15\00\000\000\000\000\000\000", null, null, null, !7, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]</div><div>!7 = !{null, !8, !8}</div><div>!8 = !{!"0xf\00\000\0064\0064\000\000", null, null, !9} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [from unsigned int]</div><div>!9 = !{!"0x24\00unsigned int\000\0032\0032\000\000\007", null, null} ; [ DW_TAG_base_type ] [unsigned int] [line 0, size 32, align 32, offset 0, enc DW_ATE_unsigned]</div><div>!10 = !{i32 2, !"Dwarf Version", i32 4}</div><div>!11 = !{i32 2, !"Debug Info Version", i32 2}</div><div>!12 = !{!"clang version 3.6.0 (tags/RELEASE_360/final)"}</div><div>!13 = !{!"0x101\00dIn\0016777218\000", !4, !5, !8} ; [ DW_TAG_arg_variable ] [dIn] [line 2]</div><div>!14 = !{!"0x102"}                                 ; [ DW_TAG_expression ]</div><div>!15 = !MDLocation(line: 2, column: 31, scope: !4)</div><div>!16 = !{!"0x101\00dOut\0033554434\000", !4, !5, !8} ; [ DW_TAG_arg_variable ] [dOut] [line 2]</div><div>!17 = !MDLocation(line: 2, column: 51, scope: !4)</div><div>!18 = !{!"0x100\00idx\003\000", !4, !5, !9}       ; [ DW_TAG_auto_variable ] [idx] [line 3]</div><div>!19 = !MDLocation(line: 3, column: 17, scope: !4)</div><div>!20 = !MDLocation(line: 5, column: 9, scope: !21)</div><div>!21 = !{!"0xb\005\004\000", !1, !4}               ; [ DW_TAG_lexical_block ] [/home/james/workspace/Libraries/opencl/coge_ocl/trunk/test/dat/ocl_kern1.c]</div><div>!22 = !MDLocation(line: 5, column: 18, scope: !23)</div><div>!23 = !{!"0xb\002", !1, !24}                      ; [ DW_TAG_lexical_block ] [/home/james/workspace/Libraries/opencl/coge_ocl/trunk/test/dat/ocl_kern1.c]</div><div>!24 = !{!"0xb\001", !1, !25}                      ; [ DW_TAG_lexical_block ] [/home/james/workspace/Libraries/opencl/coge_ocl/trunk/test/dat/ocl_kern1.c]</div><div>!25 = !{!"0xb\005\004\001", !1, !21}              ; [ DW_TAG_lexical_block ] [/home/james/workspace/Libraries/opencl/coge_ocl/trunk/test/dat/ocl_kern1.c]</div><div>!26 = !MDLocation(line: 5, column: 4, scope: !21)</div><div>!27 = !MDLocation(line: 6, column: 23, scope: !28)</div><div>!28 = !{!"0xb\005\0036\002", !1, !25}             ; [ DW_TAG_lexical_block ] [/home/james/workspace/Libraries/opencl/coge_ocl/trunk/test/dat/ocl_kern1.c]</div><div>!29 = !MDLocation(line: 6, column: 19, scope: !28)</div><div>!30 = !MDLocation(line: 6, column: 12, scope: !28)</div><div>!31 = !MDLocation(line: 6, column: 7, scope: !28)</div><div>!32 = !MDLocation(line: 7, column: 4, scope: !28)</div><div>!33 = !MDLocation(line: 5, column: 29, scope: !25)</div><div>!34 = !MDLocation(line: 5, column: 4, scope: !25)</div><div>!35 = !MDLocation(line: 9, column: 4, scope: !4)</div></div><span class=""><font color="#888888"><div>
<div style="color:rgb(0,0,0);font-family:Helvetica;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:-webkit-auto;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word"><div style="color:rgb(0,0,0);font-family:Helvetica;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:-webkit-auto;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br></div><div style="color:rgb(0,0,0);font-family:Helvetica;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:-webkit-auto;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br></div><div style="color:rgb(0,0,0);font-family:Helvetica;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:-webkit-auto;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br>James Brock</div></div></div></font></span></div><br>_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br></div></div>