llvm.org GIT mirror llvm / f3d3277
Merging r298179: ----------------------------------------------------------------------- r298179 | niravd | 2017-03-17 20:44:07 -0400 (Fri, 17 Mar 2017) | 7 lines 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 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_40@304242 91177308-0d34-0410-b5e6-96231b3b80d8 Tom Stellard 2 years ago
25 changed file(s) with 285 addition(s) and 102 deletion(s). Raw diff Collapse all Expand all
5656 };
5757 typedef std::vector ArgListTy;
5858
59 // This is a workaround to not move around the ArgListEntryTypes.
60 void markFastLibCallAttributes(const TargetLowering &TL, MachineFunction *MF,
61 unsigned CC, ArgListTy &Args) const {
62
63 TargetLowering::ArgListTy TLArgs;
64 // Convert to TargetLowering::ArgListTy
65 for (unsigned long i = 0; i < Args.size(); ++i) {
66 TargetLowering::ArgListEntry TArg;
67 TArg.Ty = Args[i].Ty;
68 TArg.isSExt = Args[i].IsSExt;
69 TArg.isZExt = Args[i].IsZExt;
70 TArg.isInReg = Args[i].IsInReg;
71 TArg.isSRet = Args[i].IsSRet;
72 TArg.isNest = Args[i].IsNest;
73 TArg.isByVal = Args[i].IsByVal;
74 TArg.isInAlloca = Args[i].IsInAlloca;
75 TArg.isReturned = Args[i].IsReturned;
76 TArg.isSwiftSelf = Args[i].IsSwiftSelf;
77 TArg.isSwiftError = Args[i].IsSwiftError;
78 TArg.Alignment = Args[i].Alignment;
79 TLArgs.push_back(TArg);
80 }
81 // Call convered
82 TL.markLibCallAttributes(MF, CC, TLArgs);
83 // Copy back.
84 for (unsigned long i = 0; i < Args.size(); ++i) {
85 Args[i].Ty = TLArgs[i].Ty;
86 Args[i].IsSExt = TLArgs[i].isSExt;
87 Args[i].IsZExt = TLArgs[i].isZExt;
88 Args[i].IsInReg = TLArgs[i].isInReg;
89 Args[i].IsSRet = TLArgs[i].isSRet;
90 Args[i].IsNest = TLArgs[i].isNest;
91 Args[i].IsByVal = TLArgs[i].isByVal;
92 Args[i].IsInAlloca = TLArgs[i].isInAlloca;
93 Args[i].IsReturned = TLArgs[i].isReturned;
94 Args[i].IsSwiftSelf = TLArgs[i].isSwiftSelf;
95 Args[i].IsSwiftError = TLArgs[i].isSwiftError;
96 Args[i].Alignment = TLArgs[i].Alignment;
97 }
98 }
99
59100 struct CallLoweringInfo {
60101 Type *RetTy;
61102 bool RetSExt : 1;
725725 /// @name Utility functions for querying Debug information.
726726 /// @{
727727
728 /// \brief Returns the Number of Register ParametersDwarf Version by checking
729 /// module flags.
730 unsigned getNumberRegisterParameters() const;
731
728732 /// \brief Returns the Dwarf Version by checking module flags.
729733 unsigned getDwarfVersion() const;
730734
2424
2525 #include "llvm/ADT/ArrayRef.h"
2626 #include "llvm/ADT/DenseMap.h"
27 #include "llvm/ADT/STLExtras.h"
2728 #include "llvm/ADT/SmallVector.h"
28 #include "llvm/ADT/STLExtras.h"
2929 #include "llvm/ADT/StringRef.h"
3030 #include "llvm/CodeGen/DAGCombine.h"
3131 #include "llvm/CodeGen/ISDOpcodes.h"
3232 #include "llvm/CodeGen/MachineValueType.h"
3333 #include "llvm/CodeGen/RuntimeLibcalls.h"
34 #include "llvm/CodeGen/SelectionDAG.h"
3435 #include "llvm/CodeGen/SelectionDAGNodes.h"
3536 #include "llvm/CodeGen/ValueTypes.h"
3637 #include "llvm/IR/Attributes.h"
25592560 };
25602561 typedef std::vector ArgListTy;
25612562
2563 virtual void markLibCallAttributes(MachineFunction *MF, unsigned CC,
2564 ArgListTy &Args) const {};
2565
25622566 /// This structure contains all information that is necessary for lowering
25632567 /// calls. It is passed to TLI::LowerCallTo when the SelectionDAG builder
25642568 /// needs to lower a call, and targets will see this struct in their LowerCall
26052609
26062610 CallLoweringInfo &setChain(SDValue InChain) {
26072611 Chain = InChain;
2612 return *this;
2613 }
2614
2615 // setCallee with target/module-specific attributes
2616 CallLoweringInfo &setLibCallee(CallingConv::ID CC, Type *ResultType,
2617 SDValue Target, ArgListTy &&ArgsList) {
2618 RetTy = ResultType;
2619 Callee = Target;
2620 CallConv = CC;
2621 NumFixedArgs = Args.size();
2622 Args = std::move(ArgsList);
2623
2624 DAG.getTargetLoweringInfo().markLibCallAttributes(
2625 &(DAG.getMachineFunction()), CC, Args);
26082626 return *this;
26092627 }
26102628
887887 Entry.setAttributes(&CS, ArgI + 1);
888888 Args.push_back(Entry);
889889 }
890 markFastLibCallAttributes(*MF->getSubtarget().getTargetLowering(), MF,
891 CS.getCallingConv(), Args);
890892
891893 CallLoweringInfo CLI;
892894 CLI.setCallee(RetTy, FTy, Symbol, std::move(Args), CS, NumArgs);
19341934 InChain = TCChain;
19351935
19361936 TargetLowering::CallLoweringInfo CLI(DAG);
1937 CLI.setDebugLoc(SDLoc(Node)).setChain(InChain)
1938 .setCallee(TLI.getLibcallCallingConv(LC), RetTy, Callee, std::move(Args))
1939 .setTailCall(isTailCall).setSExtResult(isSigned).setZExtResult(!isSigned);
1937 CLI.setDebugLoc(SDLoc(Node))
1938 .setChain(InChain)
1939 .setLibCallee(TLI.getLibcallCallingConv(LC), RetTy, Callee,
1940 std::move(Args))
1941 .setTailCall(isTailCall)
1942 .setSExtResult(isSigned)
1943 .setZExtResult(!isSigned);
19401944
19411945 std::pair CallInfo = TLI.LowerCallTo(CLI);
19421946
19691973 Type *RetTy = RetVT.getTypeForEVT(*DAG.getContext());
19701974
19711975 TargetLowering::CallLoweringInfo CLI(DAG);
1972 CLI.setDebugLoc(dl).setChain(DAG.getEntryNode())
1973 .setCallee(TLI.getLibcallCallingConv(LC), RetTy, Callee, std::move(Args))
1974 .setSExtResult(isSigned).setZExtResult(!isSigned);
1976 CLI.setDebugLoc(dl)
1977 .setChain(DAG.getEntryNode())
1978 .setLibCallee(TLI.getLibcallCallingConv(LC), RetTy, Callee,
1979 std::move(Args))
1980 .setSExtResult(isSigned)
1981 .setZExtResult(!isSigned);
19751982
19761983 std::pair CallInfo = TLI.LowerCallTo(CLI);
19771984
20032010 Type *RetTy = Node->getValueType(0).getTypeForEVT(*DAG.getContext());
20042011
20052012 TargetLowering::CallLoweringInfo CLI(DAG);
2006 CLI.setDebugLoc(SDLoc(Node)).setChain(InChain)
2007 .setCallee(TLI.getLibcallCallingConv(LC), RetTy, Callee, std::move(Args))
2008 .setSExtResult(isSigned).setZExtResult(!isSigned);
2013 CLI.setDebugLoc(SDLoc(Node))
2014 .setChain(InChain)
2015 .setLibCallee(TLI.getLibcallCallingConv(LC), RetTy, Callee,
2016 std::move(Args))
2017 .setSExtResult(isSigned)
2018 .setZExtResult(!isSigned);
20092019
20102020 std::pair CallInfo = TLI.LowerCallTo(CLI);
20112021
20982108
20992109 SDLoc dl(Node);
21002110 TargetLowering::CallLoweringInfo CLI(DAG);
2101 CLI.setDebugLoc(dl).setChain(InChain)
2102 .setCallee(TLI.getLibcallCallingConv(LC), RetTy, Callee, std::move(Args))
2103 .setSExtResult(isSigned).setZExtResult(!isSigned);
2111 CLI.setDebugLoc(dl)
2112 .setChain(InChain)
2113 .setLibCallee(TLI.getLibcallCallingConv(LC), RetTy, Callee,
2114 std::move(Args))
2115 .setSExtResult(isSigned)
2116 .setZExtResult(!isSigned);
21042117
21052118 std::pair CallInfo = TLI.LowerCallTo(CLI);
21062119
22092222
22102223 SDLoc dl(Node);
22112224 TargetLowering::CallLoweringInfo CLI(DAG);
2212 CLI.setDebugLoc(dl).setChain(InChain)
2213 .setCallee(TLI.getLibcallCallingConv(LC),
2214 Type::getVoidTy(*DAG.getContext()), Callee, std::move(Args));
2225 CLI.setDebugLoc(dl).setChain(InChain).setLibCallee(
2226 TLI.getLibcallCallingConv(LC), Type::getVoidTy(*DAG.getContext()), Callee,
2227 std::move(Args));
22152228
22162229 std::pair CallInfo = TLI.LowerCallTo(CLI);
22172230
38293842 TargetLowering::CallLoweringInfo CLI(DAG);
38303843 CLI.setDebugLoc(dl)
38313844 .setChain(Node->getOperand(0))
3832 .setCallee(CallingConv::C, Type::getVoidTy(*DAG.getContext()),
3833 DAG.getExternalSymbol("__sync_synchronize",
3834 TLI.getPointerTy(DAG.getDataLayout())),
3835 std::move(Args));
3845 .setLibCallee(
3846 CallingConv::C, Type::getVoidTy(*DAG.getContext()),
3847 DAG.getExternalSymbol("__sync_synchronize",
3848 TLI.getPointerTy(DAG.getDataLayout())),
3849 std::move(Args));
38363850
38373851 std::pair CallResult = TLI.LowerCallTo(CLI);
38383852
38693883 TargetLowering::CallLoweringInfo CLI(DAG);
38703884 CLI.setDebugLoc(dl)
38713885 .setChain(Node->getOperand(0))
3872 .setCallee(CallingConv::C, Type::getVoidTy(*DAG.getContext()),
3873 DAG.getExternalSymbol("abort",
3874 TLI.getPointerTy(DAG.getDataLayout())),
3875 std::move(Args));
3886 .setLibCallee(CallingConv::C, Type::getVoidTy(*DAG.getContext()),
3887 DAG.getExternalSymbol(
3888 "abort", TLI.getPointerTy(DAG.getDataLayout())),
3889 std::move(Args));
38763890 std::pair CallResult = TLI.LowerCallTo(CLI);
38773891
38783892 Results.push_back(CallResult.second);
26002600 SDValue Func = DAG.getExternalSymbol(TLI.getLibcallName(LC), PtrVT);
26012601
26022602 TargetLowering::CallLoweringInfo CLI(DAG);
2603 CLI.setDebugLoc(dl).setChain(Chain)
2604 .setCallee(TLI.getLibcallCallingConv(LC), RetTy, Func, std::move(Args))
2605 .setSExtResult();
2603 CLI.setDebugLoc(dl)
2604 .setChain(Chain)
2605 .setLibCallee(TLI.getLibcallCallingConv(LC), RetTy, Func, std::move(Args))
2606 .setSExtResult();
26062607
26072608 std::pair CallInfo = TLI.LowerCallTo(CLI);
26082609
10861086 Type *RetTy = Node->getValueType(0).getTypeForEVT(*DAG.getContext());
10871087
10881088 TargetLowering::CallLoweringInfo CLI(DAG);
1089 CLI.setDebugLoc(SDLoc(Node)).setChain(InChain)
1090 .setCallee(TLI.getLibcallCallingConv(LC), RetTy, Callee, std::move(Args))
1091 .setSExtResult(isSigned).setZExtResult(!isSigned);
1089 CLI.setDebugLoc(SDLoc(Node))
1090 .setChain(InChain)
1091 .setLibCallee(TLI.getLibcallCallingConv(LC), RetTy, Callee,
1092 std::move(Args))
1093 .setSExtResult(isSigned)
1094 .setZExtResult(!isSigned);
10921095
10931096 std::pair CallInfo = TLI.LowerCallTo(CLI);
10941097
49424942 TargetLowering::CallLoweringInfo CLI(*this);
49434943 CLI.setDebugLoc(dl)
49444944 .setChain(Chain)
4945 .setCallee(TLI->getLibcallCallingConv(RTLIB::MEMCPY),
4946 Dst.getValueType().getTypeForEVT(*getContext()),
4947 getExternalSymbol(TLI->getLibcallName(RTLIB::MEMCPY),
4948 TLI->getPointerTy(getDataLayout())),
4949 std::move(Args))
4945 .setLibCallee(TLI->getLibcallCallingConv(RTLIB::MEMCPY),
4946 Dst.getValueType().getTypeForEVT(*getContext()),
4947 getExternalSymbol(TLI->getLibcallName(RTLIB::MEMCPY),
4948 TLI->getPointerTy(getDataLayout())),
4949 std::move(Args))
49504950 .setDiscardResult()
49514951 .setTailCall(isTailCall);
49524952
50035003 TargetLowering::CallLoweringInfo CLI(*this);
50045004 CLI.setDebugLoc(dl)
50055005 .setChain(Chain)
5006 .setCallee(TLI->getLibcallCallingConv(RTLIB::MEMMOVE),
5007 Dst.getValueType().getTypeForEVT(*getContext()),
5008 getExternalSymbol(TLI->getLibcallName(RTLIB::MEMMOVE),
5009 TLI->getPointerTy(getDataLayout())),
5010 std::move(Args))
5006 .setLibCallee(TLI->getLibcallCallingConv(RTLIB::MEMMOVE),
5007 Dst.getValueType().getTypeForEVT(*getContext()),
5008 getExternalSymbol(TLI->getLibcallName(RTLIB::MEMMOVE),
5009 TLI->getPointerTy(getDataLayout())),
5010 std::move(Args))
50115011 .setDiscardResult()
50125012 .setTailCall(isTailCall);
50135013
50655065 TargetLowering::CallLoweringInfo CLI(*this);
50665066 CLI.setDebugLoc(dl)
50675067 .setChain(Chain)
5068 .setCallee(TLI->getLibcallCallingConv(RTLIB::MEMSET),
5069 Dst.getValueType().getTypeForEVT(*getContext()),
5070 getExternalSymbol(TLI->getLibcallName(RTLIB::MEMSET),
5071 TLI->getPointerTy(getDataLayout())),
5072 std::move(Args))
5068 .setLibCallee(TLI->getLibcallCallingConv(RTLIB::MEMSET),
5069 Dst.getValueType().getTypeForEVT(*getContext()),
5070 getExternalSymbol(TLI->getLibcallName(RTLIB::MEMSET),
5071 TLI->getPointerTy(getDataLayout())),
5072 std::move(Args))
50735073 .setDiscardResult()
50745074 .setTailCall(isTailCall);
50755075
49284928 report_fatal_error("Unsupported element size");
49294929
49304930 TargetLowering::CallLoweringInfo CLI(DAG);
4931 CLI.setDebugLoc(sdl)
4932 .setChain(getRoot())
4933 .setCallee(TLI.getLibcallCallingConv(LibraryCall),
4934 Type::getVoidTy(*DAG.getContext()),
4935 DAG.getExternalSymbol(
4936 TLI.getLibcallName(LibraryCall),
4937 TLI.getPointerTy(DAG.getDataLayout())),
4938 std::move(Args));
4931 CLI.setDebugLoc(sdl).setChain(getRoot()).setLibCallee(
4932 TLI.getLibcallCallingConv(LibraryCall),
4933 Type::getVoidTy(*DAG.getContext()),
4934 DAG.getExternalSymbol(TLI.getLibcallName(LibraryCall),
4935 TLI.getPointerTy(DAG.getDataLayout())),
4936 std::move(Args));
49394937
49404938 std::pair CallResult = TLI.LowerCallTo(CLI);
49414939 DAG.setRoot(CallResult.second);
55475545 TargetLowering::ArgListTy Args;
55485546
55495547 TargetLowering::CallLoweringInfo CLI(DAG);
5550 CLI.setDebugLoc(sdl).setChain(getRoot()).setCallee(
5548 CLI.setDebugLoc(sdl).setChain(getRoot()).setLibCallee(
55515549 CallingConv::C, I.getType(),
55525550 DAG.getExternalSymbol(TrapFuncName.data(),
55535551 TLI.getPointerTy(DAG.getDataLayout())),
137137 Type *RetTy = RetVT.getTypeForEVT(*DAG.getContext());
138138 TargetLowering::CallLoweringInfo CLI(DAG);
139139 bool signExtend = shouldSignExtendTypeInLibCall(RetVT, isSigned);
140 CLI.setDebugLoc(dl).setChain(DAG.getEntryNode())
141 .setCallee(getLibcallCallingConv(LC), RetTy, Callee, std::move(Args))
142 .setNoReturn(doesNotReturn).setDiscardResult(!isReturnValueUsed)
143 .setSExtResult(signExtend).setZExtResult(!signExtend);
140 CLI.setDebugLoc(dl)
141 .setChain(DAG.getEntryNode())
142 .setLibCallee(getLibcallCallingConv(LC), RetTy, Callee, std::move(Args))
143 .setNoReturn(doesNotReturn)
144 .setDiscardResult(!isReturnValueUsed)
145 .setSExtResult(signExtend)
146 .setZExtResult(!signExtend);
144147 return LowerCallTo(CLI);
145148 }
146149
38073810
38083811 TargetLowering::CallLoweringInfo CLI(DAG);
38093812 CLI.setDebugLoc(dl).setChain(DAG.getEntryNode());
3810 CLI.setCallee(CallingConv::C, VoidPtrType, EmuTlsGetAddr, std::move(Args));
3813 CLI.setLibCallee(CallingConv::C, VoidPtrType, EmuTlsGetAddr, std::move(Args));
38113814 std::pair CallResult = LowerCallTo(CLI);
38123815
38133816 // TLSADDR will be codegen'ed as call. Inform MFI that function has calls.
464464 GIF.dropAllReferences();
465465 }
466466
467 unsigned Module::getNumberRegisterParameters() const {
468 auto *Val =
469 cast_or_null(getModuleFlag("NumRegisterParameters"));
470 if (!Val)
471 return 0;
472 return cast(Val->getValue())->getZExtValue();
473 }
474
467475 unsigned Module::getDwarfVersion() const {
468476 auto *Val = cast_or_null(getModuleFlag("Dwarf Version"));
469477 if (!Val)
21232123
21242124 StructType *RetTy = StructType::get(ArgTy, ArgTy, nullptr);
21252125 TargetLowering::CallLoweringInfo CLI(DAG);
2126 CLI.setDebugLoc(dl).setChain(DAG.getEntryNode())
2127 .setCallee(CallingConv::Fast, RetTy, Callee, std::move(Args));
2126 CLI.setDebugLoc(dl)
2127 .setChain(DAG.getEntryNode())
2128 .setLibCallee(CallingConv::Fast, RetTy, Callee, std::move(Args));
21282129
21292130 std::pair CallResult = LowerCallTo(CLI);
21302131 return CallResult.first;
4141 Entry.Node = Size;
4242 Args.push_back(Entry);
4343 TargetLowering::CallLoweringInfo CLI(DAG);
44 CLI.setDebugLoc(dl).setChain(Chain)
45 .setCallee(CallingConv::C, Type::getVoidTy(*DAG.getContext()),
46 DAG.getExternalSymbol(bzeroEntry, IntPtr), std::move(Args))
47 .setDiscardResult();
44 CLI.setDebugLoc(dl)
45 .setChain(Chain)
46 .setLibCallee(CallingConv::C, Type::getVoidTy(*DAG.getContext()),
47 DAG.getExternalSymbol(bzeroEntry, IntPtr),
48 std::move(Args))
49 .setDiscardResult();
4850 std::pair CallResult = TLI.LowerCallTo(CLI);
4951 return CallResult.second;
5052 }
27892789
27902790 // FIXME: is there useful debug info available here?
27912791 TargetLowering::CallLoweringInfo CLI(DAG);
2792 CLI.setDebugLoc(dl).setChain(Chain)
2793 .setCallee(CallingConv::C, Type::getInt32Ty(*DAG.getContext()),
2794 DAG.getExternalSymbol("__tls_get_addr", PtrVT), std::move(Args));
2792 CLI.setDebugLoc(dl).setChain(Chain).setLibCallee(
2793 CallingConv::C, Type::getInt32Ty(*DAG.getContext()),
2794 DAG.getExternalSymbol("__tls_get_addr", PtrVT), std::move(Args));
27952795
27962796 std::pair CallResult = LowerCallTo(CLI);
27972797 return CallResult.first;
113113 TargetLowering::CallLoweringInfo CLI(DAG);
114114 CLI.setDebugLoc(dl)
115115 .setChain(Chain)
116 .setCallee(
117 TLI->getLibcallCallingConv(LC), Type::getVoidTy(*DAG.getContext()),
118 DAG.getExternalSymbol(FunctionNames[AEABILibcall][AlignVariant],
119 TLI->getPointerTy(DAG.getDataLayout())),
120 std::move(Args))
116 .setLibCallee(
117 TLI->getLibcallCallingConv(LC), Type::getVoidTy(*DAG.getContext()),
118 DAG.getExternalSymbol(FunctionNames[AEABILibcall][AlignVariant],
119 TLI->getPointerTy(DAG.getDataLayout())),
120 std::move(Args))
121121 .setDiscardResult();
122122 std::pair CallResult = TLI->LowerCallTo(CLI);
123123
353353 TargetLowering::CallLoweringInfo CLI(DAG);
354354 CLI.setDebugLoc(dl)
355355 .setChain(InChain)
356 .setCallee(getLibcallCallingConv(LC), RetTy, Callee, std::move(Args))
356 .setLibCallee(getLibcallCallingConv(LC), RetTy, Callee, std::move(Args))
357357 .setInRegister()
358358 .setSExtResult(isSigned)
359359 .setZExtResult(!isSigned);
5050 TargetLowering::CallLoweringInfo CLI(DAG);
5151 CLI.setDebugLoc(dl)
5252 .setChain(Chain)
53 .setCallee(TLI.getLibcallCallingConv(RTLIB::MEMCPY),
54 Type::getVoidTy(*DAG.getContext()),
55 DAG.getTargetExternalSymbol(SpecialMemcpyName,
56 TLI.getPointerTy(DAG.getDataLayout()), Flags),
57 std::move(Args))
53 .setLibCallee(
54 TLI.getLibcallCallingConv(RTLIB::MEMCPY),
55 Type::getVoidTy(*DAG.getContext()),
56 DAG.getTargetExternalSymbol(
57 SpecialMemcpyName, TLI.getPointerTy(DAG.getDataLayout()), Flags),
58 std::move(Args))
5859 .setDiscardResult();
5960
6061 std::pair CallResult = TLI.LowerCallTo(CLI);
18191819 Args.push_back(Entry);
18201820
18211821 TargetLowering::CallLoweringInfo CLI(DAG);
1822 CLI.setDebugLoc(DL).setChain(DAG.getEntryNode())
1823 .setCallee(CallingConv::C, PtrTy, TlsGetAddr, std::move(Args));
1822 CLI.setDebugLoc(DL)
1823 .setChain(DAG.getEntryNode())
1824 .setLibCallee(CallingConv::C, PtrTy, TlsGetAddr, std::move(Args));
18241825 std::pair CallResult = LowerCallTo(CLI);
18251826
18261827 SDValue Ret = CallResult.first;
26012601
26022602 // Lower to a call to __trampoline_setup(Trmp, TrampSize, FPtr, ctx_reg)
26032603 TargetLowering::CallLoweringInfo CLI(DAG);
2604 CLI.setDebugLoc(dl).setChain(Chain)
2605 .setCallee(CallingConv::C, Type::getVoidTy(*DAG.getContext()),
2606 DAG.getExternalSymbol("__trampoline_setup", PtrVT),
2607 std::move(Args));
2604 CLI.setDebugLoc(dl).setChain(Chain).setLibCallee(
2605 CallingConv::C, Type::getVoidTy(*DAG.getContext()),
2606 DAG.getExternalSymbol("__trampoline_setup", PtrVT), std::move(Args));
26082607
26092608 std::pair CallResult = LowerCallTo(CLI);
26102609 return CallResult.second;
5252 #include "llvm/Support/Debug.h"
5353 #include "llvm/Support/ErrorHandling.h"
5454 #include "llvm/Support/MathExtras.h"
55 #include "llvm/Target/TargetLowering.h"
5556 #include "llvm/Target/TargetOptions.h"
5657 #include
5758 #include
19301931
19311932 bool X86TargetLowering::useSoftFloat() const {
19321933 return Subtarget.useSoftFloat();
1934 }
1935
1936 void X86TargetLowering::markLibCallAttributes(MachineFunction *MF, unsigned CC,
1937 ArgListTy &Args) const {
1938
1939 // Only relabel X86-32 for C / Stdcall CCs.
1940 if (static_cast(MF->getSubtarget()).is64Bit())
1941 return;
1942 if (CC != CallingConv::C && CC != CallingConv::X86_StdCall)
1943 return;
1944 unsigned ParamRegs = 0;
1945 if (auto *M = MF->getFunction()->getParent())
1946 ParamRegs = M->getNumberRegisterParameters();
1947
1948 // Mark the first N int arguments as having reg
1949 for (unsigned Idx = 0; Idx < Args.size(); Idx++) {
1950 Type *T = Args[Idx].Ty;
1951 if (T->isPointerTy() || T->isIntegerTy())
1952 if (MF->getDataLayout().getTypeAllocSize(T) <= 8) {
1953 unsigned numRegs = 1;
1954 if (MF->getDataLayout().getTypeAllocSize(T) > 4)
1955 numRegs = 2;
1956 if (ParamRegs < numRegs)
1957 return;
1958 ParamRegs -= numRegs;
1959 Args[Idx].isInReg = true;
1960 }
1961 }
19331962 }
19341963
19351964 const MCExpr *
2115621185 getPointerTy(DAG.getDataLayout()));
2115721186
2115821187 TargetLowering::CallLoweringInfo CLI(DAG);
21159 CLI.setDebugLoc(dl).setChain(InChain)
21160 .setCallee(getLibcallCallingConv(LC),
21161 static_cast(MVT::v2i64).getTypeForEVT(*DAG.getContext()),
21162 Callee, std::move(Args))
21163 .setInRegister().setSExtResult(isSigned).setZExtResult(!isSigned);
21188 CLI.setDebugLoc(dl)
21189 .setChain(InChain)
21190 .setLibCallee(
21191 getLibcallCallingConv(LC),
21192 static_cast(MVT::v2i64).getTypeForEVT(*DAG.getContext()), Callee,
21193 std::move(Args))
21194 .setInRegister()
21195 .setSExtResult(isSigned)
21196 .setZExtResult(!isSigned);
2116421197
2116521198 std::pair CallInfo = LowerCallTo(CLI);
2116621199 return DAG.getBitcast(VT, CallInfo.first);
2288422917 : (Type*)VectorType::get(ArgTy, 4);
2288522918
2288622919 TargetLowering::CallLoweringInfo CLI(DAG);
22887 CLI.setDebugLoc(dl).setChain(DAG.getEntryNode())
22888 .setCallee(CallingConv::C, RetTy, Callee, std::move(Args));
22920 CLI.setDebugLoc(dl)
22921 .setChain(DAG.getEntryNode())
22922 .setLibCallee(CallingConv::C, RetTy, Callee, std::move(Args));
2288922923
2289022924 std::pair CallResult = TLI.LowerCallTo(CLI);
2289122925
684684
685685 unsigned getJumpTableEncoding() const override;
686686 bool useSoftFloat() const override;
687
688 void markLibCallAttributes(MachineFunction *MF, unsigned CC,
689 ArgListTy &Args) const override;
687690
688691 MVT getScalarShiftAmountTy(const DataLayout &, EVT) const override {
689692 return MVT::i8;
8484 Args.push_back(Entry);
8585
8686 TargetLowering::CallLoweringInfo CLI(DAG);
87 CLI.setDebugLoc(dl).setChain(Chain)
88 .setCallee(CallingConv::C, Type::getVoidTy(*DAG.getContext()),
89 DAG.getExternalSymbol(bzeroEntry, IntPtr), std::move(Args))
90 .setDiscardResult();
87 CLI.setDebugLoc(dl)
88 .setChain(Chain)
89 .setLibCallee(CallingConv::C, Type::getVoidTy(*DAG.getContext()),
90 DAG.getExternalSymbol(bzeroEntry, IntPtr),
91 std::move(Args))
92 .setDiscardResult();
9193
9294 std::pair CallResult = TLI.LowerCallTo(CLI);
9395 return CallResult.second;
482482 Args.push_back(Entry);
483483
484484 TargetLowering::CallLoweringInfo CLI(DAG);
485 CLI.setDebugLoc(DL).setChain(Chain).setCallee(
485 CLI.setDebugLoc(DL).setChain(Chain).setLibCallee(
486486 CallingConv::C, IntPtrTy,
487487 DAG.getExternalSymbol("__misaligned_load",
488488 getPointerTy(DAG.getDataLayout())),
3434 TargetLowering::CallLoweringInfo CLI(DAG);
3535 CLI.setDebugLoc(dl)
3636 .setChain(Chain)
37 .setCallee(TLI.getLibcallCallingConv(RTLIB::MEMCPY),
38 Type::getVoidTy(*DAG.getContext()),
39 DAG.getExternalSymbol("__memcpy_4",
40 TLI.getPointerTy(DAG.getDataLayout())),
41 std::move(Args))
37 .setLibCallee(TLI.getLibcallCallingConv(RTLIB::MEMCPY),
38 Type::getVoidTy(*DAG.getContext()),
39 DAG.getExternalSymbol(
40 "__memcpy_4", TLI.getPointerTy(DAG.getDataLayout())),
41 std::move(Args))
4242 .setDiscardResult();
4343
4444 std::pair CallResult = TLI.LowerCallTo(CLI);
0 ; RUN: llc %s -mtriple=i386-pc-linux -o - | FileCheck -check-prefix=CHECK %s
1 ; RUN: llc %s -mtriple=i386-pc-win32 -o - | FileCheck -check-prefix=WIN %s
2 ; RUN: llc %s -mtriple=i386-pc-linux -fast-isel -o - | FileCheck -check-prefix=FAST %s
3 ; RUN: llc %s -mtriple=i386-pc-win32 -fast-isel -o - | FileCheck -check-prefix=FASTWIN %s
4
5
6
7 target datalayout = "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128"
8 target triple = "i386-unknown-linux-gnu"
9
10 ; Function Attrs: argmemonly nounwind
11 declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture writeonly, i8* nocapture readonly, i32, i32, i1) #1
12
13 define void @use_memset(i8* inreg nocapture %dest, i8 inreg %c, i32 inreg %n) local_unnamed_addr #0 {
14 entry:
15 ;CHECK-LABEL: @use_memset
16 ;CHECK-NOT: push
17 ;CHECK: jmp memset
18 ;CHECK-NOT: retl
19 ;WIN-LABEL: @use_memset
20 ;WIN-NOT: push
21 ;WIN: jmp _memset
22 ;WIN-NOT: retl
23 ;FAST-LABEL: @use_memset
24 ;FAST: subl $12, %esp
25 ;FAST-NEXT: movzbl %dl, %edx
26 ;FAST-NEXT: calll memset
27 ;FAST-NEXT: addl $12, %esp
28 ;FASTWIN-LABEL: @use_memset
29 ;FASTWIN: movzbl %dl, %edx
30 ;FASTWIN-NEXT: calll _memset
31 ;FASTWIN-NEXT: retl
32 tail call void @llvm.memset.p0i8.i32(i8* %dest, i8 %c, i32 %n, i32 1, i1 false)
33 ret void
34 }
35
36 ; Function Attrs: argmemonly nounwind
37 declare void @llvm.memset.p0i8.i32(i8* nocapture writeonly, i8, i32, i32, i1) #1
38
39
40 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" }
41 attributes #1 = { argmemonly nounwind }
42
43 !llvm.module.flags = !{!0}
44 !llvm.ident = !{!1}
45
46 !0 = !{i32 1, !"NumRegisterParameters", i32 3}
47 !1 = !{!"clang version 4.0.0 (trunk 288025) (llvm/trunk 288033)"}