Previously, we were generating zeroes when generating code alignments for AArch64, but now we should omit the value and let the assembler choose to generate nops or zeroes.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Reinterpreting Value == 0 to mean the user didn't specify a value is wrong. We should distinguish between "no fill specified" and "fill zero specified". (At least, that's how it should work, as far as I can tell.)
In the "no fill specified" case, we should end up in emitCodeAlignment; we can emit the correct directive from there, instead of throwing away the information.
That makes sense. Do you know how I can get the min byte width of the Value? The nop value for ARM64 is 0xd503201f which is 4 bytes, but X86's nop value is 0x90 which is 1 byte. Currently emitCodeAlignment looks like:
void emitValueToAlignment(unsigned ByteAlignment, int64_t Value = 0, unsigned ValueSize = 1, unsigned MaxBytesToEmit = 0) override; void MCAsmStreamer::emitCodeAlignment(unsigned ByteAlignment, const MCSubtargetInfo *STI, unsigned MaxBytesToEmit) { // Emit with a text fill value. emitValueToAlignment(ByteAlignment, MAI->getTextAlignFillValue(), 1, MaxBytesToEmit); }
ValueSize is hardcoded to 1, but for ARM64 we would have to pass 4.
- Update text fill value to nop instruction for AArch64
- Still need to set ValueSize arg to 4 for AArch64
llvm/lib/MC/MCAsmStreamer.cpp | ||
---|---|---|
248 | The name "emitValueToAlignmentIfNotOmit" doesn't make any sense; the "IfNotOmit" part isn't related to the rest of the name. Maybe just "emitAlignmentDirective"? | |
251 | The logic around OmitValueIfZero is sort of hard to understand. Maybe pass in an Optional<int64_t> Value, and make the caller figure out whether the value should be omitted? |
llvm/lib/MC/MCAsmStreamer.cpp | ||
---|---|---|
1466 | else if (MaxBytesToEmit)? | |
1473 | If I'm understand correctly, this is actually a visible change to emitValueToAlignment: it will always explicitly emit the value, even if it's zero. That's probably what we want (reducing ambiguity in our asm output seems like an improvement), but we should have test coverage for the change. |
The name "emitValueToAlignmentIfNotOmit" doesn't make any sense; the "IfNotOmit" part isn't related to the rest of the name. Maybe just "emitAlignmentDirective"?