[lld] [llvm] [LoongArch] Use R_LARCH_ALIGN without symbol as much as possible (PR #93775)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Thu May 30 16:16:59 PDT 2024


================
@@ -224,20 +224,25 @@ bool LoongArchAsmBackend::shouldInsertFixupForCodeAlign(
   // Create fixup_loongarch_align fixup.
   MCFixup Fixup =
       MCFixup::create(0, Dummy, MCFixupKind(LoongArch::fixup_loongarch_align));
-  const MCSymbolRefExpr *MCSym = getSecToAlignSym()[Sec];
-  if (MCSym == nullptr) {
-    // Create a symbol and make the value of symbol is zero.
-    MCSymbol *Sym = Ctx.createNamedTempSymbol("la-relax-align");
-    Sym->setFragment(&*Sec->getBeginSymbol()->getFragment());
-    Asm.registerSymbol(*Sym);
-    MCSym = MCSymbolRefExpr::create(Sym, Ctx);
-    getSecToAlignSym()[Sec] = MCSym;
-  }
+
+  auto createExtendedValue = [&]() {
+    const MCSymbolRefExpr *MCSym = getSecToAlignSym()[Sec];
+    if (MCSym == nullptr) {
+      // Create a symbol and make the value of symbol is zero.
----------------
MaskRay wrote:

Define a marker symbol at the section with an offset of 0.

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


More information about the llvm-commits mailing list