I figured out my previous problem with DIBuilder. However, now I can't seem to get the compiler to emit location information for local variables. Here's how my IR looks:<div><br></div><div>---</div><div><div><font face="'courier new', monospace">define i32 @"\01_main"() {</font></div>
<div><font face="'courier new', monospace">init:</font></div><div><font face="'courier new', monospace"> %exception1 = alloca i8*</font></div><div><font face="'courier new', monospace"> %0 = alloca i32</font></div>
<div><font face="'courier new', monospace"> %"bar:Int32" = alloca i32</font></div><div><font face="'courier new', monospace"> %1 = alloca i32</font></div><div><font face="'courier new', monospace"> %2 = alloca i32*</font></div>
<div><font face="'courier new', monospace"> br label %code</font></div><div><font face="'courier new', monospace"><br></font></div><div><font face="'courier new', monospace">code: ; preds = %init</font></div>
<div><font face="'courier new', monospace"> call void @llvm.dbg.declare(metadata !{i32* %"bar:Int32"}, metadata !13)</font></div><div><font face="'courier new', monospace"> store i32 1, i32* %"bar:Int32", !dbg !16</font></div>
<div><font face="'courier new', monospace"> store i32 1, i32* %1, !dbg !17</font></div><div><font face="'courier new', monospace"> %3 = load i32* %"bar:Int32", !dbg !17</font></div><div><font face="'courier new', monospace"> %4 = load i32* %1, !dbg !17</font></div>
<div><font face="'courier new', monospace"> %5 = add i32 %3, %4, !dbg !17</font></div><div><font face="'courier new', monospace"> store i32 %5, i32* %"bar:Int32", !dbg !17</font></div><div><font face="'courier new', monospace"> store i32* %"bar:Int32", i32** %2, !dbg !18</font></div>
<div><font face="'courier new', monospace"> %6 = load i32** %2, !dbg !18</font></div><div><font face="'courier new', monospace"> %7 = load i32* %6, !dbg !18</font></div><div><font face="'courier new', monospace"> store i32 %7, i32* %0, !dbg !18</font></div>
<div><font face="'courier new', monospace"> br label %return, !dbg !18</font></div><div><font face="'courier new', monospace"><br></font></div><div><font face="'courier new', monospace">return: ; preds = %code</font></div>
<div><font face="'courier new', monospace"> %8 = load i32* %0</font></div><div><font face="'courier new', monospace"> ret i32 %8</font></div><div><font face="'courier new', monospace"><br></font></div>
<div><font face="'courier new', monospace">exception: ; No predecessors!</font></div><div><font face="'courier new', monospace"> unreachable</font></div><div><font face="'courier new', monospace">}</font></div>
<div><font face="'courier new', monospace"><br></font></div><div><font face="'courier new', monospace">declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone</font></div><div><font face="'courier new', monospace"><br>
</font></div><div><font face="'courier new', monospace">!<a href="http://llvm.dbg.cu">llvm.dbg.cu</a> = !{!0}</font></div><div><font face="'courier new', monospace"><br></font></div><div><font face="'courier new', monospace">!0 = metadata !{i32 720913, i32 0, i32 49572, metadata !"foo.clay", metadata !"", metadata !"clay compiler 0.1git", i1 true, i1 false, metadata !"", i32 0, metadata !1, metadata !1, metadata !3, metadata !1} ; [ DW_TAG_compile_unit ]</font></div>
<div><font face="'courier new', monospace">!1 = metadata !{metadata !2}</font></div><div><font face="'courier new', monospace">!2 = metadata !{i32 0}</font></div><div><font face="'courier new', monospace">!3 = metadata !{metadata !4}</font></div>
<div><font face="'courier new', monospace">!4 = metadata !{metadata !5}</font></div><div><font face="'courier new', monospace">!5 = metadata !{i32 720942, i32 0, metadata !6, metadata !"foo", metadata !"foo", metadata !"\01_main", metadata !7, i32 1, metadata !8, i1 false, i1 true, i32 0, i32 0, i32 0, i32 0, i1 false, i32 ()* @"\01_main", null, null, metadata !11} ; [ DW_TAG_subprogram ]</font></div>
<div><font face="'courier new', monospace">!6 = metadata !{i32 720953, null, metadata !"__main__", metadata !7, i32 1} ; [ DW_TAG_namespace ]</font></div><div><font face="'courier new', monospace">!7 = metadata !{i32 720937, metadata !"foo.clay", metadata !"", null} ; [ DW_TAG_file_type ]</font></div>
<div><font face="'courier new', monospace">!8 = metadata !{i32 720917, i32 0, metadata !"", i32 0, i32 0, i64 0, i64 0, i32 0, i32 0, i32 0, metadata !9, i32 0, i32 0} ; [ DW_TAG_subroutine_type ]</font></div>
<div><font face="'courier new', monospace">!9 = metadata !{metadata !10}</font></div><div><font face="'courier new', monospace">!10 = metadata !{i32 720932, null, metadata !"Int32", null, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ]</font></div>
<div><font face="'courier new', monospace">!11 = metadata !{metadata !12}</font></div><div><font face="'courier new', monospace">!12 = metadata !{metadata !13}</font></div><div><font face="'courier new', monospace">!13 = metadata !{i32 721152, metadata !14, metadata !"bar", metadata !7, i32 2, metadata !10, i32 0, i32 0} ; [ DW_TAG_auto_variable ]</font></div>
<div><font face="'courier new', monospace">!14 = metadata !{i32 720907, metadata !15, i32 1, i32 1, metadata !7, i32 1} ; [ DW_TAG_lexical_block ]</font></div><div><font face="'courier new', monospace">!15 = metadata !{i32 720907, metadata !5, i32 1, i32 1, metadata !7, i32 0} ; [ DW_TAG_lexical_block ]</font></div>
<div><font face="'courier new', monospace">!16 = metadata !{i32 2, i32 2, metadata !14, null}</font></div><div><font face="'courier new', monospace">!17 = metadata !{i32 3, i32 3, metadata !14, null}</font></div>
<div><font face="'courier new', monospace">!18 = metadata !{i32 4, i32 4, metadata !14, null}</font></div></div><div>---</div><div><br></div><div>And this is what dwarfdump on the compiled object file shows. The TAG_variable entry for 'bar' is missing its AT_location.</div>
<div><br></div><div>---</div><div><div><font face="'courier new', monospace">----------------------------------------------------------------------</font></div><div><font face="'courier new', monospace"> File: foo.o (x86_64)</font></div>
<div><font face="'courier new', monospace">----------------------------------------------------------------------</font></div><div><font face="'courier new', monospace">.debug_info contents:</font></div><div>
<font face="'courier new', monospace"><br></font></div><div><font face="'courier new', monospace">0x00000000: Compile Unit: length = 0x000000a9 version = 0x0002 abbr_offset = 0x00000000 addr_size = 0x08 (next CU at 0x000000ad)</font></div>
<div><font face="'courier new', monospace"><br></font></div><div><font face="'courier new', monospace">0x0000000b: TAG_compile_unit [1] *</font></div><div><font face="'courier new', monospace"> AT_producer( "clay compiler 0.1git" )</font></div>
<div><font face="'courier new', monospace"> AT_language( Unknown DW_LANG constant: 0xc1a4 )</font></div><div><font face="'courier new', monospace"> AT_name( "foo.clay" )</font></div>
<div><font face="'courier new', monospace"> AT_entry_pc( 0x0000000000000000 )</font></div><div><font face="'courier new', monospace"> AT_stmt_list( 0x00000000 )</font></div><div><font face="'courier new', monospace"><br>
</font></div><div><font face="'courier new', monospace">0x00000038: TAG_namespace [2] *</font></div><div><font face="'courier new', monospace"> AT_sibling( {0x0000005c} )</font></div><div>
<font face="'courier new', monospace"> AT_name( "__main__" )</font></div><div><font face="'courier new', monospace"> AT_decl_file( "/Users/joe/Documents/Code/others/clay/foo.clay" )</font></div>
<div><font face="'courier new', monospace"> AT_decl_line( 1 )</font></div><div><font face="'courier new', monospace"><br></font></div><div><font face="'courier new', monospace">0x00000048: TAG_subprogram [3] </font></div>
<div><font face="'courier new', monospace"> AT_MIPS_linkage_name( "_main" )</font></div><div><font face="'courier new', monospace"> AT_name( "foo" )</font></div>
<div><font face="'courier new', monospace"> AT_decl_file( "/Users/joe/Documents/Code/others/clay/foo.clay" )</font></div><div><font face="'courier new', monospace"> AT_decl_line( 1 )</font></div>
<div><font face="'courier new', monospace"> AT_type( {0x0000005c} ( Int32 ) )</font></div><div><font face="'courier new', monospace"> AT_external( 0x01 )</font></div>
<div><font face="'courier new', monospace"> AT_declaration( 0x01 )</font></div><div><font face="'courier new', monospace"><br></font></div><div><font face="'courier new', monospace">0x0000005b: NULL</font></div>
<div><font face="'courier new', monospace"><br></font></div><div><font face="'courier new', monospace">0x0000005c: TAG_base_type [4] </font></div><div><font face="'courier new', monospace"> AT_name( "Int32" )</font></div>
<div><font face="'courier new', monospace"> AT_encoding( DW_ATE_signed )</font></div><div><font face="'courier new', monospace"> AT_byte_size( 0x04 )</font></div><div><font face="'courier new', monospace"><br>
</font></div><div><font face="'courier new', monospace">0x00000065: TAG_subprogram [5] *</font></div><div><font face="'courier new', monospace"> AT_specification( {0x00000048} ( "_main" ) )</font></div>
<div><font face="'courier new', monospace"> AT_low_pc( 0x0000000000000020 )</font></div><div><font face="'courier new', monospace"> AT_high_pc( 0x0000000000000051 )</font></div>
<div><font face="'courier new', monospace"> AT_frame_base( rbp )</font></div><div><font face="'courier new', monospace"><br></font></div><div><font face="'courier new', monospace">0x0000007c: TAG_lexical_block [6] *</font></div>
<div><font face="'courier new', monospace"> AT_low_pc( 0x0000000000000028 )</font></div><div><font face="'courier new', monospace"> AT_high_pc( 0x000000000000004c )</font></div>
<div><font face="'courier new', monospace"><br></font></div><div><font face="'courier new', monospace">0x0000008d: TAG_lexical_block [6] *</font></div><div><font face="'courier new', monospace"> AT_low_pc( 0x0000000000000028 )</font></div>
<div><font face="'courier new', monospace"> AT_high_pc( 0x000000000000004c )</font></div><div><font face="'courier new', monospace"><br></font></div><div><font face="'courier new', monospace">0x0000009e: TAG_variable [7] </font></div>
<div><font face="'courier new', monospace"> AT_name( "bar" )</font></div><div><font face="'courier new', monospace"> AT_decl_file( "/Users/joe/Documents/Code/others/clay/foo.clay" )</font></div>
<div><font face="'courier new', monospace"> AT_decl_line( 2 )</font></div><div><font face="'courier new', monospace"> AT_type( {0x0000005c} ( Int32 ) )</font></div>
<div><font face="'courier new', monospace"><br></font></div><div><font face="'courier new', monospace">0x000000a9: NULL</font></div><div><font face="'courier new', monospace"><br></font></div>
<div><font face="'courier new', monospace">0x000000aa: NULL</font></div><div><font face="'courier new', monospace"><br></font></div><div><font face="'courier new', monospace">0x000000ab: NULL</font></div>
<div><font face="'courier new', monospace"><br></font></div><div><font face="'courier new', monospace">0x000000ac: NULL</font></div><div>---</div></div><div><br></div><div>Am I using llvm.dbg.declare correctly? Is there something missing in my metadata?</div>
<div><br></div><div>-Joe</div>