CCTLib
Calling-context and data-object attribution library for Intel Pin
footprint_small.c
Go to the documentation of this file.
1 // Footprint victim: SMALL footprint. Load from the SAME 8-byte address
2 // many times. Total instructions high, but unique addresses touched: 1.
3 //
4 // Inline asm so the compiler cannot lift the load out of the loop --
5 // each `movq (%rax), %rax` reads memory anew every iteration.
6 #include <stdint.h>
7 
8 static volatile uint64_t sink;
9 static uint64_t buf[8];
10 
11 int main(int argc, char** argv) {
12  (void)argc; (void)argv;
13  buf[0] = 0xDEADBEEF;
14  volatile uint64_t* p = &buf[0];
15  uint64_t acc = 0;
16 
17  for (int i = 0; i < 100000; ++i) {
18  uint64_t v;
19  __asm__ __volatile__ ("movq (%1), %0" : "=r"(v) : "r"(p) : "memory");
20  acc += v;
21  }
22  sink = acc;
23  return 0;
24 }
int main(int argc, char **argv)
static uint64_t buf[8]
static volatile uint64_t sink