http://llvm.org/bugs/show_bug.cgi?id=20193
Bug ID: 20193
Summary: ubsan emits superfluous overflow checks for promoted
arithmetic
Product: clang
Version: unspecified
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: LLVM Codegen
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected]
Classification: Unclassified
Arithmetic on types that are smaller than 'int' cannot overflow, with the
exception of SHRT_MIN * SHRT_MIN. Ubsan emits superfluous with.overflow
intrinsics in this case anyway:
char min; int main() { return min + min; }
gives:
define i32 @main() #0 prefix <{ i32, i8* }> <{ i32 1413876459, i8* bitcast ({
i8*, i8* }* @_ZTIFivE to i8*) }> {
entry:
%0 = load i8* @min, align 1, !tbaa !1
%conv = sext i8 %0 to i32
%1 = tail call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 %conv, i32 %conv)
%2 = extractvalue { i32, i1 } %1, 0
%3 = extractvalue { i32, i1 } %1, 1
br i1 %3, label %handler.add_overflow, label %cont, !prof !4
; ...
We also emit unnecessary overflow checks when one of the operands is a constant
and the other is promoted. It would seem straightforward to look at the input
value and check if it's obviously got multiple sign bits, and if so, figure out
that the overflow is impossible.
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs