summaryrefslogtreecommitdiff
path: root/test/LLC/testtrace.c
blob: c7b3e8a47e121b56604ac7aa8e46aedc30190978 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <stdio.h>

/*
 * Test routines for testing the tracing code.
 */

struct DummyStruct {
  struct DummyStruct* next;
  int seqnum;
};

int
AddCounts(struct DummyStruct* S1,
          struct DummyStruct* S2,
          struct DummyStruct* S3, int noPrint)
{
  if (!noPrint)
    printf("&S1 = %p\t&S2 = %p\t&S3 = %p\n", S1, S2, S3);
  return S1->seqnum + S2->seqnum + S3->seqnum;
}

void
testAllocaOrder(int noPrint)
{
  static int count = 0;
  struct DummyStruct S1, S2, S3;
  
  S1.seqnum = ++count;
  S2.seqnum = ++count;
  S3.seqnum = ++count;
  
  printf("sum = %d\n", AddCounts(&S1, &S2, &S3, noPrint));
}

int
main(int argc, char** argv)
{
  unsigned int i, noPrint = 1;
  if (argc > 1 && ! strcmp(argv[1], "-d"))
    noPrint = 0;
  for (i=0; i < 10; ++i)
    testAllocaOrder(noPrint);
  return 0;
}