mirror of
https://github.com/mirror/tinycc.git
synced 2026-09-03 12:12:46 +08:00
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user