On Sat, Nov 26, 2016 at 07:03:43AM +0000, Wang Nan wrote:
> Identify BPF functions, JIT functions and maps during init. Functions in
> section starting with "perfhook:" are JIT functions. They will be JIT
> compiled and hooked at perfhooks.
> 
> During init of PerfModule, mark JIT functions as AvailableExternallyLinkage.
> LLVM skips functions with linkage like this so they won't be compiled
> into BPF objects.
> 
> Signed-off-by: Wang Nan <wangn...@huawei.com>
...
> +void PerfModule::prepareBPF(void)
> +{
> +     for (llvm::Function *F : JITFunctions)
> +             F->setLinkage(llvm::GlobalValue::AvailableExternallyLinkage);
> +     for (llvm::Function *F : BPFFunctions)
> +             F->setLinkage(llvm::GlobalValue::ExternalLinkage);
> +
> +}
> +
> +void PerfModule::prepareJIT(void)
> +{
> +     for (llvm::Function *F : BPFFunctions)
> +             F->setLinkage(llvm::GlobalValue::AvailableExternallyLinkage);
> +     for (llvm::Function *F : JITFunctions)
> +             F->setLinkage(llvm::GlobalValue::ExternalLinkage);
> +
> +}

Nice trick.
Please document it in the perf+llvm design doc.

Acked-by: Alexei Starovoitov <a...@kernel.org>

Reply via email to