Commit a5362c6a by Jose E. Marchesi Committed by Jose E. Marchesi

testsuite: new require effective target indirect_calls

    
This patch adds a new dg_require_effective_target procedure to the
testsuite infrastructure: indirect_calls.  This new function tells
whether a target supports calls to non-constant call targets.
    
This patch also annotates the tests in the gcc.c-torture testuite that
require support for indirect calls.
    
    gcc/ChangeLog:
    
            * doc/sourcebuild.texi (Effective-Target Keywords): Document
            indirect_calls.
    
    gcc/testsuite/ChangeLog:
    
            * lib/target-supports.exp (check_effective_target_indirect_calls):
            New proc.
            * gcc.c-torture/compile/20010102-1.c: Annotate with
            dg-require-effective-target indirect_calls.
            * gcc.c-torture/compile/20010107-1.c: Likewise.
            * gcc.c-torture/compile/20011109-1.c: Likewise.
            * gcc.c-torture/compile/20011218-1.c: Likewise.
            * gcc.c-torture/compile/20011229-1.c: Likewise.
            * gcc.c-torture/compile/20020129-1.c: Likewise.
            * gcc.c-torture/compile/20020320-1.c: Likewise.
            * gcc.c-torture/compile/20020706-1.c: Likewise.
            * gcc.c-torture/compile/20020706-2.c: Likewise.
            * gcc.c-torture/compile/20021205-1.c: Likewise.
            * gcc.c-torture/compile/20030921-1.c: Likewise.
            * gcc.c-torture/compile/20031023-1.c: Likewise.
            * gcc.c-torture/compile/20031023-2.c: Likewise.
            * gcc.c-torture/compile/20031023-3.c: Likewise.
            * gcc.c-torture/compile/20031023-4.c: Likewise.
            * gcc.c-torture/compile/20040614-1.c: Likewise.
            * gcc.c-torture/compile/20040909-1.c: Likewise.
            * gcc.c-torture/compile/20050122-1.c: Likewise.
            * gcc.c-torture/compile/20050202-1.c: Likewise.
            * gcc.c-torture/compile/20060208-1.c: Likewise.
            * gcc.c-torture/compile/20081108-1.c: Likewise.
            * gcc.c-torture/compile/20150327.c: Likewise.
            * gcc.c-torture/compile/920428-2.c: Likewise.
            * gcc.c-torture/compile/920928-5.c: Likewise.
            * gcc.c-torture/compile/930117-1.c: Likewise.
            * gcc.c-torture/compile/930607-1.c: Likewise.
            * gcc.c-torture/compile/991213-2.c: Likewise.
            * gcc.c-torture/compile/callind.c: Likewise.
            * gcc.c-torture/compile/calls-void.c: Likewise.
            * gcc.c-torture/compile/calls.c: Likewise.
            * gcc.c-torture/compile/pr21840.c: Likewise.
            * gcc.c-torture/compile/pr32139.c: Likewise.
            * gcc.c-torture/compile/pr35607.c: Likewise.
            * gcc.c-torture/compile/pr37433-1.c: Likewise.
            * gcc.c-torture/compile/pr37433.c: Likewise.
            * gcc.c-torture/compile/pr39941.c: Likewise.
            * gcc.c-torture/compile/pr40080.c: Likewise.
            * gcc.c-torture/compile/pr43635.c: Likewise.
            * gcc.c-torture/compile/pr43791.c: Likewise.
            * gcc.c-torture/compile/pr43845.c: Likewise.
            * gcc.c-torture/compile/pr44043.c: Likewise.
            * gcc.c-torture/compile/pr51694.c: Likewise.
            * gcc.c-torture/compile/pr77754-2.c: Likewise.
            * gcc.c-torture/compile/pr77754-3.c: Likewise.
            * gcc.c-torture/compile/pr77754-4.c: Likewise.
            * gcc.c-torture/compile/pr89663-2.c: Likewise.
            * gcc.c-torture/compile/pta-1.c: Likewise.
            * gcc.c-torture/compile/stack-check-1.c: Likewise.
            * gcc.dg/Walloc-size-larger-than-18.c: Likewise.

