Pull in r280040 from upstream llvm trunk (by Hal Finkel):

[PowerPC] Add support for -mlongcall

  The "long call" option forces the use of the indirect calling
  sequence for all calls (even those that don't really need it). GCC
  provides this option; This is helpful, under certain circumstances,
  for building very-large binaries, and some other specialized use
  cases.

  Fixes PR19098.

Pull in r280041 from upstream clang trunk (by Hal Finkel):

  [PowerPC] Add support for -mlongcall

  Add support for GCC's PowerPC -mlongcall option; the backend supports
  the corresponding target feature as of r280040.

  Fixes PR19098.
This commit is contained in:
Dimitry Andric 2016-09-10 15:38:46 +00:00
parent d002f039ae
commit b6054a7b70
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/projects/clang390-import/; revision=305680
5 changed files with 19 additions and 1 deletions

View File

@ -136,6 +136,8 @@ def FeatureInvariantFunctionDescriptors :
SubtargetFeature<"invariant-function-descriptors",
"HasInvariantFunctionDescriptors", "true",
"Assume function descriptors are invariant">;
def FeatureLongCall : SubtargetFeature<"longcall", "UseLongCalls", "true",
"Always use indirect calls">;
def FeatureHTM : SubtargetFeature<"htm", "HasHTM", "true",
"Enable Hardware Transactional Memory instructions">;
def FeatureMFTB : SubtargetFeature<"", "FeatureMFTB", "true",

View File

@ -4680,7 +4680,9 @@ PPCTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
ImmutableCallSite *CS = CLI.CS;
if (isTailCall) {
if (Subtarget.isSVR4ABI() && Subtarget.isPPC64())
if (Subtarget.useLongCalls() && !(CS && CS->isMustTailCall()))
isTailCall = false;
else if (Subtarget.isSVR4ABI() && Subtarget.isPPC64())
isTailCall =
IsEligibleForTailCallOptimization_64SVR4(Callee, CallConv, CS,
isVarArg, Outs, Ins, DAG);
@ -4710,6 +4712,13 @@ PPCTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
report_fatal_error("failed to perform tail call elimination on a call "
"site marked musttail");
// When long calls (i.e. indirect calls) are always used, calls are always
// made via function pointer. If we have a function name, first translate it
// into a pointer.
if (Subtarget.useLongCalls() && isa<GlobalAddressSDNode>(Callee) &&
!isTailCall)
Callee = LowerGlobalAddress(Callee, DAG);
if (Subtarget.isSVR4ABI()) {
if (Subtarget.isPPC64())
return LowerCall_64SVR4(Chain, Callee, CallConv, isVarArg,

View File

@ -105,6 +105,7 @@ void PPCSubtarget::initializeEnvironment() {
HasFusion = false;
HasFloat128 = false;
IsISA3_0 = false;
UseLongCalls = false;
HasPOPCNTD = POPCNTD_Unavailable;
}

View File

@ -132,6 +132,7 @@ class PPCSubtarget : public PPCGenSubtargetInfo {
bool HasFusion;
bool HasFloat128;
bool IsISA3_0;
bool UseLongCalls;
POPCNTDKind HasPOPCNTD;
@ -275,6 +276,7 @@ class PPCSubtarget : public PPCGenSubtargetInfo {
bool hasFusion() const { return HasFusion; }
bool hasFloat128() const { return HasFloat128; }
bool isISA3_0() const { return IsISA3_0; }
bool useLongCalls() const { return UseLongCalls; }
POPCNTDKind hasPOPCNTD() const { return HasPOPCNTD; }

View File

@ -1574,6 +1574,10 @@ def mfloat128: Flag<["-"], "mfloat128">,
Group<m_ppc_Features_Group>;
def mno_float128 : Flag<["-"], "mno-float128">,
Group<m_ppc_Features_Group>;
def mlongcall: Flag<["-"], "mlongcall">,
Group<m_ppc_Features_Group>;
def mno_longcall : Flag<["-"], "mno-longcall">,
Group<m_ppc_Features_Group>;
def faltivec : Flag<["-"], "faltivec">, Group<f_Group>, Flags<[CC1Option]>,
HelpText<"Enable AltiVec vector initializer syntax">;