Skip to content

Commit fe5937c

Browse files
committed
[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.
1 parent 6366653 commit fe5937c

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

llvm/tools/llc/llc.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
#include "llvm/Support/TargetSelect.h"
5151
#include "llvm/Support/ToolOutputFile.h"
5252
#include "llvm/Support/WithColor.h"
53+
#include "llvm/Target/TargetLoweringObjectFile.h"
5354
#include "llvm/Target/TargetMachine.h"
5455
#include "llvm/Transforms/Utils/Cloning.h"
5556
#include <memory>
@@ -598,6 +599,8 @@ static int compileModule(char **argv, LLVMContext &Context) {
598599

599600
if (MIR) {
600601
assert(MMIWP && "Forgot to create MMIWP?");
602+
const_cast<TargetLoweringObjectFile *>(LLVMTM.getObjFileLowering())
603+
->Initialize(MMIWP->getMMI().getContext(), *Target);
601604
if (MIR->parseMachineFunctions(*M, MMIWP->getMMI()))
602605
return 1;
603606
}

0 commit comments

Comments
 (0)