[clang] [clang][codegen] Fix possible crash when setting TBAA metadata on FP math libcalls (PR #108575)
Martin Storsjö via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 16 03:46:21 PDT 2024
mstorsjo wrote:
I managed to reduce the breakage to the following snippet:
```c
long double powl(long double a, long double b);
long double a() { return powl(2.0L, 2.0L); }
```
Compiled like this:
```
$ clang -target x86_64-w64-mingw32 -S -O2 -o out.s repro.c
```
The output between before and after this change differs like this:
```diff
--- out-good.s 2024-09-16 13:45:09.505125890 +0300
+++ out-bad.s 2024-09-16 13:45:09.533125294 +0300
@@ -10,12 +10,7 @@
.scl 2;
.type 32;
.endef
- .section .rdata,"dr"
- .p2align 2, 0x0 # -- Begin function a
-.LCPI0_0:
- .long 0x40000000 # float 2
- .text
- .globl a
+ .globl a # -- Begin function a
.p2align 4, 0x90
a: # @a
.seh_proc a
@@ -26,16 +21,10 @@
.seh_stackalloc 80
.seh_endprologue
movq %rcx, %rsi
- flds .LCPI0_0(%rip)
- fld %st(0)
- fstpt 48(%rsp)
- fstpt 32(%rsp)
leaq 64(%rsp), %rcx
leaq 48(%rsp), %rdx
leaq 32(%rsp), %r8
callq powl
- fldt 64(%rsp)
- fstpt (%rsi)
movq %rsi, %rax
addq $80, %rsp
popq %rsi
```
I'll push a revert shortly.
https://github.com/llvm/llvm-project/pull/108575
More information about the cfe-commits
mailing list