blob: a7a8e34074252ae385fe41fbdb374e0d7790759b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
// REQUIRES: geq-llvm-3.7
// RUN: %clang %s -emit-llvm -g -c -o %t.bc
// RUN: rm -rf %t.klee-out
// RUN: %klee --output-dir=%t.klee-out --exit-on-error %t.bc 2>%t.log
// RUN: cat %t.klee-out/assembly.ll | FileCheck %s
// Checks that KLEE lowers atomic instructions to non-atomic operations
#include <assert.h>
#include <stdatomic.h>
void test_add() {
atomic_int a = 7;
atomic_fetch_add(&a, 7);
// CHECK-NOT: atomicrmw add
assert(a == 14);
}
void test_sub() {
atomic_int a = 7;
atomic_fetch_sub(&a, 7);
// CHECK-NOT: atomicrmw sub
assert(a == 0);
}
void test_and() {
atomic_int a = 0b10001;
atomic_fetch_and(&a, 0b00101);
// CHECK-NOT: atomicrmw and
assert(a == 0b00001);
}
void test_or() {
atomic_int a = 0b10001;
atomic_fetch_or(&a, 0b00101);
// CHECK-NOT: atomicrmw or
assert(a == 0b10101);
}
void test_xor() {
atomic_int a = 0b10001;
atomic_fetch_xor(&a, 0b00101);
// CHECK-NOT: atomicrmw xor
assert(a == 0b10100);
}
void test_xchg() {
atomic_int a = 7;
atomic_exchange(&a, 10);
// CHECK-NOT: atomicrmw xchg
assert(a == 10);
}
void test_cmp_xchg() {
atomic_int a = 7;
int b = 7;
atomic_compare_exchange_weak(&a, &b, 10);
// CHECK-NOT: cmpxchg weak
assert(a == 10);
assert(b == 7);
}
int main() {
test_and();
test_sub();
test_and();
test_or();
test_xor();
test_xchg();
test_cmp_xchg();
return 0;
}
|