<div dir="ltr">You should add your GVs to the llvm.used variable or the llvm.compiler.used variable (see <a href="https://llvm.org/docs/LangRef.html#the-llvm-used-global-variable">https://llvm.org/docs/LangRef.html#the-llvm-used-global-variable</a>). Otherwise it looks globally dead to the linker and LTO. Look at existingcalls to llvm::appendToUsed for examples.<div><br></div><div>Teresa</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Jul 22, 2019 at 7:34 AM Gleb Popov 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:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hello llvm-dev@</div><div><br></div><div>I have a pass that puts a global constant data array into the module. And another pass that gets runned by lld during LTO stage.</div><div><br></div><div>When I look at bytecode files corresponding to source TUs produced by `clang -flto`, I can see GVs inserted by my pass #1. However, when pass #2 gets to run, these GV's are gone.</div><div><br></div><div>I figured out that passing -mllvm -compute-dead=0 to the linker fixes the problem, but I'm not sure if it is right thing to do. Ideally, I'd like to trick LTO to ignore only mine GVs during compute-dead analysis.</div><div><br></div><div>I even tried creating another function that "uses" created GV, but it also got deleted.</div><div><br></div><div>Any hints?</div><div><br></div><div>Thanks in advance.<br></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="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><span style="font-family:Times;font-size:medium"><table cellspacing="0" cellpadding="0"><tbody><tr style="color:rgb(85,85,85);font-family:sans-serif;font-size:small"><td nowrap style="border-top:2px solid rgb(213,15,37)">Teresa Johnson |</td><td nowrap style="border-top:2px solid rgb(51,105,232)"> Software Engineer |</td><td nowrap style="border-top:2px solid rgb(0,153,57)"> <a href="mailto:tejohnson@google.com" target="_blank">tejohnson@google.com</a> |</td><td nowrap style="border-top:2px solid rgb(238,178,17)"><br></td></tr></tbody></table></span></div></div></div>