Heba Abbud
Heba Abbud

Reputation: 81

llvm error- error expected instruction opcode

I am trying to run this code but I am getting: error: expected instruction opcode label_3:

this is the relevant part of the code:

define void @main(){
%r1 =  alloca [50 x i32]
%r7 = alloca i32
store i32 0 , i32* %r7
label_3:
%r9 = load i32 , i32* %r7
%r8 = getelementptr [258 x i32], [258 x i32]* %r6 , i32 0 , i32 %r9
store i32 0 , i32* %r8
%r10 = add i32 1 , %r9
store i32 %r10 , i32* %r7
%r11 = icmp eq i32 256 , i32 %r10
br i1 %r11 , label %label_4 , label %label_3
label_4:
.....

Thanks in advance!

Upvotes: 2

Views: 1297

Answers (1)

Heba Abbud
Heba Abbud

Reputation: 81

I solved the problem, the problem was that before entering the loop (label_3) we need to close the previous block implicitly and to do that a “Terminator” instruction is required, so I added before label_3: line, br label label_3 for more details read this: https://zanopia.wordpress.com/2010/09/14/understanding-llvm-assembly-with-fractals-part-i/

Upvotes: 6

Related Questions