[llvm] 45af0aa - [llvm-exegesis] Create a proper LLVM IR Function for MachineFunctions

Arthur Eubanks via llvm-commits llvm-commits at lists.llvm.org
Mon May 15 16:56:45 PDT 2023


Author: Arthur Eubanks
Date: 2023-05-15T16:51:15-07:00
New Revision: 45af0aa1fdf8bfc0ba54046430d48a3b7c02ca2b

URL: https://github.com/llvm/llvm-project/commit/45af0aa1fdf8bfc0ba54046430d48a3b7c02ca2b
DIFF: https://github.com/llvm/llvm-project/commit/45af0aa1fdf8bfc0ba54046430d48a3b7c02ca2b.diff

LOG: [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

Added: 
    

Modified: 
    llvm/tools/llvm-exegesis/lib/Assembler.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/tools/llvm-exegesis/lib/Assembler.cpp b/llvm/tools/llvm-exegesis/lib/Assembler.cpp
index 1888585e2f0ac..07465c71afc70 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);
 }
 


        


More information about the llvm-commits mailing list