From 6535a57ff4dc2bbecfb255093832af8e0b2aa0b7 Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Thu, 12 Jan 2017 19:51:44 +0000 Subject: [PATCH] Add additional testcases for nsw markings on ++ and --. clang has generated correct IR for char/short decrement since r126816, but we didn't have any test coverage for decrement. Patch by Andrew Rogers. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@291805 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/CodeGen/integer-overflow.c | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/test/CodeGen/integer-overflow.c b/test/CodeGen/integer-overflow.c index 6a7c3e51ee..0b28bc5b8a 100644 --- a/test/CodeGen/integer-overflow.c +++ b/test/CodeGen/integer-overflow.c @@ -65,13 +65,37 @@ void test1() { // TRAPV: getelementptr inbounds i32, i32* // CATCH_UB: getelementptr inbounds i32, i32* - // PR9350: char increment never overflows. - extern volatile signed char PR9350; + // PR9350: char pre-increment never overflows. + extern volatile signed char PR9350_char_inc; // DEFAULT: add i8 {{.*}}, 1 // WRAPV: add i8 {{.*}}, 1 // TRAPV: add i8 {{.*}}, 1 // CATCH_UB: add i8 {{.*}}, 1 - ++PR9350; + ++PR9350_char_inc; + + // PR9350: char pre-decrement never overflows. + extern volatile signed char PR9350_char_dec; + // DEFAULT: add i8 {{.*}}, -1 + // WRAPV: add i8 {{.*}}, -1 + // TRAPV: add i8 {{.*}}, -1 + // CATCH_UB: add i8 {{.*}}, -1 + --PR9350_char_dec; + + // PR9350: short pre-increment never overflows. + extern volatile signed short PR9350_short_inc; + // DEFAULT: add i16 {{.*}}, 1 + // WRAPV: add i16 {{.*}}, 1 + // TRAPV: add i16 {{.*}}, 1 + // CATCH_UB: add i16 {{.*}}, 1 + ++PR9350_short_inc; + + // PR9350: short pre-decrement never overflows. + extern volatile signed short PR9350_short_dec; + // DEFAULT: add i16 {{.*}}, -1 + // WRAPV: add i16 {{.*}}, -1 + // TRAPV: add i16 {{.*}}, -1 + // CATCH_UB: add i16 {{.*}}, -1 + --PR9350_short_dec; // PR24256: don't instrument __builtin_frame_address. __builtin_frame_address(0 + 0); -- 2.40.0