RISCVAsmBackend::shouldInsertExtraNopBytesForCodeAlign() assumed that the align specified would be greater than or equal to the minimum nop length, but that is not always the case - for example if a user specifies ".align 0" in assembly.
Details
Details
Diff Detail
Diff Detail
Event Timeline
lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp | ||
---|---|---|
315–316 | Shouldn't make any functional difference but can we return false instead? Seems more prudent to say we 'shouldn't emit nops' rather than saying we should but the size should be 0? |
Comment Actions
Incorporated Lewis' suggested fix.
I realized that the use of this in shouldInsertFixupForCodeAlign() doesn't actually check the return value, and with the changes I've made here it means that shouldInsertFixupForCodeAlign() could read uninitialized memory. I've submitted a separate patch to fix that problem (D63285)
Shouldn't make any functional difference but can we return false instead? Seems more prudent to say we 'shouldn't emit nops' rather than saying we should but the size should be 0?