diff options
author | Håvard Pettersen <havardpe@oath.com> | 2018-08-08 10:15:56 +0000 |
---|---|---|
committer | Håvard Pettersen <havardpe@oath.com> | 2018-08-08 10:15:56 +0000 |
commit | 862bbc7ef8c4bc669fb1cd2c438db1fbe6e7595c (patch) | |
tree | 2685126b6562422879a2150c1e920a82cebc7ceb | |
parent | ad4e3a8ca7dd8d6a90555de93c37b04107f10df0 (diff) |
Avoid using the 'convenient' way to specify parameter types when
resolving application functions we want to call from an llvm-compiled
function. LLVM 3.9 uses varargs with a nullptr sentinel at the end
while newer versions of LLVM (5/6) uses variadic templates. This leads
to 'inconvenience' when upgrading where the code still compiles, but
the no longer needed/wanted nullptr sentinel triggers a signature
mismatch leading to not being able to call functions like 'sin'/'cos'
etc.
-rw-r--r-- | eval/src/vespa/eval/eval/llvm/llvm_wrapper.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/eval/src/vespa/eval/eval/llvm/llvm_wrapper.cpp b/eval/src/vespa/eval/eval/llvm/llvm_wrapper.cpp index 7a1211752f4..08330dc1ed4 100644 --- a/eval/src/vespa/eval/eval/llvm/llvm_wrapper.cpp +++ b/eval/src/vespa/eval/eval/llvm/llvm_wrapper.cpp @@ -84,6 +84,19 @@ struct FunctionBuilder : public NodeVisitor, public NodeTraverser { std::vector<gbdt::Forest::UP> &forests; std::vector<PluginState::UP> &plugin_state; + llvm::FunctionType *make_call_1_fun_t() { + std::vector<llvm::Type*> param_types; + param_types.push_back(builder.getDoubleTy()); + return llvm::FunctionType::get(builder.getDoubleTy(), param_types, false); + } + + llvm::FunctionType *make_call_2_fun_t() { + std::vector<llvm::Type*> param_types; + param_types.push_back(builder.getDoubleTy()); + param_types.push_back(builder.getDoubleTy()); + return llvm::FunctionType::get(builder.getDoubleTy(), param_types, false); + } + llvm::PointerType *make_eval_forest_funptr_t() { std::vector<llvm::Type*> param_types; param_types.push_back(builder.getVoidTy()->getPointerTo()); @@ -320,8 +333,7 @@ struct FunctionBuilder : public NodeVisitor, public NodeTraverser { make_call_1(llvm::Intrinsic::getDeclaration(&module, id, builder.getDoubleTy())); } void make_call_1(const char *name) { - make_call_1(llvm::dyn_cast<llvm::Function>( - module.getOrInsertFunction(name, builder.getDoubleTy(), builder.getDoubleTy(), nullptr))); + make_call_1(llvm::dyn_cast<llvm::Function>(module.getOrInsertFunction(name, make_call_1_fun_t()))); } void make_call_2(llvm::Function *fun) { @@ -336,8 +348,7 @@ struct FunctionBuilder : public NodeVisitor, public NodeTraverser { make_call_2(llvm::Intrinsic::getDeclaration(&module, id, builder.getDoubleTy())); } void make_call_2(const char *name) { - make_call_2(llvm::dyn_cast<llvm::Function>( - module.getOrInsertFunction(name, builder.getDoubleTy(), builder.getDoubleTy(), builder.getDoubleTy(), nullptr))); + make_call_2(llvm::dyn_cast<llvm::Function>(module.getOrInsertFunction(name, make_call_2_fun_t()))); } //------------------------------------------------------------------------- |