After updating to LLVM 3.5 I was getting an assertion failure in X86AsmPrinter::GetCPISymbol() due to it assuming COFF output if Subtarget->isTargetKnownWindowsMSVC(). In the MCJIT case it appears possible for Subtarget->isTargetKnownWindowsMSVC() to be true but for the output to be ELF, making the dyn_cast<MCSectionCOFF>() invalid. This patch adds a check for isTargetCOFF() in addition to isTargetKnownWindowsMSVC().
Details
- Reviewers
- None
Diff Detail
Event Timeline
I think I submitted this incorrectly the first time, pinging now with subscribers updated.
Why do you think the dyn_cast<MCSectionCOFF>() is invalid? It's supposed to return NULL if the section isn't a COFF section (i.e. if it's an ELF section).
In release mode I get a crash in GetCPISymbol() and in Debug I get an assertion failure:
assert(isa<X>(Val) && "cast<Ty>() argument of incompatible type!");
with this backtrace:
llvm::cast<llvm::MCSectionCOFF,llvm::MCSection const >(const llvm::MCSection * Val) Line 237
llvm::X86AsmPrinter::GetCPISymbol(unsigned int CPID) Line 562
llvm::AsmPrinter::EmitConstantPool() Line 1099
llvm::AsmPrinter::EmitFunctionHeader() Line 513
llvm::X86AsmPrinter::runOnMachineFunction(llvm::MachineFunction & MF) Line 66
llvm::MachineFunctionPass::runOnFunction(llvm::Function & F) Line 34
llvm::FPPassManager::runOnFunction(llvm::Function & F) Line 1545
llvm::FPPassManager::runOnModule(llvm::Module & M) Line 1565
`anonymous namespace'::MPPassManager::runOnModule(llvm::Module & M) Line 1623
llvm::legacy::PassManagerImpl::run(llvm::Module & M) Line 1730
llvm::legacy::PassManager::run(llvm::Module & M) Line 1768
llvm::MCJIT::emitObject(llvm::Module * M) Line 161
llvm::MCJIT::generateCodeForModule(llvm::Module * M) Line 197
llvm::MCJIT::finalizeObject() Line 240
...
This is with LLVM 3.5, if there's anything else you'd like me to try just let me know.
Actually taking a look at trunk it looks like the dyn_cast<> was added since LLVM 3.5 and it was a plain cast<> before, hence the crash I'm seeing. So it looks like this has been resolved since LLVM 3.5, I can verify once we upgrade again but I think this can just be closed, sorry for the noise.