<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>