Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/llvm/llvm-project.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabian Parzefall <parzefall@fb.com>2022-09-09 03:10:27 +0300
committerFabian Parzefall <parzefall@fb.com>2022-09-09 03:10:29 +0300
commit3ac46f377a06f344705f334640c4e1d5eca4e9c0 (patch)
tree0173e0fdaf59b6367b76a4a101e26c3005f25e28 /bolt/lib/Core/BinaryEmitter.cpp
parentae2b4da16664a684341aa611309cfd302afe5ffa (diff)
[BOLT] Emit LSDA call sites for all fragments
For exception handling, LSDA call sites have to be emitted for each fragment individually. With this patch, call sites and respective LSDA symbols are generated and associated with each fragment of their function, such that they can be used by the emitter. Reviewed By: maksfb Differential Revision: https://reviews.llvm.org/D132052
Diffstat (limited to 'bolt/lib/Core/BinaryEmitter.cpp')
-rw-r--r--bolt/lib/Core/BinaryEmitter.cpp32
1 files changed, 14 insertions, 18 deletions
diff --git a/bolt/lib/Core/BinaryEmitter.cpp b/bolt/lib/Core/BinaryEmitter.cpp
index 8061601fd91b..5927269500d6 100644
--- a/bolt/lib/Core/BinaryEmitter.cpp
+++ b/bolt/lib/Core/BinaryEmitter.cpp
@@ -154,7 +154,7 @@ private:
void emitCFIInstruction(const MCCFIInstruction &Inst) const;
/// Emit exception handling ranges for the function.
- void emitLSDA(BinaryFunction &BF, bool EmitColdPart);
+ void emitLSDA(BinaryFunction &BF, const FunctionFragment &FF);
/// Emit line number information corresponding to \p NewLoc. \p PrevLoc
/// provides a context for de-duplication of line number info.
@@ -333,9 +333,7 @@ bool BinaryEmitter::emitFunction(BinaryFunction &Function,
if (Function.getPersonalityFunction() != nullptr)
Streamer.emitCFIPersonality(Function.getPersonalityFunction(),
Function.getPersonalityEncoding());
- MCSymbol *LSDASymbol = FF.isSplitFragment()
- ? Function.getColdLSDASymbol(FF.getFragmentNum())
- : Function.getLSDASymbol();
+ MCSymbol *LSDASymbol = Function.getLSDASymbol(FF.getFragmentNum());
if (LSDASymbol)
Streamer.emitCFILsda(LSDASymbol, BC.LSDAEncoding);
else
@@ -394,7 +392,7 @@ bool BinaryEmitter::emitFunction(BinaryFunction &Function,
emitLineInfoEnd(Function, EndSymbol);
// Exception handling info for the function.
- emitLSDA(Function, FF.isSplitFragment());
+ emitLSDA(Function, FF);
if (FF.isMainFragment() && opts::JumpTables > JTS_NONE)
emitJumpTables(Function);
@@ -880,10 +878,10 @@ void BinaryEmitter::emitCFIInstruction(const MCCFIInstruction &Inst) const {
}
// The code is based on EHStreamer::emitExceptionTable().
-void BinaryEmitter::emitLSDA(BinaryFunction &BF, bool EmitColdPart) {
- const BinaryFunction::CallSitesType *Sites =
- EmitColdPart ? &BF.getColdCallSites() : &BF.getCallSites();
- if (Sites->empty())
+void BinaryEmitter::emitLSDA(BinaryFunction &BF, const FunctionFragment &FF) {
+ const BinaryFunction::CallSitesRange Sites =
+ BF.getCallSites(FF.getFragmentNum());
+ if (llvm::empty(Sites))
return;
// Calculate callsite table size. Size of each callsite entry is:
@@ -893,9 +891,9 @@ void BinaryEmitter::emitLSDA(BinaryFunction &BF, bool EmitColdPart) {
// or
//
// sizeof(dwarf::DW_EH_PE_data4) * 3 + sizeof(uleb128(action))
- uint64_t CallSiteTableLength = Sites->size() * 4 * 3;
- for (const BinaryFunction::CallSite &CallSite : *Sites)
- CallSiteTableLength += getULEB128Size(CallSite.Action);
+ uint64_t CallSiteTableLength = llvm::size(Sites) * 4 * 3;
+ for (const auto &FragmentCallSite : Sites)
+ CallSiteTableLength += getULEB128Size(FragmentCallSite.second.Action);
Streamer.switchSection(BC.MOFI->getLSDASection());
@@ -907,15 +905,12 @@ void BinaryEmitter::emitLSDA(BinaryFunction &BF, bool EmitColdPart) {
Streamer.emitValueToAlignment(TTypeAlignment);
// Emit the LSDA label.
- MCSymbol *LSDASymbol = EmitColdPart
- ? BF.getColdLSDASymbol(FragmentNum::cold())
- : BF.getLSDASymbol();
+ MCSymbol *LSDASymbol = BF.getLSDASymbol(FF.getFragmentNum());
assert(LSDASymbol && "no LSDA symbol set");
Streamer.emitLabel(LSDASymbol);
// Corresponding FDE start.
- const MCSymbol *StartSymbol =
- BF.getSymbol(EmitColdPart ? FragmentNum::cold() : FragmentNum::main());
+ const MCSymbol *StartSymbol = BF.getSymbol(FF.getFragmentNum());
// Emit the LSDA header.
@@ -987,7 +982,8 @@ void BinaryEmitter::emitLSDA(BinaryFunction &BF, bool EmitColdPart) {
Streamer.emitIntValue(dwarf::DW_EH_PE_sdata4, 1);
Streamer.emitULEB128IntValue(CallSiteTableLength);
- for (const BinaryFunction::CallSite &CallSite : *Sites) {
+ for (const auto &FragmentCallSite : Sites) {
+ const BinaryFunction::CallSite &CallSite = FragmentCallSite.second;
const MCSymbol *BeginLabel = CallSite.Start;
const MCSymbol *EndLabel = CallSite.End;