CCTLib
Calling-context and data-object attribution library for Intel Pin
redspy_tp_simple.c
Go to the documentation of this file.
1 // True-positive victim for redspy: write the SAME value to the same
2 // location twice. Redspy classifies the second write as REDUNDANT because
3 // the memory content did not change.
4 #include <stdint.h>
5 
6 #define WORK_COUNT 10000
7 
8 static volatile uint64_t sink;
9 
10 __attribute__((noinline)) void store8(volatile uint64_t* p, uint64_t v) {
11  *p = v;
12 }
13 
14 int main(int argc, char** argv) {
15  (void)argc; (void)argv;
16  uint64_t buf[WORK_COUNT];
17  for (int i = 0; i < WORK_COUNT; ++i) buf[i] = 0xAAULL;
18 
19  for (int i = 0; i < WORK_COUNT; ++i) {
20  store8(&buf[i], 0xDEADBEEF);
21  store8(&buf[i], 0xDEADBEEF); // redundant: same value as previous
22  }
23 
24  uint64_t s = 0;
25  for (int i = 0; i < WORK_COUNT; ++i) s += buf[i];
26  sink = s;
27  return 0;
28 }
static uint64_t buf[ITERS]
#define WORK_COUNT
int main(int argc, char **argv)
__attribute__((noinline))
static volatile uint64_t sink