[PATCH] D97891: Revert "[MC] Remove PhysRegSize from MCRegisterClass"

Rafael Auler via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 4 17:41:06 PST 2021


rafauler added a comment.

> If you need this I'd rather "add the needed support" than doing it as a revert

Sounds good, let me work on that a little bit.

Regarding where is this used, the dependency of BOLT on this interface is a single line here:
https://github.com/facebookincubator/BOLT/blob/master/src/MCPlusBuilder.cpp#L445
and here
https://github.com/facebookincubator/BOLT/blob/master/src/Target/X86/X86MCPlusBuilder.cpp#L1417

BOLT offers a framework for running dataflow analyses on binaries. We use it to perform shrinkwrapping, for example. For this to happen, we need to know the register size when analyzing an MCInst to figure out how wide is the load or store to stack. With this information, we build a model of which bytes of the stack are being used and how, and if we have enough information to move load/stores to colder positions.

This register size information is exposed inside BOLT though an interface that abstracts away all target information. When writing a pass in BOLT, you may query, then, whether registers alias with each other and their size. As you can imagine, this is provided by MC. BOLT builds the size information straight out of the tablegen'd specs of the target though MC. I tried to move this logic to use TRI, but TRI is only available to code living inside libTarget. To an external tool like BOLT that relies a lot on the MC library, it is not possible to fetch it though libTarget unless we create an interface in libTarget to expose this information, which I think would be awkward.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97891/new/

https://reviews.llvm.org/D97891



More information about the llvm-commits mailing list