diff options
author | Fangrui Song <i@maskray.me> | 2024-06-09 23:05:05 -0700 |
---|---|---|
committer | Fangrui Song <i@maskray.me> | 2024-06-09 23:05:05 -0700 |
commit | 9d0754ada5dbbc0c009bcc2f7824488419cc5530 (patch) | |
tree | 8a31f077ffa3bd8ed235527c1f029bf9d776b7da /llvm/lib/MC/MCExpr.cpp | |
parent | cb1a727dea9f063085db10190971dbd7aa7fb8e2 (diff) | |
download | llvm-9d0754ada5dbbc0c009bcc2f7824488419cc5530.zip llvm-9d0754ada5dbbc0c009bcc2f7824488419cc5530.tar.gz llvm-9d0754ada5dbbc0c009bcc2f7824488419cc5530.tar.bz2 |
[MC] Relax fragments eagerly
Lazy relaxation caused hash table lookups (`getFragmentOffset`) and
complex use/compute interdependencies. Some expressions involding
forward declared symbols (e.g. `subsection-if.s`) cannot be computed.
Recursion detection requires complex `IsBeingLaidOut`
(https://reviews.llvm.org/D79570).
D76114's `invalidateFragmentsFrom` makes lazy relaxation even less
useful.
Switch to eager relaxation to greatly simplify code and resolve these
issues. This change also removes a `getPrevNode` use, which makes it
more feasible to replace the fragment representation, which might yield
a large peak RSS win.
Minor downsides: The number of section relaxations may increase (offset
by avoiding the hash table lookup). For relax-recompute-align.s, the
computed layout is not optimal.
Diffstat (limited to 'llvm/lib/MC/MCExpr.cpp')
-rw-r--r-- | llvm/lib/MC/MCExpr.cpp | 4 |
1 files changed, 0 insertions, 4 deletions
diff --git a/llvm/lib/MC/MCExpr.cpp b/llvm/lib/MC/MCExpr.cpp index b065d03..b70ac86 100644 --- a/llvm/lib/MC/MCExpr.cpp +++ b/llvm/lib/MC/MCExpr.cpp @@ -645,10 +645,6 @@ static void AttemptToFoldSymbolOffsetDifference( Addend += SA.getOffset() - SB.getOffset(); return FinalizeFolding(); } - // One of the symbol involved is part of a fragment being laid out. Quit now - // to avoid a self loop. - if (!Layout->canGetFragmentOffset(FA) || !Layout->canGetFragmentOffset(FB)) - return; // Eagerly evaluate when layout is finalized. Addend += Layout->getSymbolOffset(A->getSymbol()) - |