[llvm] MC,AMDGPU: Don't pad .text with s_code_end if it would otherwise be empty (PR #147980)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 22 00:25:46 PDT 2025


================
@@ -342,12 +342,10 @@ void MCObjectStreamer::emitInstructionImpl(const MCInst &Inst,
                                            const MCSubtargetInfo &STI) {
   MCStreamer::emitInstruction(Inst, STI);
 
-  MCSection *Sec = getCurrentSectionOnly();
----------------
MaskRay wrote:

emitInstruction is a performance bottleneck. Caution needed when making changes. 

getCurrentSectionOnly is efficient. getCurrentSection is not, and the nullness check is redundant. I haven't checked in detail, but adding `Sec->setHasInstructions(true);` to MCAsmStreamer is likely better .

https://github.com/llvm/llvm-project/pull/147980


More information about the llvm-commits mailing list