Ahmed Bougacha | ff75f3d | 2015-06-11 18:19:34 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s \ |
| 2 | // RUN: -fsanitize=signed-integer-overflow \ |
Mandeep Singh Grang | d9d3b21 | 2016-04-20 01:02:18 +0000 | [diff] [blame] | 3 | // RUN: | FileCheck %s |
Ahmed Bougacha | ff75f3d | 2015-06-11 18:19:34 +0000 | [diff] [blame] | 4 | |
| 5 | // Verify we emit constants for "immediate" inline assembly arguments. |
| 6 | // Emitting a scalar expression can make the immediate be generated as |
| 7 | // overflow intrinsics, if the overflow sanitizer is enabled. |
| 8 | |
| 9 | // Check both 'i' and 'I': |
| 10 | // - 'i' accepts symbolic constants. |
| 11 | // - 'I' doesn't, and is really an immediate-required constraint. |
| 12 | |
| 13 | // See also PR23517. |
| 14 | |
| 15 | // CHECK-LABEL: @test_inlineasm_i |
| 16 | // CHECK: call void asm sideeffect "int $0", "i{{.*}}"(i32 2) |
| 17 | void test_inlineasm_i() { |
| 18 | __asm__ __volatile__("int %0" :: "i"(1 + 1)); |
| 19 | } |
| 20 | |
| 21 | // CHECK-LABEL: @test_inlineasm_I |
| 22 | // CHECK: call void asm sideeffect "int $0", "I{{.*}}"(i32 2) |
Ahmed Bougacha | f6a9f0e | 2015-06-13 01:16:10 +0000 | [diff] [blame] | 23 | // CHECK: call void asm sideeffect "int $0", "I{{.*}}"(i32 3) |
Ahmed Bougacha | ff75f3d | 2015-06-11 18:19:34 +0000 | [diff] [blame] | 24 | void test_inlineasm_I() { |
| 25 | __asm__ __volatile__("int %0" :: "I"(1 + 1)); |
Ahmed Bougacha | f6a9f0e | 2015-06-13 01:16:10 +0000 | [diff] [blame] | 26 | |
| 27 | // Also check a C non-ICE. |
| 28 | static const int N = 1; |
| 29 | __asm__ __volatile__("int %0" :: "I"(N + 2)); |
Ahmed Bougacha | ff75f3d | 2015-06-11 18:19:34 +0000 | [diff] [blame] | 30 | } |