[llvm] 9d09db9 - [NFC][X86] Use CallBase interface to simplify code
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 1 15:24:58 PST 2021
Author: Philip Reames
Date: 2021-02-01T15:24:41-08:00
New Revision: 9d09db941ff882a0be761e5d3d170a474bf047c8
URL: https://github.com/llvm/llvm-project/commit/9d09db941ff882a0be761e5d3d170a474bf047c8
DIFF: https://github.com/llvm/llvm-project/commit/9d09db941ff882a0be761e5d3d170a474bf047c8.diff
LOG: [NFC][X86] Use CallBase interface to simplify code
Added:
Modified:
llvm/lib/Target/X86/X86FastISel.cpp
llvm/lib/Target/X86/X86ISelLowering.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/X86/X86FastISel.cpp b/llvm/lib/Target/X86/X86FastISel.cpp
index 6838d39e13e8..2496a814e0a5 100644
--- a/llvm/lib/Target/X86/X86FastISel.cpp
+++ b/llvm/lib/Target/X86/X86FastISel.cpp
@@ -3200,21 +3200,19 @@ bool X86FastISel::fastLowerCall(CallLoweringInfo &CLI) {
bool &IsTailCall = CLI.IsTailCall;
bool IsVarArg = CLI.IsVarArg;
const Value *Callee = CLI.Callee;
- MCSymbol *Symbol = CLI.Symbol;
+ MCSymbol *Symbol = CLI.Symbol;
+ const auto *CB = CLI.CB;
bool Is64Bit = Subtarget->is64Bit();
bool IsWin64 = Subtarget->isCallingConvWin64(CC);
- const CallInst *CI = dyn_cast_or_null<CallInst>(CLI.CB);
-
// Call / invoke instructions with NoCfCheck attribute require special
// handling.
- const auto *II = dyn_cast_or_null<InvokeInst>(CLI.CB);
- if ((CI && CI->doesNoCfCheck()) || (II && II->doesNoCfCheck()))
+ if (CB && CB->doesNoCfCheck())
return false;
// Functions with no_caller_saved_registers that need special handling.
- if ((CI && CI->hasFnAttr("no_caller_saved_registers")))
+ if ((CB && isa<CallInst>(CB) && CB->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 5befee9f7ce7..6c844e7bcfcf 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -3900,6 +3900,7 @@ X86TargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
CallingConv::ID CallConv = CLI.CallConv;
bool &isTailCall = CLI.IsTailCall;
bool isVarArg = CLI.IsVarArg;
+ const auto *CB = CLI.CB;
MachineFunction &MF = DAG.getMachineFunction();
bool Is64Bit = Subtarget.is64Bit();
@@ -3909,12 +3910,10 @@ X86TargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
bool IsGuaranteeTCO = MF.getTarget().Options.GuaranteedTailCallOpt ||
CallConv == CallingConv::Tail;
X86MachineFunctionInfo *X86Info = MF.getInfo<X86MachineFunctionInfo>();
- const auto *CI = dyn_cast_or_null<CallInst>(CLI.CB);
- 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());
- bool IsIndirectCall = (CI && CI->isIndirectCall());
+ bool HasNCSR = (CB && isa<CallInst>(CB) &&
+ CB->hasFnAttr("no_caller_saved_registers"));
+ bool HasNoCfCheck = (CB && CB->doesNoCfCheck());
+ bool IsIndirectCall = (CB && isa<CallInst>(CB) && CB->isIndirectCall());
const Module *M = MF.getMMI().getModule();
Metadata *IsCFProtectionSupported = M->getModuleFlag("cf-protection-branch");
More information about the llvm-commits
mailing list