LLVM - 使用clang自动运行自己的传递 [英] LLVM - Run Own Pass automatically with clang

查看:202
本文介绍了LLVM - 使用clang自动运行自己的传递的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我将它们集成在llvm中(非动态加载)。在输入时,它们甚至会列在优化可用部分:

  opt --help-隐藏

我现在要自动运行自己的一个通行证作为 strong>当我调用clang:

  clang ./hello.bc -o ./hello 

或甚至使用c代码:

  clang ./hello.c -o ./hello 

,生成修改的ByteCode并将其写入新的.bc文件:

  opt -my-pass< ./hello.bc> ./hello_optimized.bc 



当我用clang编译修改的.bc时,正常的clang优化会再次运行,它会破坏我手动执行的pass的优化:

  clang -O0 -m32 ./hello_optimized.bc -o ./hello_optimized 

我的问题是:




  • 如何自动运行我自己的书面传递,最后一次传递是俚语?

  • 另一个可能的解决方案是完全停用所有传递,函数消除clang / opt。

正确的方法是做ang添加您的传递给它构建的传递管理器。参见 clang / lib / CodeGen / BackendUtil.cpp:void EmitAssemblyHelper :: CreatePasses()了解如何处理消毒剂。


I wrote a few own passes for llvm, in order to use them with clang.

I integrated them in llvm (not dynamically loaded). They are even listed in the Optimizations available: section when I type:

opt --help-hidden

I want to run one of own my passes now automatically as the last one when I call clang:

clang ./hello.bc -o ./hello

or even with c-code:

clang ./hello.c -o ./hello

When I run my pass with opt manually, the modified ByteCode is generated and written to a new .bc file:

opt -my-pass < ./hello.bc > ./hello_optimized.bc

When I compile the modified .bc with clang, normal clang Optimizations are run again, which destroy the optimizations of my manual executed pass:

clang -O0 -m32 ./hello_optimized.bc -o ./hello_optimized

My Question is:

  • How can I run my own written pass automatically with clang as the last pass of all?
  • Another possible solution is deactivating all passes completely, or at least the dead code/function elimination of clang/opt. How could I do this?

解决方案

The proper way to do this would be to make clang add your pass to the pass manager it builds. See clang/lib/CodeGen/BackendUtil.cpp:void EmitAssemblyHelper::CreatePasses() for how it's handled for the sanitizers.

这篇关于LLVM - 使用clang自动运行自己的传递的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