From 13680223b9d80bb01e17372f0907cf215e424cce Mon Sep 17 00:00:00 2001 From: James Y Knight Date: Fri, 1 Feb 2019 02:28:03 +0000 Subject: [opaque pointer types] Add a FunctionCallee wrapper type, and use it. Recommit r352791 after tweaking DerivedTypes.h slightly, so that gcc doesn't choke on it, hopefully. Original Message: The FunctionCallee type is effectively a {FunctionType*,Value*} pair, and is a useful convenience to enable code to continue passing the result of getOrInsertFunction() through to EmitCall, even once pointer types lose their pointee-type. Then: - update the CallInst/InvokeInst instruction creation functions to take a Callee, - modify getOrInsertFunction to return FunctionCallee, and - update all callers appropriately. One area of particular note is the change to the sanitizer code. Previously, they had been casting the result of `getOrInsertFunction` to a `Function*` via `checkSanitizerInterfaceFunction`, and storing that. That would report an error if someone had already inserted a function declaraction with a mismatching signature. However, in general, LLVM allows for such mismatches, as `getOrInsertFunction` will automatically insert a bitcast if needed. As part of this cleanup, cause the sanitizer code to do the same. (It will call its functions using the expected signature, however they may have been declared.) Finally, in a small number of locations, callers of `getOrInsertFunction` actually were expecting/requiring that a brand new function was being created. In such cases, I've switched them to Function::Create instead. Differential Revision: https://reviews.llvm.org/D57315 llvm-svn: 352827 --- llvm/examples/ParallelJIT/ParallelJIT.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'llvm/examples/ParallelJIT/ParallelJIT.cpp') diff --git a/llvm/examples/ParallelJIT/ParallelJIT.cpp b/llvm/examples/ParallelJIT/ParallelJIT.cpp index 8485848e0a7..b5815dd2f78 100644 --- a/llvm/examples/ParallelJIT/ParallelJIT.cpp +++ b/llvm/examples/ParallelJIT/ParallelJIT.cpp @@ -49,11 +49,10 @@ using namespace llvm; static Function* createAdd1(Module *M) { // Create the add1 function entry and insert this entry into module M. The // function will have a return type of "int" and take an argument of "int". - // The '0' terminates the list of argument types. Function *Add1F = - cast(M->getOrInsertFunction("add1", - Type::getInt32Ty(M->getContext()), - Type::getInt32Ty(M->getContext()))); + Function::Create(FunctionType::get(Type::getInt32Ty(Context), + {Type::getInt32Ty(Context)}, false), + Function::ExternalLinkage, "add1", M); // Add a basic block to the function. As before, it automatically inserts // because of the last argument. @@ -80,10 +79,10 @@ static Function* createAdd1(Module *M) { static Function *CreateFibFunction(Module *M) { // Create the fib function and insert it into module M. This function is said // to return an int and take an int parameter. - Function *FibF = - cast(M->getOrInsertFunction("fib", - Type::getInt32Ty(M->getContext()), - Type::getInt32Ty(M->getContext()))); + FunctionType *FibFTy = FunctionType::get(Type::getInt32Ty(Context), + {Type::getInt32Ty(Context)}, false); + Function *FibF = + Function::Create(FibFTy, Function::ExternalLinkage, "fib", M); // Add a basic block to the function. BasicBlock *BB = BasicBlock::Create(M->getContext(), "EntryBlock", FibF); -- cgit v1.2.3