mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-03-05 02:49:18 +00:00
[MC] Use unique_ptr to manage WinFrameInfos, NFC
The FrameInfo cannot be stored directly in the vector because chained frames may refer to parent frames, so we need pointers that are stable across a vector resize. llvm-svn: 315080
This commit is contained in:
parent
b5d8ee26b4
commit
a8495e2ea4
@ -176,7 +176,10 @@ class MCStreamer {
|
||||
MCSymbol *EmitCFILabel();
|
||||
MCSymbol *EmitCFICommon();
|
||||
|
||||
std::vector<WinEH::FrameInfo *> WinFrameInfos;
|
||||
/// Similar to DwarfFrameInfos, but for SEH unwind info. Chained frames may
|
||||
/// refer to each other, so use std::unique_ptr to provide pointer stability.
|
||||
std::vector<std::unique_ptr<WinEH::FrameInfo>> WinFrameInfos;
|
||||
|
||||
WinEH::FrameInfo *CurrentWinFrameInfo;
|
||||
void EnsureValidWinFrameInfo();
|
||||
|
||||
@ -238,7 +241,7 @@ public:
|
||||
bool hasUnfinishedDwarfFrameInfo();
|
||||
|
||||
unsigned getNumWinFrameInfos() { return WinFrameInfos.size(); }
|
||||
ArrayRef<WinEH::FrameInfo *> getWinFrameInfos() const {
|
||||
ArrayRef<std::unique_ptr<WinEH::FrameInfo>> getWinFrameInfos() const {
|
||||
return WinFrameInfos;
|
||||
}
|
||||
|
||||
|
@ -56,17 +56,12 @@ MCStreamer::MCStreamer(MCContext &Ctx)
|
||||
SectionStack.push_back(std::pair<MCSectionSubPair, MCSectionSubPair>());
|
||||
}
|
||||
|
||||
MCStreamer::~MCStreamer() {
|
||||
for (unsigned i = 0; i < getNumWinFrameInfos(); ++i)
|
||||
delete WinFrameInfos[i];
|
||||
}
|
||||
MCStreamer::~MCStreamer() {}
|
||||
|
||||
void MCStreamer::reset() {
|
||||
DwarfFrameInfos.clear();
|
||||
for (unsigned i = 0; i < getNumWinFrameInfos(); ++i)
|
||||
delete WinFrameInfos[i];
|
||||
WinFrameInfos.clear();
|
||||
CurrentWinFrameInfo = nullptr;
|
||||
WinFrameInfos.clear();
|
||||
SymbolOrdering.clear();
|
||||
SectionStack.clear();
|
||||
SectionStack.push_back(std::pair<MCSectionSubPair, MCSectionSubPair>());
|
||||
@ -538,8 +533,9 @@ void MCStreamer::EmitWinCFIStartProc(const MCSymbol *Symbol) {
|
||||
|
||||
MCSymbol *StartProc = EmitCFILabel();
|
||||
|
||||
WinFrameInfos.push_back(new WinEH::FrameInfo(Symbol, StartProc));
|
||||
CurrentWinFrameInfo = WinFrameInfos.back();
|
||||
WinFrameInfos.emplace_back(
|
||||
llvm::make_unique<WinEH::FrameInfo>(Symbol, StartProc));
|
||||
CurrentWinFrameInfo = WinFrameInfos.back().get();
|
||||
CurrentWinFrameInfo->TextSection = getCurrentSectionOnly();
|
||||
}
|
||||
|
||||
@ -557,9 +553,9 @@ void MCStreamer::EmitWinCFIStartChained() {
|
||||
|
||||
MCSymbol *StartProc = EmitCFILabel();
|
||||
|
||||
WinFrameInfos.push_back(new WinEH::FrameInfo(CurrentWinFrameInfo->Function,
|
||||
StartProc, CurrentWinFrameInfo));
|
||||
CurrentWinFrameInfo = WinFrameInfos.back();
|
||||
WinFrameInfos.emplace_back(llvm::make_unique<WinEH::FrameInfo>(
|
||||
CurrentWinFrameInfo->Function, StartProc, CurrentWinFrameInfo));
|
||||
CurrentWinFrameInfo = WinFrameInfos.back().get();
|
||||
CurrentWinFrameInfo->TextSection = getCurrentSectionOnly();
|
||||
}
|
||||
|
||||
|
@ -220,17 +220,17 @@ static void EmitUnwindInfo(MCStreamer &streamer, WinEH::FrameInfo *info) {
|
||||
|
||||
void llvm::Win64EH::UnwindEmitter::Emit(MCStreamer &Streamer) const {
|
||||
// Emit the unwind info structs first.
|
||||
for (WinEH::FrameInfo *CFI : Streamer.getWinFrameInfos()) {
|
||||
for (const auto &CFI : Streamer.getWinFrameInfos()) {
|
||||
MCSection *XData = Streamer.getAssociatedXDataSection(CFI->TextSection);
|
||||
Streamer.SwitchSection(XData);
|
||||
::EmitUnwindInfo(Streamer, CFI);
|
||||
::EmitUnwindInfo(Streamer, CFI.get());
|
||||
}
|
||||
|
||||
// Now emit RUNTIME_FUNCTION entries.
|
||||
for (WinEH::FrameInfo *CFI : Streamer.getWinFrameInfos()) {
|
||||
for (const auto &CFI : Streamer.getWinFrameInfos()) {
|
||||
MCSection *PData = Streamer.getAssociatedPDataSection(CFI->TextSection);
|
||||
Streamer.SwitchSection(PData);
|
||||
EmitRuntimeFunction(Streamer, CFI);
|
||||
EmitRuntimeFunction(Streamer, CFI.get());
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user