From 45af0aa1fdf8bfc0ba54046430d48a3b7c02ca2b Mon Sep 17 00:00:00 2001 From: Arthur Eubanks Date: Mon, 15 May 2023 16:50:56 -0700 Subject: [PATCH] [llvm-exegesis] Create a proper LLVM IR Function for MachineFunctions I have upcoming changes break with invalid Function definitions. Reviewed By: aidengrossman, courbet Differential Revision: https://reviews.llvm.org/D149207 --- llvm/tools/llvm-exegesis/lib/Assembler.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/llvm/tools/llvm-exegesis/lib/Assembler.cpp b/llvm/tools/llvm-exegesis/lib/Assembler.cpp index 1888585..07465c7 100644 --- a/llvm/tools/llvm-exegesis/lib/Assembler.cpp +++ b/llvm/tools/llvm-exegesis/lib/Assembler.cpp @@ -21,6 +21,8 @@ #include "llvm/CodeGen/TargetPassConfig.h" #include "llvm/CodeGen/TargetSubtargetInfo.h" #include "llvm/ExecutionEngine/SectionMemoryManager.h" +#include "llvm/IR/BasicBlock.h" +#include "llvm/IR/Instructions.h" #include "llvm/IR/LegacyPassManager.h" #include "llvm/MC/MCInstrInfo.h" #include "llvm/Support/Alignment.h" @@ -81,9 +83,8 @@ MachineFunction &createVoidVoidPtrMachineFunction(StringRef FunctionName, FunctionType::get(ReturnType, {MemParamType}, false); Function *const F = Function::Create( FunctionType, GlobalValue::InternalLinkage, FunctionName, Module); - // Making sure we can create a MachineFunction out of this Function even if it - // contains no IR. - F->setIsMaterializable(true); + BasicBlock *BB = BasicBlock::Create(Module->getContext(), "", F); + new UnreachableInst(Module->getContext(), BB); return MMI->getOrCreateMachineFunction(*F); } -- 2.7.4