diff options
author | Djordje Todorovic <djordje.todorovic@rt-rk.com> | 2019-06-27 13:10:29 +0000 |
---|---|---|
committer | Djordje Todorovic <djordje.todorovic@rt-rk.com> | 2019-06-27 13:10:29 +0000 |
commit | 71d3869f60c3c0df56086db26d534e603e7d6f78 (patch) | |
tree | dde2d8f056f4d2dd7174d5208edb5ef12d8b6433 /llvm/lib/CodeGen/MachineFunction.cpp | |
parent | 79dc930c131cfd9f0104b9b9cd4a2c936ad40545 (diff) | |
download | bcm5719-llvm-71d3869f60c3c0df56086db26d534e603e7d6f78.tar.gz bcm5719-llvm-71d3869f60c3c0df56086db26d534e603e7d6f78.zip |
[Backend] Keep call site info valid through the backend
Handle call instruction replacements and deletions in order to preserve
valid state of the call site info of the MachineFunction.
NOTE: If the call site info is enabled for a new target, the assertion from
the MachineFunction::DeleteMachineInstr() should help to locate places
where the updateCallSiteInfo() should be called in order to preserve valid
state of the call site info.
([10/13] Introduce the debug entry values.)
Co-authored-by: Ananth Sowda <asowda@cisco.com>
Co-authored-by: Nikola Prica <nikola.prica@rt-rk.com>
Co-authored-by: Ivan Baev <ibaev@cisco.com>
Differential Revision: https://reviews.llvm.org/D61062
llvm-svn: 364536
Diffstat (limited to 'llvm/lib/CodeGen/MachineFunction.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineFunction.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/MachineFunction.cpp b/llvm/lib/CodeGen/MachineFunction.cpp index 4394ea29df6..9c75d0fd81e 100644 --- a/llvm/lib/CodeGen/MachineFunction.cpp +++ b/llvm/lib/CodeGen/MachineFunction.cpp @@ -363,6 +363,13 @@ MachineInstr &MachineFunction::CloneMachineInstrBundle(MachineBasicBlock &MBB, /// ~MachineInstr() destructor must be empty. void MachineFunction::DeleteMachineInstr(MachineInstr *MI) { + // Verify that a call site info is at valid state. This assertion should + // be triggered during the implementation of support for the + // call site info of a new architecture. If the assertion is triggered, + // back trace will tell where to insert a call to updateCallSiteInfo(). + assert((!MI->isCall(MachineInstr::IgnoreBundle) || + CallSitesInfo.find(MI) == CallSitesInfo.end()) && + "Call site info was not updated!"); // Strip it for parts. The operand array and the MI object itself are // independently recyclable. if (MI->Operands) @@ -826,6 +833,22 @@ void MachineFunction::addCodeViewHeapAllocSite(MachineInstr *I, MDNode *MD) { CodeViewHeapAllocSites.push_back(std::make_tuple(BeginLabel, EndLabel, DI)); } +void MachineFunction::updateCallSiteInfo(const MachineInstr *Old, + const MachineInstr *New) { + if (!Target.Options.EnableDebugEntryValues || Old == New) + return; + + assert(Old->isCall() && (!New || New->isCall()) && + "Call site info referes only to call instructions!"); + CallSiteInfoMap::iterator CSIt = CallSitesInfo.find(Old); + if (CSIt == CallSitesInfo.end()) + return; + CallSiteInfo CSInfo = std::move(CSIt->second); + CallSitesInfo.erase(CSIt); + if (New) + CallSitesInfo[New] = CSInfo; +} + /// \} //===----------------------------------------------------------------------===// |