Skip to content

Commit

Permalink
Revert "[LEB128] Mark error condition with LLVM_UNLIKELY"
Browse files Browse the repository at this point in the history
This reverts commit 80fc872.
  • Loading branch information
adrian-prantl committed Nov 29, 2023
1 parent 3313c25 commit 77e5c5d
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions llvm/include/llvm/Support/LEB128.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,16 +135,15 @@ inline uint64_t decodeULEB128(const uint8_t *p, unsigned *n = nullptr,
uint64_t Value = 0;
unsigned Shift = 0;
do {
if (LLVM_UNLIKELY(p == end)) {
if (p == end) {
if (error)
*error = "malformed uleb128, extends past end";
Value = 0;
break;
}
uint64_t Slice = *p & 0x7f;
if (LLVM_UNLIKELY(Shift >= 63) &&
((Shift == 63 && (Slice << Shift >> Shift) != Slice) ||
(Shift > 63 && Slice != 0))) {
if (Shift >= 63 && ((Shift == 63 && (Slice << Shift >> Shift) != Slice) ||
(Shift > 63 && Slice != 0))) {
if (error)
*error = "uleb128 too big for uint64";
Value = 0;
Expand All @@ -170,7 +169,7 @@ inline int64_t decodeSLEB128(const uint8_t *p, unsigned *n = nullptr,
unsigned Shift = 0;
uint8_t Byte;
do {
if (LLVM_UNLIKELY(p == end)) {
if (p == end) {
if (error)
*error = "malformed sleb128, extends past end";
if (n)
Expand All @@ -179,9 +178,8 @@ inline int64_t decodeSLEB128(const uint8_t *p, unsigned *n = nullptr,
}
Byte = *p;
uint64_t Slice = Byte & 0x7f;
if (LLVM_UNLIKELY(Shift >= 63) &&
((Shift == 63 && Slice != 0 && Slice != 0x7f) ||
(Shift > 63 && Slice != (Value < 0 ? 0x7f : 0x00)))) {
if ((Shift >= 63) && ((Shift == 63 && Slice != 0 && Slice != 0x7f) ||
(Shift > 63 && Slice != (Value < 0 ? 0x7f : 0x00)))) {
if (error)
*error = "sleb128 too big for int64";
if (n)
Expand Down

0 comments on commit 77e5c5d

Please sign in to comment.