summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/ipa/ipa-pta-19.c
blob: ae47cb053b2d9c594323d8f1c785e985a588ef47 (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
45
46
/* { dg-do run } */
/* { dg-require-ifunc "" } */
/* { dg-options "-O2 -fipa-pta" } */

#include <stdlib.h>
#include <stdbool.h>

#define hot __attribute__((hot))

static hot void multiver_default(unsigned int in, bool *ret)
{
	if ( in & 1 ) {
		*ret = false;
	}else{
		*ret = true;
	}
}

static void (*resolve_multiver(void))(unsigned int in, bool *out)
{
	return &multiver_default;
}

__attribute__ ((ifunc("resolve_multiver")))
static void multiver_test(unsigned int val, bool *ret);

static hot bool do_test(unsigned int val)
{
	bool ret = false;

	multiver_test(val, &ret);

	return (ret == !(val & 0x1));
}

volatile unsigned int x = 2;
int main()
{
  int i;
  for(i = 1; i < x; i++) {
      unsigned int val = x;
      if ( !do_test(val) )
	abort ();
  }
  return 0;
}