-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Closed
Labels
bugIndicates an unexpected problem or unintended behaviorIndicates an unexpected problem or unintended behaviorllvm:optimizationsmiscompilationregression
Milestone
Description
; ModuleID = 'test'
source_filename = "test"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
define external ccc void @"_start"() unnamed_addr {
Entry:
%0 = alloca i1
call fastcc void @foo(i1* sret(i1) %0)
%1 = load i1, i1* %0
%2 = zext i1 %1 to i64
call i64 asm sideeffect "syscall", "={rax},{rax},{rdi},~{rcx},~{r11},~{memory},~{dirflag},~{fpsr},~{flags}"(i64 231, i64 %2)
unreachable
}
define internal fastcc void @foo(i1* nocapture nonnull writeonly sret(i1) %0) unnamed_addr noinline {
Entry:
%1 = alloca i1
store i1 true, i1* %1
%2 = bitcast i1* %0 to i8*
%3 = bitcast i1* %1 to i8*
%4 = load i8, i8* %3
store i8 %4, i8* %2
ret void
}
With LLVM 14.0.5, this program gives a correct result at -O0
, but at -O1
the zero-extended i1
value is 255:
$ opt-14 test.ll -o test.bc -filetype=obj -O0
$ llc-14 ./test.bc -O0 -o ./test.o -filetype=obj
$ ld.lld -o test ./test.o && ./test
$ echo $?
1
$ opt-14 test.ll -o test.bc -filetype=obj -O1
$ llc-14 ./test.bc -O1 -o ./test.o -filetype=obj
$ ld.lld -o test ./test.o && ./test
$ echo $?
255
Does not reproduce with LLVM 13.0.1:
$ opt-13 test.ll -o test.bc -filetype=obj -O0
$ llc-13 ./test.bc -O0 -o ./test.o -filetype=obj
$ ld.lld -o test ./test.o && ./test
$ echo $?
1
$ opt-13 test.ll -o test.bc -filetype=obj -O1
$ llc-13 ./test.bc -O1 -o ./test.o -filetype=obj
$ ld.lld -o test ./test.o && ./test
$ echo $?
1
Metadata
Metadata
Assignees
Labels
bugIndicates an unexpected problem or unintended behaviorIndicates an unexpected problem or unintended behaviorllvm:optimizationsmiscompilationregression
Type
Projects
Status
Done