Skip to content

Commit 2bc36af

Browse files
authored
[SPARC][IAS] Handle the case of non-4-byte aligned writeNopData
If the Count passed into writeNopData is not a multiple of four, add a little amount of zeros before writing the NOP stream. This makes it match the behavior of GNU binutils. Reviewers: brad0, rorth, s-barannikov, jrtc27 Reviewed By: s-barannikov Pull Request: #94251
1 parent 8901f71 commit 2bc36af

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

llvm/lib/Target/Sparc/MCTargetDesc/SparcAsmBackend.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -323,9 +323,11 @@ namespace {
323323

324324
bool writeNopData(raw_ostream &OS, uint64_t Count,
325325
const MCSubtargetInfo *STI) const override {
326-
// Cannot emit NOP with size not multiple of 32 bits.
327-
if (Count % 4 != 0)
328-
return false;
326+
327+
// If the count is not 4-byte aligned, we must be writing data into the
328+
// text section (otherwise we have unaligned instructions, and thus have
329+
// far bigger problems), so just write zeros instead.
330+
OS.write_zeros(Count % 4);
329331

330332
uint64_t NumNops = Count / 4;
331333
for (uint64_t i = 0; i != NumNops; ++i)

0 commit comments

Comments
 (0)