<div dir="ltr"><div>Hi,</div><div><br></div><div>I have bitcode files built by LLVM v3.3 and need to process them using v3.4 tools. While I don't expect a lot of backward compatibility in LLVM, luckily it seems everything's working fine, except for reading source line information attached to instructions. I use this piece of code [0] to get source line information. For v3.4, <span style="font-family:'courier new',monospace">instruction.getMetadata </span><font face="arial, helvetica, sans-serif">returns NULL.</font></div>
<div><br></div><div>I used llvm-dis to see what's going on. For a sample program [1], llvm-dis v3.3, of course, didn't have problems and dumped [2], showing dbg info. However, llvm-dis v3.4 seemed to have problems grabbing the dbg info [3].</div>
<div><br></div><div>Any idea how I can modify the code [0] to solve the problem? Attached is the bitcode file used as an example in this mail. It was complied with clang v3.3 -g -O0. </div><div><br></div><div>Thanks,</div>
<div>James</div><div><br></div><div><p class=""><font face="arial, helvetica, sans-serif">[0]</font></p><p class=""><font face="courier new, monospace">llvm::LLVMContext llvmContext;</font></p><p class=""><font face="courier new, monospace"><span class="">unsigned</span> dbgKind = llvmContext.getMDKindID(<span class="">"dbg"</span>);</font></p>
<p class=""><font face="courier new, monospace"><span class="">if</span> (MDNode *N = instruction.getMetadata(dbgKind))</font><span style="font-family:'courier new',monospace">{</span></p><p class=""><font face="courier new, monospace">    DILocation location(N);</font></p>
<p class=""><font face="courier new, monospace">    fileDirectoryName = location.getDirectory();</font></p><p class=""><font face="courier new, monospace">    fileName = location.getFilename();</font></p><p class=""><font face="courier new, monospace">    lineNumber = location.getLineNumber();</font></p>
<p class=""><font face="courier new, monospace">    columnNumber = location.getColumnNumber();</font></p><p class=""></p><p class=""><font face="courier new, monospace">}</font></p></div>[1]<br><div>







<p class=""><font face="courier new, monospace">int main(int argc, char **argv)</font><font face="courier new, monospace">{</font><span style="font-family:'courier new',monospace">    </span></p><p class=""><span style="font-family:'courier new',monospace">   return 0;</span></p>
<p class=""><span style="font-family:'courier new',monospace">}</span></p><p class="">[2]</p></div><div>







<p class=""><font face="courier new, monospace">define i32 @main(i32 %argc, i8** %argv) #0 {</font></p>
<p class=""><font face="courier new, monospace">entry:</font></p>
<p class=""><font face="courier new, monospace">  %retval = alloca i32, align 4</font></p>
<p class=""><font face="courier new, monospace">  %argc.addr = alloca i32, align 4</font></p>
<p class=""><font face="courier new, monospace">  %argv.addr = alloca i8**, align 8</font></p>
<p class=""><font face="courier new, monospace">  store i32 0, i32* %retval</font></p>
<p class=""><font face="courier new, monospace">  store i32 %argc, i32* %argc.addr, align 4</font></p>
<p class=""><font face="courier new, monospace">  call void @llvm.dbg.declare(metadata !{i32* %argc.addr}, metadata !12), !dbg !13</font></p>
<p class=""><font face="courier new, monospace">  store i8** %argv, i8*** %argv.addr, align 8</font></p>
<p class=""><font face="courier new, monospace">  call void @llvm.dbg.declare(metadata !{i8*** %argv.addr}, metadata !14), !dbg !13</font></p>
<p class=""><font face="courier new, monospace">  ret i32 0, !dbg !15</font></p>
<p class=""><font face="courier new, monospace">}</font></p><p class="">[3]<br></p><p class=""><font face="courier new, monospace">define i32 @main(i32 %argc, i8** %argv) #0 {</font></p><p class=""><font face="courier new, monospace">entry:</font></p>
<p class=""><font face="courier new, monospace">  %retval = alloca i32, align 4</font></p><p class=""><font face="courier new, monospace">  %argc.addr = alloca i32, align 4</font></p><p class=""><font face="courier new, monospace">  %argv.addr = alloca i8**, align 8</font></p>
<p class=""><font face="courier new, monospace">  store i32 0, i32* %retval</font></p><p class=""><font face="courier new, monospace">  store i32 %argc, i32* %argc.addr, align 4</font></p><p class=""><font face="courier new, monospace">  store i8** %argv, i8*** %argv.addr, align 8</font></p>
<p class=""><font face="courier new, monospace">  ret i32 0</font></p><p class="">
















</p><p class=""><font face="courier new, monospace">}</font></p></div></div>