Switch the code added in r173885 to use the new, shiny RTTI

infrastructure on MCStreamer to test for whether there is an
MCELFStreamer object available.

This is just a cleanup on the AsmPrinter side of things, moving ad-hoc
tests of random APIs to a direct type query. But the AsmParser
completely broken. There were no tests, it just blindly cast its
streamer to an MCELFStreamer and started manipulating it.

I don't have a test case -- this actually failed on LLVM's own
regression test suite. Unfortunately the failure only appears when the
stars, compilers, and runtime align to misbehave when we read a pointer
to a formatted_raw_ostream as-if it were an MCAssembler. =/

UBSan would catch this immediately.

Many thanks to Matt for doing about 80% of the debugging work here in
GDB, Jim for helping to explain how exactly to fix this, and others for
putting up with the hair pulling that ensued during debugging it.

llvm-svn: 174118
This commit is contained in:
Chandler Carruth 2013-01-31 23:43:14 +00:00
parent a983b4de7a
commit e5d8d0d64b
2 changed files with 5 additions and 9 deletions

View File

@ -704,12 +704,8 @@ void ARMAsmPrinter::EmitEndOfAsmFile(Module &M) {
// FIXME: This should eventually end up somewhere else where more
// intelligent flag decisions can be made. For now we are just maintaining
// the status quo for ARM and setting EF_ARM_EABI_VER5 as the default.
if (Subtarget->isTargetELF()) {
if (OutStreamer.hasRawTextSupport()) return;
MCELFStreamer &MES = static_cast<MCELFStreamer &>(OutStreamer);
MES.getAssembler().setELFHeaderEFlags(ELF::EF_ARM_EABI_VER5);
}
if (MCELFStreamer *MES = dyn_cast<MCELFStreamer>(&OutStreamer))
MES->getAssembler().setELFHeaderEFlags(ELF::EF_ARM_EABI_VER5);
}
//===----------------------------------------------------------------------===//

View File

@ -257,9 +257,9 @@ public:
// Set ELF header flags.
// FIXME: This should eventually end up somewhere else where more
// intelligent flag decisions can be made. For now we are just maintaining
// the status quo for ARM and setting EF_ARM_EABI_VER5 as the default.
MCELFStreamer &MES = static_cast<MCELFStreamer &>(Parser.getStreamer());
MES.getAssembler().setELFHeaderEFlags(ELF::EF_ARM_EABI_VER5);
// the statu/parseDirects quo for ARM and setting EF_ARM_EABI_VER5 as the default.
if (MCELFStreamer *MES = dyn_cast<MCELFStreamer>(&Parser.getStreamer()))
MES->getAssembler().setELFHeaderEFlags(ELF::EF_ARM_EABI_VER5);
}
// Implementation of the MCTargetAsmParser interface: