This is an archive of the discontinued LLVM Phabricator instance.

[Alignment] Use Align in MCStreamer emitZeroFill/emitLocalCommonSymbol
ClosedPublic

Authored by gchatelet on Dec 6 2022, 8:58 AM.

Details

Summary

Before performing this change, I checked that ByteAlignment was never 0 inside MCAsmStreamer:emitZeroFill and MCAsmStreamer::emitLocalCommonSymbol.
I believe it is NFC as 0 values are illegal in emitZeroFill anyways, Log2(ByteAlignment) would be undefined.
And currently, all calls to emitLocalCommonSymbol are provably >0.

Diff Detail

Event Timeline

gchatelet created this revision.Dec 6 2022, 8:58 AM
Herald added a project: Restricted Project. · View Herald Transcript
gchatelet requested review of this revision.Dec 6 2022, 8:58 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 6 2022, 8:58 AM

I don;t think we're guaranteed that there does not exist an override that accepts 0 as a value. What about switching to MaybeAligned instead ? We can always tighten in a second step once there are no other raw values left ?

I don;t think we're guaranteed that there does not exist an override that accepts 0 as a value. What about switching to MaybeAligned instead ? We can always tighten in a second step once there are no other raw values left ?

It is quite painful to change virtual methods exactly because we can't know all the implementations. Private implementations need to adapt to the new signature, it adds churn.
If we go with MaybeAlign we will pay the price of that change twice. Once now and a second time later on when we decide to use Align.
I believe we'll never be in a position where it is safe to assume that implementers are not using 0 to convey something special.

I think it's better to go with this change and revert if it breaks someone. This way we learn something (and we can also fix the downstream code if it passes 0 for a wrong reason).
I'll remove the NFC part of the patch description.

gchatelet retitled this revision from [Alignment][NFC] Use Align in MCStreamer emitZeroFill/emitLocalCommonSymbol to [Alignment] Use Align in MCStreamer emitZeroFill/emitLocalCommonSymbol.Dec 7 2022, 6:09 AM
courbet accepted this revision.Dec 7 2022, 6:19 AM
This revision is now accepted and ready to land.Dec 7 2022, 6:19 AM
This revision was landed with ongoing or failed builds.Dec 7 2022, 6:29 AM
This revision was automatically updated to reflect the committed changes.