Skip to content

Commit 19860ce

Browse files
authored
[Win][X86]Fix issue where _fltused reference is incorrectly issued for vector floating point operations (#146792)
Fixes #146428 _fltused reference generated for vector floating point operations Currently references to _fltused are incorrectly emitted due to the presence of vector floating point operations. This causes spurious references to _fltused in vector floating point system code where the CRT is not used. This issue is limited to the X86 MSVC environment. As described in the bug: * _fltused should only be emitted for floating point operations as the reference is used to initialize some parts of FP CRT support. * Vector floating point operations on their own don't require that CRT support. Have confirmed intended behavior with MSVC team. Fix alters usesMSVCFloatingPoint() to look for floating point instructions/operands rather than floating point or vector floating point.
1 parent 71ffa2a commit 19860ce

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

llvm/lib/Target/X86/X86AsmPrinter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,11 +1002,11 @@ static bool usesMSVCFloatingPoint(const Triple &TT, const Module &M) {
10021002

10031003
for (const Function &F : M) {
10041004
for (const Instruction &I : instructions(F)) {
1005-
if (I.getType()->isFPOrFPVectorTy())
1005+
if (I.getType()->isFloatingPointTy())
10061006
return true;
10071007

10081008
for (const auto &Op : I.operands()) {
1009-
if (Op->getType()->isFPOrFPVectorTy())
1009+
if (Op->getType()->isFloatingPointTy())
10101010
return true;
10111011
}
10121012
}

llvm/test/CodeGen/X86/fltused_vec.ll

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
; The purpose of this test to verify that the fltused symbol is
2+
; not emitted when purely vector floating point operations are used on Windows.
3+
4+
; RUN: llc < %s -mtriple i686-pc-win32 | FileCheck %s
5+
; RUN: llc < %s -mtriple x86_64-pc-win32 | FileCheck %s
6+
7+
@foo = external dso_local global [4 x float], align 16
8+
9+
; Function Attrs: noinline nounwind optnone sspstrong uwtable
10+
define dso_local <4 x float> @func() #0 {
11+
entry:
12+
%__p.addr.i = alloca ptr, align 8
13+
%vector1 = alloca <4 x float>, align 16
14+
store ptr @foo, ptr %__p.addr.i, align 8
15+
%0 = load ptr, ptr %__p.addr.i, align 8
16+
%1 = load <4 x float>, ptr %0, align 16
17+
store <4 x float> %1, ptr %vector1, align 16
18+
%2 = load <4 x float>, ptr %vector1, align 16
19+
ret <4 x float> %2
20+
}
21+
22+
define <4 x float> @mul_vectors(<4 x float> %a, <4 x float> %b) {
23+
entry:
24+
%result = fmul <4 x float> %a, %b
25+
ret <4 x float> %result
26+
}
27+
28+
; _fltused is determined at a module level
29+
; CHECK-NOT: .globl {{_?}}_fltused

0 commit comments

Comments
 (0)