Skip to content

Commit 753d99a

Browse files
committed
Fixed compilation issue.
1 parent 0a6575c commit 753d99a

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

llvm/examples/Kaleidoscope/Chapter8/toy.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "llvm/ADT/APFloat.h"
22
#include "llvm/ADT/STLExtras.h"
3+
#include "llvm/CodeGen/MachineModuleInfo.h"
34
#include "llvm/IR/BasicBlock.h"
45
#include "llvm/IR/Constants.h"
56
#include "llvm/IR/DerivedTypes.h"
@@ -1257,9 +1258,12 @@ int main() {
12571258
}
12581259

12591260
legacy::PassManager pass;
1261+
llvm::MachineModuleInfo MMI(
1262+
static_cast<LLVMTargetMachine *>(TheTargetMachine));
12601263
auto FileType = CodeGenFileType::ObjectFile;
12611264

1262-
if (TheTargetMachine->addPassesToEmitFile(pass, dest, nullptr, FileType)) {
1265+
if (TheTargetMachine->addPassesToEmitFile(pass, MMI, dest, nullptr,
1266+
FileType)) {
12631267
errs() << "TheTargetMachine can't emit a file of this type";
12641268
return 1;
12651269
}

llvm/include/llvm/Target/TargetMachine.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ using ModulePassManager = PassManager<Module>;
3434

3535
class Function;
3636
class GlobalValue;
37-
class MachineModuleInfoWrapperPass;
37+
class MachineModuleInfo;
3838
class Mangler;
3939
class MCAsmInfo;
4040
class MCContext;

llvm/unittests/MI/LiveIntervalTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ static void doTest(StringRef MIRFunc,
209209
return;
210210

211211
legacy::PassManager PM;
212-
MachineModuleInfo MMI(TM->get());
212+
MachineModuleInfo MMI(TM.get());
213213
std::unique_ptr<MIRParser> MIR;
214214
std::unique_ptr<Module> M = parseMIR(Context, MMI, MIR, *TM, MIRFunc);
215215
ASSERT_TRUE(M);

mlir/lib/Target/LLVM/ModuleToObject.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "mlir/Target/LLVMIR/ModuleTranslation.h"
2121

2222
#include "llvm/Bitcode/BitcodeWriter.h"
23+
#include "llvm/CodeGen/MachineModuleInfo.h"
2324
#include "llvm/IR/LegacyPassManager.h"
2425
#include "llvm/IRReader/IRReader.h"
2526
#include "llvm/Linker/Linker.h"
@@ -175,8 +176,11 @@ ModuleToObject::translateToISA(llvm::Module &llvmModule,
175176
{ // Drop pstream after this to prevent the ISA from being stuck buffering
176177
llvm::buffer_ostream pstream(stream);
177178
llvm::legacy::PassManager codegenPasses;
179+
llvm::MachineModuleInfo machineModuleInfo(
180+
static_cast<llvm::LLVMTargetMachine *>(&targetMachine));
178181

179-
if (targetMachine.addPassesToEmitFile(codegenPasses, pstream, nullptr,
182+
if (targetMachine.addPassesToEmitFile(codegenPasses, machineModuleInfo,
183+
pstream, nullptr,
180184
llvm::CodeGenFileType::AssemblyFile))
181185
return std::nullopt;
182186

0 commit comments

Comments
 (0)