<div dir="ltr"><div dir="ltr">Hi Dwight,<div><br></div><div>Welcome to LLVM-dev! A few comments below. Cc'ing a few people who hopefully can add info on some of the specific issues here.</div><div><br></div><div>Teresa</div></div><br><div class="gmail_quote"></div><div dir="ltr" class="gmail_attr">On Wed, Sep 18, 2019 at 9:04 AM Dwight Guth via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">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="auto"><div class="gmail_quote" dir="auto"><div dir="ltr" class="gmail_attr">Hi,<br></div><div dir="ltr"><div><br></div><div>I am lead developer of a project that is using LLVM to implement an ahead-of-time compiled functional language. We use llc -tailcallopt to ensure that functions that end in a tail call are compiled to a tail call at the machine level, because we have a number of cases in our interpreter where functions with different function signatures call one another in deeply nested recursive calls. </div></div></div></div></blockquote><div><br></div><div>Maybe a naive question - would that be fixable?</div><div> </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="auto"><div class="gmail_quote" dir="auto"><div dir="ltr"><div>We can't use `musttail` because the callee and caller often have different signatures.</div><div><br></div><div>We would like to support link time optimization in our programming language, because performance is important to us. However, there is no clang flag to enable the GuaranteedTailCallOpt flag, and the only way to pass target options to the lto plugin currently is via an unsupported API that parses those flags to static variables. </div></div></div></div></blockquote><div><br></div><div>I assume you mean passing internal options via -mllvm through the linker?</div><div> </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="auto"><div class="gmail_quote" dir="auto"><div dir="ltr"><div>This works on Linux, but the Mac OS linker does not actually initialize the TargetOptions that it passes as an llvm::lto::Config based on the parsed static variables, and Apple is uninterested in spending time supporting an unsupported LLVM API like -mllvm (understandably).</div></div></div></div></blockquote><div><br></div><div>lto::Config is part of the new LTO API. For the most part ld64 uses the old legacy LTO API, and therefore does not even use llvm::lto::Config (the one exception is to share the code for computing a cache key). But it doesn't use this when invoking the code generation passes. I'm surprised that ld64 would not have a way to pass through internal llvm options - presumably that is necessary for debugging and tuning. <a class="gmail_plusreply" id="m_5552590222737411273m_1307007006384030996plusReplyChip-0" href="mailto:stevenwu@apple.com" target="_blank">+Steven Wu</a> to give more info here (I work on Linux code and therefore have only directly used gold and lld, which both use the new LTO API).</div><div><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="auto"><div class="gmail_quote" dir="auto"><div dir="ltr"><div><br></div><div>Is there a change to the LLVM project that you might be willing to accept that we might be able to create a patch for that would allow us to get link time optimization enabled in our programming language on Mac OS, at least in the future? And if so, is it possible that someone could give me pointers on how to proceed? I'm a relative novice studying this code and I'm not really sure how all the components fit together at a high level and thus what the correct design for something like this would be.</div></div></div></div></blockquote><div><br></div><div>I guess the question is what interface would work for you. Would passing an internal option like what works on lld or what you are doing with llc be acceptable?</div><div><br></div><div>If you need a more officially supported mechanism, IMO the best way is probably to create a new function attribute (e.g. 'forcetailcall' or something equivalent to what GuaranteedTailCallOpt implies). That would be completely linker agnostic and also not rely on internal options.</div><div><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="auto"><div class="gmail_quote" dir="auto"><div dir="ltr"><div><br></div><div>Or am I going to have to resign myself to waiting until lld is well supported at linking mach-o files?</div></div></div></div></blockquote><div><br></div><div><a class="gmail_plusreply" id="m_5552590222737411273m_1307007006384030996plusReplyChip-1" href="mailto:ruiu@google.com" target="_blank">+Rui Ueyama</a> and </div><div><a class="gmail_plusreply" id="plusReplyChip-3" href="mailto:echristo@gmail.com" tabindex="-1">+Eric Christopher</a> to comment on lld Mach-O support.</div><div><br></div><div>Teresa</div><div> <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="auto"><div class="gmail_quote" dir="auto"><div dir="ltr"><div><br></div><div>Thanks,<br></div><div><div><br>-- <br><div dir="ltr"><div dir="ltr"><div><div dir="ltr"><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-family:arial,helvetica,sans-serif"><span style="font-size:12pt;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">Dwight Guth</span></span></p><p style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-family:arial,helvetica,sans-serif"><span style="font-size:10pt;color:rgb(0,153,204);background-color:transparent;font-weight:700;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">Director of Engineering<br></span></span></p><span style="font-family:arial,helvetica,sans-serif"><br></span><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-family:arial,helvetica,sans-serif"><span style="font-size:10pt;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">Email: <a href="mailto:dwight.guth@runtimeverification.com" rel="noreferrer noreferrer" target="_blank">dwight.guth@runtimeverification.com</a></span></span></p><span style="font-family:arial,helvetica,sans-serif"><br></span><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><a href="https://www.runtimeverification.com" rel="noreferrer noreferrer" target="_blank"><span style="font-family:arial,helvetica,sans-serif"><span style="font-size:10pt;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"><img style="border: medium none;" width="127" height="29"></span></span></a></p><span style="font-family:arial,helvetica,sans-serif"><br></span><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-family:arial,helvetica,sans-serif"><a href="https://github.com/dwightguth" style="text-decoration:none" rel="noreferrer noreferrer" target="_blank"><span style="font-size:11pt;color:rgb(17,85,204);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:underline;vertical-align:baseline;white-space:pre-wrap"><img style="border: medium none;" width="22" height="22"></span></a><span style="font-size:11pt;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"> </span><a href="https://www.linkedin.com/company/3142238/" style="text-decoration:none" rel="noreferrer noreferrer" target="_blank"><span style="font-size:11pt;color:rgb(17,85,204);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:underline;vertical-align:baseline;white-space:pre-wrap"><img style="border: medium none;" width="22" height="22"></span></a><span style="font-size:11pt;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">  </span><a href="https://twitter.com/rv_inc" style="text-decoration:none" rel="noreferrer noreferrer" target="_blank"><span style="font-size:11pt;color:rgb(17,85,204);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:underline;vertical-align:baseline;white-space:pre-wrap"><img style="border: medium none;" width="23" height="23"></span></a></span></p><span style="font-family:arial,helvetica,sans-serif"><br></span><br><br><br></div></div></div></div></div></div></div>
</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><br clear="all"><div><br></div>-- <br><div dir="ltr"><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></div>