在llc给了我以下错误:
LLVM ERROR: Cannot select: t20: i8,ch = load<LD1[%x], zext from i1> t0, FrameIndex:i16<0>, undef:i16
t1: i16 = FrameIndex<0>
t3: i16 = undef
In function: main
这是prg.ll文件的内容:
; ModuleID = 'new_module'
define i16 @main() {
entry:
%x = alloca i1
store i1 true, i1* %x
%0 = load i1, i1* %x
%relation_op = icmp eq i1 %0, true
br i1 %relation_op, label %then, label %else
then: ; preds = %entry
store i1 false, i1* %x
br label %ifcont3
else: ; preds = %entry
%1 = load i1, i1* %x
%relation_op1 = icmp eq i1 %1, false
br i1 %relation_op1, label %then2, label %ifcont
then2: ; preds = %else
store i1 true, i1* %x
br label %ifcont
ifcont: ; preds = %then2, %else
br label %ifcont3
ifcont3: ; preds = %ifcont, %then
ret i16 0
}
Run Code Online (Sandbox Code Playgroud)
我不明白llc说什么。该prg.ll输出是从我avr的自定义编译器。我avr在此链接中找到了 LLVM 后端:avr-llvm backend。到目前为止,后端工作正常。有人看到有什么问题吗?
提前致谢!
我将编译器中的 bool 类型宽度从 i1 更改为 i8(在本例中,x 是 bool)。那解决了我的问题。avr-backend 可能不支持 i1 或其他什么。如果他们回答我到底是什么问题,我会发布问题跟踪器的答案。
问题跟踪器的答案:
一堆 LLVM 后端处理 i1 很糟糕(这很可悲)。这就是为什么几乎所有前端都将 bool 定义为 i8。
不过,我绝对想解决这个问题。如此看来,它可能在 i1 操作的 zext 上失败了。所需要做的就是在内部将 i1 升级为 i8。