[pkg-d-commits] [ldc] 37/211: Decorate thunk target calls as tail-calls (=> jumps)
Matthias Klumpp
mak at moszumanska.debian.org
Sun Apr 23 22:36:07 UTC 2017
This is an automated email from the git hooks/post-receive script.
mak pushed a commit to annotated tag v1.1.0
in repository ldc.
commit 642d755e998db4e556f65332233a5618b105acee
Author: Martin <noone at nowhere.com>
Date: Wed Sep 21 19:44:15 2016 +0200
Decorate thunk target calls as tail-calls (=> jumps)
I noticed that the C++ thunks would adjust the `this` pointer and then
jump directly to the actual target function.
The D thunks (on Linux, verified by disassembling) on the other hand
performed a regular call + return. Requesting tail-calls here leads to
direct jumps for D thunks as well, improving performance when calling
virtual functions via interfaces.
---
ir/irclass.cpp | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/ir/irclass.cpp b/ir/irclass.cpp
index 6b4e9fa..44965f8 100644
--- a/ir/irclass.cpp
+++ b/ir/irclass.cpp
@@ -419,15 +419,15 @@ llvm::GlobalVariable *IrAggr::getInterfaceVtbl(BaseClass *b, bool new_instance,
gIR->DBuilder.EmitStopPoint(fd->loc);
// call the real vtbl function.
- llvm::CallSite call = gIR->ir->CreateCall(irFunc->func, args);
- call.setCallingConv(irFunc->func->getCallingConv());
+ llvm::CallInst *call = gIR->ir->CreateCall(irFunc->func, args);
+ call->setCallingConv(irFunc->func->getCallingConv());
+ call->setTailCallKind(llvm::CallInst::TCK_Tail);
// return from the thunk
if (thunk->getReturnType() == LLType::getVoidTy(gIR->context())) {
llvm::ReturnInst::Create(gIR->context(), beginbb);
} else {
- llvm::ReturnInst::Create(gIR->context(), call.getInstruction(),
- beginbb);
+ llvm::ReturnInst::Create(gIR->context(), call, beginbb);
}
gIR->DBuilder.EmitFuncEnd(thunkFd);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-d/ldc.git
More information about the pkg-d-commits
mailing list