diff options
author | Paschalis Mpeis <paschalis.mpeis@arm.com> | 2024-06-11 19:21:11 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-11 19:21:11 +0100 |
commit | a13bc9714a6bfb766693aa7900217f6f9be6f25d (patch) | |
tree | c133af9d37929f6dfe933ba3c82d0d366a69258c /bolt/test | |
parent | ca6386073308d3c41647d8fc3e2cf72a77d46c76 (diff) | |
download | llvm-a13bc9714a6bfb766693aa7900217f6f9be6f25d.zip llvm-a13bc9714a6bfb766693aa7900217f6f9be6f25d.tar.gz llvm-a13bc9714a6bfb766693aa7900217f6f9be6f25d.tar.bz2 |
[BOLT][AArch64] Implement PLTCall optimization (#93584)
`convertCallToIndirectCall` applies the PLTCall optimization and returns
an (updated if needed) iterator to the converted call instruction. Since
AArch64 requires to inject additional instructions to implement this
pass, the relevant BasicBlock and an iterator was passed to the
`convertCallToIndirectCall`.
`NumCallsOptimized` is updated only on successful application of the
pass.
Tests:
- Inputs/plt-tailcall.c: an example of a tail call optimized PLT call.
- AArch64/plt-call.test: it is the actual A64 test, that runs the
PLTCall optimization on the above input file and verifies the
application of the pass to the calls: 'printf' and 'puts'.
Diffstat (limited to 'bolt/test')
-rw-r--r-- | bolt/test/AArch64/plt-call.test | 15 | ||||
-rw-r--r-- | bolt/test/Inputs/plt-tailcall.c | 8 | ||||
-rw-r--r-- | bolt/test/X86/plt-call.test | 11 |
3 files changed, 34 insertions, 0 deletions
diff --git a/bolt/test/AArch64/plt-call.test b/bolt/test/AArch64/plt-call.test new file mode 100644 index 0000000..da307d4 --- /dev/null +++ b/bolt/test/AArch64/plt-call.test @@ -0,0 +1,15 @@ +// Verify that PLTCall optimization works. + +RUN: %clang %cflags %p/../Inputs/plt-tailcall.c \ +RUN: -o %t -Wl,-q +RUN: llvm-bolt %t -o %t.bolt --plt=all --print-plt --print-only=foo | FileCheck %s + +// Call to printf +CHECK: adrp x16, printf@GOT +CHECK: ldr x17, [x16, :lo12:printf@GOT] +CHECK: blr x17 # PLTCall: 1 + +// Call to puts, that was tail-call optimized +CHECK: adrp x16, puts@GOT +CHECK: ldr x17, [x16, :lo12:puts@GOT] +CHECK: br x17 # TAILCALL # PLTCall: 1 diff --git a/bolt/test/Inputs/plt-tailcall.c b/bolt/test/Inputs/plt-tailcall.c new file mode 100644 index 0000000..13f6e29 --- /dev/null +++ b/bolt/test/Inputs/plt-tailcall.c @@ -0,0 +1,8 @@ +#include "stub.h" + +int foo(char *c) { + printf(""); + __attribute__((musttail)) return puts(c); +} + +int main() { return foo("a"); } diff --git a/bolt/test/X86/plt-call.test b/bolt/test/X86/plt-call.test new file mode 100644 index 0000000..e6ae86c --- /dev/null +++ b/bolt/test/X86/plt-call.test @@ -0,0 +1,11 @@ +// Verify that PLTCall optimization works. + +RUN: %clang %cflags %p/../Inputs/plt-tailcall.c \ +RUN: -o %t -Wl,-q +RUN: llvm-bolt %t -o %t.bolt --plt=all --print-plt --print-only=foo | FileCheck %s + +// Call to printf +CHECK: callq *printf@GOT(%rip) # PLTCall: 1 + +// Call to puts, that was tail-call optimized +CHECK: jmpl *puts@GOT(%rip) # TAILCALL # PLTCall: 1 |