diff options
Diffstat (limited to 'include/llvm/CodeGen/MachineFunction.h')
-rw-r--r-- | include/llvm/CodeGen/MachineFunction.h | 76 |
1 files changed, 61 insertions, 15 deletions
diff --git a/include/llvm/CodeGen/MachineFunction.h b/include/llvm/CodeGen/MachineFunction.h index 25edf5bcce51..201c126ee52e 100644 --- a/include/llvm/CodeGen/MachineFunction.h +++ b/include/llvm/CodeGen/MachineFunction.h @@ -1,9 +1,8 @@ //===- llvm/CodeGen/MachineFunction.h ---------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // @@ -31,11 +30,6 @@ #include "llvm/CodeGen/MachineBasicBlock.h" #include "llvm/CodeGen/MachineInstr.h" #include "llvm/CodeGen/MachineMemOperand.h" -#include "llvm/IR/DebugLoc.h" -#include "llvm/IR/Instructions.h" -#include "llvm/IR/Metadata.h" -#include "llvm/MC/MCDwarf.h" -#include "llvm/MC/MCSymbol.h" #include "llvm/Support/Allocator.h" #include "llvm/Support/ArrayRecycler.h" #include "llvm/Support/AtomicOrdering.h" @@ -53,6 +47,7 @@ namespace llvm { class BasicBlock; class BlockAddress; class DataLayout; +class DebugLoc; class DIExpression; class DILocalVariable; class DILocation; @@ -67,6 +62,7 @@ class MachineModuleInfo; class MachineRegisterInfo; class MCContext; class MCInstrDesc; +class MCSymbol; class Pass; class PseudoSourceValueManager; class raw_ostream; @@ -86,7 +82,7 @@ template <> struct ilist_callback_traits<MachineBasicBlock> { template <class Iterator> void transferNodesFromList(ilist_callback_traits &OldList, Iterator, Iterator) { - llvm_unreachable("Never transfer between lists"); + assert(this == &OldList && "never transfer MBBs between functions"); } }; @@ -325,6 +321,10 @@ class MachineFunction { /// CodeView label annotations. std::vector<std::pair<MCSymbol *, MDNode *>> CodeViewAnnotations; + /// CodeView heapallocsites. + std::vector<std::tuple<MCSymbol*, MCSymbol*, DIType*>> + CodeViewHeapAllocSites; + bool CallsEHReturn = false; bool CallsUnwindInit = false; bool HasEHScopes = false; @@ -378,9 +378,28 @@ public: virtual void MF_HandleRemoval(MachineInstr &MI) = 0; }; + /// Structure used to represent pair of argument number after call lowering + /// and register used to transfer that argument. + /// For now we support only cases when argument is transferred through one + /// register. + struct ArgRegPair { + unsigned Reg; + uint16_t ArgNo; + ArgRegPair(unsigned R, unsigned Arg) : Reg(R), ArgNo(Arg) { + assert(Arg < (1 << 16) && "Arg out of range"); + } + }; + /// Vector of call argument and its forwarding register. + using CallSiteInfo = SmallVector<ArgRegPair, 1>; + using CallSiteInfoImpl = SmallVectorImpl<ArgRegPair>; + private: Delegate *TheDelegate = nullptr; + using CallSiteInfoMap = DenseMap<const MachineInstr *, CallSiteInfo>; + /// Map a call instruction to call site arguments forwarding info. + CallSiteInfoMap CallSitesInfo; + // Callbacks for insertion and removal. void handleInsertion(MachineInstr &MI); void handleRemoval(MachineInstr &MI); @@ -443,7 +462,6 @@ public: /// getSubtarget - Return the subtarget for which this machine code is being /// compiled. const TargetSubtargetInfo &getSubtarget() const { return *STI; } - void setSubtarget(const TargetSubtargetInfo *ST) { STI = ST; } /// getSubtarget - This method returns a pointer to the specified type of /// TargetSubtargetInfo. In debug builds, it verifies that the object being @@ -741,6 +759,12 @@ public: MachineMemOperand *getMachineMemOperand(const MachineMemOperand *MMO, const AAMDNodes &AAInfo); + /// Allocate a new MachineMemOperand by copying an existing one, + /// replacing the flags. MachineMemOperands are owned + /// by the MachineFunction and need not be explicitly deallocated. + MachineMemOperand *getMachineMemOperand(const MachineMemOperand *MMO, + MachineMemOperand::Flags Flags); + using OperandCapacity = ArrayRecycler<MachineOperand>::Capacity; /// Allocate an array of MachineOperands. This is only intended for use by @@ -791,10 +815,7 @@ public: return FrameInstructions; } - LLVM_NODISCARD unsigned addFrameInst(const MCCFIInstruction &Inst) { - FrameInstructions.push_back(Inst); - return FrameInstructions.size() - 1; - } + LLVM_NODISCARD unsigned addFrameInst(const MCCFIInstruction &Inst); /// \name Exception Handling /// \{ @@ -913,6 +934,14 @@ public: return CodeViewAnnotations; } + /// Record heapallocsites + void addCodeViewHeapAllocSite(MachineInstr *I, MDNode *MD); + + ArrayRef<std::tuple<MCSymbol*, MCSymbol*, DIType*>> + getCodeViewHeapAllocSites() const { + return CodeViewHeapAllocSites; + } + /// Return a reference to the C++ typeinfo for the current function. const std::vector<const GlobalValue *> &getTypeInfos() const { return TypeInfos; @@ -936,6 +965,23 @@ public: const VariableDbgInfoMapTy &getVariableDbgInfo() const { return VariableDbgInfos; } + + void addCallArgsForwardingRegs(const MachineInstr *CallI, + CallSiteInfoImpl &&CallInfo) { + assert(CallI->isCall()); + CallSitesInfo[CallI] = std::move(CallInfo); + } + + const CallSiteInfoMap &getCallSitesInfo() const { + return CallSitesInfo; + } + + /// Update call sites info by deleting entry for \p Old call instruction. + /// If \p New is present then transfer \p Old call info to it. This function + /// should be called before removing call instruction or before replacing + /// call instruction with new one. + void updateCallSiteInfo(const MachineInstr *Old, + const MachineInstr *New = nullptr); }; //===--------------------------------------------------------------------===// |