LLVM - invalid instruction without BB

Does anyone know what this error means? I get an error when I try to parse a file written by LLVMWriteBitcodeToFile. When I reset the module using LLVMDumpModule and manually assemble and parse the file, an error does not occur. The module I'm trying to compile (from LLVMDumpModule) is as follows:

; 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)

Any clues?

+3
source share
2 answers

I don’t know what error message is displayed for which command, but I assume that

call void @RAISE(i32 1), 

and the reason may be that it is after the terminator command (the last instruction in the base unit)

ret i32 %0

and therefore no BB parent

+4
source

, LLVM , IR. , , , .

+2

Source: https://habr.com/ru/post/1771814/


All Articles