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();
|
||||
const MCAsmInfo *MAI = Context.getAsmInfo();
|
||||
|
||||
MCSymbol *StartSymbol = nullptr;
|
||||
|
||||
// Emit all symbols associated with the main function entry.
|
||||
if (!EmitColdPart) {
|
||||
for (auto *Symbol : Function.getSymbols()) {
|
||||
StartSymbol = Function.getSymbol();
|
||||
for (MCSymbol *Symbol : Function.getSymbols()) {
|
||||
Streamer.EmitSymbolAttribute(Symbol, MCSA_ELF_TypeFunction);
|
||||
Streamer.EmitLabel(Symbol);
|
||||
}
|
||||
} else {
|
||||
auto *Symbol = Function.getColdSymbol();
|
||||
Streamer.EmitSymbolAttribute(Symbol, MCSA_ELF_TypeFunction);
|
||||
Streamer.EmitLabel(Symbol);
|
||||
StartSymbol = Function.getColdSymbol();
|
||||
Streamer.EmitSymbolAttribute(StartSymbol, MCSA_ELF_TypeFunction);
|
||||
Streamer.EmitLabel(StartSymbol);
|
||||
}
|
||||
|
||||
// Emit CFI start
|
||||
|
@ -358,8 +361,16 @@ bool BinaryEmitter::emitFunction(BinaryFunction &Function, bool EmitColdPart) {
|
|||
if (Function.hasCFI())
|
||||
Streamer.EmitCFIEndProc();
|
||||
|
||||
Streamer.EmitLabel(EmitColdPart ? Function.getFunctionColdEndLabel()
|
||||
: Function.getFunctionEndLabel());
|
||||
MCSymbol *EndSymbol = EmitColdPart ? Function.getFunctionColdEndLabel()
|
||||
: 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.
|
||||
emitLSDA(Function, EmitColdPart);
|
||||
|
|
Loading…
Reference in New Issue