Fix use of llvm::Module::getOrInsertFunction after the upstream opaque pointer type changes.

PiperOrigin-RevId: 232002583
This commit is contained in:
River Riddle 2019-02-01 11:04:48 -08:00 committed by jpienaar
parent 0353ef99eb
commit c46b0feadb
2 changed files with 9 additions and 7 deletions

View File

@ -216,8 +216,9 @@ void packFunctionArguments(llvm::Module *module) {
builder.getVoidTy(), builder.getInt8PtrTy()->getPointerTo(),
/*isVarArg=*/false);
auto newName = makePackedFunctionName(func.getName());
llvm::Constant *funcCst = module->getOrInsertFunction(newName, newType);
llvm::Function *interfaceFunc = llvm::cast<llvm::Function>(funcCst);
auto funcCst = module->getOrInsertFunction(newName, newType);
llvm::Function *interfaceFunc =
llvm::cast<llvm::Function>(funcCst.getCallee());
interfaceFunctions.insert(interfaceFunc);
// Extract the arguments from the type-erased argument list and cast them to

View File

@ -149,9 +149,9 @@ private:
llvm::IntegerType *indexType;
/// Allocation function : (index) -> i8*, declaration only.
llvm::Constant *allocFunc;
llvm::FunctionCallee allocFunc;
/// Deallocation function : (i8*) -> void, declaration only.
llvm::Constant *freeFunc;
llvm::FunctionCallee freeFunc;
};
llvm::IntegerType *ModuleLowerer::convertIndexType(IndexType type) {
@ -872,10 +872,11 @@ bool ModuleLowerer::convertFunctions(const Module &mlirModule,
// call graph with cycles.
for (const Function &function : mlirModule) {
const Function *functionPtr = &function;
llvm::Constant *llvmFuncCst = llvmModule.getOrInsertFunction(
llvm::FunctionCallee llvmFuncCst = llvmModule.getOrInsertFunction(
function.getName(), convertFunctionType(function.getType()));
assert(isa<llvm::Function>(llvmFuncCst));
functionMapping[functionPtr] = cast<llvm::Function>(llvmFuncCst);
assert(isa<llvm::Function>(llvmFuncCst.getCallee()));
functionMapping[functionPtr] =
cast<llvm::Function>(llvmFuncCst.getCallee());
}
// Convert functions.