Hi,
This is a (tested!) patch to add checks that both pre-increment and pre-decrement don’t overflow, for both char and short integer types (since they’re both narrower than int), as per the problem fixed in PR9350. Thanks, Andrew R From: Friedman, Eli [mailto:efrie...@codeaurora.org] Sent: 4 January 2017 6:42 pm To: andrew.rog...@cantab.net; cfe-...@lists.llvm.org Subject: Re: [cfe-dev] Testcase for LLVM PR9350 On 1/3/2017 2:28 PM, via cfe-dev wrote: Hi clang devs, I was looking at PR9350 and saw that Eli added a test to check LLVM doesn't overflow on [signed] char increment: --- cfe/trunk/test/CodeGen/integer-overflow.c 2011/03/02 01:43:30 126815 +++ cfe/trunk/test/CodeGen/integer-overflow.c 2011/03/02 01:49:12 126816 @@ -50,11 +50,17 @@ // TRAPV_HANDLER: foo( --a; - // -fwrapv should turn off inbounds for GEP's, PR9256 extern int* P; ++P; // DEFAULT: getelementptr inbounds i32* // WRAPV: getelementptr i32* // TRAPV: getelementptr inbounds i32* + + // PR9350: char increment never overflows. + extern volatile signed char PR9350; + // DEFAULT: add i8 {{.*}}, 1 + // WRAPV: add i8 {{.*}}, 1 + // TRAPV: add i8 {{.*}}, 1 + ++PR9350; } http://llvm.org/viewvc/llvm-project?view=revision <http://llvm.org/viewvc/llvm-project?view=revision&revision=126816> &revision=126816 Presumably the logic about promotion to int applies the same as in the argument John gave in PR9350 since 6.5.3.1 §3 says "the prefix -- operator is analogous to the prefix ++ operator, except that the value of the operand is decremented". Would it therefore make sense to add the equivalent test to integer-overflow.c that decrement of a [signed] char didn't ever cause underflow: // DEFAULT: sub i8 {{.*}}, 1 // WRAPV: sub i8 {{.*}}, 1 // TRAPV: sub i8 {{.*}}, 1 --PR9350; Yes, it probably makes sense to add a testcase like that. Patch welcome. -Eli -- Employee of Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
llvm-pr9350-test-improvement.patch
Description: Binary data
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits