@@ -2034,11 +2034,17 @@ X86TargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
20342034 X86MachineFunctionInfo *X86Info = MF.getInfo <X86MachineFunctionInfo>();
20352035 bool HasNCSR = (CB && isa<CallInst>(CB) &&
20362036 CB->hasFnAttr (" no_caller_saved_registers" ));
2037- bool HasNoCfCheck = (CB && CB->doesNoCfCheck ());
20382037 bool IsIndirectCall = (CB && isa<CallInst>(CB) && CB->isIndirectCall ());
20392038 bool IsCFICall = IsIndirectCall && CLI.CFIType ;
20402039 const Module *M = MF.getFunction ().getParent ();
2041- Metadata *IsCFProtectionSupported = M->getModuleFlag (" cf-protection-branch" );
2040+
2041+ // If the indirect call target has the nocf_check attribute, the call needs
2042+ // the NOTRACK prefix. For simplicity just disable tail calls as there there
2043+ // are too many variants
2044+ bool IsNoTrackIndirectCall = IsIndirectCall && CB->doesNoCfCheck () &&
2045+ M->getModuleFlag (" cf-protection-branch" );
2046+ if (IsNoTrackIndirectCall)
2047+ isTailCall = false ;
20422048
20432049 MachineFunction::CallSiteInfo CSInfo;
20442050 if (CallConv == CallingConv::X86_INTR)
@@ -2549,7 +2555,7 @@ X86TargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
25492555
25502556 // Returns a chain & a glue for retval copy to use.
25512557 SDVTList NodeTys = DAG.getVTList (MVT::Other, MVT::Glue);
2552- if (HasNoCfCheck && IsCFProtectionSupported && IsIndirectCall ) {
2558+ if (IsNoTrackIndirectCall ) {
25532559 Chain = DAG.getNode (X86ISD::NT_CALL, dl, NodeTys, Ops);
25542560 } else if (CLI.CB && objcarc::hasAttachedCallOpBundle (CLI.CB )) {
25552561 // Calls with a "clang.arc.attachedcall" bundle are special. They should be
0 commit comments