CCTLib
Calling-context and data-object attribution library for Intel Pin
deadspy_repstos_tp.c
Go to the documentation of this file.
1 // deadspy ISA test: `rep stosq` -- string store instruction.
2 // Writes N * 8 bytes of the same value in a single instruction. Doing it
3 // TWICE without an intervening read makes the first N*8 bytes dead.
4 // Exercises deadspy's handling of variable-length string writes.
5 #include <stdint.h>
6 #include <string.h>
7 #define N 512
8 static volatile uint64_t sink;
9 static uint64_t buf[N];
10 int main(int argc, char** argv) {
11  (void)argc; (void)argv;
12  for (int iter = 0; iter < 100; ++iter) {
13  // First: rep stosq of 512 qwords
14  __asm__ __volatile__(
15  "cld\n\t"
16  "rep stosq"
17  :
18  : "D"(buf), "c"((size_t)N), "a"((uint64_t)0xDEADBEEF)
19  : "memory", "cc");
20  // Second: rep stosq of same range -- overwrite -> dead writes
21  __asm__ __volatile__(
22  "cld\n\t"
23  "rep stosq"
24  :
25  : "D"(buf), "c"((size_t)N), "a"((uint64_t)0xCAFEB0BA)
26  : "memory", "cc");
27  }
28  sink = buf[0];
29  return 0;
30 }
#define N
int main(int argc, char **argv)
static uint64_t buf[N]
static volatile uint64_t sink