x86: Define __rdtsc and __rdtscp as macros
Define __rdtsc and __rdtscp as macros for callers with general-regs-only target attribute to avoid inline failure with always_inline attribute. gcc/ PR target/99744 * config/i386/ia32intrin.h (__rdtsc): Defined as macro. (__rdtscp): Likewise. gcc/testsuite/ PR target/99744 * gcc.target/i386/pr99744-1.c: New test.
This commit is contained in:
parent
9c68e2abe2
commit
5463cee277
@ -107,22 +107,12 @@ __rdpmc (int __S)
|
||||
#endif /* __iamcu__ */
|
||||
|
||||
/* rdtsc */
|
||||
extern __inline unsigned long long
|
||||
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
|
||||
__rdtsc (void)
|
||||
{
|
||||
return __builtin_ia32_rdtsc ();
|
||||
}
|
||||
#define __rdtsc() __builtin_ia32_rdtsc ()
|
||||
|
||||
#ifndef __iamcu__
|
||||
|
||||
/* rdtscp */
|
||||
extern __inline unsigned long long
|
||||
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
|
||||
__rdtscp (unsigned int *__A)
|
||||
{
|
||||
return __builtin_ia32_rdtscp (__A);
|
||||
}
|
||||
#define __rdtscp(a) __builtin_ia32_rdtscp (a)
|
||||
|
||||
#endif /* __iamcu__ */
|
||||
|
||||
|
25
gcc/testsuite/gcc.target/i386/pr99744-1.c
Normal file
25
gcc/testsuite/gcc.target/i386/pr99744-1.c
Normal file
@ -0,0 +1,25 @@
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-O0" } */
|
||||
|
||||
#include <x86intrin.h>
|
||||
|
||||
extern unsigned long long int curr_deadline;
|
||||
extern void bar (void);
|
||||
|
||||
__attribute__ ((target("general-regs-only")))
|
||||
void
|
||||
foo1 (void)
|
||||
{
|
||||
if (__rdtsc () < curr_deadline)
|
||||
return;
|
||||
bar ();
|
||||
}
|
||||
|
||||
__attribute__ ((target("general-regs-only")))
|
||||
void
|
||||
foo2 (unsigned int *p)
|
||||
{
|
||||
if (__rdtscp (p) < curr_deadline)
|
||||
return;
|
||||
bar ();
|
||||
}
|
Loading…
Reference in New Issue
Block a user