[llvm] [RISC-V] Add SMLoc info for fixup. [NFCI] (PR #142054)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Fri May 30 20:28:18 PDT 2025


MaskRay wrote:

> > I actually plan to remove SMLoc from MCFixup to reduce its size, as the SMLoc can typically be retrieved from `MCExpr *MCFixup::Value`.
> > I also considered removing SMLoc from MCExpr. [llvm-compile-time-tracker.com/compare.php?from=193135c80019a01e08014b5727088b860a09f493&to=b8a413de2798260fabf6b5650fc22c803fa13831&stat=max-rss&linkStats=on](https://llvm-compile-time-tracker.com/compare.php?from=193135c80019a01e08014b5727088b860a09f493&to=b8a413de2798260fabf6b5650fc22c803fa13831&stat=max-rss&linkStats=on)
> > The saving is actually quite decent for a -g build, but some folks might need the MCExpr loc.
> > #### stage1-ReleaseLTO-g (link only):
> > Benchmark | Old | New
> > -- | -- | -- kimwitu++ | 248MiB | 242MiB (-2.52%) sqlite3 | 221MiB | 216MiB (-2.43%) consumer-typeset | 162MiB | 158MiB (-2.26%) Bullet | 208MiB | 204MiB (-1.81%) tramp3d-v4 | 624MiB | 616MiB (-1.32%) mafft | 122MiB | 123MiB (+1.08%) ClamAV | 230MiB | 224MiB (-2.61%) lencod | 277MiB | 270MiB (-2.63%) SPASS | 289MiB | 284MiB (-1.67%) 7zip | 467MiB | 454MiB (-2.84%) geomean | 256MiB | 251MiB (-1.91%)
> 
> I don't understand how SMLoc is saving size on these non-LLVM executable.

This page demonstrates that a stage1 build of LLVM with my commit applied (removing SMLoc from MCExpr), will use less memory when building these llvm-test-suite projects.
The saving is quite high, but as mentioned, we might not proceed as the MCExpr location can be useful.

If we keep MCExpr location, we can remove the MCFixup location or repurose the field for something else (perhaps more similar to GNU Assembler). 

> > I think we should remove SMLoc from either MCFixup or MCExpr. If we end up updating MCFixup, this change will be rewritten.
> 
> I don't have preferences, as long as we can still prompt errors that point to the line that is causing the error.
> 
> Some context on why I created this MR. I am currently debugging some failures in the relocations for Macho-O, adding these SMLoc helped me out to figure out what was wrong. I can keep these changes locally if you don't find them useful. Even if we merged this change, I don't have a regression test for it (other than the failure I am debugging, which of course I cannot upstream as it is), so if you end up removing it in the cleanup, nobody will notice.



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


More information about the llvm-commits mailing list