[PATCH] Add option to force indirect calls for x86

Rainer Orth ro@CeBiTec.Uni-Bielefeld.DE
Fri Nov 10 14:40:00 GMT 2017


Hi Andi,

> This patch adds a -mforce-indirect-call option to force all calls
> or tail calls on x86_64 between functions to indirect. This is similar to the
> large code model, but doesn't affect jumps inside functions, so has much
> less run time overhead.
>
> This is useful with Intel Processor Trace (PT). PT has precise timing
> for indirect calls/jumps, but not for direct ones. So if we can force
> them to indirect it allows to time every function relatively accurately
> (minus the overhead of the indirect branch)
>
> Without this short functions often don't see a timing update and cannot
> be measured.
[...]
> gcc/testsuite/:
> 2017-11-08  Andi Kleen  <ak@linux.intel.com>
>
> 	* gcc.target/i386/force-indirect-call-1.c: New test.
> 	* gcc.target/i386/force-indirect-call-2.c: New test.
> 	* gcc.target/i386/force-indirect-call-3.c: New test.

two of those new tests FAIL for 32-bit x86 (seen on both
i386-pc-solaris2.11 and x86_64-pc-linux-gnu):

+FAIL: gcc.target/i386/force-indirect-call-2.c scan-assembler-times call[ \\\\t]
+\\\\*% 2 (found 3 times)
+FAIL: gcc.target/i386/force-indirect-call-2.c scan-assembler-times jmp[ \\\\t]+
\\\\*% 1 (found 0 times)

Also, the test uses -fPIC, thus requires target fpic.

+FAIL: gcc.target/i386/force-indirect-call-3.c (test for excess errors)

cc1: error: code model 'medium' not supported in the 32 bit mode

+UNRESOLVED: gcc.target/i386/force-indirect-call-3.c scan-assembler-times call[ 
\\\\t]+\\\\*% 2
+UNRESOLVED: gcc.target/i386/force-indirect-call-3.c scan-assembler-times jmp[ \
\\\t]+\\\\*% 1

Please fix.

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University



More information about the Gcc-patches mailing list