From 8f5eff7e76491f39c62455d97cf8f704631e54d7 Mon Sep 17 00:00:00 2001 From: Derek Schuff Date: Fri, 26 Oct 2012 19:52:27 +0000 Subject: [PATCH] Stop APInt::shl from generating llvm.trap APInt::shl generated llvm.trap to guard against shifts greater than bit-width. This was already checked with an assert, and there was a special case for shifts equal to bit-width. Modify this check to catch shifts greater than or equal to bit-width, so llvm.trap isn't generated. Patch contributed by JF Bastien llvm-svn: 166803 --- llvm/include/llvm/ADT/APInt.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llvm/include/llvm/ADT/APInt.h b/llvm/include/llvm/ADT/APInt.h index 4470534..90114e2 100644 --- a/llvm/include/llvm/ADT/APInt.h +++ b/llvm/include/llvm/ADT/APInt.h @@ -760,7 +760,7 @@ public: APInt shl(unsigned shiftAmt) const { assert(shiftAmt <= BitWidth && "Invalid shift amount"); if (isSingleWord()) { - if (shiftAmt == BitWidth) + if (shiftAmt >= BitWidth) return APInt(BitWidth, 0); // avoid undefined shift results return APInt(BitWidth, VAL << shiftAmt); } -- 2.7.4