diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2016-02-01 20:36:49 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2016-02-01 20:36:49 +0000 |
commit | 52570ea2a2498b8462e2a3a20576aea07647758d (patch) | |
tree | 1fda205d0ff14a6214c9d52ef185e47ef4c7690b | |
parent | 2d9da4dc501d71a4be5f56c40ed47a9f3ce8430e (diff) | |
download | bcm5719-llvm-52570ea2a2498b8462e2a3a20576aea07647758d.tar.gz bcm5719-llvm-52570ea2a2498b8462e2a3a20576aea07647758d.zip |
Fix infinite recursion in MCAsmStreamer::EmitValueImpl.
If a target can only emit 8-bits data, we would loop in EmitValueImpl
since it will try to split a 32-bits data in 1 chunk of 32-bits.
No test since all current targets can emit 32bits at a time.
Patch by Alexandru Guduleasa!
llvm-svn: 259399
-rw-r--r-- | llvm/lib/MC/MCAsmStreamer.cpp | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/llvm/lib/MC/MCAsmStreamer.cpp b/llvm/lib/MC/MCAsmStreamer.cpp index b31fd2c34dc..1bac42a8d09 100644 --- a/llvm/lib/MC/MCAsmStreamer.cpp +++ b/llvm/lib/MC/MCAsmStreamer.cpp @@ -720,17 +720,15 @@ void MCAsmStreamer::EmitValueImpl(const MCExpr *Value, unsigned Size, report_fatal_error("Don't know how to emit this value."); // We couldn't handle the requested integer size so we fallback by breaking - // the request down into several, smaller, integers. Since sizes greater - // than eight are invalid and size equivalent to eight should have been - // handled earlier, we use four bytes as our largest piece of granularity. + // the request down into several, smaller, integers. + // Since sizes greater or equal to "Size" are invalid, we use the greatest + // power of 2 that is less than "Size" as our largest piece of granularity. bool IsLittleEndian = MAI->isLittleEndian(); for (unsigned Emitted = 0; Emitted != Size;) { unsigned Remaining = Size - Emitted; // The size of our partial emission must be a power of two less than - // eight. - unsigned EmissionSize = PowerOf2Floor(Remaining); - if (EmissionSize > 4) - EmissionSize = 4; + // Size. + unsigned EmissionSize = PowerOf2Floor(std::min(Remaining, Size - 1)); // Calculate the byte offset of our partial emission taking into account // the endianness of the target. unsigned ByteOffset = |