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.
Teresa
On Tue, Jan 7, 2020 at 6:35 AM Marc via llvm-dev <llvm-dev at
lists.llvm.org>
wrote:
> Hello,
>
> so far I am using standard llvm and writing "standard" llvm pass
> modules, e.g. with RegisterAFLPass(PassManagerBuilder::EP_OptimizerLast,
> foo).
>
> In llvm-9 there is now the new flag to run the module at link time. I
> get a test module compiled but it does not seem to run.
>
> Example module test.cc (based on an llvm example):
>
> #include "llvm/Pass.h"
> #include "llvm/IR/Function.h"
> #include "llvm/Support/raw_ostream.h"
> #include "llvm/IR/LegacyPassManager.h"
> #include "llvm/Transforms/IPO/PassManagerBuilder.h"
> using namespace llvm;
>
> namespace {
> struct Hello : public FunctionPass {
> static char ID;
> Hello() : FunctionPass(ID) {}
>
> bool runOnFunction(Function &F) override {
> errs() << "Hello: ";
> errs().write_escaped(F.getName()) << '\n';
> return false;
> }
> }; // end of struct Hello
> } // end of anonymous namespace
>
> char Hello::ID = 0;
> static RegisterPass<Hello> X("hello", "Hello World
Pass", false, false);
>
> static RegisterStandardPasses Y(
> PassManagerBuilder::EP_FullLinkTimeOptimizationLast,
> [](const PassManagerBuilder &Builder,
> legacy::PassManagerBase &PM) { PM.add(new Hello()); });
>
>
> Compiled with:
> clang++-9 `llvm-config --cxxflags` -Wl,-znodelete -fno-rtti -fpic -O3
> -funroll-loops -Wall -D_FORTIFY_SOURCE=2 -g -I ../include/
> -DVERSION=\"++2.58e\" -Wno-variadic-macros -DLLVMInsTrim_EXPORTS
> -fno-rtti -fPIC -std=gnu++11 -shared test.cc -o test.so `llvm-config
> --ldflags`
>
> And when I try to run it:
> clang -Xclang -load -Xclang ./test.so -Qunused-arguments -g -O3 -flto -o
> foo foo.c
>
> I dont see any of the "Hello: <functioname>" outputs.
> If I set EP_OptimizerLast instead it works, but that at compile time of
> each .c file and that is not what I want to do in my project.
>
> How do I run it correctly?
> Thanks!
>
> Regards,
> Marc
>
> --
> Marc Heuse
> www.mh-sec.de
>
> PGP: AF3D 1D4C D810 F0BB 977D 3807 C7EE D0A0 6BE9 F573
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
--
Teresa Johnson | Software Engineer | tejohnson at google.com |
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20200107/99952843/attachment.html>