forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 14
Closed
Labels
A-llvmAffects the LLVM AVR backendAffects the LLVM AVR backendhas-llvm-commitThis issue should be fixed in upstream LLVMThis issue should be fixed in upstream LLVMhas-reduced-testcaseA small LLVM IR file exists that demonstrates the problemA small LLVM IR file exists that demonstrates the problem
Description
Here's the minimized LLVM IR:
target triple = "avr-atmel-none"
define internal fastcc void @loopy() unnamed_addr{
start:
br label %bb7.preheader
bb7.preheader: ; preds = %bb10, %start
%i = phi i8 [ 0, %start ], [ %j, %bb10 ]
%j = phi i8 [ 1, %start ], [ %next, %bb10 ]
br label %bb10
bb4: ; preds = %bb10
ret void
bb10: ; preds = %bb7.preheader
tail call fastcc void @observe(i8 %i, i8 1)
%0 = icmp ult i8 %j, 20
%1 = zext i1 %0 to i8
%next = add i8 %j, %1
br i1 %0, label %bb7.preheader, label %bb4
}
declare void @observe(i8, i8) unnamed_addr;
And here's the generated assembly:
loopy: ; @loopy
; BB#0: ; %start
push r16
push r17
ldi r17, 1
ldi r24, 0
LBB0_1: ; %bb4
pop r17
pop r16
ret
LBB0_2: ; %bb10
ldi r17, 0
LBB0_3: ; %bb10
add r17, r16
cpi r16, 20
mov r24, r16
brlo .+2
rjmp LBB0_1
; BB#4: ; %bb7.preheader
mov r16, r17
ldi r17, 1
ldi r22, 1
call observe
cpi r16, 20
brlo .+2
rjmp LBB0_2
rjmp LBB0_3
The problem is that BB#0
doesn't jump to its continuation, and so falls through to LBB0_1
which should only happen at the end of the loop.
Metadata
Metadata
Assignees
Labels
A-llvmAffects the LLVM AVR backendAffects the LLVM AVR backendhas-llvm-commitThis issue should be fixed in upstream LLVMThis issue should be fixed in upstream LLVMhas-reduced-testcaseA small LLVM IR file exists that demonstrates the problemA small LLVM IR file exists that demonstrates the problem