1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 18:54:02 +01:00

[llc] Initialize TargetLoweringObjectFile for MIR input

MIRParser uses MC and transitively calls MCObjectFileInfo::getObjectFileType().
TargetLoweringObjectFile::Initialize should be called beforehand to
initialize MCObjectFileInfo::Env.

This manifested as a -fsanitize=undefined
test/CodeGen/MIR/X86/instr-symbols-and-mcsymbol-operands.mir failure
when D71360/aa5ee8f244441a8ea103a7e0ed8b6f3e74454516 was committed.
This commit is contained in:
Fangrui Song 2020-03-20 10:35:19 -07:00
parent 3de3902a62
commit 0ac65271c0

View File

@ -50,6 +50,7 @@
#include "llvm/Support/TargetSelect.h"
#include "llvm/Support/ToolOutputFile.h"
#include "llvm/Support/WithColor.h"
#include "llvm/Target/TargetLoweringObjectFile.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Transforms/Utils/Cloning.h"
#include <memory>
@ -598,6 +599,8 @@ static int compileModule(char **argv, LLVMContext &Context) {
if (MIR) {
assert(MMIWP && "Forgot to create MMIWP?");
const_cast<TargetLoweringObjectFile *>(LLVMTM.getObjFileLowering())
->Initialize(MMIWP->getMMI().getContext(), *Target);
if (MIR->parseMachineFunctions(*M, MMIWP->getMMI()))
return 1;
}