summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPedro Artigas <partigas@apple.com>2012-12-14 18:52:11 +0000
committerPedro Artigas <partigas@apple.com>2012-12-14 18:52:11 +0000
commitb95c53e216e593a871d8c6f37f8f07f4b6b57623 (patch)
tree5dafba9112786166d13f7f019b58dbecf97932f6
parentf8e9a5a061734115bbf43a1e859a5da9d7b6ea1d (diff)
downloadbcm5719-llvm-b95c53e216e593a871d8c6f37f8f07f4b6b57623.tar.gz
bcm5719-llvm-b95c53e216e593a871d8c6f37f8f07f4b6b57623.zip
Add more reset methods to make all objects that the backend may use for outputting code have a reset, some are not used but were declared for completeness
llvm-svn: 170227
-rw-r--r--llvm/include/llvm/MC/MCAsmBackend.h3
-rw-r--r--llvm/include/llvm/MC/MCCodeEmitter.h3
-rw-r--r--llvm/include/llvm/MC/MCMachObjectWriter.h14
-rw-r--r--llvm/include/llvm/MC/MCObjectWriter.h3
-rw-r--r--llvm/lib/MC/MCAssembler.cpp5
-rw-r--r--llvm/lib/MC/MCObjectStreamer.cpp3
-rw-r--r--llvm/lib/MC/MachObjectWriter.cpp10
7 files changed, 40 insertions, 1 deletions
diff --git a/llvm/include/llvm/MC/MCAsmBackend.h b/llvm/include/llvm/MC/MCAsmBackend.h
index 72ed1a317c5..48bd9d07420 100644
--- a/llvm/include/llvm/MC/MCAsmBackend.h
+++ b/llvm/include/llvm/MC/MCAsmBackend.h
@@ -41,6 +41,9 @@ protected: // Can only create subclasses.
public:
virtual ~MCAsmBackend();
+ /// lifetime management
+ virtual void reset() { }
+
/// createObjectWriter - Create a new MCObjectWriter instance for use by the
/// assembler backend to emit the final object file.
virtual MCObjectWriter *createObjectWriter(raw_ostream &OS) const = 0;
diff --git a/llvm/include/llvm/MC/MCCodeEmitter.h b/llvm/include/llvm/MC/MCCodeEmitter.h
index 05748909029..9bfa08eb5d0 100644
--- a/llvm/include/llvm/MC/MCCodeEmitter.h
+++ b/llvm/include/llvm/MC/MCCodeEmitter.h
@@ -29,6 +29,9 @@ protected: // Can only create subclasses.
public:
virtual ~MCCodeEmitter();
+ /// Lifetime management
+ virtual void reset() { }
+
/// EncodeInstruction - Encode the given \p Inst to bytes on the output
/// stream \p OS.
virtual void EncodeInstruction(const MCInst &Inst, raw_ostream &OS,
diff --git a/llvm/include/llvm/MC/MCMachObjectWriter.h b/llvm/include/llvm/MC/MCMachObjectWriter.h
index efaabfb9e88..2ddde0b68a7 100644
--- a/llvm/include/llvm/MC/MCMachObjectWriter.h
+++ b/llvm/include/llvm/MC/MCMachObjectWriter.h
@@ -45,6 +45,13 @@ protected:
public:
virtual ~MCMachObjectTargetWriter();
+ /// @name Lifetime Management
+ /// @{
+
+ virtual void reset() {};
+
+ /// @}
+
/// @name Accessors
/// @{
@@ -111,6 +118,13 @@ public:
: MCObjectWriter(_OS, _IsLittleEndian), TargetObjectWriter(MOTW) {
}
+ /// @name Lifetime management Methods
+ /// @{
+
+ virtual void reset();
+
+ /// @}
+
/// @name Utility Methods
/// @{
diff --git a/llvm/include/llvm/MC/MCObjectWriter.h b/llvm/include/llvm/MC/MCObjectWriter.h
index f77b7d853db..9d5c1a785eb 100644
--- a/llvm/include/llvm/MC/MCObjectWriter.h
+++ b/llvm/include/llvm/MC/MCObjectWriter.h
@@ -51,6 +51,9 @@ protected: // Can only create subclasses.
public:
virtual ~MCObjectWriter();
+ /// lifetime management
+ virtual void reset() { }
+
bool isLittleEndian() const { return IsLittleEndian; }
raw_ostream &getStream() { return OS; }
diff --git a/llvm/lib/MC/MCAssembler.cpp b/llvm/lib/MC/MCAssembler.cpp
index 8ca849be17b..2558eff0455 100644
--- a/llvm/lib/MC/MCAssembler.cpp
+++ b/llvm/lib/MC/MCAssembler.cpp
@@ -232,6 +232,11 @@ void MCAssembler::reset() {
RelaxAll = false;
NoExecStack = false;
SubsectionsViaSymbols = false;
+
+ // reset objects owned by us
+ getBackend().reset();
+ getEmitter().reset();
+ getWriter().reset();
}
bool MCAssembler::isSymbolLinkerVisible(const MCSymbol &Symbol) const {
diff --git a/llvm/lib/MC/MCObjectStreamer.cpp b/llvm/lib/MC/MCObjectStreamer.cpp
index 98c8bdac3ab..c69d76428cb 100644
--- a/llvm/lib/MC/MCObjectStreamer.cpp
+++ b/llvm/lib/MC/MCObjectStreamer.cpp
@@ -45,7 +45,8 @@ MCObjectStreamer::~MCObjectStreamer() {
}
void MCObjectStreamer::reset() {
- Assembler->reset();
+ if (Assembler)
+ Assembler->reset();
MCStreamer::reset();
}
diff --git a/llvm/lib/MC/MachObjectWriter.cpp b/llvm/lib/MC/MachObjectWriter.cpp
index cc8d2fb4771..0098bead45c 100644
--- a/llvm/lib/MC/MachObjectWriter.cpp
+++ b/llvm/lib/MC/MachObjectWriter.cpp
@@ -27,6 +27,16 @@
using namespace llvm;
using namespace llvm::object;
+void MachObjectWriter::reset() {
+ Relocations.clear();
+ IndirectSymBase.clear();
+ StringTable.clear();
+ LocalSymbolData.clear();
+ ExternalSymbolData.clear();
+ UndefinedSymbolData.clear();
+ MCObjectWriter::reset();
+}
+
bool MachObjectWriter::
doesSymbolRequireExternRelocation(const MCSymbolData *SD) {
// Undefined symbols are always extern.
OpenPOWER on IntegriCloud