Implement function alignment via attributes

which requires being able to emit an arbitrary number of NOP
instructions, which is also implemented here.  For x86 we
could emit other sequences but these are the easiest.
This commit is contained in:
Michael Matz
2018-04-06 23:01:45 +02:00
parent ef668aae1e
commit 671dcace82
8 changed files with 56 additions and 0 deletions

View File

@@ -2270,6 +2270,8 @@ int fib(int n)
return fib(n-1) + fib(n-2);
}
void __attribute__((aligned(16))) aligned_function(int i) {}
void funcptr_test()
{
void (*func)(int);
@@ -2300,6 +2302,10 @@ void funcptr_test()
func(42);
(func + diff)(42);
(num + a)(43);
/* Check that we can align functions */
func = aligned_function;
printf("aligned_function (should be zero): %d\n", ((int)func) & 15);
}
void lloptest(long long a, long long b)