[llvm] [MC,CodeGen] Update .prefalign for symbol-based preferred alignment (PR #184032)

Alexis Engelke via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 30 00:30:17 PDT 2026


================
@@ -774,6 +798,37 @@ void MCAssembler::relaxAlign(MCFragment &F) {
     F.getParent()->ContentStorage.resize(F.VarContentEnd);
 }
 
+// Compute the body size by walking forward from F to the End symbol and
+// summing fragment sizes. This avoids depending on stale layout offsets.
+void MCAssembler::relaxPrefAlign(MCFragment &F) {
+  uint64_t RawStart = F.Offset + F.getFixedSize();
+  const MCSymbol &End = F.getPrefAlignEnd();
+  if (!End.getFragment() || End.getFragment()->getParent() != F.getParent()) {
+    recordError(SMLoc(), "end symbol '" + End.getName() +
+                             "' must be in the current section");
----------------
aengelke wrote:

Still relevant.

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


More information about the llvm-commits mailing list