[llvm] bb6c23b - [NFC][X86] Avoid redundant work inspecting callee
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 1 15:24:55 PST 2021
Author: Philip Reames
Date: 2021-02-01T15:24:41-08:00
New Revision: bb6c23b1f50780390eafd73aac1a2a895a8971a4
URL: https://github.com/llvm/llvm-project/commit/bb6c23b1f50780390eafd73aac1a2a895a8971a4
DIFF: https://github.com/llvm/llvm-project/commit/bb6c23b1f50780390eafd73aac1a2a895a8971a4.diff
LOG: [NFC][X86] Avoid redundant work inspecting callee
Added:
Modified:
llvm/lib/Target/X86/X86FastISel.cpp
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/test/CodeGen/X86/x86-no_caller_saved_registers-preserve.ll
llvm/test/CodeGen/X86/x86-no_caller_saved_registers.ll
Removed:
################################################################################
diff --git a/llvm/lib/Target/X86/X86FastISel.cpp b/llvm/lib/Target/X86/X86FastISel.cpp
index caf158102230..6838d39e13e8 100644
--- a/llvm/lib/Target/X86/X86FastISel.cpp
+++ b/llvm/lib/Target/X86/X86FastISel.cpp
@@ -3206,7 +3206,6 @@ bool X86FastISel::fastLowerCall(CallLoweringInfo &CLI) {
bool IsWin64 = Subtarget->isCallingConvWin64(CC);
const CallInst *CI = dyn_cast_or_null<CallInst>(CLI.CB);
- const Function *CalledFn = CI ? CI->getCalledFunction() : nullptr;
// Call / invoke instructions with NoCfCheck attribute require special
// handling.
@@ -3215,8 +3214,7 @@ bool X86FastISel::fastLowerCall(CallLoweringInfo &CLI) {
return false;
// Functions with no_caller_saved_registers that need special handling.
- if ((CI && CI->hasFnAttr("no_caller_saved_registers")) ||
- (CalledFn && CalledFn->hasFnAttribute("no_caller_saved_registers")))
+ if ((CI && CI->hasFnAttr("no_caller_saved_registers")))
return false;
// Functions using thunks for indirect calls need to use SDISel.
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 9a1c9bf7aa3b..5befee9f7ce7 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -3910,9 +3910,7 @@ X86TargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
CallConv == CallingConv::Tail;
X86MachineFunctionInfo *X86Info = MF.getInfo<X86MachineFunctionInfo>();
const auto *CI = dyn_cast_or_null<CallInst>(CLI.CB);
- const Function *Fn = CI ? CI->getCalledFunction() : nullptr;
- bool HasNCSR = (CI && CI->hasFnAttr("no_caller_saved_registers")) ||
- (Fn && Fn->hasFnAttribute("no_caller_saved_registers"));
+ bool HasNCSR = (CI && CI->hasFnAttr("no_caller_saved_registers"));
const auto *II = dyn_cast_or_null<InvokeInst>(CLI.CB);
bool HasNoCfCheck =
(CI && CI->doesNoCfCheck()) || (II && II->doesNoCfCheck());
diff --git a/llvm/test/CodeGen/X86/x86-no_caller_saved_registers-preserve.ll b/llvm/test/CodeGen/X86/x86-no_caller_saved_registers-preserve.ll
index 2687e735300b..bfb963bb7540 100644
--- a/llvm/test/CodeGen/X86/x86-no_caller_saved_registers-preserve.ll
+++ b/llvm/test/CodeGen/X86/x86-no_caller_saved_registers-preserve.ll
@@ -41,7 +41,7 @@ define x86_64_sysvcc float @foo(i32 %a0, i32 %a1, float %b0) {
; CHECK-NEXT: cvtsi2ss %eax, %xmm0
; CHECK-NEXT: addss %xmm0, %xmm1
; CHECK: retq
- %call = call i32 @bar(i32 %a0, i32 %a1, float %b0) #0
+ %call = call i32 @bar(i32 %a0, i32 %a1, float %b0)
%c0 = add i32 %a0, %call
%c1 = add i32 %c0, %a1
%c2 = sitofp i32 %c1 to float
diff --git a/llvm/test/CodeGen/X86/x86-no_caller_saved_registers.ll b/llvm/test/CodeGen/X86/x86-no_caller_saved_registers.ll
index 7fb82d15b85e..014470f33149 100644
--- a/llvm/test/CodeGen/X86/x86-no_caller_saved_registers.ll
+++ b/llvm/test/CodeGen/X86/x86-no_caller_saved_registers.ll
@@ -28,4 +28,13 @@ entry:
ret void
}
+; Same as foo, but rely on attribute on @bar decl, not callsite
+define x86_intrcc void @baz(i8* byval(i8) nocapture readnone %c) {
+; CHECK-LABEL: baz
+; CHECK-NOT: xmm
+entry:
+ tail call i32 @bar(i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8)
+ ret void
+}
+
attributes #0 = { "no_caller_saved_registers" }
More information about the llvm-commits
mailing list