https://bugs.llvm.org/show_bug.cgi?id=51340
Bug ID: 51340
Summary: Wrong code generated for x86 inline assembly
Product: clang
Version: 12.0
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: C
Assignee: unassignedclangb...@nondot.org
Reporter: pgof...@codeweavers.com
CC: blitzrak...@gmail.com, dgre...@apple.com,
erik.pilking...@gmail.com, llvm-bugs@lists.llvm.org,
richard-l...@metafoo.co.uk
Created attachment 25105
--> https://bugs.llvm.org/attachment.cgi?id=25105&action=edit
Isolated test case
The bug affects wine-mono project (compiling WPF code with clang).
I am attaching an isolated test case which reproduces the issue which isolates
the miscompiled code.
When compiled with 'clang -fms-extensions -m32 ./clang_bug.c' wrongly
translates 'movss fi.f,xmm1;' instruction. Instead of referencing the
address on stack it uses eax as destination address where the compiler has
stored the stack address before the asm block. The eax has been overwritten by
prior instructions in the assembly. 'movss fi.f,xmm1;' is also translated
wrong using 'ecx' where the compiler has also stored the same stack address of
'fi' variable.
The issue is not reproducible if not using union here (e. g., just defining
'fi' as float or int). It is also not reproducible when adding '-O2' to
compiler flags.
Here is the relevant asm compilation result for the wrong case:
round_func: # @round_func
.cfi_startproc
# %bb.0:
pushl %ebp
.cfi_def_cfa_offset 8
.cfi_offset %ebp, -8
movl %esp, %ebp
.cfi_def_cfa_register %ebp
subl $8, %esp
movss 8(%ebp), %xmm0 # xmm0 = mem[0],zero,zero,zero
leal -8(%ebp), %eax
leal -8(%ebp), %ecx
#APP
movss 8(%ebp), %xmm0 # xmm0 = mem[0],zero,zero,zero
cvtss2si %xmm0, %eax
cvtsi2ss %eax, %xmm1
subss %xmm0, %xmm1
movss round_func.negHalf, %xmm0 # xmm0 = mem[0],zero,zero,zero
cmpless %xmm0, %xmm1
movss %xmm1, (%eax)
subl (%ecx), %eax
#NO_APP
addl $8, %esp
popl %ebp
.cfi_def_cfa %esp, 4
retl
.Lfunc_end0:
.size round_func, .Lfunc_end0-round_func
.cfi_endproc
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs