This patch changes the functionality of AsmPrinter to name the basic block end labels as LBB_END${i}_${j}, with ${i} being the identifier for the function and ${j} being the identifier for the basic block. The new naming scheme is consistent with how basic block labels are named (.LBB${i}_{j}), and how function end symbol are named (.Lfunc_end${i}) and helps to write stronger tests for the upcoming patch for BB-Info section (as proposed in https://lists.llvm.org/pipermail/llvm-dev/2020-July/143512.html). The end label is used with basicblock-labels (BB-Info section in future) and basicblock-sections to compute the size of basic blocks and basic block sections, respectively. For BB sections, the section containing the entry basic block will not have a BB end label since it already gets the function end-label.
This label is cached for every basic block (CachedEndMCSymbol) like the label for the basic block (CachedMCSymbol).
Details
Diff Detail
Event Timeline
Some inital comments. Expanding the summary to provide a bit more detail on why this symbol naming scheme is better might be useful. Thanks for doing this.
llvm/include/llvm/CodeGen/MachineBasicBlock.h | ||
---|---|---|
177–179 | The comment "Used during basic block sections..." is still relevant? | |
478 | Can we name it getCachedEndMCSymbol? | |
llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | ||
3055 | Remove this, it does not belong to this patch. |
llvm/include/llvm/CodeGen/MachineBasicBlock.h | ||
---|---|---|
478 | This naming follows the similar function MachineBasicBlock::getSymbol() which also uses a cached symbol (called CachedMCSymbol). |
llvm/include/llvm/CodeGen/MachineBasicBlock.h | ||
---|---|---|
479 | If all usage of getEndSymbol() accept a const version of "MCSymbol *", maybe change it to "const MCSymbol *" that goes along with the const nature of the function. |
llvm/include/llvm/CodeGen/MachineBasicBlock.h | ||
---|---|---|
479 | Unfortunately, that's not the case. MCObjectStreamer::emitLabel takes a non-const reference to a symbol (and actually mutates the symbol). |
.Ltmp -> .LBB_END is a good idea. The assembly is more readable. There is no space hit because .L symbols are usually not emitted into the symbol table.
llvm/include/llvm/CodeGen/MachineBasicBlock.h | ||
---|---|---|
479 | If you delete`const` from getEndSymbol() , can you delete the mutable specifier on CachedEndMCSymbol? |
llvm/include/llvm/CodeGen/MachineBasicBlock.h | ||
---|---|---|
479 | That's possible. The current pattern is borrowed from MachineBasicBlock::getSymbol() and how it interacts with MachineBasicBlock::CachedMCSymbol*, which are respectively declared const and mutable. WDYT? |
The comment "Used during basic block sections..." is still relevant?