[MCAssembler] changing layout in assembler backend

… Replying to my own message since no one else did :-;

… and hoping for a little insight on the MCCodePadding class.

Essentially I need a way to create alignment padding whose size can be adjusted based on the content (not just the address) of other MCFragments. (MCAlignFragments don’t quite fit the bill because they only look at the next Fragment’s Offset, not its contents.) It seems like this sort of aligns with the purpose of MCCodePadder, which adjusts the size of an MCPaddingFragment based on other fragments. But MCCodePadder is an enigma. No targets seem to use it; it has virtual methods as if it’s intended for targets to override it MCAssembler is hardwired to construct the base class; its addPolicy() is also protected from target access; and it’s not clear what it’s actually intending to do – in particular I don’t get the “window” concept.

Can anyone shed light on how this is supposed to work?


I don’t really know the history, but I was just looking at this and wondering if I could rip out that entire infrastructure since it seems to be rather complex dead-code.

There’s an abandoned follow-on patch https://reviews.llvm.org/D34396 that may be helpful to look at.