[llvm] [LoongArch] Insert nops and emit align reloc when handle alignment directive (PR #72962)

Lu Weining via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 16 05:04:33 PST 2024


================
@@ -174,6 +177,72 @@ void LoongArchAsmBackend::applyFixup(const MCAssembler &Asm,
   }
 }
 
+// Linker relaxation may change code size. We have to insert Nops
+// for .align directive when linker relaxation enabled. So then Linker
+// could satisfy alignment by removing Nops.
+// The function returns the total Nops Size we need to insert.
+bool LoongArchAsmBackend::shouldInsertExtraNopBytesForCodeAlign(
+    const MCAlignFragment &AF, unsigned &Size) {
+  // Calculate Nops Size only when linker relaxation enabled.
+  const MCSubtargetInfo *STI = AF.getSubtargetInfo();
----------------
SixWeining wrote:

We can inline one-time-used variable `STI`.

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


More information about the llvm-commits mailing list