summaryrefslogtreecommitdiff
path: root/lib/LTO/LTOModule.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2014-01-22 22:11:14 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2014-01-22 22:11:14 +0000
commita73e920f0982137083ba6291842cd81f4100fb0e (patch)
tree735ba556e40735093f78a14fa917887377b9a16c /lib/LTO/LTOModule.cpp
parentefa1355495c836f13f98efbb27a99a4aabd60598 (diff)
downloadllvm-a73e920f0982137083ba6291842cd81f4100fb0e.tar.gz
llvm-a73e920f0982137083ba6291842cd81f4100fb0e.tar.bz2
llvm-a73e920f0982137083ba6291842cd81f4100fb0e.tar.xz
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
Diffstat (limited to 'lib/LTO/LTOModule.cpp')
-rw-r--r--lib/LTO/LTOModule.cpp27
1 files changed, 26 insertions, 1 deletions
diff --git a/lib/LTO/LTOModule.cpp b/lib/LTO/LTOModule.cpp
index f73a608e3c..b648982af1 100644
--- a/lib/LTO/LTOModule.cpp
+++ b/lib/LTO/LTOModule.cpp
@@ -24,6 +24,7 @@
#include "llvm/MC/MCInst.h"
#include "llvm/MC/MCInstrInfo.h"
#include "llvm/MC/MCParser/MCAsmParser.h"
+#include "llvm/MC/MCSection.h"
#include "llvm/MC/MCStreamer.h"
#include "llvm/MC/MCSubtargetInfo.h"
#include "llvm/MC/MCSymbol.h"
@@ -532,10 +533,32 @@ LTOModule::addPotentialUndefinedSymbol(const GlobalValue *decl, bool isFunc) {
}
namespace {
+
+// Common infrastructure is allowed to assume the existence of a current
+// section. Since this streamer doesn't need one itself, we just provide
+// a dummy one.
+class DummySection : public MCSection {
+public:
+ DummySection() : MCSection(SV_ELF, SectionKind::getText()) {}
+
+ virtual void PrintSwitchToSection(const MCAsmInfo &MAI, raw_ostream &OS,
+ const MCExpr *Subsection) const {}
+
+ virtual std::string getLabelBeginName() const { return ""; }
+
+ virtual std::string getLabelEndName() const { return ""; }
+
+ virtual bool UseCodeAlign() const { return false; }
+
+ virtual bool isVirtualSection() const { return false; }
+};
+
class RecordStreamer : public MCStreamer {
public:
enum State { NeverSeen, Global, Defined, DefinedGlobal, Used };
+ DummySection TheSection;
+
private:
StringMap<State> Symbols;
@@ -621,7 +644,9 @@ namespace {
return Symbols.end();
}
- RecordStreamer(MCContext &Context) : MCStreamer(Context, 0) {}
+ RecordStreamer(MCContext &Context) : MCStreamer(Context, 0) {
+ SwitchSection(&TheSection);
+ }
virtual void EmitInstruction(const MCInst &Inst) {
// Scan for values.