llc: LLVM ERROR: Cannot select:

llc: LLVM ERROR: Cannot select:

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
}

我不明白 llc 说的是什么。 prg.ll 输出来自我的 avr 自定义编译器。我在这个 link: avr-llvm backend 找到了 avr 的 LLVM 后端。到目前为止,后端工作正常。有人看出问题所在了吗?

提前致谢!

我将编译器中的 bool 类型宽度从 i1 更改为 i8(在本例中,x 是 bool)。那解决了我的问题。 avr-backend 可能不支持 i1 或其他。如果他们回答我到底是什么问题,我会 post 问题跟踪器的答案。


问题跟踪器的回答:

A bunch of the LLVM backends handle i1 badly (which is pretty sad). This is why almost all frontends define bool to be i8.

I would definitely like to fix this though. By the looks of this, it is probably failing on the zext from i1 operation. All that should be needed is to promote the i1 to an i8 internally.