[FastISel] Don't force SDAG fallback for libcalls (#171782)

The fast instruction selector should should not force an SDAG fallback
to potentially make use of optimized libcall implementations.

Looking at
3e6fa462f3,
part of the motivation was to avoid libcalls in unoptimized builds for
targets that don't have them, but I believe this should be handled by
Clang directly emitting intrinsics instead of libcalls (which it already
does). FastISel should not second guess this.

Followup to https://github.com/llvm/llvm-project/pull/171288.
This commit is contained in:
Nikita Popov 2025-12-11 14:14:06 +01:00 committed by GitHub
parent 2967815249
commit d33d80fae6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 6 additions and 16 deletions

View File

@ -1565,14 +1565,6 @@ bool FastISel::selectInstruction(const Instruction *I) {
if (const auto *Call = dyn_cast<CallInst>(I)) {
const Function *F = Call->getCalledFunction();
LibFunc Func;
// As a special case, don't handle calls to builtin library functions that
// may be translated directly to target instructions.
if (F && !F->hasLocalLinkage() && F->hasName() &&
LibInfo->getLibFunc(F->getName(), Func) &&
LibInfo->hasOptimizedCodeGen(Func))
return false;
// Don't handle Intrinsic::trap if a trap function is specified.
if (F && F->getIntrinsicID() == Intrinsic::trap &&

View File

@ -63,11 +63,10 @@ define void @test(ptr %a) nounwind ssp minsize {
; MSVC-X86-O0-NEXT: movl ___security_cookie, %eax
; MSVC-X86-O0-NEXT: xorl %esp, %eax
; MSVC-X86-O0-NEXT: movl %eax, {{[0-9]+}}(%esp)
; MSVC-X86-O0-NEXT: movl {{[0-9]+}}(%esp), %ecx
; MSVC-X86-O0-NEXT: movl %esp, %eax
; MSVC-X86-O0-NEXT: movl %ecx, 4(%eax)
; MSVC-X86-O0-NEXT: movl {{[0-9]+}}(%esp), %eax
; MSVC-X86-O0-NEXT: leal {{[0-9]+}}(%esp), %ecx
; MSVC-X86-O0-NEXT: movl %ecx, (%eax)
; MSVC-X86-O0-NEXT: movl %ecx, (%esp)
; MSVC-X86-O0-NEXT: movl %eax, {{[0-9]+}}(%esp)
; MSVC-X86-O0-NEXT: calll _strcpy
; MSVC-X86-O0-NEXT: leal LC, %ecx
; MSVC-X86-O0-NEXT: leal {{[0-9]+}}(%esp), %eax

View File

@ -75,11 +75,10 @@ define void @test(ptr %a) nounwind ssp {
; MSVC-X86-O0-NEXT: movl ___security_cookie, %eax
; MSVC-X86-O0-NEXT: xorl %esp, %eax
; MSVC-X86-O0-NEXT: movl %eax, {{[0-9]+}}(%esp)
; MSVC-X86-O0-NEXT: movl {{[0-9]+}}(%esp), %ecx
; MSVC-X86-O0-NEXT: movl %esp, %eax
; MSVC-X86-O0-NEXT: movl %ecx, 4(%eax)
; MSVC-X86-O0-NEXT: movl {{[0-9]+}}(%esp), %eax
; MSVC-X86-O0-NEXT: leal {{[0-9]+}}(%esp), %ecx
; MSVC-X86-O0-NEXT: movl %ecx, (%eax)
; MSVC-X86-O0-NEXT: movl %ecx, (%esp)
; MSVC-X86-O0-NEXT: movl %eax, {{[0-9]+}}(%esp)
; MSVC-X86-O0-NEXT: calll _strcpy
; MSVC-X86-O0-NEXT: leal LC, %ecx
; MSVC-X86-O0-NEXT: leal {{[0-9]+}}(%esp), %eax