forked from OSchip/llvm-project
[BOLT] Emit symbol size for functions
Summary: On targets that support it, emit size of the emitted function symbol. At the moment there's no use for the size except that it is visible in a temporary .o file symbol table. (cherry picked from FBD24246177)
This commit is contained in:
parent
528da5d795
commit
247b4181a3
|
@ -290,16 +290,19 @@ bool BinaryEmitter::emitFunction(BinaryFunction &Function, bool EmitColdPart) {
|
||||||
MCContext &Context = Streamer.getContext();
|
MCContext &Context = Streamer.getContext();
|
||||||
const MCAsmInfo *MAI = Context.getAsmInfo();
|
const MCAsmInfo *MAI = Context.getAsmInfo();
|
||||||
|
|
||||||
|
MCSymbol *StartSymbol = nullptr;
|
||||||
|
|
||||||
// Emit all symbols associated with the main function entry.
|
// Emit all symbols associated with the main function entry.
|
||||||
if (!EmitColdPart) {
|
if (!EmitColdPart) {
|
||||||
for (auto *Symbol : Function.getSymbols()) {
|
StartSymbol = Function.getSymbol();
|
||||||
|
for (MCSymbol *Symbol : Function.getSymbols()) {
|
||||||
Streamer.EmitSymbolAttribute(Symbol, MCSA_ELF_TypeFunction);
|
Streamer.EmitSymbolAttribute(Symbol, MCSA_ELF_TypeFunction);
|
||||||
Streamer.EmitLabel(Symbol);
|
Streamer.EmitLabel(Symbol);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
auto *Symbol = Function.getColdSymbol();
|
StartSymbol = Function.getColdSymbol();
|
||||||
Streamer.EmitSymbolAttribute(Symbol, MCSA_ELF_TypeFunction);
|
Streamer.EmitSymbolAttribute(StartSymbol, MCSA_ELF_TypeFunction);
|
||||||
Streamer.EmitLabel(Symbol);
|
Streamer.EmitLabel(StartSymbol);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Emit CFI start
|
// Emit CFI start
|
||||||
|
@ -358,8 +361,16 @@ bool BinaryEmitter::emitFunction(BinaryFunction &Function, bool EmitColdPart) {
|
||||||
if (Function.hasCFI())
|
if (Function.hasCFI())
|
||||||
Streamer.EmitCFIEndProc();
|
Streamer.EmitCFIEndProc();
|
||||||
|
|
||||||
Streamer.EmitLabel(EmitColdPart ? Function.getFunctionColdEndLabel()
|
MCSymbol *EndSymbol = EmitColdPart ? Function.getFunctionColdEndLabel()
|
||||||
: Function.getFunctionEndLabel());
|
: Function.getFunctionEndLabel();
|
||||||
|
Streamer.EmitLabel(EndSymbol);
|
||||||
|
|
||||||
|
if (MAI->hasDotTypeDotSizeDirective()) {
|
||||||
|
const MCExpr *SizeExpr = MCBinaryExpr::createSub(
|
||||||
|
MCSymbolRefExpr::create(EndSymbol, Context),
|
||||||
|
MCSymbolRefExpr::create(StartSymbol, Context), Context);
|
||||||
|
Streamer.emitELFSize(StartSymbol, SizeExpr);
|
||||||
|
}
|
||||||
|
|
||||||
// Exception handling info for the function.
|
// Exception handling info for the function.
|
||||||
emitLSDA(Function, EmitColdPart);
|
emitLSDA(Function, EmitColdPart);
|
||||||
|
|
Loading…
Reference in New Issue