CCTLib
Calling-context and data-object attribution library for Intel Pin
loadspy_mixed_widths_tp.c
Go to the documentation of this file.
1 // Loadspy ISA edge case: mixed-width redundant loads (qword then two
2 // dwords covering the same 8 bytes). If loadspy's per-byte shadow works
3 // correctly across access-size boundaries, the two dword loads should be
4 // classified as redundant against the earlier qword load.
5 #include <stdint.h>
6 #define WORK_COUNT 50000
7 static volatile uint64_t sink;
8 static uint64_t buf[2] __attribute__((aligned(8))) = {0x1122334455667788ULL, 0};
9 int main(int argc, char** argv) {
10  (void)argc; (void)argv;
11  uint64_t acc = 0;
12  for (int i = 0; i < WORK_COUNT; ++i) {
13  uint64_t q;
14  uint32_t d1, d2;
15  __asm__ __volatile__(
16  "movq (%[p]), %[q]\n\t" // 8B load
17  "movl (%[p]), %[d1]\n\t" // 4B load, covers bytes 0..3 -- redundant
18  "movl 4(%[p]), %[d2]\n\t" // 4B load, covers bytes 4..7 -- redundant
19  : [q] "=r"(q), [d1] "=r"(d1), [d2] "=r"(d2)
20  : [p] "r"(buf)
21  : "memory");
22  acc += q + d1 + d2;
23  }
24  sink = acc;
25  return 0;
26 }
static uint64_t buf[ITERS]
#define WORK_COUNT
int main(int argc, char **argv)
static uint64_t buf[2] __attribute__((aligned(8)))
static volatile uint64_t sink