<div dir="ltr">I have not tried the extension points or loading an LTO pass dynamically myself, but adding the author of the patch that added the new EPs (D61738) for insights. Not sure how they interact with dynamically loaded LTO passes.<div>Teresa</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jan 7, 2020 at 6:35 AM Marc 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">Hello,<br>
<br>
so far I am using standard llvm and writing "standard" llvm pass<br>
modules, e.g. with RegisterAFLPass(PassManagerBuilder::EP_OptimizerLast,<br>
foo).<br>
<br>
In llvm-9 there is now the new flag to run the module at link time. I<br>
get a test module compiled but it does not seem to run.<br>
<br>
Example module test.cc (based on an llvm example):<br>
<br>
#include "llvm/Pass.h"<br>
#include "llvm/IR/Function.h"<br>
#include "llvm/Support/raw_ostream.h"<br>
#include "llvm/IR/LegacyPassManager.h"<br>
#include "llvm/Transforms/IPO/PassManagerBuilder.h"<br>
using namespace llvm;<br>
<br>
namespace {<br>
struct Hello : public FunctionPass {<br>
static char ID;<br>
Hello() : FunctionPass(ID) {}<br>
<br>
bool runOnFunction(Function &F) override {<br>
errs() << "Hello: ";<br>
errs().write_escaped(F.getName()) << '\n';<br>
return false;<br>
}<br>
}; // end of struct Hello<br>
} // end of anonymous namespace<br>
<br>
char Hello::ID = 0;<br>
static RegisterPass<Hello> X("hello", "Hello World Pass", false, false);<br>
<br>
static RegisterStandardPasses Y(<br>
PassManagerBuilder::EP_FullLinkTimeOptimizationLast,<br>
[](const PassManagerBuilder &Builder,<br>
legacy::PassManagerBase &PM) { PM.add(new Hello()); });<br>
<br>
<br>
Compiled with:<br>
clang++-9 `llvm-config --cxxflags` -Wl,-znodelete -fno-rtti -fpic -O3<br>
-funroll-loops -Wall -D_FORTIFY_SOURCE=2 -g -I ../include/<br>
-DVERSION=\"++2.58e\" -Wno-variadic-macros -DLLVMInsTrim_EXPORTS<br>
-fno-rtti -fPIC -std=gnu++11 -shared test.cc -o test.so `llvm-config<br>
--ldflags`<br>
<br>
And when I try to run it:<br>
clang -Xclang -load -Xclang ./test.so -Qunused-arguments -g -O3 -flto -o<br>
foo foo.c<br>
<br>
I dont see any of the "Hello: <functioname>" outputs.<br>
If I set EP_OptimizerLast instead it works, but that at compile time of<br>
each .c file and that is not what I want to do in my project.<br>
<br>
How do I run it correctly?<br>
Thanks!<br>
<br>
Regards,<br>
Marc<br>
<br>
-- <br>
Marc Heuse<br>
<a href="http://www.mh-sec.de" rel="noreferrer" target="_blank">www.mh-sec.de</a><br>
<br>
PGP: AF3D 1D4C D810 F0BB 977D 3807 C7EE D0A0 6BE9 F573<br>
_______________________________________________<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"><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>