CCTLib
Calling-context and data-object attribution library for Intel Pin
redspy_tn_simple.c
Go to the documentation of this file.
1 // True-negative victim: writes DIFFERENT values -- second write is NOT
2 // redundant because the stored value changes.
3 #include <stdint.h>
4 
5 #define WORK_COUNT 10000
6 
7 static volatile uint64_t sink;
8 
9 __attribute__((noinline)) void store8(volatile uint64_t* p, uint64_t v) {
10  *p = v;
11 }
12 
13 int main(int argc, char** argv) {
14  (void)argc; (void)argv;
15  uint64_t buf[WORK_COUNT];
16  for (int i = 0; i < WORK_COUNT; ++i) buf[i] = 0xAAULL;
17 
18  for (int i = 0; i < WORK_COUNT; ++i) {
19  store8(&buf[i], 0xDEADBEEF);
20  store8(&buf[i], 0xC0FFEE); // different -- not redundant
21  }
22 
23  uint64_t s = 0;
24  for (int i = 0; i < WORK_COUNT; ++i) s += buf[i];
25  sink = s;
26  return 0;
27 }
static uint64_t buf[ITERS]
#define WORK_COUNT
int main(int argc, char **argv)
__attribute__((noinline))
static volatile uint64_t sink