Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

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!

question from:https://stackoverflow.com/questions/65829059/llvm-error-error-expected-instruction-opcode

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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/


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...