Skip to content

Commit

Permalink
[llc] Initialize TargetLoweringObjectFile for MIR input
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
MaskRay committed Mar 20, 2020
1 parent 6366653 commit fe5937c
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions llvm/tools/llc/llc.cpp
Expand Up @@ -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>
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit fe5937c

Please sign in to comment.