如何生成LLVM位码 [英] How to generate LLVM bitcode
本文介绍了如何生成LLVM位码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要生成在文档中编写的位代码文件(.bc):
hello.c
#include <stdio.h>
int main() {
printf("hello world\n");
return 0;
}
然后
% clang -O3 -emit-llvm hello.c -c -o hello.bc
和
% lli hello.bc
运行代码,但输出奇怪:
to run the code, but I have weird output:
lli: Attributes.cpp:367: static llvm::AttrListPtr llvm::AttrListPtr::get(llvm::LLVMContext &, ArrayRef<llvm::AttributeWithIndex>): Assertion `Attrs[i].Attrs.hasAttributes() && "Pointless attribute!"' failed.
0 lli 0x0000000000c944ff
1 lli 0x0000000000c94a79
2 libpthread.so.0 0x00007fbf12a88060
3 libc.so.6 0x00007fbf11d663e5 gsignal + 53
4 libc.so.6 0x00007fbf11d69b4b abort + 379
5 libc.so.6 0x00007fbf11d5ed8d __assert_fail + 221
6 lli 0x0000000000b8b285 llvm::AttrListPtr::get(llvm::LLVMContext&, llvm::ArrayRef<llvm::AttributeWithIndex>) + 517
7 lli 0x000000000051f14e llvm::BitcodeReader::ParseAttributeBlock() + 494
8 lli 0x00000000005249f1 llvm::BitcodeReader::ParseModule(bool) + 497
9 lli 0x0000000000526617 llvm::BitcodeReader::ParseBitcodeInto(llvm::Module*) + 359
10 lli 0x000000000052eae9 llvm::getLazyBitcodeModule(llvm::MemoryBuffer*, llvm::LLVMContext&, std::string*) + 569
11 lli 0x000000000052ee3f llvm::ParseBitcodeFile(llvm::MemoryBuffer*, llvm::LLVMContext&, std::string*) + 15
12 lli 0x00000000004ea29a llvm::ParseIR(llvm::MemoryBuffer*, llvm::SMDiagnostic&, llvm::LLVMContext&) + 170
13 lli 0x00000000004e7078 llvm::ParseIRFile(std::string const&, llvm::SMDiagnostic&, llvm::LLVMContext&) + 536
14 lli 0x00000000004e3a58 main + 312
15 libc.so.6 0x00007fbf11d5130d __libc_start_main + 237
16 lli 0x00000000004e1f49
Stack dump:
0. Program arguments: lli hello.bc
Aborted
出了什么问题.为什么它不起作用?
What is the problem. Why it does not work?
推荐答案
您的特定LLVM/Clang版本可能存在问题.您是否已从启用了断言的源代码进行编译?您只需要修复此错误的较新版本即可.(请参见 http://llvm.org/bugs/show_bug.cgi?id=15786获取与旧版本相似的断言失败报告.)
That is likely a problem with your particular LLVM/Clang version. Have you compiled it from source with assertions enabled? You just need to get a newer build with that bug fixed. (See http://llvm.org/bugs/show_bug.cgi?id=15786 for a similar assertion failure report with older version.)
FWIW-该程序可以在我的本地SVN版本(clang版本3.4(trunk 182672))上正常运行.
FWIW - that program works fine on my local SVN build (clang version 3.4 (trunk 182672)).
这篇关于如何生成LLVM位码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文