CallingConvLower.h 21 KB

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