Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
640 views
in Technique[技术] by (71.8m points)

自制编译器生成的llvm ir无法编译为可执行文件

我在使用llvm 编写一个编译器,成功的生成了一定的llvm ir ,但是在生成可执行文件的时候遇到了一些问题。
错误显示为:

Assertion failed: (Val && "isa<> used on a null pointer"), function doit, file /Users/li/code/src_llvm/include/llvm/Support/Casting.h, line 95.
Abort trap: 6

下面是产生错误的ir:

@0 = global double 0.000000e+00

define double @main() {
entry:
store double 2.000000e+00, double* @0
%a = load double, double* @0
%cmptmp = fcmp ult double 1.000000e+00, %a
%booltmp = uitofp i1 %cmptmp to double
%ifcond = fcmp one double %booltmp, 0.000000e+00
br i1 %ifcond, label %then, label %else

then: ; preds = %entry
%a1 = load double, double* @0
%addtmp = fadd double %a1, 1.000000e+00
store double %addtmp, double* @0
br label %ifcont

else: ; preds = %entry
%a2 = load double, double* @0
%subtmp = fsub double %a2, 1.000000e+00
store double %subtmp, double* @0
br label %ifcont

ifcont: ; preds = %else, %then
ret double 0.000000e+00
}

请问这段ir的哪里有问题


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...