[llvm] r298179 - Make library calls sensitive to regparm module flag (Fixes PR3997).

Chandler Carruth via llvm-commits llvm-commits at lists.llvm.org
Thu May 11 16:09:12 PDT 2017


Hey Tom, I'd like to propose merging this into 4.0.1. I know it is both
somewhat late and somewhat large, but Linux kernel developers are asking me
for it to be included in a released version of LLVM and Clang to simplify
things, and so if it isn't too high of risk, I'd like to float the idea of
pulling it.

CC-ing both the reviewers but also some other interested parties since it's
a bit higher risk than usual.

-Chandler

On Fri, Mar 17, 2017 at 5:56 PM Nirav Dave via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> Author: niravd
> Date: Fri Mar 17 19:44:07 2017
> New Revision: 298179
>
> URL: http://llvm.org/viewvc/llvm-project?rev=298179&view=rev
> Log:
> Make library calls sensitive to regparm module flag (Fixes PR3997).
>
> Reviewers: mkuper, rnk
>
> Subscribers: mehdi_amini, jyknight, aemerson, llvm-commits, rengolin
>
> Differential Revision: https://reviews.llvm.org/D27050
>
> Added:
>     llvm/trunk/test/CodeGen/X86/regparm.ll
> Modified:
>     llvm/trunk/include/llvm/CodeGen/FastISel.h
>     llvm/trunk/include/llvm/IR/Module.h
>     llvm/trunk/include/llvm/Target/TargetLowering.h
>     llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp
>     llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
>     llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
>     llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
>     llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
>     llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
>     llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp
>     llvm/trunk/lib/IR/Module.cpp
>     llvm/trunk/lib/Target/AArch64/AArch64ISelLowering.cpp
>     llvm/trunk/lib/Target/AArch64/AArch64SelectionDAGInfo.cpp
>     llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp
>     llvm/trunk/lib/Target/ARM/ARMSelectionDAGInfo.cpp
>     llvm/trunk/lib/Target/AVR/AVRISelLowering.cpp
>     llvm/trunk/lib/Target/Hexagon/HexagonSelectionDAGInfo.cpp
>     llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp
>     llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp
>     llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
>     llvm/trunk/lib/Target/X86/X86ISelLowering.h
>     llvm/trunk/lib/Target/X86/X86SelectionDAGInfo.cpp
>     llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp
>     llvm/trunk/lib/Target/XCore/XCoreSelectionDAGInfo.cpp
>
> Modified: llvm/trunk/include/llvm/CodeGen/FastISel.h
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/FastISel.h?rev=298179&r1=298178&r2=298179&view=diff
>
> ==============================================================================
> --- llvm/trunk/include/llvm/CodeGen/FastISel.h (original)
> +++ llvm/trunk/include/llvm/CodeGen/FastISel.h Fri Mar 17 19:44:07 2017
> @@ -41,32 +41,8 @@ class MachineConstantPool;
>  /// quickly.
>  class FastISel {
>  public:
> -  struct ArgListEntry {
> -    Value *Val = nullptr;
> -    Type *Ty = nullptr;
> -    bool IsSExt : 1;
> -    bool IsZExt : 1;
> -    bool IsInReg : 1;
> -    bool IsSRet : 1;
> -    bool IsNest : 1;
> -    bool IsByVal : 1;
> -    bool IsInAlloca : 1;
> -    bool IsReturned : 1;
> -    bool IsSwiftSelf : 1;
> -    bool IsSwiftError : 1;
> -    uint16_t Alignment = 0;
> -
> -    ArgListEntry()
> -        : IsSExt(false), IsZExt(false), IsInReg(false), IsSRet(false),
> -          IsNest(false), IsByVal(false), IsInAlloca(false),
> IsReturned(false),
> -          IsSwiftSelf(false), IsSwiftError(false) {}
> -
> -    /// \brief Set CallLoweringInfo attribute flags based on a call
> instruction
> -    /// and called function attributes.
> -    void setAttributes(ImmutableCallSite *CS, unsigned AttrIdx);
> -  };
> -  typedef std::vector<ArgListEntry> ArgListTy;
> -
> +  typedef TargetLoweringBase::ArgListEntry ArgListEntry;
> +  typedef TargetLoweringBase::ArgListTy ArgListTy;
>    struct CallLoweringInfo {
>      Type *RetTy = nullptr;
>      bool RetSExt : 1;
>
> Modified: llvm/trunk/include/llvm/IR/Module.h
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Module.h?rev=298179&r1=298178&r2=298179&view=diff
>
> ==============================================================================
> --- llvm/trunk/include/llvm/IR/Module.h (original)
> +++ llvm/trunk/include/llvm/IR/Module.h Fri Mar 17 19:44:07 2017
> @@ -726,6 +726,10 @@ public:
>  /// @name Utility functions for querying Debug information.
>  /// @{
>
> +  /// \brief Returns the Number of Register ParametersDwarf Version by
> checking
> +  /// module flags.
> +  unsigned getNumberRegisterParameters() const;
> +
>    /// \brief Returns the Dwarf Version by checking module flags.
>    unsigned getDwarfVersion() const;
>
>
> Modified: llvm/trunk/include/llvm/Target/TargetLowering.h
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetLowering.h?rev=298179&r1=298178&r2=298179&view=diff
>
> ==============================================================================
> --- llvm/trunk/include/llvm/Target/TargetLowering.h (original)
> +++ llvm/trunk/include/llvm/Target/TargetLowering.h Fri Mar 17 19:44:07
> 2017
> @@ -25,13 +25,14 @@
>
>  #include "llvm/ADT/ArrayRef.h"
>  #include "llvm/ADT/DenseMap.h"
> -#include "llvm/ADT/SmallVector.h"
>  #include "llvm/ADT/STLExtras.h"
> +#include "llvm/ADT/SmallVector.h"
>  #include "llvm/ADT/StringRef.h"
>  #include "llvm/CodeGen/DAGCombine.h"
>  #include "llvm/CodeGen/ISDOpcodes.h"
>  #include "llvm/CodeGen/MachineValueType.h"
>  #include "llvm/CodeGen/RuntimeLibcalls.h"
> +#include "llvm/CodeGen/SelectionDAG.h"
>  #include "llvm/CodeGen/SelectionDAGNodes.h"
>  #include "llvm/CodeGen/ValueTypes.h"
>  #include "llvm/IR/Attributes.h"
> @@ -2628,6 +2629,20 @@ public:
>        return *this;
>      }
>
> +    // setCallee with target/module-specific attributes
> +    CallLoweringInfo &setLibCallee(CallingConv::ID CC, Type *ResultType,
> +                                   SDValue Target, ArgListTy &&ArgsList) {
> +      RetTy = ResultType;
> +      Callee = Target;
> +      CallConv = CC;
> +      NumFixedArgs = Args.size();
> +      Args = std::move(ArgsList);
> +
> +      DAG.getTargetLoweringInfo().markLibCallAttributes(
> +          &(DAG.getMachineFunction()), CC, Args);
> +      return *this;
> +    }
> +
>      CallLoweringInfo &setCallee(CallingConv::ID CC, Type *ResultType,
>                                  SDValue Target, ArgListTy &&ArgsList) {
>        RetTy = ResultType;
>
> Modified: llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp?rev=298179&r1=298178&r2=298179&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp (original)
> +++ llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp Fri Mar 17 19:44:07
> 2017
> @@ -119,21 +119,6 @@ STATISTIC(NumFastIselSuccessTarget, "Num
>                                      "target-specific selector");
>  STATISTIC(NumFastIselDead, "Number of dead insts removed on failure");
>
> -void FastISel::ArgListEntry::setAttributes(ImmutableCallSite *CS,
> -                                           unsigned AttrIdx) {
> -  IsSExt = CS->paramHasAttr(AttrIdx, Attribute::SExt);
> -  IsZExt = CS->paramHasAttr(AttrIdx, Attribute::ZExt);
> -  IsInReg = CS->paramHasAttr(AttrIdx, Attribute::InReg);
> -  IsSRet = CS->paramHasAttr(AttrIdx, Attribute::StructRet);
> -  IsNest = CS->paramHasAttr(AttrIdx, Attribute::Nest);
> -  IsByVal = CS->paramHasAttr(AttrIdx, Attribute::ByVal);
> -  IsInAlloca = CS->paramHasAttr(AttrIdx, Attribute::InAlloca);
> -  IsReturned = CS->paramHasAttr(AttrIdx, Attribute::Returned);
> -  IsSwiftSelf = CS->paramHasAttr(AttrIdx, Attribute::SwiftSelf);
> -  IsSwiftError = CS->paramHasAttr(AttrIdx, Attribute::SwiftError);
> -  Alignment = CS->getParamAlignment(AttrIdx);
> -}
> -
>  /// Set the current block to which generated machine instructions will be
>  /// appended, and clear the local CSE map.
>  void FastISel::startNewBlock() {
> @@ -929,6 +914,7 @@ bool FastISel::lowerCallTo(const CallIns
>      Entry.setAttributes(&CS, ArgI + 1);
>      Args.push_back(Entry);
>    }
> +  TLI.markLibCallAttributes(MF, CS.getCallingConv(), Args);
>
>    CallLoweringInfo CLI;
>    CLI.setCallee(RetTy, FTy, Symbol, std::move(Args), CS, NumArgs);
>
> Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp?rev=298179&r1=298178&r2=298179&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp (original)
> +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Fri Mar 17
> 19:44:07 2017
> @@ -1935,9 +1935,13 @@ SDValue SelectionDAGLegalize::ExpandLibC
>      InChain = TCChain;
>
>    TargetLowering::CallLoweringInfo CLI(DAG);
> -  CLI.setDebugLoc(SDLoc(Node)).setChain(InChain)
> -    .setCallee(TLI.getLibcallCallingConv(LC), RetTy, Callee,
> std::move(Args))
> -
> .setTailCall(isTailCall).setSExtResult(isSigned).setZExtResult(!isSigned);
> +  CLI.setDebugLoc(SDLoc(Node))
> +      .setChain(InChain)
> +      .setLibCallee(TLI.getLibcallCallingConv(LC), RetTy, Callee,
> +                    std::move(Args))
> +      .setTailCall(isTailCall)
> +      .setSExtResult(isSigned)
> +      .setZExtResult(!isSigned);
>
>    std::pair<SDValue, SDValue> CallInfo = TLI.LowerCallTo(CLI);
>
> @@ -1970,9 +1974,12 @@ SDValue SelectionDAGLegalize::ExpandLibC
>    Type *RetTy = RetVT.getTypeForEVT(*DAG.getContext());
>
>    TargetLowering::CallLoweringInfo CLI(DAG);
> -  CLI.setDebugLoc(dl).setChain(DAG.getEntryNode())
> -    .setCallee(TLI.getLibcallCallingConv(LC), RetTy, Callee,
> std::move(Args))
> -    .setSExtResult(isSigned).setZExtResult(!isSigned);
> +  CLI.setDebugLoc(dl)
> +      .setChain(DAG.getEntryNode())
> +      .setLibCallee(TLI.getLibcallCallingConv(LC), RetTy, Callee,
> +                    std::move(Args))
> +      .setSExtResult(isSigned)
> +      .setZExtResult(!isSigned);
>
>    std::pair<SDValue,SDValue> CallInfo = TLI.LowerCallTo(CLI);
>
> @@ -2004,9 +2011,12 @@ SelectionDAGLegalize::ExpandChainLibCall
>    Type *RetTy = Node->getValueType(0).getTypeForEVT(*DAG.getContext());
>
>    TargetLowering::CallLoweringInfo CLI(DAG);
> -  CLI.setDebugLoc(SDLoc(Node)).setChain(InChain)
> -    .setCallee(TLI.getLibcallCallingConv(LC), RetTy, Callee,
> std::move(Args))
> -    .setSExtResult(isSigned).setZExtResult(!isSigned);
> +  CLI.setDebugLoc(SDLoc(Node))
> +      .setChain(InChain)
> +      .setLibCallee(TLI.getLibcallCallingConv(LC), RetTy, Callee,
> +                    std::move(Args))
> +      .setSExtResult(isSigned)
> +      .setZExtResult(!isSigned);
>
>    std::pair<SDValue, SDValue> CallInfo = TLI.LowerCallTo(CLI);
>
> @@ -2099,9 +2109,12 @@ SelectionDAGLegalize::ExpandDivRemLibCal
>
>    SDLoc dl(Node);
>    TargetLowering::CallLoweringInfo CLI(DAG);
> -  CLI.setDebugLoc(dl).setChain(InChain)
> -    .setCallee(TLI.getLibcallCallingConv(LC), RetTy, Callee,
> std::move(Args))
> -    .setSExtResult(isSigned).setZExtResult(!isSigned);
> +  CLI.setDebugLoc(dl)
> +      .setChain(InChain)
> +      .setLibCallee(TLI.getLibcallCallingConv(LC), RetTy, Callee,
> +                    std::move(Args))
> +      .setSExtResult(isSigned)
> +      .setZExtResult(!isSigned);
>
>    std::pair<SDValue, SDValue> CallInfo = TLI.LowerCallTo(CLI);
>
> @@ -2210,9 +2223,9 @@ SelectionDAGLegalize::ExpandSinCosLibCal
>
>    SDLoc dl(Node);
>    TargetLowering::CallLoweringInfo CLI(DAG);
> -  CLI.setDebugLoc(dl).setChain(InChain)
> -    .setCallee(TLI.getLibcallCallingConv(LC),
> -               Type::getVoidTy(*DAG.getContext()), Callee,
> std::move(Args));
> +  CLI.setDebugLoc(dl).setChain(InChain).setLibCallee(
> +      TLI.getLibcallCallingConv(LC), Type::getVoidTy(*DAG.getContext()),
> Callee,
> +      std::move(Args));
>
>    std::pair<SDValue, SDValue> CallInfo = TLI.LowerCallTo(CLI);
>
> @@ -3830,10 +3843,11 @@ void SelectionDAGLegalize::ConvertNodeTo
>      TargetLowering::CallLoweringInfo CLI(DAG);
>      CLI.setDebugLoc(dl)
>          .setChain(Node->getOperand(0))
> -        .setCallee(CallingConv::C, Type::getVoidTy(*DAG.getContext()),
> -                   DAG.getExternalSymbol("__sync_synchronize",
> -
>  TLI.getPointerTy(DAG.getDataLayout())),
> -                   std::move(Args));
> +        .setLibCallee(
> +            CallingConv::C, Type::getVoidTy(*DAG.getContext()),
> +            DAG.getExternalSymbol("__sync_synchronize",
> +                                  TLI.getPointerTy(DAG.getDataLayout())),
> +            std::move(Args));
>
>      std::pair<SDValue, SDValue> CallResult = TLI.LowerCallTo(CLI);
>
> @@ -3870,10 +3884,10 @@ void SelectionDAGLegalize::ConvertNodeTo
>      TargetLowering::CallLoweringInfo CLI(DAG);
>      CLI.setDebugLoc(dl)
>          .setChain(Node->getOperand(0))
> -        .setCallee(CallingConv::C, Type::getVoidTy(*DAG.getContext()),
> -                   DAG.getExternalSymbol("abort",
> -
>  TLI.getPointerTy(DAG.getDataLayout())),
> -                   std::move(Args));
> +        .setLibCallee(CallingConv::C, Type::getVoidTy(*DAG.getContext()),
> +                      DAG.getExternalSymbol(
> +                          "abort", TLI.getPointerTy(DAG.getDataLayout())),
> +                      std::move(Args));
>      std::pair<SDValue, SDValue> CallResult = TLI.LowerCallTo(CLI);
>
>      Results.push_back(CallResult.second);
>
> Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp?rev=298179&r1=298178&r2=298179&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp (original)
> +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp Fri Mar
> 17 19:44:07 2017
> @@ -2607,7 +2607,7 @@ void DAGTypeLegalizer::ExpandIntRes_XMUL
>    TargetLowering::CallLoweringInfo CLI(DAG);
>    CLI.setDebugLoc(dl)
>        .setChain(Chain)
> -      .setCallee(TLI.getLibcallCallingConv(LC), RetTy, Func,
> std::move(Args))
> +      .setLibCallee(TLI.getLibcallCallingConv(LC), RetTy, Func,
> std::move(Args))
>        .setSExtResult();
>
>    std::pair<SDValue, SDValue> CallInfo = TLI.LowerCallTo(CLI);
>
> Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp?rev=298179&r1=298178&r2=298179&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp (original)
> +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp Fri Mar 17
> 19:44:07 2017
> @@ -1094,9 +1094,12 @@ DAGTypeLegalizer::ExpandChainLibCall(RTL
>    Type *RetTy = Node->getValueType(0).getTypeForEVT(*DAG.getContext());
>
>    TargetLowering::CallLoweringInfo CLI(DAG);
> -  CLI.setDebugLoc(SDLoc(Node)).setChain(InChain)
> -    .setCallee(TLI.getLibcallCallingConv(LC), RetTy, Callee,
> std::move(Args))
> -    .setSExtResult(isSigned).setZExtResult(!isSigned);
> +  CLI.setDebugLoc(SDLoc(Node))
> +      .setChain(InChain)
> +      .setLibCallee(TLI.getLibcallCallingConv(LC), RetTy, Callee,
> +                    std::move(Args))
> +      .setSExtResult(isSigned)
> +      .setZExtResult(!isSigned);
>
>    std::pair<SDValue, SDValue> CallInfo = TLI.LowerCallTo(CLI);
>
>
> Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=298179&r1=298178&r2=298179&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original)
> +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Fri Mar 17
> 19:44:07 2017
> @@ -5175,11 +5175,11 @@ SDValue SelectionDAG::getMemcpy(SDValue
>    TargetLowering::CallLoweringInfo CLI(*this);
>    CLI.setDebugLoc(dl)
>        .setChain(Chain)
> -      .setCallee(TLI->getLibcallCallingConv(RTLIB::MEMCPY),
> -                 Dst.getValueType().getTypeForEVT(*getContext()),
> -                 getExternalSymbol(TLI->getLibcallName(RTLIB::MEMCPY),
> -                                   TLI->getPointerTy(getDataLayout())),
> -                 std::move(Args))
> +      .setLibCallee(TLI->getLibcallCallingConv(RTLIB::MEMCPY),
> +                    Dst.getValueType().getTypeForEVT(*getContext()),
> +                    getExternalSymbol(TLI->getLibcallName(RTLIB::MEMCPY),
> +                                      TLI->getPointerTy(getDataLayout())),
> +                    std::move(Args))
>        .setDiscardResult()
>        .setTailCall(isTailCall);
>
> @@ -5236,11 +5236,11 @@ SDValue SelectionDAG::getMemmove(SDValue
>    TargetLowering::CallLoweringInfo CLI(*this);
>    CLI.setDebugLoc(dl)
>        .setChain(Chain)
> -      .setCallee(TLI->getLibcallCallingConv(RTLIB::MEMMOVE),
> -                 Dst.getValueType().getTypeForEVT(*getContext()),
> -                 getExternalSymbol(TLI->getLibcallName(RTLIB::MEMMOVE),
> -                                   TLI->getPointerTy(getDataLayout())),
> -                 std::move(Args))
> +      .setLibCallee(TLI->getLibcallCallingConv(RTLIB::MEMMOVE),
> +                    Dst.getValueType().getTypeForEVT(*getContext()),
> +                    getExternalSymbol(TLI->getLibcallName(RTLIB::MEMMOVE),
> +                                      TLI->getPointerTy(getDataLayout())),
> +                    std::move(Args))
>        .setDiscardResult()
>        .setTailCall(isTailCall);
>
> @@ -5298,11 +5298,11 @@ SDValue SelectionDAG::getMemset(SDValue
>    TargetLowering::CallLoweringInfo CLI(*this);
>    CLI.setDebugLoc(dl)
>        .setChain(Chain)
> -      .setCallee(TLI->getLibcallCallingConv(RTLIB::MEMSET),
> -                 Dst.getValueType().getTypeForEVT(*getContext()),
> -                 getExternalSymbol(TLI->getLibcallName(RTLIB::MEMSET),
> -                                   TLI->getPointerTy(getDataLayout())),
> -                 std::move(Args))
> +      .setLibCallee(TLI->getLibcallCallingConv(RTLIB::MEMSET),
> +                    Dst.getValueType().getTypeForEVT(*getContext()),
> +                    getExternalSymbol(TLI->getLibcallName(RTLIB::MEMSET),
> +                                      TLI->getPointerTy(getDataLayout())),
> +                    std::move(Args))
>        .setDiscardResult()
>        .setTailCall(isTailCall);
>
>
> Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp?rev=298179&r1=298178&r2=298179&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (original)
> +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Fri Mar 17
> 19:44:07 2017
> @@ -4912,7 +4912,7 @@ SelectionDAGBuilder::visitIntrinsicCall(
>        report_fatal_error("Unsupported element size");
>
>      TargetLowering::CallLoweringInfo CLI(DAG);
> -    CLI.setDebugLoc(sdl).setChain(getRoot()).setCallee(
> +    CLI.setDebugLoc(sdl).setChain(getRoot()).setLibCallee(
>          TLI.getLibcallCallingConv(LibraryCall),
>          Type::getVoidTy(*DAG.getContext()),
>          DAG.getExternalSymbol(TLI.getLibcallName(LibraryCall),
> @@ -5536,7 +5536,7 @@ SelectionDAGBuilder::visitIntrinsicCall(
>      TargetLowering::ArgListTy Args;
>
>      TargetLowering::CallLoweringInfo CLI(DAG);
> -    CLI.setDebugLoc(sdl).setChain(getRoot()).setCallee(
> +    CLI.setDebugLoc(sdl).setChain(getRoot()).setLibCallee(
>          CallingConv::C, I.getType(),
>          DAG.getExternalSymbol(TrapFuncName.data(),
>                                TLI.getPointerTy(DAG.getDataLayout())),
>
> Modified: llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp?rev=298179&r1=298178&r2=298179&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp (original)
> +++ llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp Fri Mar 17
> 19:44:07 2017
> @@ -96,8 +96,8 @@ bool TargetLowering::parametersInCSRMatc
>
>  /// \brief Set CallLoweringInfo attribute flags based on a call
> instruction
>  /// and called function attributes.
> -void TargetLowering::ArgListEntry::setAttributes(ImmutableCallSite *CS,
> -                                                 unsigned AttrIdx) {
> +void TargetLoweringBase::ArgListEntry::setAttributes(ImmutableCallSite
> *CS,
> +                                                     unsigned AttrIdx) {
>    IsSExt = CS->paramHasAttr(AttrIdx, Attribute::SExt);
>    IsZExt = CS->paramHasAttr(AttrIdx, Attribute::ZExt);
>    IsInReg = CS->paramHasAttr(AttrIdx, Attribute::InReg);
> @@ -138,10 +138,13 @@ TargetLowering::makeLibCall(SelectionDAG
>    Type *RetTy = RetVT.getTypeForEVT(*DAG.getContext());
>    TargetLowering::CallLoweringInfo CLI(DAG);
>    bool signExtend = shouldSignExtendTypeInLibCall(RetVT, isSigned);
> -  CLI.setDebugLoc(dl).setChain(DAG.getEntryNode())
> -    .setCallee(getLibcallCallingConv(LC), RetTy, Callee, std::move(Args))
> -    .setNoReturn(doesNotReturn).setDiscardResult(!isReturnValueUsed)
> -    .setSExtResult(signExtend).setZExtResult(!signExtend);
> +  CLI.setDebugLoc(dl)
> +      .setChain(DAG.getEntryNode())
> +      .setLibCallee(getLibcallCallingConv(LC), RetTy, Callee,
> std::move(Args))
> +      .setNoReturn(doesNotReturn)
> +      .setDiscardResult(!isReturnValueUsed)
> +      .setSExtResult(signExtend)
> +      .setZExtResult(!signExtend);
>    return LowerCallTo(CLI);
>  }
>
> @@ -3853,7 +3856,7 @@ SDValue TargetLowering::LowerToTLSEmulat
>
>    TargetLowering::CallLoweringInfo CLI(DAG);
>    CLI.setDebugLoc(dl).setChain(DAG.getEntryNode());
> -  CLI.setCallee(CallingConv::C, VoidPtrType, EmuTlsGetAddr,
> std::move(Args));
> +  CLI.setLibCallee(CallingConv::C, VoidPtrType, EmuTlsGetAddr,
> std::move(Args));
>    std::pair<SDValue, SDValue> CallResult = LowerCallTo(CLI);
>
>    // TLSADDR will be codegen'ed as call. Inform MFI that function has
> calls.
>
> Modified: llvm/trunk/lib/IR/Module.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Module.cpp?rev=298179&r1=298178&r2=298179&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/IR/Module.cpp (original)
> +++ llvm/trunk/lib/IR/Module.cpp Fri Mar 17 19:44:07 2017
> @@ -465,6 +465,14 @@ void Module::dropAllReferences() {
>      GIF.dropAllReferences();
>  }
>
> +unsigned Module::getNumberRegisterParameters() const {
> +  auto *Val =
> +
> cast_or_null<ConstantAsMetadata>(getModuleFlag("NumRegisterParameters"));
> +  if (!Val)
> +    return 0;
> +  return cast<ConstantInt>(Val->getValue())->getZExtValue();
> +}
> +
>  unsigned Module::getDwarfVersion() const {
>    auto *Val = cast_or_null<ConstantAsMetadata>(getModuleFlag("Dwarf
> Version"));
>    if (!Val)
>
> Modified: llvm/trunk/lib/Target/AArch64/AArch64ISelLowering.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AArch64ISelLowering.cpp?rev=298179&r1=298178&r2=298179&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Target/AArch64/AArch64ISelLowering.cpp (original)
> +++ llvm/trunk/lib/Target/AArch64/AArch64ISelLowering.cpp Fri Mar 17
> 19:44:07 2017
> @@ -2123,8 +2123,9 @@ SDValue AArch64TargetLowering::LowerFSIN
>
>    StructType *RetTy = StructType::get(ArgTy, ArgTy, nullptr);
>    TargetLowering::CallLoweringInfo CLI(DAG);
> -  CLI.setDebugLoc(dl).setChain(DAG.getEntryNode())
> -    .setCallee(CallingConv::Fast, RetTy, Callee, std::move(Args));
> +  CLI.setDebugLoc(dl)
> +      .setChain(DAG.getEntryNode())
> +      .setLibCallee(CallingConv::Fast, RetTy, Callee, std::move(Args));
>
>    std::pair<SDValue, SDValue> CallResult = LowerCallTo(CLI);
>    return CallResult.first;
>
> Modified: llvm/trunk/lib/Target/AArch64/AArch64SelectionDAGInfo.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AArch64SelectionDAGInfo.cpp?rev=298179&r1=298178&r2=298179&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Target/AArch64/AArch64SelectionDAGInfo.cpp (original)
> +++ llvm/trunk/lib/Target/AArch64/AArch64SelectionDAGInfo.cpp Fri Mar 17
> 19:44:07 2017
> @@ -44,8 +44,9 @@ SDValue AArch64SelectionDAGInfo::EmitTar
>      TargetLowering::CallLoweringInfo CLI(DAG);
>      CLI.setDebugLoc(dl)
>          .setChain(Chain)
> -        .setCallee(CallingConv::C, Type::getVoidTy(*DAG.getContext()),
> -                   DAG.getExternalSymbol(bzeroEntry, IntPtr),
> std::move(Args))
> +        .setLibCallee(CallingConv::C, Type::getVoidTy(*DAG.getContext()),
> +                      DAG.getExternalSymbol(bzeroEntry, IntPtr),
> +                      std::move(Args))
>          .setDiscardResult();
>      std::pair<SDValue, SDValue> CallResult = TLI.LowerCallTo(CLI);
>      return CallResult.second;
>
> Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=298179&r1=298178&r2=298179&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original)
> +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Fri Mar 17 19:44:07 2017
> @@ -2873,7 +2873,7 @@ ARMTargetLowering::LowerToTLSGeneralDyna
>
>    // FIXME: is there useful debug info available here?
>    TargetLowering::CallLoweringInfo CLI(DAG);
> -  CLI.setDebugLoc(dl).setChain(Chain).setCallee(
> +  CLI.setDebugLoc(dl).setChain(Chain).setLibCallee(
>        CallingConv::C, Type::getInt32Ty(*DAG.getContext()),
>        DAG.getExternalSymbol("__tls_get_addr", PtrVT), std::move(Args));
>
>
> Modified: llvm/trunk/lib/Target/ARM/ARMSelectionDAGInfo.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMSelectionDAGInfo.cpp?rev=298179&r1=298178&r2=298179&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Target/ARM/ARMSelectionDAGInfo.cpp (original)
> +++ llvm/trunk/lib/Target/ARM/ARMSelectionDAGInfo.cpp Fri Mar 17 19:44:07
> 2017
> @@ -114,7 +114,7 @@ SDValue ARMSelectionDAGInfo::EmitSpecial
>    TargetLowering::CallLoweringInfo CLI(DAG);
>    CLI.setDebugLoc(dl)
>        .setChain(Chain)
> -      .setCallee(
> +      .setLibCallee(
>            TLI->getLibcallCallingConv(LC),
> Type::getVoidTy(*DAG.getContext()),
>            DAG.getExternalSymbol(FunctionNames[AEABILibcall][AlignVariant],
>                                  TLI->getPointerTy(DAG.getDataLayout())),
>
> Modified: llvm/trunk/lib/Target/AVR/AVRISelLowering.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AVR/AVRISelLowering.cpp?rev=298179&r1=298178&r2=298179&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Target/AVR/AVRISelLowering.cpp (original)
> +++ llvm/trunk/lib/Target/AVR/AVRISelLowering.cpp Fri Mar 17 19:44:07 2017
> @@ -356,7 +356,7 @@ SDValue AVRTargetLowering::LowerDivRem(S
>    TargetLowering::CallLoweringInfo CLI(DAG);
>    CLI.setDebugLoc(dl)
>        .setChain(InChain)
> -      .setCallee(getLibcallCallingConv(LC), RetTy, Callee,
> std::move(Args))
> +      .setLibCallee(getLibcallCallingConv(LC), RetTy, Callee,
> std::move(Args))
>        .setInRegister()
>        .setSExtResult(isSigned)
>        .setZExtResult(!isSigned);
> @@ -1983,4 +1983,3 @@ unsigned AVRTargetLowering::getRegisterB
>  }
>
>  } // end of namespace llvm
> -
>
> Modified: llvm/trunk/lib/Target/Hexagon/HexagonSelectionDAGInfo.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/HexagonSelectionDAGInfo.cpp?rev=298179&r1=298178&r2=298179&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Target/Hexagon/HexagonSelectionDAGInfo.cpp (original)
> +++ llvm/trunk/lib/Target/Hexagon/HexagonSelectionDAGInfo.cpp Fri Mar 17
> 19:44:07 2017
> @@ -51,7 +51,7 @@ SDValue HexagonSelectionDAGInfo::EmitTar
>    TargetLowering::CallLoweringInfo CLI(DAG);
>    CLI.setDebugLoc(dl)
>        .setChain(Chain)
> -      .setCallee(
> +      .setLibCallee(
>            TLI.getLibcallCallingConv(RTLIB::MEMCPY),
>            Type::getVoidTy(*DAG.getContext()),
>            DAG.getTargetExternalSymbol(
>
> Modified: llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp?rev=298179&r1=298178&r2=298179&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp (original)
> +++ llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp Fri Mar 17 19:44:07
> 2017
> @@ -1922,8 +1922,9 @@ lowerGlobalTLSAddress(SDValue Op, Select
>      Args.push_back(Entry);
>
>      TargetLowering::CallLoweringInfo CLI(DAG);
> -    CLI.setDebugLoc(DL).setChain(DAG.getEntryNode())
> -      .setCallee(CallingConv::C, PtrTy, TlsGetAddr, std::move(Args));
> +    CLI.setDebugLoc(DL)
> +        .setChain(DAG.getEntryNode())
> +        .setLibCallee(CallingConv::C, PtrTy, TlsGetAddr, std::move(Args));
>      std::pair<SDValue, SDValue> CallResult = LowerCallTo(CLI);
>
>      SDValue Ret = CallResult.first;
>
> Modified: llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp?rev=298179&r1=298178&r2=298179&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp (original)
> +++ llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp Fri Mar 17 19:44:07
> 2017
> @@ -2647,10 +2647,9 @@ SDValue PPCTargetLowering::LowerINIT_TRA
>
>    // Lower to a call to __trampoline_setup(Trmp, TrampSize, FPtr, ctx_reg)
>    TargetLowering::CallLoweringInfo CLI(DAG);
> -  CLI.setDebugLoc(dl).setChain(Chain)
> -    .setCallee(CallingConv::C, Type::getVoidTy(*DAG.getContext()),
> -               DAG.getExternalSymbol("__trampoline_setup", PtrVT),
> -               std::move(Args));
> +  CLI.setDebugLoc(dl).setChain(Chain).setLibCallee(
> +      CallingConv::C, Type::getVoidTy(*DAG.getContext()),
> +      DAG.getExternalSymbol("__trampoline_setup", PtrVT),
> std::move(Args));
>
>    std::pair<SDValue, SDValue> CallResult = LowerCallTo(CLI);
>    return CallResult.second;
>
> Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=298179&r1=298178&r2=298179&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
> +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Fri Mar 17 19:44:07 2017
> @@ -53,6 +53,7 @@
>  #include "llvm/Support/Debug.h"
>  #include "llvm/Support/ErrorHandling.h"
>  #include "llvm/Support/MathExtras.h"
> +#include "llvm/Target/TargetLowering.h"
>  #include "llvm/Target/TargetOptions.h"
>  #include <algorithm>
>  #include <bitset>
> @@ -1961,6 +1962,34 @@ bool X86TargetLowering::useSoftFloat() c
>    return Subtarget.useSoftFloat();
>  }
>
> +void X86TargetLowering::markLibCallAttributes(MachineFunction *MF,
> unsigned CC,
> +                                              ArgListTy &Args) const {
> +
> +  // Only relabel X86-32 for C / Stdcall CCs.
> +  if (static_cast<const X86Subtarget &>(MF->getSubtarget()).is64Bit())
> +    return;
> +  if (CC != CallingConv::C && CC != CallingConv::X86_StdCall)
> +    return;
> +  unsigned ParamRegs = 0;
> +  if (auto *M = MF->getFunction()->getParent())
> +    ParamRegs = M->getNumberRegisterParameters();
> +
> +  // Mark the first N int arguments as having reg
> +  for (unsigned Idx = 0; Idx < Args.size(); Idx++) {
> +    Type *T = Args[Idx].Ty;
> +    if (T->isPointerTy() || T->isIntegerTy())
> +      if (MF->getDataLayout().getTypeAllocSize(T) <= 8) {
> +        unsigned numRegs = 1;
> +        if (MF->getDataLayout().getTypeAllocSize(T) > 4)
> +          numRegs = 2;
> +        if (ParamRegs < numRegs)
> +          return;
> +        ParamRegs -= numRegs;
> +        Args[Idx].IsInReg = true;
> +      }
> +  }
> +}
> +
>  const MCExpr *
>  X86TargetLowering::LowerCustomJumpTableEntry(const MachineJumpTableInfo
> *MJTI,
>                                               const MachineBasicBlock *MBB,
> @@ -21517,11 +21546,15 @@ SDValue X86TargetLowering::LowerWin64_i1
>
> getPointerTy(DAG.getDataLayout()));
>
>    TargetLowering::CallLoweringInfo CLI(DAG);
> -  CLI.setDebugLoc(dl).setChain(InChain)
> -    .setCallee(getLibcallCallingConv(LC),
> -
>  static_cast<EVT>(MVT::v2i64).getTypeForEVT(*DAG.getContext()),
> -               Callee, std::move(Args))
> -    .setInRegister().setSExtResult(isSigned).setZExtResult(!isSigned);
> +  CLI.setDebugLoc(dl)
> +      .setChain(InChain)
> +      .setLibCallee(
> +          getLibcallCallingConv(LC),
> +          static_cast<EVT>(MVT::v2i64).getTypeForEVT(*DAG.getContext()),
> Callee,
> +          std::move(Args))
> +      .setInRegister()
> +      .setSExtResult(isSigned)
> +      .setZExtResult(!isSigned);
>
>    std::pair<SDValue, SDValue> CallInfo = LowerCallTo(CLI);
>    return DAG.getBitcast(VT, CallInfo.first);
> @@ -23245,8 +23278,9 @@ static SDValue LowerFSINCOS(SDValue Op,
>      : (Type*)VectorType::get(ArgTy, 4);
>
>    TargetLowering::CallLoweringInfo CLI(DAG);
> -  CLI.setDebugLoc(dl).setChain(DAG.getEntryNode())
> -    .setCallee(CallingConv::C, RetTy, Callee, std::move(Args));
> +  CLI.setDebugLoc(dl)
> +      .setChain(DAG.getEntryNode())
> +      .setLibCallee(CallingConv::C, RetTy, Callee, std::move(Args));
>
>    std::pair<SDValue, SDValue> CallResult = TLI.LowerCallTo(CLI);
>
>
> Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.h
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.h?rev=298179&r1=298178&r2=298179&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Target/X86/X86ISelLowering.h (original)
> +++ llvm/trunk/lib/Target/X86/X86ISelLowering.h Fri Mar 17 19:44:07 2017
> @@ -688,6 +688,9 @@ namespace llvm {
>      unsigned getJumpTableEncoding() const override;
>      bool useSoftFloat() const override;
>
> +    void markLibCallAttributes(MachineFunction *MF, unsigned CC,
> +                               ArgListTy &Args) const override;
> +
>      MVT getScalarShiftAmountTy(const DataLayout &, EVT) const override {
>        return MVT::i8;
>      }
>
> Modified: llvm/trunk/lib/Target/X86/X86SelectionDAGInfo.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86SelectionDAGInfo.cpp?rev=298179&r1=298178&r2=298179&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Target/X86/X86SelectionDAGInfo.cpp (original)
> +++ llvm/trunk/lib/Target/X86/X86SelectionDAGInfo.cpp Fri Mar 17 19:44:07
> 2017
> @@ -87,8 +87,9 @@ SDValue X86SelectionDAGInfo::EmitTargetC
>        TargetLowering::CallLoweringInfo CLI(DAG);
>        CLI.setDebugLoc(dl)
>            .setChain(Chain)
> -          .setCallee(CallingConv::C, Type::getVoidTy(*DAG.getContext()),
> -                     DAG.getExternalSymbol(bzeroEntry, IntPtr),
> std::move(Args))
> +          .setLibCallee(CallingConv::C,
> Type::getVoidTy(*DAG.getContext()),
> +                        DAG.getExternalSymbol(bzeroEntry, IntPtr),
> +                        std::move(Args))
>            .setDiscardResult();
>
>        std::pair<SDValue,SDValue> CallResult = TLI.LowerCallTo(CLI);
>
> Modified: llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp?rev=298179&r1=298178&r2=298179&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp (original)
> +++ llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp Fri Mar 17 19:44:07
> 2017
> @@ -483,7 +483,7 @@ LowerLOAD(SDValue Op, SelectionDAG &DAG)
>    Args.push_back(Entry);
>
>    TargetLowering::CallLoweringInfo CLI(DAG);
> -  CLI.setDebugLoc(DL).setChain(Chain).setCallee(
> +  CLI.setDebugLoc(DL).setChain(Chain).setLibCallee(
>        CallingConv::C, IntPtrTy,
>        DAG.getExternalSymbol("__misaligned_load",
>                              getPointerTy(DAG.getDataLayout())),
>
> Modified: llvm/trunk/lib/Target/XCore/XCoreSelectionDAGInfo.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/XCore/XCoreSelectionDAGInfo.cpp?rev=298179&r1=298178&r2=298179&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Target/XCore/XCoreSelectionDAGInfo.cpp (original)
> +++ llvm/trunk/lib/Target/XCore/XCoreSelectionDAGInfo.cpp Fri Mar 17
> 19:44:07 2017
> @@ -35,11 +35,11 @@ SDValue XCoreSelectionDAGInfo::EmitTarge
>      TargetLowering::CallLoweringInfo CLI(DAG);
>      CLI.setDebugLoc(dl)
>          .setChain(Chain)
> -        .setCallee(TLI.getLibcallCallingConv(RTLIB::MEMCPY),
> -                   Type::getVoidTy(*DAG.getContext()),
> -                   DAG.getExternalSymbol("__memcpy_4",
> -
>  TLI.getPointerTy(DAG.getDataLayout())),
> -                   std::move(Args))
> +        .setLibCallee(TLI.getLibcallCallingConv(RTLIB::MEMCPY),
> +                      Type::getVoidTy(*DAG.getContext()),
> +                      DAG.getExternalSymbol(
> +                          "__memcpy_4",
> TLI.getPointerTy(DAG.getDataLayout())),
> +                      std::move(Args))
>          .setDiscardResult();
>
>      std::pair<SDValue,SDValue> CallResult = TLI.LowerCallTo(CLI);
>
> Added: llvm/trunk/test/CodeGen/X86/regparm.ll
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/regparm.ll?rev=298179&view=auto
>
> ==============================================================================
> --- llvm/trunk/test/CodeGen/X86/regparm.ll (added)
> +++ llvm/trunk/test/CodeGen/X86/regparm.ll Fri Mar 17 19:44:07 2017
> @@ -0,0 +1,48 @@
> +; RUN: llc %s -mtriple=i386-pc-linux -o - | FileCheck -check-prefix=CHECK
> %s
> +; RUN: llc %s -mtriple=i386-pc-win32 -o - | FileCheck -check-prefix=WIN %s
> +; RUN: llc %s -mtriple=i386-pc-linux -fast-isel -o - | FileCheck
> -check-prefix=FAST %s
> +; RUN: llc %s -mtriple=i386-pc-win32 -fast-isel -o - | FileCheck
> -check-prefix=FASTWIN %s
> +
> +
> +
> +target datalayout = "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128"
> +target triple = "i386-unknown-linux-gnu"
> +
> +; Function Attrs: argmemonly nounwind
> +declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture writeonly, i8*
> nocapture readonly, i32, i32, i1) #1
> +
> +define void @use_memset(i8* inreg nocapture %dest, i8 inreg %c, i32 inreg
> %n) local_unnamed_addr #0 {
> +entry:
> +;CHECK-LABEL: @use_memset
> +;CHECK-NOT: push
> +;CHECK: jmp    memset
> +;CHECK-NOT: retl
> +;WIN-LABEL: @use_memset
> +;WIN-NOT: push
> +;WIN: jmp      _memset
> +;WIN-NOT: retl
> +;FAST-LABEL: @use_memset
> +;FAST: subl    $12, %esp
> +;FAST-NEXT:    movzbl  %dl, %edx
> +;FAST-NEXT:     calll  memset
> +;FAST-NEXT:    addl    $12, %esp
> +;FASTWIN-LABEL: @use_memset
> +;FASTWIN:      movzbl  %dl, %edx
> +;FASTWIN-NEXT:     calll       _memset
> +;FASTWIN-NEXT:     retl
> +  tail call void @llvm.memset.p0i8.i32(i8* %dest, i8 %c, i32 %n, i32 1,
> i1 false)
> +  ret void
> +}
> +
> +; Function Attrs: argmemonly nounwind
> +declare void @llvm.memset.p0i8.i32(i8* nocapture writeonly, i8, i32, i32,
> i1) #1
> +
> +
> +attributes #0 = { nounwind
> "correctly-rounded-divide-sqrt-fp-math"="false"
> "disable-tail-calls"="false" "less-precise-fpmad"="false"
> "no-frame-pointer-elim"="false" "no-infs-fp-math"="false"
> "no-jump-tables"="false" "no-nans-fp-math"="false"
> "no-signed-zeros-fp-math"="false" "no-trapping-math"="false"
> "stack-protector-buffer-size"="8" "target-cpu"="pentium4"
> "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false"
> "use-soft-float"="false" }
> +attributes #1 = { argmemonly nounwind }
> +
> +!llvm.module.flags = !{!0}
> +!llvm.ident = !{!1}
> +
> +!0 = !{i32 1, !"NumRegisterParameters", i32 3}
> +!1 = !{!"clang version 4.0.0 (trunk 288025) (llvm/trunk 288033)"}
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170511/ae6d0837/attachment-0001.html>


More information about the llvm-commits mailing list