<div dir="ltr">Hi all.<div><br><div>There are two steps in LTO codegen so the problem is how to pass ABI info into LTO code generator. <br></div><div><br></div><div>The easier way is pass -target-abi via option to LTO codegen, but there is linking issue when linking two bitcodes generated by different -mabi option. (see <a href="https://reviews.llvm.org/D71387#1792169">https://reviews.llvm.org/D71387#1792169</a>)</div><div><br></div><div><div>Usually the ABI info  for a file is derived from target triple, mcpu or -mabi, but in RISC-V, target-abi is only derived from -mabi and -mattr option, so the one of solutions is encoding target-abi in IR via LLVM module flags metadata.</div><div><br></div><div>But there is an another issue in assembler. In current LLVM design, there is no mechanism to extract info from IR before AsmBackend construction, so I  use some little weird approach to init target-abi option before construct AsmBackend[1] or reassign target-abi option in 

getSubtargetImpl 

and do some hack in backend[2].</div><div><br></div><div>1. <a href="https://reviews.llvm.org/D72245#change-sHyISc6hOqcy">https://reviews.llvm.org/D72245#change-sHyISc6hOqcy</a> (see llc.cpp<span style="color:rgb(0,0,0);font-family:"Segoe UI","Segoe UI Emoji","Segoe UI Symbol",Lato,"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:14px;font-weight:700">)</span></div><div>2. <a href="https://reviews.llvm.org/D72246">https://reviews.llvm.org/D72246</a> (see RISCVAsmBackend.h)</div><div><br></div><div>I think [1] and [2] are not good enough, the other ideals like<br></div><div><br></div><div>3. encode target abi info in triple name. ex. riscv64-unknown-elf-lp64d</div><div>4. encode target-abi into in target-feature (maybe it's not a good ideal because mips reverted this approach </div><div>before. <a href="http://llvm.org/viewvc/llvm-project?view=revision&revision=227583">http://llvm.org/viewvc/llvm-project?view=revision&revision=227583</a>)<br></div><div><br></div><div>5. users should pass target-abi themselves. (append -Wl,-plugin-opt=-target-abi=ipl32f when compiling with 

-mabi=ilp32f)<br></div><div><br></div><div></div><div>Is it a good idea to encode target-abi into bitcode? </div><div>If yes, is there another good approach to fix AsmBackend issue?</div><div>I’d appreciate <span class="gmail-il">any</span> help or <span class="gmail-il">suggestions</span>.  <br></div><div><br></div><div>Thanks.</div><div><br></div><div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">Best regards,<br>Kuan-Hsu<br><br><br><br></div></div></div></div></div>