CallingConvLower.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- llvm/CallingConvLower.h - Calling Conventions ------------*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. //
  14. // This file declares the CCState and CCValAssign classes, used for lowering
  15. // and implementing calling conventions.
  16. //
  17. //===----------------------------------------------------------------------===//
  18. #ifndef LLVM_CODEGEN_CALLINGCONVLOWER_H
  19. #define LLVM_CODEGEN_CALLINGCONVLOWER_H
  20. #include "llvm/ADT/SmallVector.h"
  21. #include "llvm/CodeGen/Register.h"
  22. #include "llvm/CodeGen/TargetCallingConv.h"
  23. #include "llvm/IR/CallingConv.h"
  24. #include "llvm/Support/Alignment.h"
  25. namespace llvm {
  26. class CCState;
  27. class MachineFunction;
  28. class MVT;
  29. class TargetRegisterInfo;
  30. /// CCValAssign - Represent assignment of one arg/retval to a location.
  31. class CCValAssign {
  32. public:
  33. enum LocInfo {
  34. Full, // The value fills the full location.
  35. SExt, // The value is sign extended in the location.
  36. ZExt, // The value is zero extended in the location.
  37. AExt, // The value is extended with undefined upper bits.
  38. SExtUpper, // The value is in the upper bits of the location and should be
  39. // sign extended when retrieved.
  40. ZExtUpper, // The value is in the upper bits of the location and should be
  41. // zero extended when retrieved.
  42. AExtUpper, // The value is in the upper bits of the location and should be
  43. // extended with undefined upper bits when retrieved.
  44. BCvt, // The value is bit-converted in the location.
  45. Trunc, // The value is truncated in the location.
  46. VExt, // The value is vector-widened in the location.
  47. // FIXME: Not implemented yet. Code that uses AExt to mean
  48. // vector-widen should be fixed to use VExt instead.
  49. FPExt, // The floating-point value is fp-extended in the location.
  50. Indirect // The location contains pointer to the value.
  51. // TODO: a subset of the value is in the location.
  52. };
  53. private:
  54. // Holds one of:
  55. // - the register that the value is assigned to;
  56. // - the memory offset at which the value resides;
  57. // - additional information about pending location; the exact interpretation
  58. // of the data is target-dependent.
  59. std::variant<Register, int64_t, unsigned> Data;
  60. /// ValNo - This is the value number being assigned (e.g. an argument number).
  61. unsigned ValNo;
  62. /// isCustom - True if this arg/retval requires special handling.
  63. unsigned isCustom : 1;
  64. /// Information about how the value is assigned.
  65. LocInfo HTP : 6;
  66. /// ValVT - The type of the value being assigned.
  67. MVT ValVT;
  68. /// LocVT - The type of the location being assigned to.
  69. MVT LocVT;
  70. CCValAssign(LocInfo HTP, unsigned ValNo, MVT ValVT, MVT LocVT, bool IsCustom)
  71. : ValNo(ValNo), isCustom(IsCustom), HTP(HTP), ValVT(ValVT), LocVT(LocVT) {
  72. }
  73. public:
  74. static CCValAssign getReg(unsigned ValNo, MVT ValVT, unsigned RegNo,
  75. MVT LocVT, LocInfo HTP, bool IsCustom = false) {
  76. CCValAssign Ret(HTP, ValNo, ValVT, LocVT, IsCustom);
  77. Ret.Data = Register(RegNo);
  78. return Ret;
  79. }
  80. static CCValAssign getCustomReg(unsigned ValNo, MVT ValVT, unsigned RegNo,
  81. MVT LocVT, LocInfo HTP) {
  82. return getReg(ValNo, ValVT, RegNo, LocVT, HTP, /*IsCustom=*/true);
  83. }
  84. static CCValAssign getMem(unsigned ValNo, MVT ValVT, unsigned Offset,
  85. MVT LocVT, LocInfo HTP, bool IsCustom = false) {
  86. CCValAssign Ret(HTP, ValNo, ValVT, LocVT, IsCustom);
  87. Ret.Data = int64_t(Offset);
  88. return Ret;
  89. }
  90. static CCValAssign getCustomMem(unsigned ValNo, MVT ValVT, unsigned Offset,
  91. MVT LocVT, LocInfo HTP) {
  92. return getMem(ValNo, ValVT, Offset, LocVT, HTP, /*IsCustom=*/true);
  93. }
  94. static CCValAssign getPending(unsigned ValNo, MVT ValVT, MVT LocVT,
  95. LocInfo HTP, unsigned ExtraInfo = 0) {
  96. CCValAssign Ret(HTP, ValNo, ValVT, LocVT, false);
  97. Ret.Data = ExtraInfo;
  98. return Ret;
  99. }
  100. void convertToReg(unsigned RegNo) { Data = Register(RegNo); }
  101. void convertToMem(unsigned Offset) { Data = int64_t(Offset); }
  102. unsigned getValNo() const { return ValNo; }
  103. MVT getValVT() const { return ValVT; }
  104. bool isRegLoc() const { return std::holds_alternative<Register>(Data); }
  105. bool isMemLoc() const { return std::holds_alternative<int64_t>(Data); }
  106. bool isPendingLoc() const { return std::holds_alternative<unsigned>(Data); }
  107. bool needsCustom() const { return isCustom; }
  108. Register getLocReg() const { return std::get<Register>(Data); }
  109. unsigned getLocMemOffset() const { return std::get<int64_t>(Data); }
  110. unsigned getExtraInfo() const { return std::get<unsigned>(Data); }
  111. MVT getLocVT() const { return LocVT; }
  112. LocInfo getLocInfo() const { return HTP; }
  113. bool isExtInLoc() const {
  114. return (HTP == AExt || HTP == SExt || HTP == ZExt);
  115. }
  116. bool isUpperBitsInLoc() const {
  117. return HTP == AExtUpper || HTP == SExtUpper || HTP == ZExtUpper;
  118. }
  119. };
  120. /// Describes a register that needs to be forwarded from the prologue to a
  121. /// musttail call.
  122. struct ForwardedRegister {
  123. ForwardedRegister(Register VReg, MCPhysReg PReg, MVT VT)
  124. : VReg(VReg), PReg(PReg), VT(VT) {}
  125. Register VReg;
  126. MCPhysReg PReg;
  127. MVT VT;
  128. };
  129. /// CCAssignFn - This function assigns a location for Val, updating State to
  130. /// reflect the change. It returns 'true' if it failed to handle Val.
  131. typedef bool CCAssignFn(unsigned ValNo, MVT ValVT,
  132. MVT LocVT, CCValAssign::LocInfo LocInfo,
  133. ISD::ArgFlagsTy ArgFlags, CCState &State);
  134. /// CCCustomFn - This function assigns a location for Val, possibly updating
  135. /// all args to reflect changes and indicates if it handled it. It must set
  136. /// isCustom if it handles the arg and returns true.
  137. typedef bool CCCustomFn(unsigned &ValNo, MVT &ValVT,
  138. MVT &LocVT, CCValAssign::LocInfo &LocInfo,
  139. ISD::ArgFlagsTy &ArgFlags, CCState &State);
  140. /// CCState - This class holds information needed while lowering arguments and
  141. /// return values. It captures which registers are already assigned and which
  142. /// stack slots are used. It provides accessors to allocate these values.
  143. class CCState {
  144. private:
  145. CallingConv::ID CallingConv;
  146. bool IsVarArg;
  147. bool AnalyzingMustTailForwardedRegs = false;
  148. MachineFunction &MF;
  149. const TargetRegisterInfo &TRI;
  150. SmallVectorImpl<CCValAssign> &Locs;
  151. LLVMContext &Context;
  152. unsigned StackOffset;
  153. Align MaxStackArgAlign;
  154. SmallVector<uint32_t, 16> UsedRegs;
  155. SmallVector<CCValAssign, 4> PendingLocs;
  156. SmallVector<ISD::ArgFlagsTy, 4> PendingArgFlags;
  157. // ByValInfo and SmallVector<ByValInfo, 4> ByValRegs:
  158. //
  159. // Vector of ByValInfo instances (ByValRegs) is introduced for byval registers
  160. // tracking.
  161. // Or, in another words it tracks byval parameters that are stored in
  162. // general purpose registers.
  163. //
  164. // For 4 byte stack alignment,
  165. // instance index means byval parameter number in formal
  166. // arguments set. Assume, we have some "struct_type" with size = 4 bytes,
  167. // then, for function "foo":
  168. //
  169. // i32 foo(i32 %p, %struct_type* %r, i32 %s, %struct_type* %t)
  170. //
  171. // ByValRegs[0] describes how "%r" is stored (Begin == r1, End == r2)
  172. // ByValRegs[1] describes how "%t" is stored (Begin == r3, End == r4).
  173. //
  174. // In case of 8 bytes stack alignment,
  175. // In function shown above, r3 would be wasted according to AAPCS rules.
  176. // ByValRegs vector size still would be 2,
  177. // while "%t" goes to the stack: it wouldn't be described in ByValRegs.
  178. //
  179. // Supposed use-case for this collection:
  180. // 1. Initially ByValRegs is empty, InRegsParamsProcessed is 0.
  181. // 2. HandleByVal fills up ByValRegs.
  182. // 3. Argument analysis (LowerFormatArguments, for example). After
  183. // some byval argument was analyzed, InRegsParamsProcessed is increased.
  184. struct ByValInfo {
  185. ByValInfo(unsigned B, unsigned E) : Begin(B), End(E) {}
  186. // First register allocated for current parameter.
  187. unsigned Begin;
  188. // First after last register allocated for current parameter.
  189. unsigned End;
  190. };
  191. SmallVector<ByValInfo, 4 > ByValRegs;
  192. // InRegsParamsProcessed - shows how many instances of ByValRegs was proceed
  193. // during argument analysis.
  194. unsigned InRegsParamsProcessed;
  195. public:
  196. CCState(CallingConv::ID CC, bool isVarArg, MachineFunction &MF,
  197. SmallVectorImpl<CCValAssign> &locs, LLVMContext &C);
  198. void addLoc(const CCValAssign &V) {
  199. Locs.push_back(V);
  200. }
  201. LLVMContext &getContext() const { return Context; }
  202. MachineFunction &getMachineFunction() const { return MF; }
  203. CallingConv::ID getCallingConv() const { return CallingConv; }
  204. bool isVarArg() const { return IsVarArg; }
  205. /// getNextStackOffset - Return the next stack offset such that all stack
  206. /// slots satisfy their alignment requirements.
  207. unsigned getNextStackOffset() const {
  208. return StackOffset;
  209. }
  210. /// getAlignedCallFrameSize - Return the size of the call frame needed to
  211. /// be able to store all arguments and such that the alignment requirement
  212. /// of each of the arguments is satisfied.
  213. unsigned getAlignedCallFrameSize() const {
  214. return alignTo(StackOffset, MaxStackArgAlign);
  215. }
  216. /// isAllocated - Return true if the specified register (or an alias) is
  217. /// allocated.
  218. bool isAllocated(MCRegister Reg) const {
  219. return UsedRegs[Reg / 32] & (1 << (Reg & 31));
  220. }
  221. /// AnalyzeFormalArguments - Analyze an array of argument values,
  222. /// incorporating info about the formals into this state.
  223. void AnalyzeFormalArguments(const SmallVectorImpl<ISD::InputArg> &Ins,
  224. CCAssignFn Fn);
  225. /// The function will invoke AnalyzeFormalArguments.
  226. void AnalyzeArguments(const SmallVectorImpl<ISD::InputArg> &Ins,
  227. CCAssignFn Fn) {
  228. AnalyzeFormalArguments(Ins, Fn);
  229. }
  230. /// AnalyzeReturn - Analyze the returned values of a return,
  231. /// incorporating info about the result values into this state.
  232. void AnalyzeReturn(const SmallVectorImpl<ISD::OutputArg> &Outs,
  233. CCAssignFn Fn);
  234. /// CheckReturn - Analyze the return values of a function, returning
  235. /// true if the return can be performed without sret-demotion, and
  236. /// false otherwise.
  237. bool CheckReturn(const SmallVectorImpl<ISD::OutputArg> &Outs,
  238. CCAssignFn Fn);
  239. /// AnalyzeCallOperands - Analyze the outgoing arguments to a call,
  240. /// incorporating info about the passed values into this state.
  241. void AnalyzeCallOperands(const SmallVectorImpl<ISD::OutputArg> &Outs,
  242. CCAssignFn Fn);
  243. /// AnalyzeCallOperands - Same as above except it takes vectors of types
  244. /// and argument flags.
  245. void AnalyzeCallOperands(SmallVectorImpl<MVT> &ArgVTs,
  246. SmallVectorImpl<ISD::ArgFlagsTy> &Flags,
  247. CCAssignFn Fn);
  248. /// The function will invoke AnalyzeCallOperands.
  249. void AnalyzeArguments(const SmallVectorImpl<ISD::OutputArg> &Outs,
  250. CCAssignFn Fn) {
  251. AnalyzeCallOperands(Outs, Fn);
  252. }
  253. /// AnalyzeCallResult - Analyze the return values of a call,
  254. /// incorporating info about the passed values into this state.
  255. void AnalyzeCallResult(const SmallVectorImpl<ISD::InputArg> &Ins,
  256. CCAssignFn Fn);
  257. /// A shadow allocated register is a register that was allocated
  258. /// but wasn't added to the location list (Locs).
  259. /// \returns true if the register was allocated as shadow or false otherwise.
  260. bool IsShadowAllocatedReg(MCRegister Reg) const;
  261. /// AnalyzeCallResult - Same as above except it's specialized for calls which
  262. /// produce a single value.
  263. void AnalyzeCallResult(MVT VT, CCAssignFn Fn);
  264. /// getFirstUnallocated - Return the index of the first unallocated register
  265. /// in the set, or Regs.size() if they are all allocated.
  266. unsigned getFirstUnallocated(ArrayRef<MCPhysReg> Regs) const {
  267. for (unsigned i = 0; i < Regs.size(); ++i)
  268. if (!isAllocated(Regs[i]))
  269. return i;
  270. return Regs.size();
  271. }
  272. void DeallocateReg(MCPhysReg Reg) {
  273. assert(isAllocated(Reg) && "Trying to deallocate an unallocated register");
  274. MarkUnallocated(Reg);
  275. }
  276. /// AllocateReg - Attempt to allocate one register. If it is not available,
  277. /// return zero. Otherwise, return the register, marking it and any aliases
  278. /// as allocated.
  279. MCRegister AllocateReg(MCPhysReg Reg) {
  280. if (isAllocated(Reg))
  281. return MCRegister();
  282. MarkAllocated(Reg);
  283. return Reg;
  284. }
  285. /// Version of AllocateReg with extra register to be shadowed.
  286. MCRegister AllocateReg(MCPhysReg Reg, MCPhysReg ShadowReg) {
  287. if (isAllocated(Reg))
  288. return MCRegister();
  289. MarkAllocated(Reg);
  290. MarkAllocated(ShadowReg);
  291. return Reg;
  292. }
  293. /// AllocateReg - Attempt to allocate one of the specified registers. If none
  294. /// are available, return zero. Otherwise, return the first one available,
  295. /// marking it and any aliases as allocated.
  296. MCPhysReg AllocateReg(ArrayRef<MCPhysReg> Regs) {
  297. unsigned FirstUnalloc = getFirstUnallocated(Regs);
  298. if (FirstUnalloc == Regs.size())
  299. return MCRegister(); // Didn't find the reg.
  300. // Mark the register and any aliases as allocated.
  301. MCPhysReg Reg = Regs[FirstUnalloc];
  302. MarkAllocated(Reg);
  303. return Reg;
  304. }
  305. /// AllocateRegBlock - Attempt to allocate a block of RegsRequired consecutive
  306. /// registers. If this is not possible, return zero. Otherwise, return the first
  307. /// register of the block that were allocated, marking the entire block as allocated.
  308. MCPhysReg AllocateRegBlock(ArrayRef<MCPhysReg> Regs, unsigned RegsRequired) {
  309. if (RegsRequired > Regs.size())
  310. return 0;
  311. for (unsigned StartIdx = 0; StartIdx <= Regs.size() - RegsRequired;
  312. ++StartIdx) {
  313. bool BlockAvailable = true;
  314. // Check for already-allocated regs in this block
  315. for (unsigned BlockIdx = 0; BlockIdx < RegsRequired; ++BlockIdx) {
  316. if (isAllocated(Regs[StartIdx + BlockIdx])) {
  317. BlockAvailable = false;
  318. break;
  319. }
  320. }
  321. if (BlockAvailable) {
  322. // Mark the entire block as allocated
  323. for (unsigned BlockIdx = 0; BlockIdx < RegsRequired; ++BlockIdx) {
  324. MarkAllocated(Regs[StartIdx + BlockIdx]);
  325. }
  326. return Regs[StartIdx];
  327. }
  328. }
  329. // No block was available
  330. return 0;
  331. }
  332. /// Version of AllocateReg with list of registers to be shadowed.
  333. MCRegister AllocateReg(ArrayRef<MCPhysReg> Regs, const MCPhysReg *ShadowRegs) {
  334. unsigned FirstUnalloc = getFirstUnallocated(Regs);
  335. if (FirstUnalloc == Regs.size())
  336. return MCRegister(); // Didn't find the reg.
  337. // Mark the register and any aliases as allocated.
  338. MCRegister Reg = Regs[FirstUnalloc], ShadowReg = ShadowRegs[FirstUnalloc];
  339. MarkAllocated(Reg);
  340. MarkAllocated(ShadowReg);
  341. return Reg;
  342. }
  343. /// AllocateStack - Allocate a chunk of stack space with the specified size
  344. /// and alignment.
  345. unsigned AllocateStack(unsigned Size, Align Alignment) {
  346. StackOffset = alignTo(StackOffset, Alignment);
  347. unsigned Result = StackOffset;
  348. StackOffset += Size;
  349. MaxStackArgAlign = std::max(Alignment, MaxStackArgAlign);
  350. ensureMaxAlignment(Alignment);
  351. return Result;
  352. }
  353. void ensureMaxAlignment(Align Alignment);
  354. /// Version of AllocateStack with list of extra registers to be shadowed.
  355. /// Note that, unlike AllocateReg, this shadows ALL of the shadow registers.
  356. unsigned AllocateStack(unsigned Size, Align Alignment,
  357. ArrayRef<MCPhysReg> ShadowRegs) {
  358. for (MCPhysReg Reg : ShadowRegs)
  359. MarkAllocated(Reg);
  360. return AllocateStack(Size, Alignment);
  361. }
  362. // HandleByVal - Allocate a stack slot large enough to pass an argument by
  363. // value. The size and alignment information of the argument is encoded in its
  364. // parameter attribute.
  365. void HandleByVal(unsigned ValNo, MVT ValVT, MVT LocVT,
  366. CCValAssign::LocInfo LocInfo, int MinSize, Align MinAlign,
  367. ISD::ArgFlagsTy ArgFlags);
  368. // Returns count of byval arguments that are to be stored (even partly)
  369. // in registers.
  370. unsigned getInRegsParamsCount() const { return ByValRegs.size(); }
  371. // Returns count of byval in-regs arguments processed.
  372. unsigned getInRegsParamsProcessed() const { return InRegsParamsProcessed; }
  373. // Get information about N-th byval parameter that is stored in registers.
  374. // Here "ByValParamIndex" is N.
  375. void getInRegsParamInfo(unsigned InRegsParamRecordIndex,
  376. unsigned& BeginReg, unsigned& EndReg) const {
  377. assert(InRegsParamRecordIndex < ByValRegs.size() &&
  378. "Wrong ByVal parameter index");
  379. const ByValInfo& info = ByValRegs[InRegsParamRecordIndex];
  380. BeginReg = info.Begin;
  381. EndReg = info.End;
  382. }
  383. // Add information about parameter that is kept in registers.
  384. void addInRegsParamInfo(unsigned RegBegin, unsigned RegEnd) {
  385. ByValRegs.push_back(ByValInfo(RegBegin, RegEnd));
  386. }
  387. // Goes either to next byval parameter (excluding "waste" record), or
  388. // to the end of collection.
  389. // Returns false, if end is reached.
  390. bool nextInRegsParam() {
  391. unsigned e = ByValRegs.size();
  392. if (InRegsParamsProcessed < e)
  393. ++InRegsParamsProcessed;
  394. return InRegsParamsProcessed < e;
  395. }
  396. // Clear byval registers tracking info.
  397. void clearByValRegsInfo() {
  398. InRegsParamsProcessed = 0;
  399. ByValRegs.clear();
  400. }
  401. // Rewind byval registers tracking info.
  402. void rewindByValRegsInfo() {
  403. InRegsParamsProcessed = 0;
  404. }
  405. // Get list of pending assignments
  406. SmallVectorImpl<CCValAssign> &getPendingLocs() {
  407. return PendingLocs;
  408. }
  409. // Get a list of argflags for pending assignments.
  410. SmallVectorImpl<ISD::ArgFlagsTy> &getPendingArgFlags() {
  411. return PendingArgFlags;
  412. }
  413. /// Compute the remaining unused register parameters that would be used for
  414. /// the given value type. This is useful when varargs are passed in the
  415. /// registers that normal prototyped parameters would be passed in, or for
  416. /// implementing perfect forwarding.
  417. void getRemainingRegParmsForType(SmallVectorImpl<MCPhysReg> &Regs, MVT VT,
  418. CCAssignFn Fn);
  419. /// Compute the set of registers that need to be preserved and forwarded to
  420. /// any musttail calls.
  421. void analyzeMustTailForwardedRegisters(
  422. SmallVectorImpl<ForwardedRegister> &Forwards, ArrayRef<MVT> RegParmTypes,
  423. CCAssignFn Fn);
  424. /// Returns true if the results of the two calling conventions are compatible.
  425. /// This is usually part of the check for tailcall eligibility.
  426. static bool resultsCompatible(CallingConv::ID CalleeCC,
  427. CallingConv::ID CallerCC, MachineFunction &MF,
  428. LLVMContext &C,
  429. const SmallVectorImpl<ISD::InputArg> &Ins,
  430. CCAssignFn CalleeFn, CCAssignFn CallerFn);
  431. /// The function runs an additional analysis pass over function arguments.
  432. /// It will mark each argument with the attribute flag SecArgPass.
  433. /// After running, it will sort the locs list.
  434. template <class T>
  435. void AnalyzeArgumentsSecondPass(const SmallVectorImpl<T> &Args,
  436. CCAssignFn Fn) {
  437. unsigned NumFirstPassLocs = Locs.size();
  438. /// Creates similar argument list to \p Args in which each argument is
  439. /// marked using SecArgPass flag.
  440. SmallVector<T, 16> SecPassArg;
  441. // SmallVector<ISD::InputArg, 16> SecPassArg;
  442. for (auto Arg : Args) {
  443. Arg.Flags.setSecArgPass();
  444. SecPassArg.push_back(Arg);
  445. }
  446. // Run the second argument pass
  447. AnalyzeArguments(SecPassArg, Fn);
  448. // Sort the locations of the arguments according to their original position.
  449. SmallVector<CCValAssign, 16> TmpArgLocs;
  450. TmpArgLocs.swap(Locs);
  451. auto B = TmpArgLocs.begin(), E = TmpArgLocs.end();
  452. std::merge(B, B + NumFirstPassLocs, B + NumFirstPassLocs, E,
  453. std::back_inserter(Locs),
  454. [](const CCValAssign &A, const CCValAssign &B) -> bool {
  455. return A.getValNo() < B.getValNo();
  456. });
  457. }
  458. private:
  459. /// MarkAllocated - Mark a register and all of its aliases as allocated.
  460. void MarkAllocated(MCPhysReg Reg);
  461. void MarkUnallocated(MCPhysReg Reg);
  462. };
  463. } // end namespace llvm
  464. #endif // LLVM_CODEGEN_CALLINGCONVLOWER_H
  465. #ifdef __GNUC__
  466. #pragma GCC diagnostic pop
  467. #endif