CCTLib
Calling-context and data-object attribution library for Intel Pin
deadspy_partial_qword_then_byte_tp.c
Go to the documentation of this file.
1 // deadspy ISA test: partial overlap.
2 // Pattern per iter: write full qword to &buf[i], then write single byte to
3 // same address. The qword's byte 0 is dead (overwritten by the byte store
4 // without a read); bytes 1-7 are NOT dead.
5 // This exercises deadspy's per-byte shadow: exactly 1 dead byte per iter.
6 #include <stdint.h>
7 #define WORK_COUNT 20000
8 static volatile uint64_t sink;
9 static uint64_t buf[WORK_COUNT];
10 int main(int argc, char** argv) {
11  (void)argc; (void)argv;
12  for (int i = 0; i < WORK_COUNT; ++i) {
13  uint64_t qval = 0xDEADBEEFULL;
14  uint8_t bval = 0x5A;
15  __asm__ __volatile__(
16  "movq %1, (%0)\n\t" // 8B write of qval
17  "movb %2, (%0)\n\t" // 1B write of bval over byte 0 -- byte 0 dead
18  :
19  : "r"(&buf[i]), "r"(qval), "r"(bval)
20  : "memory");
21  }
22  sink = buf[0];
23  return 0;
24 }
int main(int argc, char **argv)
static uint64_t buf[WORK_COUNT]
static volatile uint64_t sink