From-SVN: r275505
parent e9b8025b
2019-09-09 Jose E. Marchesi <jose.marchesi@oracle.com> 2019-09-09 Jose E. Marchesi <jose.marchesi@oracle.com>
* doc/sourcebuild.texi (Effective-Target Keywords): Document
indirect_calls.
2019-09-09 Jose E. Marchesi <jose.marchesi@oracle.com>
* opt-functions.awk (integer_range_info): Make sure values are in * opt-functions.awk (integer_range_info): Make sure values are in
numeric context before operating with them. numeric context before operating with them.
......
...@@ -2374,6 +2374,10 @@ Target supports @code{wchar_t} that is compatible with @code{char32_t}. ...@@ -2374,6 +2374,10 @@ Target supports @code{wchar_t} that is compatible with @code{char32_t}.
@item comdat_group @item comdat_group
Target uses comdat groups. Target uses comdat groups.
@item indirect_calls
Target supports indirect calls, i.e. calls where the target is not
constant.
@end table @end table
@subsubsection Local to tests in @code{gcc.target/i386} @subsubsection Local to tests in @code{gcc.target/i386}
......
2019-09-09 Jose E. Marchesi <jose.marchesi@oracle.com> 2019-09-09 Jose E. Marchesi <jose.marchesi@oracle.com>
* lib/target-supports.exp (check_effective_target_indirect_calls):
New proc.
* gcc.c-torture/compile/20010102-1.c: Annotate with
dg-require-effective-target indirect_calls.
* gcc.c-torture/compile/20010107-1.c: Likewise.
* gcc.c-torture/compile/20011109-1.c: Likewise.
* gcc.c-torture/compile/20011218-1.c: Likewise.
* gcc.c-torture/compile/20011229-1.c: Likewise.
* gcc.c-torture/compile/20020129-1.c: Likewise.
* gcc.c-torture/compile/20020320-1.c: Likewise.
* gcc.c-torture/compile/20020706-1.c: Likewise.
* gcc.c-torture/compile/20020706-2.c: Likewise.
* gcc.c-torture/compile/20021205-1.c: Likewise.
* gcc.c-torture/compile/20030921-1.c: Likewise.
* gcc.c-torture/compile/20031023-1.c: Likewise.
* gcc.c-torture/compile/20031023-2.c: Likewise.
* gcc.c-torture/compile/20031023-3.c: Likewise.
* gcc.c-torture/compile/20031023-4.c: Likewise.
* gcc.c-torture/compile/20040614-1.c: Likewise.
* gcc.c-torture/compile/20040909-1.c: Likewise.
* gcc.c-torture/compile/20050122-1.c: Likewise.
* gcc.c-torture/compile/20050202-1.c: Likewise.
* gcc.c-torture/compile/20060208-1.c: Likewise.
* gcc.c-torture/compile/20081108-1.c: Likewise.
* gcc.c-torture/compile/20150327.c: Likewise.
* gcc.c-torture/compile/920428-2.c: Likewise.
* gcc.c-torture/compile/920928-5.c: Likewise.
* gcc.c-torture/compile/930117-1.c: Likewise.
* gcc.c-torture/compile/930607-1.c: Likewise.
* gcc.c-torture/compile/991213-2.c: Likewise.
* gcc.c-torture/compile/callind.c: Likewise.
* gcc.c-torture/compile/calls-void.c: Likewise.
* gcc.c-torture/compile/calls.c: Likewise.
* gcc.c-torture/compile/pr21840.c: Likewise.
* gcc.c-torture/compile/pr32139.c: Likewise.
* gcc.c-torture/compile/pr35607.c: Likewise.
* gcc.c-torture/compile/pr37433-1.c: Likewise.
* gcc.c-torture/compile/pr37433.c: Likewise.
* gcc.c-torture/compile/pr39941.c: Likewise.
* gcc.c-torture/compile/pr40080.c: Likewise.
* gcc.c-torture/compile/pr43635.c: Likewise.
* gcc.c-torture/compile/pr43791.c: Likewise.
* gcc.c-torture/compile/pr43845.c: Likewise.
* gcc.c-torture/compile/pr44043.c: Likewise.
* gcc.c-torture/compile/pr51694.c: Likewise.
* gcc.c-torture/compile/pr77754-2.c: Likewise.
* gcc.c-torture/compile/pr77754-3.c: Likewise.
* gcc.c-torture/compile/pr77754-4.c: Likewise.
* gcc.c-torture/compile/pr89663-2.c: Likewise.
* gcc.c-torture/compile/pta-1.c: Likewise.
* gcc.c-torture/compile/stack-check-1.c: Likewise.
* gcc.dg/Walloc-size-larger-than-18.c: Likewise.
2019-09-09 Jose E. Marchesi <jose.marchesi@oracle.com>
* gcc.c-torture/compile/20000609-1.c: Annotate with * gcc.c-torture/compile/20000609-1.c: Annotate with
dg-require-stack-size. dg-require-stack-size.
* gcc.c-torture/compile/20000804-1.c: Likewise. * gcc.c-torture/compile/20000804-1.c: Likewise.
......
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
Copyright (C) 2001 Free Software Foundation. */ Copyright (C) 2001 Free Software Foundation. */
/* { dg-require-effective-target indirect_calls } */
# define PTR_INT_TYPE __PTRDIFF_TYPE__ # define PTR_INT_TYPE __PTRDIFF_TYPE__
struct _obstack_chunk struct _obstack_chunk
......
/* { dg-require-effective-target indirect_calls } */
unsigned long x[4]; unsigned long x[4];
void foo(void) void foo(void)
......
/* { dg-require-effective-target indirect_calls } */
typedef struct { short x[4]; } S; typedef struct { short x[4]; } S;
typedef struct { unsigned int a, b, c; S *d; } T; typedef struct { unsigned int a, b, c; S *d; } T;
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
for the indirect call was exposed too early and reload couldn't for the indirect call was exposed too early and reload couldn't
allocate it for multiplication and division. */ allocate it for multiplication and division. */
/* { dg-require-effective-target indirect_calls } */
struct S { struct S {
int a, b; int a, b;
void (*f) (long, int); void (*f) (long, int);
......
/* ICE: call insn does not satisfy its constraints, MMIX port. /* ICE: call insn does not satisfy its constraints, MMIX port.
Origin: ghostscript-6.52, reduction from hp@bitrange.com. */ Origin: ghostscript-6.52, reduction from hp@bitrange.com. */
/* { dg-require-effective-target indirect_calls } */
struct s0 struct s0
{ {
void (*init_color)(void *, void *); void (*init_color)(void *, void *);
......
/* Test call to static variable. */ /* Test call to static variable. */
/* { dg-require-effective-target indirect_calls } */
typedef struct typedef struct
{ {
long long a[10]; long long a[10];
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
This testcase caused infinite loop in flow (several places), This testcase caused infinite loop in flow (several places),
because flow assumes gen_jump generates simple_jump_p. */ because flow assumes gen_jump generates simple_jump_p. */
/* { dg-require-effective-target indirect_calls } */
typedef void (*T) (void); typedef void (*T) (void);
extern T x[]; extern T x[];
......
// Contributed by Alexandre Oliva <aoliva@redhat.com> // Contributed by Alexandre Oliva <aoliva@redhat.com>
// From Red Hat case 106165. // From Red Hat case 106165.
/* { dg-require-effective-target indirect_calls } */
typedef struct s1 typedef struct s1
{ {
unsigned short v1; unsigned short v1;
......
// Contributed by Alexandre Oliva <aoliva@redhat.com> // Contributed by Alexandre Oliva <aoliva@redhat.com>
// From Red Hat case 106165. // From Red Hat case 106165.
/* { dg-require-effective-target indirect_calls } */
typedef unsigned short (FUNC_P) (void *, unsigned char *, unsigned short); typedef unsigned short (FUNC_P) (void *, unsigned char *, unsigned short);
void crashIt(int id, FUNC_P *func, unsigned char *funcparm) void crashIt(int id, FUNC_P *func, unsigned char *funcparm)
......
/* { dg-require-effective-target indirect_calls } */
typedef struct x x; typedef struct x x;
extern void *baz(char *); extern void *baz(char *);
struct x { char * (*bar) (int); }; struct x { char * (*bar) (int); };
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
f is not being emitted. TREE_SYMBOL_REFERENCED was being set f is not being emitted. TREE_SYMBOL_REFERENCED was being set
instead of calling mark_referenced. */ instead of calling mark_referenced. */
/* { dg-require-effective-target indirect_calls } */
static void f(void); static void f(void);
void g(void (*x) (void)){x();} void g(void (*x) (void)){x();}
......
/* Declaration of the frame size doesn't work on ptx. */ /* Declaration of the frame size doesn't work on ptx. */
/* { dg-require-effective-target untyped_assembly } */ /* { dg-require-effective-target untyped_assembly } */
/* { dg-require-effective-target indirect_calls } */
#ifndef ASIZE #ifndef ASIZE
# define ASIZE 0x10000000000UL # define ASIZE 0x10000000000UL
#endif #endif
......
/* Declaration of the frame size doesn't work on ptx. */ /* Declaration of the frame size doesn't work on ptx. */
/* { dg-require-effective-target untyped_assembly } */ /* { dg-require-effective-target untyped_assembly } */
/* { dg-require-effective-target indirect_calls } */
#define ASIZE 0x1000000000UL #define ASIZE 0x1000000000UL
#include "20031023-1.c" #include "20031023-1.c"
/* Declaration of the frame size doesn't work on ptx. */ /* Declaration of the frame size doesn't work on ptx. */
/* { dg-require-effective-target untyped_assembly } */ /* { dg-require-effective-target untyped_assembly } */
/* { dg-require-effective-target indirect_calls } */
#define ASIZE 0x100000000UL #define ASIZE 0x100000000UL
#include "20031023-1.c" #include "20031023-1.c"
/* { dg-require-effective-target indirect_calls } */
#define ASIZE 0x80000000UL #define ASIZE 0x80000000UL
#include "20031023-1.c" #include "20031023-1.c"
/* { dg-require-effective-target label_values } */ /* { dg-require-effective-target label_values } */
/* { dg-require-effective-target indirect_calls } */
void f(int r1, int *fp) void f(int r1, int *fp)
{ {
......
/* { dg-require-effective-target indirect_calls } */
static __inline__ int static __inline__ int
one_utf8_to_utf16 () { } one_utf8_to_utf16 () { }
......
/* From PR 19484. */ /* From PR 19484. */
/* { dg-require-effective-target indirect_calls } */
extern void foo (void) __attribute__((noreturn)); extern void foo (void) __attribute__((noreturn));
int n; int n;
......
/* From PR 19578. */ /* From PR 19578. */
/* { dg-require-effective-target indirect_calls } */
extern void foo (void) __attribute__((noreturn)); extern void foo (void) __attribute__((noreturn));
void void
......
/* PR middle-end/26092 */ /* PR middle-end/26092 */
/* { dg-require-effective-target indirect_calls } */
/* { dg-skip-if "can't take address of malloc" { nvptx-*-* } } */ /* { dg-skip-if "can't take address of malloc" { nvptx-*-* } } */
typedef __SIZE_TYPE__ size_t; typedef __SIZE_TYPE__ size_t;
extern void *malloc (size_t); extern void *malloc (size_t);
......
/* { dg-require-effective-target indirect_calls } */
/* Test function call with function designator involving VLA /* Test function call with function designator involving VLA
side-effects does not lead to an ICE. */ side-effects does not lead to an ICE. */
......
/* { dg-require-effective-target indirect_calls } */
int a; int a;
int (*b)(), (*c)(); int (*b)(), (*c)();
int fn1(int p1) { int fn1(int p1) {
......
/* { dg-require-effective-target indirect_calls } */
double sin(double x); double sin(double x);
double cos(double x); double cos(double x);
double tan(double x); double tan(double x);
......
/* REPRODUCED:CC1:SIGNAL MACHINE:m68k OPTIONS:-fpcc-struct-return */ /* REPRODUCED:CC1:SIGNAL MACHINE:m68k OPTIONS:-fpcc-struct-return */
/* { dg-require-effective-target indirect_calls } */
struct b{}; struct b{};
f(struct b(*f)()) f(struct b(*f)())
{ {
......
/* { dg-require-effective-target indirect_calls } */
f(x) f(x)
{ {
(*(void (*)())&x)(); (*(void (*)())&x)();
......
/* { dg-require-effective-target indirect_calls } */
typedef void f (); typedef void f ();
typedef f *pf; typedef f *pf;
long long i; long long i;
......
/* { dg-require-effective-target indirect_calls } */
typedef long __kernel_time_t; typedef long __kernel_time_t;
typedef __kernel_time_t time_t; typedef __kernel_time_t time_t;
time2( time2(
......
/* { dg-require-effective-target indirect_calls } */
bar (foo, a) bar (foo, a)
int (**foo) (); int (**foo) ();
{ {
......
/* { dg-require-effective-target ptr32plus } */ /* { dg-require-effective-target ptr32plus } */
/* { dg-require-effective-target untyped_assembly } */ /* { dg-require-effective-target untyped_assembly } */
/* { dg-require-effective-target indirect_calls } */
typedef void (*T)(void); typedef void (*T)(void);
f1 () f1 ()
......
/* { dg-require-effective-target ptr32plus } */ /* { dg-require-effective-target ptr32plus } */
/* { dg-require-effective-target untyped_assembly } */ /* { dg-require-effective-target untyped_assembly } */
/* { dg-require-effective-target indirect_calls } */
typedef void *(*T)(void); typedef void *(*T)(void);
f1 () f1 ()
......
/* { dg-require-effective-target indirect_calls } */
void fn_show_state(void); void fn_show_state(void);
typedef void (*fn_handler_fn)(void); typedef void (*fn_handler_fn)(void);
static fn_handler_fn fn_handler[1]; static fn_handler_fn fn_handler[1];
......
/* PR tree-optimization/32139 */ /* PR tree-optimization/32139 */
/* { dg-require-effective-target indirect_calls } */
int foo (void); int foo (void);
int bar (void) __attribute__ ((const)); int bar (void) __attribute__ ((const));
......
/* { dg-require-effective-target indirect_calls } */
extern void (*__fini_array_start []) (void); extern void (*__fini_array_start []) (void);
extern void (*__fini_array_end []) (void); extern void (*__fini_array_end []) (void);
void void
......
/* { dg-require-effective-target indirect_calls } */
void regex_subst(void) void regex_subst(void)
{ {
const void *subst = ""; const void *subst = "";
......
/* { dg-require-effective-target indirect_calls } */
int regex_subst(void) int regex_subst(void)
{ {
const void *subst = ""; const void *subst = "";
......
/* { dg-require-effective-target indirect_calls } */
typedef void (*entry_func) (void) __attribute__ ((noreturn)); typedef void (*entry_func) (void) __attribute__ ((noreturn));
extern entry_func entry_addr; extern entry_func entry_addr;
static void bsd_boot_entry (void) static void bsd_boot_entry (void)
......
/* { dg-require-effective-target indirect_calls } */
extern void *ff(void*,int); extern void *ff(void*,int);
struct lpgl { struct lpgl *next; }; struct lpgl { struct lpgl *next; };
......
/* { dg-require-effective-target untyped_assembly } */ /* { dg-require-effective-target untyped_assembly } */
/* { dg-require-effective-target indirect_calls } */
extern void d (void); extern void d (void);
void (*foo (void)) (float) void (*foo (void)) (float)
......
/* { dg-require-effective-target indirect_calls } */
int owner(); int owner();
int clear(); int clear();
......
/* { dg-require-effective-target indirect_calls } */
typedef int __attribute__ ((const)) (*x264_pixel_cmp_t)(void); typedef int __attribute__ ((const)) (*x264_pixel_cmp_t)(void);
typedef struct { typedef struct {
......
/* { dg-require-effective-target indirect_calls } */
typedef unsigned char __u8; typedef unsigned char __u8;
typedef unsigned short __u16; typedef unsigned short __u16;
typedef unsigned int __u32; typedef unsigned int __u32;
......
/* { dg-require-effective-target untyped_assembly } */ /* { dg-require-effective-target untyped_assembly } */
/* { dg-require-effective-target indirect_calls } */
void void
foo (x, fn) foo (x, fn)
void (*fn) (); void (*fn) ();
......
// { dg-require-effective-target alloca } // { dg-require-effective-target alloca }
// { dg-require-effective-target indirect_calls }
/* PR c/77754 */ /* PR c/77754 */
int fn3(); int fn3();
......
// { dg-require-effective-target alloca } // { dg-require-effective-target alloca }
// { dg-require-effective-target indirect_calls }
/* PR c/77754 */ /* PR c/77754 */
int fn3(); int fn3();
......
// { dg-require-effective-target alloca } // { dg-require-effective-target alloca }
// { dg-require-effective-target indirect_calls }
/* PR c/77754 */ /* PR c/77754 */
int fn3(); int fn3();
......
/* PR middle-end/89663 */ /* PR middle-end/89663 */
/* { dg-require-effective-target indirect_calls } */
int irint (double); int irint (double);
long lrint (double); long lrint (double);
......
/* { dg-require-effective-target indirect_calls } */
typedef struct JSObject JSObject; typedef struct JSObject JSObject;
typedef struct JSObjectMap *(*JSNewObjectMapOp) (JSObject *obj); typedef struct JSObjectMap *(*JSNewObjectMapOp) (JSObject *obj);
typedef JSObject *(*JSGetMethodOp) (JSObject *obj); typedef JSObject *(*JSGetMethodOp) (JSObject *obj);
......
/* { dg-require-effective-target indirect_calls } */
/* { dg-require-effective-target untyped_assembly } */ /* { dg-require-effective-target untyped_assembly } */
/* { dg-require-stack-check "" } */ /* { dg-require-stack-check "" } */
/* { dg-additional-options "-fstack-check" } */ /* { dg-additional-options "-fstack-check" } */
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
with zero or excessive size trigger either -Walloc-zero or with zero or excessive size trigger either -Walloc-zero or
-Walloc-size-larger-than warnings. -Walloc-size-larger-than warnings.
{ dg-do compile } { dg-do compile }
{ dg-require-effective-target indirect_calls }
{ dg-options "-O2 -Wall -Walloc-zero -ftrack-macro-expansion=0" } */ { dg-options "-O2 -Wall -Walloc-zero -ftrack-macro-expansion=0" } */
#define ATTR(...) __attribute__ ((__VA_ARGS__)) #define ATTR(...) __attribute__ ((__VA_ARGS__))
......
...@@ -9502,3 +9502,11 @@ proc check_effective_target_mfentry { } { ...@@ -9502,3 +9502,11 @@ proc check_effective_target_mfentry { } {
void foo (void) { } void foo (void) { }
} "-mfentry"] } "-mfentry"]
} }
# Return 1 if this target supports indirect calls
proc check_effective_target_indirect_calls { } {
if { [istarget bpf-*-*] } {
return 0
}
return 1
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment