[llvm] r207366 - Avoid using MCSymbolData on the asm streamer.
Rafael Espindola
rafael.espindola at gmail.com
Sun Apr 27 10:10:47 PDT 2014
Author: rafael
Date: Sun Apr 27 12:10:46 2014
New Revision: 207366
URL: http://llvm.org/viewvc/llvm-project?rev=207366&view=rev
Log:
Avoid using MCSymbolData on the asm streamer.
Only the object streamers need to track if a symbol should be marked thumb or
not. This ports the ELF case. The COFF case is not ported since it is currently
not working for some other reason (I will report a bug).
Modified:
llvm/trunk/lib/MC/MCAsmStreamer.cpp
llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp
Modified: llvm/trunk/lib/MC/MCAsmStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmStreamer.cpp?rev=207366&r1=207365&r2=207366&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCAsmStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCAsmStreamer.cpp Sun Apr 27 12:10:46 2014
@@ -59,10 +59,6 @@ private:
EHPrivateExtern = 1 << 2 };
DenseMap<const MCSymbol*, unsigned> FlagMap;
- // Using std::unordered_map to ensure pointers to MCSymbolData remain valid
- // over insertions/removals from the SymbolMap.
- std::unordered_map<const MCSymbol*, MCSymbolData> SymbolMap;
-
void EmitRegisterName(int64_t Register);
void EmitCFIStartProcImpl(MCDwarfFrameInfo &Frame) override;
void EmitCFIEndProcImpl(MCDwarfFrameInfo &Frame) override;
@@ -258,8 +254,6 @@ public:
void EmitRawTextImpl(StringRef String) override;
void FinishImpl() override;
-
- virtual MCSymbolData &getOrCreateSymbolData(const MCSymbol *Symbol) override;
};
} // end anonymous namespace.
@@ -1472,14 +1466,6 @@ void MCAsmStreamer::FinishImpl() {
EmitFrames(AsmBackend.get(), false);
}
-MCSymbolData &MCAsmStreamer::getOrCreateSymbolData(const MCSymbol *Symbol) {
- auto Iter = SymbolMap.find(Symbol);
- if (Iter == SymbolMap.end())
- Iter = SymbolMap.insert(
- Iter, std::make_pair(Symbol, MCSymbolData(*Symbol, nullptr, 0)));
- return Iter->second;
-}
-
MCStreamer *llvm::createAsmStreamer(MCContext &Context,
formatted_raw_ostream &OS,
bool isVerboseAsm, bool useCFI,
Modified: llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp?rev=207366&r1=207365&r2=207366&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp (original)
+++ llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Sun Apr 27 12:10:46 2014
@@ -22,9 +22,7 @@
#include "llvm/MC/MCAssembler.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCDisassembler.h"
-#include "llvm/MC/MCELF.h"
#include "llvm/MC/MCELFStreamer.h"
-#include "llvm/MC/MCELFSymbolFlags.h"
#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCInst.h"
#include "llvm/MC/MCInstrDesc.h"
@@ -8364,32 +8362,6 @@ void ARMAsmParser::onLabelParsed(MCSymbo
if (NextSymbolIsThumb) {
getParser().getStreamer().EmitThumbFunc(Symbol);
NextSymbolIsThumb = false;
- return;
- }
-
- if (!isThumb())
- return;
-
- const MCObjectFileInfo::Environment Format =
- getContext().getObjectFileInfo()->getObjectFileType();
- switch (Format) {
- case MCObjectFileInfo::IsCOFF: {
- const MCSymbolData &SD =
- getParser().getStreamer().getOrCreateSymbolData(Symbol);
- char Type = COFF::IMAGE_SYM_DTYPE_FUNCTION << COFF::SCT_COMPLEX_TYPE_SHIFT;
- if (SD.getFlags() & (Type << COFF::SF_TypeShift))
- getParser().getStreamer().EmitThumbFunc(Symbol);
- break;
- }
- case MCObjectFileInfo::IsELF: {
- const MCSymbolData &SD =
- getParser().getStreamer().getOrCreateSymbolData(Symbol);
- if (MCELF::GetType(SD) & (ELF::STT_FUNC << ELF_STT_Shift))
- getParser().getStreamer().EmitThumbFunc(Symbol);
- break;
- }
- case MCObjectFileInfo::IsMachO:
- break;
}
}
Modified: llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp?rev=207366&r1=207365&r2=207366&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp (original)
+++ llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp Sun Apr 27 12:10:46 2014
@@ -30,6 +30,7 @@
#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCInst.h"
#include "llvm/MC/MCInstPrinter.h"
+#include "llvm/MC/MCObjectFileInfo.h"
#include "llvm/MC/MCObjectStreamer.h"
#include "llvm/MC/MCRegisterInfo.h"
#include "llvm/MC/MCSection.h"
@@ -406,6 +407,7 @@ private:
void emitFPU(unsigned FPU) override;
void emitInst(uint32_t Inst, char Suffix = '\0') override;
void finishAttributeSection() override;
+ void emitLabel(MCSymbol *Symbol) override;
void AnnotateTLSDescriptorSequence(const MCSymbolRefExpr *SRE) override;
@@ -981,6 +983,17 @@ void ARMTargetELFStreamer::finishAttribu
Contents.clear();
FPU = ARM::INVALID_FPU;
}
+
+void ARMTargetELFStreamer::emitLabel(MCSymbol *Symbol) {
+ ARMELFStreamer &Streamer = getStreamer();
+ if (!Streamer.IsThumb)
+ return;
+
+ const MCSymbolData &SD = Streamer.getOrCreateSymbolData(Symbol);
+ if (MCELF::GetType(SD) & (ELF::STT_FUNC << ELF_STT_Shift))
+ Streamer.EmitThumbFunc(Symbol);
+}
+
void
ARMTargetELFStreamer::AnnotateTLSDescriptorSequence(const MCSymbolRefExpr *S) {
getStreamer().EmitFixup(S, FK_Data_4);
More information about the llvm-commits
mailing list