我正在使用LLVM C++ API开发一种新语言,并希望利用优化过程.(注意:我目前正在使用来自源LLVM的最新产品,我认为相当于3.8)
我还没有找到任何使用新PassManager的例子,甚至Clang仍在使用LegacyPassManager.
我所遇到的职位,如这是几年前的,现在提及新PassManager,但他们都仍然使用旧系统.
有没有关于如何使用这个新的(ish)PassManager的示例/教程?新的LLVM项目是否更喜欢PassManager到LegacyPassManager?Clang是否计划迁移,或者这就是遗产系统陷入困境的原因?
我一直在为我的语言编写一个编译器,并希望利用LLVM支持库CommandLine来处理参数解析.
我只添加了两个简单的声明:
static cl::opt<std::string>
OutputFilename("o", cl::desc("Output filename"), cl::value_desc("filename"));
static cl::list<std::string>
InputFilenames("i", cl::desc("Input files"), cl::value_desc("filenames"), cl::OneOrMore);
Run Code Online (Sandbox Code Playgroud)
然后我在main中添加通常的调用:
int main(int argc, char *argv[])
{
cl::ParseCommandLineOptions(argc, argv, " My compiler\n");
...
Run Code Online (Sandbox Code Playgroud)
传递-help给我的程序时问题非常明显:
General options:
-aarch64-neon-syntax - Choose style of NEON code to emit from AArch64 backend:
=generic - Emit generic NEON assembly
=apple - Emit Apple-style NEON assembly
-cppfname=<function name> - Specify the name of the generated function
-cppfor=<string> - Specify the name of the thing to generate
-cppgen …Run Code Online (Sandbox Code Playgroud) 我正在为LLVM中的一种新语言开发编译器,并在生成调试信息时遇到问题.
我还没有找到很多关于如何使用DIBuilder实际生成调试信息的文档,所以我很可能做了一些非常错误的事情.
我一直在看Kaleidoscope示例,因为它是我发现的唯一使用调试信息的示例.我还没有打开Clang来看看他们是如何使用它的,但我很乐意听到有人的声音.
我已经能够使用一些更复杂的示例来编译和运行我的语言,但我在一些基础知识中重新开始添加调试支持.这是我正在尝试编译的简单脚本:
double my_main()
{
return 0.0;
}
Run Code Online (Sandbox Code Playgroud)
这是来自verifyFunction,verifyModule和转储模块的输出.
编辑:注意在下面的编辑中我指出转储是在调用finalize之后正确删除临时.
Failed To Verify Function: my_main error: Expected no forward declarations!
!8 = <temporary!> !{}
Failed To Verify Module: test.str error: Expected no forward declarations!
!8 = <temporary!> !{}
; ModuleID = 'test.str'
define double @my_main() !dbg !6 {
entry:
br label %block, !dbg !10
block: ; preds = %entry
ret double 0.000000e+00, !dbg !10
}
!llvm.module.flags = !{!0, !1}
!llvm.dbg.cu = !{!2} …Run Code Online (Sandbox Code Playgroud)