<div dir="ltr"><div>The reason the module name is <stdin> is because you used input redirection via "< mytestcode.ll" on your command line. This means the shell opened the file and sent it through stdin. Opt never saw your file name. I'm not sure, but the output redirection "> result" may also be keep llc from reading the file. Try this to read and write your file</div><div><br></div><div>
<span style="background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">opt -load ~/mypass/libLLVMMYPASS.so -insert mytestcode.ll -o result.bc</span><br></div><div><span style="background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">llc result.bc</span></div><br clear="all"><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">~Craig</div></div><br></div><br><div class="gmail_quote"><div dir="ltr">On Tue, Jun 12, 2018 at 2:24 PM Yin Liu via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Hello,<br></div><div><br></div><div>I met a very strange error after transforming IR code.</div><div><br></div><div>What I did is that I create a function and insert it into the original program's IR code.</div><div><br></div><div>I use following command to load my pass and generate the transformed bytecode (the "result").</div><div><div>opt -load ~/mypass/libLLVMMYPASS.so -insert < mytestcode.ll > result</div></div><div><br></div><div>Then, I try to compile it to assembly code via llc</div><div>llc result<br></div><div><br></div><div>After that, the error occurs:</div><div>llc: result:1:1: error: expected top-level entity<br></div><div><br></div><div>It seems like the error is about the IR code.</div><div>Thus, I dump the module during my pass, it turns out that there is only one line different:</div><div>1. when I just open the IR code - mytestcode.ll, the first line is:</div><div>; ModuleID = './mytestcode.c'</div><div><br></div><div>2. when I dump it during my pass, the first line is:</div><div>; ModuleID = '<stdin>'<br></div><div><br></div><div>The strange thing is, after transformation by my pass, I also dump the transformed module, and copy all the dumped content to a file, and then, perform "llc" on it. Surprisingly, I found It works well. I also compile it to an executable and run it. The result is correct for my transformation.</div><div><br></div><div>Thus, I'm so confused about:</div><div>1. what the different between "; ModuleID = './mytestcode.c'" and "; ModuleID = '<stdin>'". Will it impact the "llc" and trigger the error?</div><div><br></div><div>2. when I read the module during my pass, why the ModuleID has been changed from './mytestcode.c' to '<stdin>'</div><div><br></div><div>3. why does the error "llc: result:1:1: error: expected top-level entity" happen, and why does the IR code dumped during my pass work well?</div><div><br></div><div>Thanks in advance!</div><div><br></div><div>Best,</div><div>Yin</div></div>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>