aboutsummaryrefslogtreecommitdiff
path: root/lib/Target/CppBackend
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-12-25 15:09:49 -0800
committerAlon Zakai <alonzakai@gmail.com>2013-12-25 15:09:49 -0800
commit3f5b2cb9b31b217126a3da36d3e87a55b5e5d692 (patch)
treec07a309ba2de6a22afa0374794c95ed826983374 /lib/Target/CppBackend
parent3750b7d55dc655b4be9b34e210e76a5ac38d6686 (diff)
do not emit unnecessary casts on internal function calls
Diffstat (limited to 'lib/Target/CppBackend')
-rw-r--r--lib/Target/CppBackend/CallHandlers.h12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/Target/CppBackend/CallHandlers.h b/lib/Target/CppBackend/CallHandlers.h
index 872b961da4..d23fa7e9b9 100644
--- a/lib/Target/CppBackend/CallHandlers.h
+++ b/lib/Target/CppBackend/CallHandlers.h
@@ -13,17 +13,25 @@ CallHandlerMap *CallHandlers;
DEF_CALL_HANDLER(__default__, {
const Value *CV = CI->getCalledValue();
- if (!isa<Function>(CV)) {
+ bool NeedCasts;
+ if (const Function *F = dyn_cast<const Function>(CV)) {
+ NeedCasts = F->isDeclaration(); // if ffi call, need casts
+ } else {
// function pointer call
FunctionType *FT = dyn_cast<FunctionType>(dyn_cast<PointerType>(CV->getType())->getElementType());
std::string Sig = getFunctionSignature(FT);
Name = std::string("FUNCTION_TABLE_") + Sig + "[" + Name + " & #FM_" + Sig + "#]";
ensureFunctionTable(FT);
+ NeedCasts = false; // function table call, so stays in asm module
}
std::string text = Name + "(";
if (NumArgs == -1) NumArgs = CI->getNumOperands()-1; // last operand is the function itself
for (int i = 0; i < NumArgs; i++) {
- text += getValueAsCastStr(CI->getArgOperand(i), ASM_NONSPECIFIC); // FIXME: differentiate ffi calls
+ if (!NeedCasts) {
+ text += getValueAsStr(CI->getArgOperand(i));
+ } else {
+ text += getValueAsCastStr(CI->getArgOperand(i), ASM_NONSPECIFIC);
+ }
if (i < NumArgs - 1) text += ", ";
}
text += ")";