LLVM - 没有 BB 的无效指令

cap*_*ane 4 llvm

有人知道这个错误是什么意思吗?当我尝试反汇编由 LLVMWriteBitcodeToFile 编写的文件时出现错误。当我使用 LLVMDumpModule 转储模块并手动组装和反汇编文件时,不会发生错误。我试图编译的模块(来自 LLVMDumpModule)看起来像:

; ModuleID = 'Test'

define i32 @a(i32) {
entry:
  %icmp = icmp eq i32 %0, 1                       ; <i1> [#uses=1]
  br i1 %icmp, label %_L2, label %_L3

_L1:                                              ; preds = %_L3
  ret i32 %0
  call void @RAISE(i32 1)
  unreachable

_L2:                                              ; preds = %entry
  ret i32 1

_L3:                                              ; preds = %entry
  br label %_L1
}

declare void @RAISE(i32)
Run Code Online (Sandbox Code Playgroud)

有什么线索吗?

Jas*_*son 5

我不知道针对哪条指令显示错误消息,但我猜是

call void @RAISE(i32 1), 
Run Code Online (Sandbox Code Playgroud)

原因可能是它在终止符指令之后(基本块中的最后一条指令)

ret i32 %0
Run Code Online (Sandbox Code Playgroud)

,因此没有父BB