llvm.org GIT mirror llvm / 2144c52
CodeGen: Refactor MIR parsing When parsing .mir files immediately construct the MachineFunctions and put them into MachineModuleInfo. This allows us to get rid of the delayed construction (and delayed error reporting) through the MachineFunctionInitialzier interface. Differential Revision: https://reviews.llvm.org/D33809 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@304758 91177308-0d34-0410-b5e6-96231b3b80d8 Matthias Braun 3 years ago
19 changed file(s) with 151 addition(s) and 171 deletion(s). Raw diff Collapse all Expand all
1717 #ifndef LLVM_CODEGEN_MIRPARSER_MIRPARSER_H
1818 #define LLVM_CODEGEN_MIRPARSER_MIRPARSER_H
1919
20 #include "llvm/CodeGen/MachineFunctionInitializer.h"
2120 #include "llvm/IR/Module.h"
2221 #include "llvm/Support/MemoryBuffer.h"
2322 #include
2625
2726 class StringRef;
2827 class MIRParserImpl;
28 class MachineModuleInfo;
2929 class SMDiagnostic;
3030
3131 /// This class initializes machine functions by applying the state loaded from
3232 /// a MIR file.
33 class MIRParser : public MachineFunctionInitializer {
33 class MIRParser {
3434 std::unique_ptr Impl;
3535
3636 public:
3737 MIRParser(std::unique_ptr Impl);
3838 MIRParser(const MIRParser &) = delete;
39 ~MIRParser() override;
39 ~MIRParser();
4040
41 /// Parse the optional LLVM IR module that's embedded in the MIR file.
41 /// Parses the optional LLVM IR module in the MIR file.
4242 ///
4343 /// A new, empty module is created if the LLVM IR isn't present.
44 /// Returns null if a parsing error occurred.
45 std::unique_ptr parseLLVMModule();
44 /// \returns nullptr if a parsing error occurred.
45 std::unique_ptr parseIRModule();
4646
47 /// Initialize the machine function to the state that's described in the MIR
48 /// file.
47 /// \brief Parses MachineFunctions in the MIR file and add them to the given
48 /// MachineModuleInfo \p MMI.
4949 ///
50 /// Return true if error occurred.
51 bool initializeMachineFunction(MachineFunction &MF) override;
50 /// \returns true if an error occurred.
51 bool parseMachineFunctions(Module &M, MachineModuleInfo &MMI);
5252 };
5353
5454 /// This function is the main interface to the MIR serialization format parser.
+0
-38
include/llvm/CodeGen/MachineFunctionInitializer.h less more
None //=- MachineFunctionInitializer.h - machine function initializer --*- C++ -*-=//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file declares an interface that allows custom machine function
10 // initialization.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_CODEGEN_MACHINEFUNCTIONINITIALIZER_H
15 #define LLVM_CODEGEN_MACHINEFUNCTIONINITIALIZER_H
16
17 namespace llvm {
18
19 class MachineFunction;
20
21 /// This interface provides a way to initialize machine functions after they are
22 /// created by the machine function analysis pass.
23 class MachineFunctionInitializer {
24 virtual void anchor();
25
26 public:
27 virtual ~MachineFunctionInitializer() = default;
28
29 /// Initialize the machine function.
30 ///
31 /// Return true if error occurred.
32 virtual bool initializeMachineFunction(MachineFunction &MF) = 0;
33 };
34
35 } // end namespace llvm
36
37 #endif // LLVM_CODEGEN_MACHINEFUNCTIONINITIALIZER_H
4646 class CallInst;
4747 class Function;
4848 class MachineFunction;
49 class MachineFunctionInitializer;
5049 class MMIAddrLabelMap;
5150 class Module;
5251 class TargetMachine;
125124 /// comments in lib/Target/X86/X86FrameLowering.cpp for more details.
126125 bool UsesMorestackAddr;
127126
128 MachineFunctionInitializer *MFInitializer;
129127 /// Maps IR Functions to their corresponding MachineFunctions.
130128 DenseMap> MachineFunctions;
131129 /// Next unique number available for a MachineFunction.
149147 void setModule(const Module *M) { TheModule = M; }
150148 const Module *getModule() const { return TheModule; }
151149
152 void setMachineFunctionInitializer(MachineFunctionInitializer *MFInit) {
153 MFInitializer = MFInit;
154 }
155
156150 /// Returns the MachineFunction constructed for the IR function \p F.
157 /// Creates a new MachineFunction and runs the MachineFunctionInitializer
158 /// if none exists yet.
159 MachineFunction &getMachineFunction(const Function &F);
151 /// Creates a new MachineFunction if none exists yet.
152 MachineFunction &getOrCreateMachineFunction(const Function &F);
153
154 /// \bried Returns the MachineFunction associated to IR function \p F if there
155 /// is one, otherwise nullptr.
156 MachineFunction *getMachineFunction(const Function &F) const;
160157
161158 /// Delete the MachineFunction \p MF and reset the link in the IR Function to
162159 /// Machine Function map.
2424 namespace llvm {
2525
2626 class GlobalValue;
27 class MachineFunctionInitializer;
2827 class Mangler;
2928 class MCAsmInfo;
3029 class MCContext;
226225 PassManagerBase &, raw_pwrite_stream &, CodeGenFileType,
227226 bool /*DisableVerify*/ = true, AnalysisID /*StartBefore*/ = nullptr,
228227 AnalysisID /*StartAfter*/ = nullptr, AnalysisID /*StopBefore*/ = nullptr,
229 AnalysisID /*StopAfter*/ = nullptr,
230 MachineFunctionInitializer * /*MFInitializer*/ = nullptr) {
228 AnalysisID /*StopAfter*/ = nullptr) {
231229 return true;
232230 }
233231
288286 PassManagerBase &PM, raw_pwrite_stream &Out, CodeGenFileType FileType,
289287 bool DisableVerify = true, AnalysisID StartBefore = nullptr,
290288 AnalysisID StartAfter = nullptr, AnalysisID StopBefore = nullptr,
291 AnalysisID StopAfter = nullptr,
292 MachineFunctionInitializer *MFInitializer = nullptr) override;
289 AnalysisID StopAfter = nullptr) override;
293290
294291 /// Add passes to the specified pass manager to get machine code emitted with
295292 /// the MCJIT. This method returns true if machine code is not supported. It
9494 addPassesToGenerateCode(LLVMTargetMachine *TM, PassManagerBase &PM,
9595 bool DisableVerify, AnalysisID StartBefore,
9696 AnalysisID StartAfter, AnalysisID StopBefore,
97 AnalysisID StopAfter,
98 MachineFunctionInitializer *MFInitializer = nullptr) {
99
97 AnalysisID StopAfter) {
10098 // Targets may override createPassConfig to provide a target-specific
10199 // subclass.
102100 TargetPassConfig *PassConfig = TM->createPassConfig(PM);
106104 PassConfig->setDisableVerify(DisableVerify);
107105 PM.add(PassConfig);
108106 MachineModuleInfo *MMI = new MachineModuleInfo(TM);
109 MMI->setMachineFunctionInitializer(MFInitializer);
110107 PM.add(MMI);
111108
112109 if (PassConfig->addISelPasses())
191188 bool LLVMTargetMachine::addPassesToEmitFile(
192189 PassManagerBase &PM, raw_pwrite_stream &Out, CodeGenFileType FileType,
193190 bool DisableVerify, AnalysisID StartBefore, AnalysisID StartAfter,
194 AnalysisID StopBefore, AnalysisID StopAfter,
195 MachineFunctionInitializer *MFInitializer) {
191 AnalysisID StopBefore, AnalysisID StopAfter) {
196192 // Add common CodeGen passes.
197193 MCContext *Context =
198194 addPassesToGenerateCode(this, PM, DisableVerify, StartBefore, StartAfter,
199 StopBefore, StopAfter, MFInitializer);
195 StopBefore, StopAfter);
200196 if (!Context)
201197 return true;
202198
4949 /// file.
5050 class MIRParserImpl {
5151 SourceMgr SM;
52 yaml::Input In;
5253 StringRef Filename;
5354 LLVMContext &Context;
54 StringMap> Functions;
5555 SlotMapping IRSlots;
5656 /// Maps from register class names to register classes.
5757 Name2RegClassMap Names2RegClasses;
5858 /// Maps from register bank names to register banks.
5959 Name2RegBankMap Names2RegBanks;
60 /// True when the MIR file doesn't have LLVM IR. Dummy IR functions are
61 /// created and inserted into the given module when this is true.
62 bool NoLLVMIR = false;
63 /// True when a well formed MIR file does not contain any MIR/machine function
64 /// parts.
65 bool NoMIRDocuments = false;
6066
6167 public:
62 MIRParserImpl(std::unique_ptr Contents, StringRef Filename,
63 LLVMContext &Context);
68 MIRParserImpl(std::unique_ptr Contents,
69 StringRef Filename, LLVMContext &Context);
6470
6571 void reportDiagnostic(const SMDiagnostic &Diag);
6672
8490 /// file.
8591 ///
8692 /// Return null if an error occurred.
87 std::unique_ptr parse();
93 std::unique_ptr parseIRModule();
94
95 bool parseMachineFunctions(Module &M, MachineModuleInfo &MMI);
8896
8997 /// Parse the machine function in the current YAML document.
9098 ///
91 /// \param NoLLVMIR - set to true when the MIR file doesn't have LLVM IR.
92 /// A dummy IR function is created and inserted into the given module when
93 /// this parameter is true.
9499 ///
95100 /// Return true if an error occurred.
96 bool parseMachineFunction(yaml::Input &In, Module &M, bool NoLLVMIR);
101 bool parseMachineFunction(Module &M, MachineModuleInfo &MMI);
97102
98103 /// Initialize the machine function to the state that's described in the MIR
99104 /// file.
100105 ///
101106 /// Return true if error occurred.
102 bool initializeMachineFunction(MachineFunction &MF);
107 bool initializeMachineFunction(const yaml::MachineFunction &YamlMF,
108 MachineFunction &MF);
103109
104110 bool parseRegisterInfo(PerFunctionMIParsingState &PFS,
105111 const yaml::MachineFunction &YamlMF);
142148 /// block scalar string.
143149 SMDiagnostic diagFromBlockStringDiag(const SMDiagnostic &Error,
144150 SMRange SourceRange);
145
146 /// Create an empty function with the given name.
147 void createDummyFunction(StringRef Name, Module &M);
148151
149152 void initNames2RegClasses(const MachineFunction &MF);
150153 void initNames2RegBanks(const MachineFunction &MF);
165168
166169 } // end namespace llvm
167170
171 static void handleYAMLDiag(const SMDiagnostic &Diag, void *Context) {
172 reinterpret_cast(Context)->reportDiagnostic(Diag);
173 }
174
168175 MIRParserImpl::MIRParserImpl(std::unique_ptr Contents,
169176 StringRef Filename, LLVMContext &Context)
170 : SM(), Filename(Filename), Context(Context) {
171 SM.AddNewSourceBuffer(std::move(Contents), SMLoc());
177 : SM(),
178 In(SM.getMemoryBuffer(
179 SM.AddNewSourceBuffer(std::move(Contents), SMLoc()))->getBuffer(),
180 nullptr, handleYAMLDiag, this),
181 Filename(Filename),
182 Context(Context) {
183 In.setContext(&In);
172184 }
173185
174186 bool MIRParserImpl::error(const Twine &Message) {
205217 Context.diagnose(DiagnosticInfoMIRParser(Kind, Diag));
206218 }
207219
208 static void handleYAMLDiag(const SMDiagnostic &Diag, void *Context) {
209 reinterpret_cast(Context)->reportDiagnostic(Diag);
210 }
211
212 std::unique_ptr MIRParserImpl::parse() {
213 yaml::Input In(SM.getMemoryBuffer(SM.getMainFileID())->getBuffer(),
214 /*Ctxt=*/nullptr, handleYAMLDiag, this);
215 In.setContext(&In);
216
220 std::unique_ptr MIRParserImpl::parseIRModule() {
217221 if (!In.setCurrentDocument()) {
218222 if (In.error())
219223 return nullptr;
220224 // Create an empty module when the MIR file is empty.
225 NoMIRDocuments = true;
221226 return llvm::make_unique(Filename, Context);
222227 }
223228
224229 std::unique_ptr M;
225 bool NoLLVMIR = false;
226230 // Parse the block scalar manually so that we can return unique pointer
227231 // without having to go trough YAML traits.
228232 if (const auto *BSN =
236240 }
237241 In.nextDocument();
238242 if (!In.setCurrentDocument())
239 return M;
243 NoMIRDocuments = true;
240244 } else {
241245 // Create an new, empty module.
242246 M = llvm::make_unique(Filename, Context);
243247 NoLLVMIR = true;
244248 }
249 return M;
250 }
251
252 bool MIRParserImpl::parseMachineFunctions(Module &M, MachineModuleInfo &MMI) {
253 if (NoMIRDocuments)
254 return false;
245255
246256 // Parse the machine functions.
247257 do {
248 if (parseMachineFunction(In, *M, NoLLVMIR))
249 return nullptr;
258 if (parseMachineFunction(M, MMI))
259 return true;
250260 In.nextDocument();
251261 } while (In.setCurrentDocument());
252262
253 return M;
254 }
255
256 bool MIRParserImpl::parseMachineFunction(yaml::Input &In, Module &M,
257 bool NoLLVMIR) {
258 auto MF = llvm::make_unique();
259 yaml::EmptyContext Ctx;
260 yaml::yamlize(In, *MF, false, Ctx);
261 if (In.error())
262 return true;
263 auto FunctionName = MF->Name;
264 if (Functions.find(FunctionName) != Functions.end())
265 return error(Twine("redefinition of machine function '") + FunctionName +
266 "'");
267 Functions.insert(std::make_pair(FunctionName, std::move(MF)));
268 if (NoLLVMIR)
269 createDummyFunction(FunctionName, M);
270 else if (!M.getFunction(FunctionName))
271 return error(Twine("function '") + FunctionName +
272 "' isn't defined in the provided LLVM IR");
273 return false;
274 }
275
276 void MIRParserImpl::createDummyFunction(StringRef Name, Module &M) {
263 return false;
264 }
265
266 /// Create an empty function with the given name.
267 static Function *createDummyFunction(StringRef Name, Module &M) {
277268 auto &Context = M.getContext();
278269 Function *F = cast(M.getOrInsertFunction(
279270 Name, FunctionType::get(Type::getVoidTy(Context), false)));
280271 BasicBlock *BB = BasicBlock::Create(Context, "entry", F);
281272 new UnreachableInst(Context, BB);
273 return F;
274 }
275
276 bool MIRParserImpl::parseMachineFunction(Module &M, MachineModuleInfo &MMI) {
277 // Parse the yaml.
278 yaml::MachineFunction YamlMF;
279 yaml::EmptyContext Ctx;
280 yaml::yamlize(In, YamlMF, false, Ctx);
281 if (In.error())
282 return true;
283
284 // Search for the corresponding IR function.
285 StringRef FunctionName = YamlMF.Name;
286 Function *F = M.getFunction(FunctionName);
287 if (!F) {
288 if (NoLLVMIR) {
289 F = createDummyFunction(FunctionName, M);
290 } else {
291 return error(Twine("function '") + FunctionName +
292 "' isn't defined in the provided LLVM IR");
293 }
294 }
295 if (MMI.getMachineFunction(*F) != nullptr)
296 return error(Twine("redefinition of machine function '") + FunctionName +
297 "'");
298
299 // Create the MachineFunction.
300 MachineFunction &MF = MMI.getOrCreateMachineFunction(*F);
301 if (initializeMachineFunction(YamlMF, MF))
302 return true;
303
304 return false;
282305 }
283306
284307 static bool isSSA(const MachineFunction &MF) {
318341 Properties.set(MachineFunctionProperties::Property::NoVRegs);
319342 }
320343
321 bool MIRParserImpl::initializeMachineFunction(MachineFunction &MF) {
322 auto It = Functions.find(MF.getName());
323 if (It == Functions.end())
324 return error(Twine("no machine function information for function '") +
325 MF.getName() + "' in the MIR file");
344 bool
345 MIRParserImpl::initializeMachineFunction(const yaml::MachineFunction &YamlMF,
346 MachineFunction &MF) {
326347 // TODO: Recreate the machine function.
327348 initNames2RegClasses(MF);
328349 initNames2RegBanks(MF);
329 const yaml::MachineFunction &YamlMF = *It->getValue();
330350 if (YamlMF.Alignment)
331351 MF.setAlignment(YamlMF.Alignment);
332352 MF.setExposesReturnsTwice(YamlMF.ExposesReturnsTwice);
837857
838858 MIRParser::~MIRParser() {}
839859
840 std::unique_ptr MIRParser::parseLLVMModule() { return Impl->parse(); }
841
842 bool MIRParser::initializeMachineFunction(MachineFunction &MF) {
843 return Impl->initializeMachineFunction(MF);
860 std::unique_ptr MIRParser::parseIRModule() {
861 return Impl->parseIRModule();
862 }
863
864 bool MIRParser::parseMachineFunctions(Module &M, MachineModuleInfo &MMI) {
865 return Impl->parseMachineFunctions(M, MMI);
844866 }
845867
846868 std::unique_ptr llvm::createMIRParserFromFile(StringRef Filename,
1919 #include "llvm/Analysis/EHPersonalities.h"
2020 #include "llvm/CodeGen/MachineConstantPool.h"
2121 #include "llvm/CodeGen/MachineFrameInfo.h"
22 #include "llvm/CodeGen/MachineFunctionInitializer.h"
2322 #include "llvm/CodeGen/MachineFunctionPass.h"
2423 #include "llvm/CodeGen/MachineInstr.h"
2524 #include "llvm/CodeGen/MachineJumpTableInfo.h"
5150 cl::desc("Force the alignment of all functions."),
5251 cl::init(0), cl::Hidden);
5352
54 void MachineFunctionInitializer::anchor() {}
55
5653 static const char *getPropertyName(MachineFunctionProperties::Property Prop) {
5754 typedef MachineFunctionProperties::Property P;
5855 switch(Prop) {
4141 return false;
4242
4343 MachineModuleInfo &MMI = getAnalysis();
44 MachineFunction &MF = MMI.getMachineFunction(F);
44 MachineFunction &MF = MMI.getOrCreateMachineFunction(F);
4545
4646 MachineFunctionProperties &MFProps = MF.getProperties();
4747
1212 #include "llvm/ADT/StringRef.h"
1313 #include "llvm/ADT/TinyPtrVector.h"
1414 #include "llvm/CodeGen/MachineFunction.h"
15 #include "llvm/CodeGen/MachineFunctionInitializer.h"
1615 #include "llvm/CodeGen/MachineModuleInfo.h"
1716 #include "llvm/CodeGen/Passes.h"
1817 #include "llvm/IR/BasicBlock.h"
258257
259258 /// \}
260259
261 MachineFunction &MachineModuleInfo::getMachineFunction(const Function &F) {
260 MachineFunction *
261 MachineModuleInfo::getMachineFunction(const Function &F) const {
262 auto I = MachineFunctions.find(&F);
263 return I != MachineFunctions.end() ? I->second.get() : nullptr;
264 }
265
266 MachineFunction &
267 MachineModuleInfo::getOrCreateMachineFunction(const Function &F) {
262268 // Shortcut for the common case where a sequence of MachineFunctionPasses
263269 // all query for the same Function.
264270 if (LastRequest == &F)
272278 MF = new MachineFunction(&F, TM, NextFnNum++, *this);
273279 // Update the set entry.
274280 I.first->second.reset(MF);
275
276 if (MFInitializer)
277 if (MFInitializer->initializeMachineFunction(*MF))
278 report_fatal_error("Unable to initialize machine function");
279281 } else {
280282 MF = I.first->second.get();
281283 }
11101110 Builder.CreateRetVoid();
11111111
11121112 MachineModuleInfo &MMI = getAnalysis();
1113 MachineFunction &MF = MMI.getMachineFunction(*F);
1113 MachineFunction &MF = MMI.getOrCreateMachineFunction(*F);
11141114 MachineBasicBlock &MBB = *MF.CreateMachineBasicBlock();
11151115 const TargetSubtargetInfo &STI = MF.getSubtarget();
11161116 const TargetInstrInfo &TII = *STI.getInstrInfo();
12061206 return false;
12071207
12081208 MachineModuleInfo &MMI = getAnalysis();
1209 const TargetSubtargetInfo &STI = MMI.getMachineFunction(*M.begin())
1209 const TargetSubtargetInfo &STI = MMI.getOrCreateMachineFunction(*M.begin())
12101210 .getSubtarget();
12111211 const TargetRegisterInfo *TRI = STI.getRegisterInfo();
12121212 const TargetInstrInfo *TII = STI.getInstrInfo();
12151215
12161216 // Build instruction mappings for each function in the module.
12171217 for (Function &F : M) {
1218 MachineFunction &MF = MMI.getMachineFunction(F);
1218 MachineFunction &MF = MMI.getOrCreateMachineFunction(F);
12191219
12201220 // Is the function empty? Safe to outline from?
12211221 if (F.empty() || !TII->isFunctionSafeToOutlineFrom(MF))
1616 liveins: %w0
1717 ; ERR: generic virtual registers must have a type
1818 ; ERR-NEXT: %0
19 ; ERR: Unable to initialize machine function
2019 %0 = G_ADD i32 %w0, %w0
2120 ...
1717 liveins: %w0
1818 ; ERR: generic virtual registers must have a type
1919 ; ERR-NEXT: %0
20 ; ERR: Unable to initialize machine function
2120 %0 = G_ADD i32 %w0, %w0
2221 ...
+0
-13
test/CodeGen/MIR/Generic/function-missing-machine-function.mir less more
None # RUN: not llc -run-pass none -o /dev/null %s 2>&1 | FileCheck %s
1 # This test verifies that an error is reported when a MIR file has some
2 # function but is missing a corresponding machine function.
3
4 # CHECK: no machine function information for function 'foo' in the MIR file
5
6 --- |
7
8 define i32 @foo() {
9 ret i32 0
10 }
11
12 ...
0 # RUN: llc -run-pass none -o - %s | FileCheck %s
1 # Make sure empty files don't crash us
2 # CHECK: --- |
3 # ... moduleid, sourcefilename stuff here ..
4 # CHECK: target datalayout =
5 # CHECK: ...
0 # RUN: llc -run-pass none -o - %s | FileCheck %s
1 # Make sure empty files don't crash us
2 --- |
3 ...
4 # CHECK: --- |
5 # ... moduleid, sourcefilename stuff here ..
6 # CHECK: target datalayout =
7 # CHECK: ...
0 # RUN: llc -run-pass none -o - %s | FileCheck %s
1 # Make sure empty files don't crash us
2 ---
3 ...
4 # CHECK: --- |
5 # ... moduleid, sourcefilename stuff here ..
6 # CHECK: target datalayout =
7 # CHECK: ...
400400 if (StringRef(InputFilename).endswith_lower(".mir")) {
401401 MIR = createMIRParserFromFile(InputFilename, Err, Context);
402402 if (MIR)
403 M = MIR->parseLLVMModule();
403 M = MIR->parseIRModule();
404404 } else
405405 M = parseIRFile(InputFilename, Err, Context);
406406 if (!M) {
539539 TPC.setDisableVerify(NoVerify);
540540 PM.add(&TPC);
541541 MachineModuleInfo *MMI = new MachineModuleInfo(&LLVMTM);
542 MMI->setMachineFunctionInitializer(MIR.get());
542 if (MIR->parseMachineFunctions(*M, *MMI))
543 return 1;
543544 PM.add(MMI);
544545 TPC.printAndVerify("");
545546
5858 if (!MIR)
5959 return nullptr;
6060
61 std::unique_ptr M = MIR->parseLLVMModule();
61 std::unique_ptr M = MIR->parseIRModule();
6262 if (!M)
6363 return nullptr;
6464
6565 M->setDataLayout(TM.createDataLayout());
6666
67 Function *F = M->getFunction(FuncName);
68 if (!F)
67 MachineModuleInfo *MMI = new MachineModuleInfo(&TM);
68 if (MIR->parseMachineFunctions(*M, *MMI))
6969 return nullptr;
70
71 MachineModuleInfo *MMI = new MachineModuleInfo(&TM);
72 MMI->setMachineFunctionInitializer(MIR.get());
7370 PM.add(MMI);
7471
7572 return M;
153150 std::unique_ptr MIR;
154151 std::unique_ptr M = parseMIR(Context, PM, MIR, *TM, MIRString,
155152 "func");
153 assert(M && "MIR parsing successfull");
156154
157155 PM.add(new TestPass(T));
158156
5959 createMIRParser(std::move(MBuffer), Context);
6060 assert(MParser && "Couldn't create MIR parser");
6161
62 std::unique_ptr M = MParser->parseLLVMModule();
62 std::unique_ptr M = MParser->parseIRModule();
6363 assert(M && "Couldn't parse module");
6464
6565 M->setTargetTriple(TM->getTargetTriple().getTriple());
6666 M->setDataLayout(TM->createDataLayout());
6767
68 MachineModuleInfo MMI(TM);
69 bool Res = MParser->parseMachineFunctions(*M, MMI);
70 assert(!Res && "Couldn't parse MIR functions");
71
6872 auto F = M->getFunction("sizes");
6973 assert(F && "Couldn't find intended function");
70
71 MachineModuleInfo MMI(TM);
72 MMI.setMachineFunctionInitializer(MParser.get());
73 auto &MF = MMI.getMachineFunction(*F);
74 auto &MF = MMI.getOrCreateMachineFunction(*F);
7475
7576 Checks(*II, MF);
7677 }