From 51924e517bd2d25faea6ef873db3c59ec4d09bf8 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sat, 26 Jun 2010 21:25:03 +0000 Subject: Implement support for -fwrapv, rdar://7221421 As part of this, pull together trapv handling into the same enum. This also add support for NSW multiplies. This also makes PCH disagreement on overflow behavior silent, since it really doesn't matter except for warnings and codegen (no macros get defined etc). llvm-svn: 106956 --- clang/test/CodeGen/integer-overflow.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 clang/test/CodeGen/integer-overflow.c (limited to 'clang/test/CodeGen/integer-overflow.c') diff --git a/clang/test/CodeGen/integer-overflow.c b/clang/test/CodeGen/integer-overflow.c new file mode 100644 index 00000000000..79692161042 --- /dev/null +++ b/clang/test/CodeGen/integer-overflow.c @@ -0,0 +1,33 @@ +// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s --check-prefix=DEFAULT +// RUN: %clang_cc1 %s -emit-llvm -o - -fwrapv | FileCheck %s --check-prefix=WRAPV +// RUN: %clang_cc1 %s -emit-llvm -o - -ftrapv | FileCheck %s --check-prefix=TRAPV + + +// Tests for signed integer overflow stuff. +// rdar://7432000 rdar://7221421 +void test1() { + // DEFAULT: define void @test1 + // WRAPV: define void @test1 + // TRAPV: define void @test1 + extern volatile int f11G, a, b; + + // DEFAULT: add nsw i32 + // WRAPV: add i32 + // TRAPV: llvm.sadd.with.overflow.i32 + f11G = a + b; + + // DEFAULT: sub nsw i32 + // WRAPV: sub i32 + // TRAPV: llvm.ssub.with.overflow.i32 + f11G = a - b; + + // DEFAULT: sub nsw i32 0, + // WRAPV: sub i32 0, + // TRAPV: sub nsw i32 0, + f11G = -a; + + // DEFAULT: mul nsw i32 + // WRAPV: mul i32 + // TRAPV: llvm.smul.with.overflow.i32 + f11G = a * b; +} -- cgit v1.2.3