llvm - 有限责任公司 : LLVM ERROR: Cannot select:

标签 llvm

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自定义编译器。我找到了 avr 的 LLVM 后端在此链接:avr-llvm backend .到目前为止,后端工作正常。有人看到有什么问题吗?

提前致谢!

最佳答案

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

问题跟踪器的答案:

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.

关于llvm - 有限责任公司 : LLVM ERROR: Cannot select:,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39320834/

相关文章:

visual-studio-2010 - Windows中的llvm-config在哪里?

macos - Mavericks 中没有 llvm opt 命令

javascript - 如何将 javascript 转换为 LLVM IR?

ios - App Store 允许自动引用计数 (ARC) 应用程序吗?

compiler-construction - 如果clang是编译器的前端,那么为什么它可以生成可执行文件?

c++ - 使用 LLVM 链接器生成 C 代码

c++ - 使用 LLVM 的可执行文件的动态符号解析

c++ - 如何在 LLVM 中声明一个函数并在以后定义它

c++ - CMake 和 Clang 工具链接错误(树外)

llvm - 将 IR 操作数与 LLVM 中的常量进行比较