OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.dg/] [simulate-thread/] [speculative-store.c] - Blame information for rev 801

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 689 jeremybenn
/* { dg-do link } */
2
/* { dg-options "--param allow-store-data-races=0" } */
3
/* { dg-final { simulate-thread } } */
4
 
5
#include <stdio.h>
6
#include "simulate-thread.h"
7
 
8
/* This file tests that speculative store movement out of a loop doesn't
9
   happen.  This is disallowed when --param allow-store-data-races is 0.  */
10
 
11
int global = 100;
12
 
13
/* Other thread makes sure global is 100 before the next instruction is
14
 * exceuted.  */
15
void simulate_thread_other_threads()
16
{
17
  global = 100;
18
}
19
 
20
int simulate_thread_step_verify()
21
{
22
  if (global != 100)
23
    {
24
      printf("FAIL: global variable was assigned to.  \n");
25
      return 1;
26
    }
27
  return 0;
28
}
29
 
30
int simulate_thread_final_verify()
31
{
32
  return 0;
33
}
34
 
35
/* The variable global should never be assigned if func(0) is called.
36
   This tests store movement out of loop thats never executed. */
37
void test (int y)
38
{
39
  int x;
40
  for (x=0; x< y; x++)
41
    {
42
       global = y;   /* This should never speculatively execute.  */
43
    }
44
}
45
 
46
__attribute__((noinline))
47
void simulate_thread_main()
48
{
49
  test(0);
50
  simulate_thread_done();
51
}
52
 
53
__attribute__((noinline))
54
int main()
55
{
56
  simulate_thread_main();
57
  return 0;
58
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.