<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">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 class=""><br class=""></div><div class=""><div class="">void test_func(unsigned int * dIn, unsigned int * dOut) {</div><div class="">   unsigned int idx = 0;</div><div class="">   for (idx = 0; idx < 100; idx++) {</div><div class="">      dOut[idx] = dIn[idx];</div><div class="">   }</div><div class="">   return;</div><div class="">}</div></div><div class=""><br class=""></div><div class="">and the compile command shown below</div><div class=""><br class=""></div><div class="">/path/to/clang -target x86_64 -v -g -S -emit-llvm -o func.ll func.c</div><div class=""><br class=""></div><div class="">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 class=""><br class=""></div><div class=""><div class=""><br class=""></div><div class="">; Function Attrs: nounwind readnone</div><div class="">declare void @llvm.dbg.declare(metadata, metadata, metadata) #1</div><div class=""><br class=""></div><div class="">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 class="">attributes #1 = { nounwind readnone }</div><div class=""><br class=""></div><div class="">!llvm.dbg.cu = !{!0}</div><div class="">!llvm.module.flags = !{!10, !11}</div><div class="">!llvm.ident = !{!12}</div><div class=""><br class=""></div><div class="">!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 class="">!1 = !{!"ocl_kern1.c", !"/home/james/workspace/Libraries/opencl/coge_ocl/trunk/test/dat"}</div><div class="">!2 = !{}</div><div class="">!3 = !{!4}</div><div class="">!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 class="">!5 = !{!"0x29", !1}                               ; [ DW_TAG_file_type ] [/home/james/workspace/Libraries/opencl/coge_ocl/trunk/test/dat/ocl_kern1.c]</div><div class="">!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 class="">!7 = !{null, !8, !8}</div><div class="">!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 class="">!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 class="">!10 = !{i32 2, !"Dwarf Version", i32 4}</div><div class="">!11 = !{i32 2, !"Debug Info Version", i32 2}</div><div class="">!12 = !{!"clang version 3.6.0 (tags/RELEASE_360/final)"}</div><div class="">!13 = !{!"0x101\00dIn\0016777218\000", !4, !5, !8} ; [ DW_TAG_arg_variable ] [dIn] [line 2]</div><div class="">!14 = !{!"0x102"}                                 ; [ DW_TAG_expression ]</div><div class="">!15 = !MDLocation(line: 2, column: 31, scope: !4)</div><div class="">!16 = !{!"0x101\00dOut\0033554434\000", !4, !5, !8} ; [ DW_TAG_arg_variable ] [dOut] [line 2]</div><div class="">!17 = !MDLocation(line: 2, column: 51, scope: !4)</div><div class="">!18 = !{!"0x100\00idx\003\000", !4, !5, !9}       ; [ DW_TAG_auto_variable ] [idx] [line 3]</div><div class="">!19 = !MDLocation(line: 3, column: 17, scope: !4)</div><div class="">!20 = !MDLocation(line: 5, column: 9, scope: !21)</div><div class="">!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 class="">!22 = !MDLocation(line: 5, column: 18, scope: !23)</div><div class="">!23 = !{!"0xb\002", !1, !24}                      ; [ DW_TAG_lexical_block ] [/home/james/workspace/Libraries/opencl/coge_ocl/trunk/test/dat/ocl_kern1.c]</div><div class="">!24 = !{!"0xb\001", !1, !25}                      ; [ DW_TAG_lexical_block ] [/home/james/workspace/Libraries/opencl/coge_ocl/trunk/test/dat/ocl_kern1.c]</div><div class="">!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 class="">!26 = !MDLocation(line: 5, column: 4, scope: !21)</div><div class="">!27 = !MDLocation(line: 6, column: 23, scope: !28)</div><div class="">!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 class="">!29 = !MDLocation(line: 6, column: 19, scope: !28)</div><div class="">!30 = !MDLocation(line: 6, column: 12, scope: !28)</div><div class="">!31 = !MDLocation(line: 6, column: 7, scope: !28)</div><div class="">!32 = !MDLocation(line: 7, column: 4, scope: !28)</div><div class="">!33 = !MDLocation(line: 5, column: 29, scope: !25)</div><div class="">!34 = !MDLocation(line: 5, column: 4, scope: !25)</div><div class="">!35 = !MDLocation(line: 9, column: 4, scope: !4)</div></div><div apple-content-edited="true" class="">
<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; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><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; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""></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; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""></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; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class="Apple-interchange-newline">James Brock</div></div></div></body></html>