From 9d0f923e7c2956ade5794a0621d8c7f0d7b172de Mon Sep 17 00:00:00 2001 From: Owen Anderson Date: Wed, 29 Aug 2012 22:18:56 +0000 Subject: Allow targets to specify a minimum supported NOP size when performing NOP padding. If the desired padding is smaller than the supported NOP size, we will enlarge the padding to make it work. llvm-svn: 162870 --- llvm/lib/MC/MCAssembler.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'llvm/lib/MC/MCAssembler.cpp') diff --git a/llvm/lib/MC/MCAssembler.cpp b/llvm/lib/MC/MCAssembler.cpp index 05519b56ffe..c872bd62c9a 100644 --- a/llvm/lib/MC/MCAssembler.cpp +++ b/llvm/lib/MC/MCAssembler.cpp @@ -325,6 +325,12 @@ uint64_t MCAssembler::computeFragmentSize(const MCAsmLayout &Layout, const MCAlignFragment &AF = cast(F); unsigned Offset = Layout.getFragmentOffset(&AF); unsigned Size = OffsetToAlignment(Offset, AF.getAlignment()); + // If we are padding with nops, force the padding to be larger than the + // minimum nop size. + if (Size > 0 && AF.hasEmitNops()) { + while (Size % getBackend().getMinimumNopSize()) + Size += AF.getAlignment(); + } if (Size > AF.getMaxBytesToEmit()) return 0; return Size; -- cgit v1.2.3