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

Francesco Petrogalli via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 6 06:34:45 PDT 2025


fpetrogalli 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).

Thanks for the explanation. Let me summarize:

1. Removing SMLoc from MCExpr would save a lot of memory for a stage1 build of LLVM...
2. ... but we cannot remove it because it is essential to MCExpr.
3. We could remove SMLoc from MCFixup because there is potential to save memory (do you have numbers?)

I don't have anything against removing SMLoc from MCFixup, but I found the changes in this MR useful for my own development process. I think we should get them in: if you end up removing SMLoc from MCFixup, the functionality provided by this change will likely still be there via MCExpr and the link it has with MCFixup.


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


More information about the llvm-commits mailing list