This is an archive of the discontinued LLVM Phabricator instance.

CodeGen: Remove MaxBytesForAlignment from MachineBasicBlock
Needs ReviewPublic

Authored by arsenm on Apr 20 2022, 7:39 AM.

Details

Summary

This was an overcomplicated way of tracking a constant used in the
AsmPrinter. This was not serialized in MIR. None of the in tree code
was changing this dynamically based on individual blocks. It was
always set to a subtarget defined constant.

This should probably be moved out of TargetLowering and into
MCAsmInfo. The only place I think this should change codegen is
BranchRelaxation which didn't account for potentially ignored
alignment in the first place.

Diff Detail

Event Timeline

arsenm created this revision.Apr 20 2022, 7:39 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 20 2022, 7:39 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
arsenm requested review of this revision.Apr 20 2022, 7:39 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 20 2022, 7:39 AM
Herald added a subscriber: wdng. · View Herald Transcript
courbet accepted this revision.Jun 1 2022, 6:54 AM
This revision is now accepted and ready to land.Jun 1 2022, 6:54 AM
dmgreen requested changes to this revision.Jun 1 2022, 6:59 AM

I'm not sure I understand. Why do you think that MaxBytesForAlignment isn't a per-basic-block parameter? Any aligned block can have a MaxBytesForAlignment, and they could all be different from one block to the next, just as alignments can change.

This revision now requires changes to proceed.Jun 1 2022, 6:59 AM
arsenm added a comment.Jun 1 2022, 7:05 AM

I'm not sure I understand. Why do you think that MaxBytesForAlignment isn't a per-basic-block parameter? Any aligned block can have a MaxBytesForAlignment, and they could all be different from one block to the next, just as alignments can change.

But that isn't actually used. This is only ever sourced from a target constant value. This is an unused feature essentially

I'm not sure I understand. Why do you think that MaxBytesForAlignment isn't a per-basic-block parameter? Any aligned block can have a MaxBytesForAlignment, and they could all be different from one block to the next, just as alignments can change.

I think the point is that it's never actually used anywhere.

It's used by AArch64, even if it's just a single value at the moment. getMaxPermittedBytesForAlignment should probably be called something like getMaxPermittedBytesForLoopAlignment. GCC sets different alignment/maxbytes for Loops vs Jumptable (vs Functions). You could imagine having different alignments/maxbytes for outer loops vs inner loops, or based on some other characteristics of the loop.

It is a value that seems to fit most naturally paired together with the Alignment on the MachineBasicBlock.

arsenm added a comment.Jun 1 2022, 9:08 AM

It's used by AArch64, even if it's just a single value at the moment. getMaxPermittedBytesForAlignment should probably be called something like getMaxPermittedBytesForLoopAlignment. GCC sets different alignment/maxbytes for Loops vs Jumptable (vs Functions). You could imagine having different alignments/maxbytes for outer loops vs inner loops, or based on some other characteristics of the loop.

You could imagine it, but unless someone implements something using this, it's bitrotting, incomplete infrastructure.

arsenm updated this revision to Diff 555186.Aug 31 2023, 3:45 PM

It's been over a year, and this still isn't serialized or set from anywhere. It needs to be dropped or fully implemented

dmgreen added a subscriber: chill.Sep 4 2023, 1:02 AM

@chill was changing how some of this works in https://reviews.llvm.org/D156235. What are the other parts that are needed? In MachineBasicBlock::print and MIParser::parseBasicBlockDefinition it needs to print and parse like it does for align?