[PATCH] D97891: Add register size info back to MCRegisterClass

Yifeng Dong via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 21 19:49:00 PDT 2021


dongAxis1944 added subscribers: rafaelauler, dongAxis1944.
dongAxis1944 added a comment.

In D97891#2605188 <https://reviews.llvm.org/D97891#2605188>, @rafauler wrote:

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

@rafaelauler I have a question about that, if I want to use this patch to bolt, dose it means we need to change the code from "I->getSize()" to "I->getSizeInBits() / 8"
thanks in advance.


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