[llvm] fe5937c - [llc] Initialize TargetLoweringObjectFile for MIR input
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 20 11:18:48 PDT 2020
Author: Fangrui Song
Date: 2020-03-20T11:18:36-07:00
New Revision: fe5937cb33b7753ff95edbe7cbd3be549961b733
URL: https://github.com/llvm/llvm-project/commit/fe5937cb33b7753ff95edbe7cbd3be549961b733
DIFF: https://github.com/llvm/llvm-project/commit/fe5937cb33b7753ff95edbe7cbd3be549961b733.diff
LOG: [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.
Added:
Modified:
llvm/tools/llc/llc.cpp
Removed:
################################################################################
diff --git a/llvm/tools/llc/llc.cpp b/llvm/tools/llc/llc.cpp
index a97d87d739a5..1e381bb729bd 100644
--- a/llvm/tools/llc/llc.cpp
+++ b/llvm/tools/llc/llc.cpp
@@ -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;
}
More information about the llvm-commits
mailing list