llvm.org GIT mirror llvm / a73e920
Provide a dummy section to fix a crash with inline assembly in LTO. Fixes pr18508. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199843 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 6 years ago
2 changed file(s) with 30 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
2323 #include "llvm/MC/MCInst.h"
2424 #include "llvm/MC/MCInstrInfo.h"
2525 #include "llvm/MC/MCParser/MCAsmParser.h"
26 #include "llvm/MC/MCSection.h"
2627 #include "llvm/MC/MCStreamer.h"
2728 #include "llvm/MC/MCSubtargetInfo.h"
2829 #include "llvm/MC/MCSymbol.h"
531532 }
532533
533534 namespace {
535
536 // Common infrastructure is allowed to assume the existence of a current
537 // section. Since this streamer doesn't need one itself, we just provide
538 // a dummy one.
539 class DummySection : public MCSection {
540 public:
541 DummySection() : MCSection(SV_ELF, SectionKind::getText()) {}
542
543 virtual void PrintSwitchToSection(const MCAsmInfo &MAI, raw_ostream &OS,
544 const MCExpr *Subsection) const {}
545
546 virtual std::string getLabelBeginName() const { return ""; }
547
548 virtual std::string getLabelEndName() const { return ""; }
549
550 virtual bool UseCodeAlign() const { return false; }
551
552 virtual bool isVirtualSection() const { return false; }
553 };
554
534555 class RecordStreamer : public MCStreamer {
535556 public:
536557 enum State { NeverSeen, Global, Defined, DefinedGlobal, Used };
558
559 DummySection TheSection;
537560
538561 private:
539562 StringMap Symbols;
620643 return Symbols.end();
621644 }
622645
623 RecordStreamer(MCContext &Context) : MCStreamer(Context, 0) {}
646 RecordStreamer(MCContext &Context) : MCStreamer(Context, 0) {
647 SwitchSection(&TheSection);
648 }
624649
625650 virtual void EmitInstruction(const MCInst &Inst) {
626651 // Scan for values.
0 ; RUN: llvm-as < %s >%t1
1 ; RUN: llvm-lto -o %t2 %t1
2
3 module asm ".align 4"