[llvm-commits] [llvm] r100258 - in /llvm/trunk/lib/Target/ARM/Disassembler: ARMDisassemblerCore.cpp ARMDisassemblerCore.h
Johnny Chen
johnny.chen at apple.com
Fri Apr 2 18:09:47 PDT 2010
Author: johnny
Date: Fri Apr 2 20:09:47 2010
New Revision: 100258
URL: http://llvm.org/viewvc/llvm-project?rev=100258&view=rev
Log:
Register ARMAlgorithm::DoCleanup() to be called on exit to free the memory
occuplied by the cached ARMAlgorithm objects.
Modified:
llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp
llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.h
Modified: llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp?rev=100258&r1=100257&r2=100258&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp (original)
+++ llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp Fri Apr 2 20:09:47 2010
@@ -3130,6 +3130,13 @@
/// Algorithms - Algorithms stores a map from Format to ARMAlgorithm*.
static std::vector<ARMAlgorithm*> Algorithms;
+/// DoCleanup - Do cleanup of Algorithms upon exit.
+void ARMAlgorithm::DoCleanup() {
+ for (unsigned i = 0; i < array_lengthof(FuncPtrs); ++i)
+ if (Algorithms[i])
+ delete Algorithms[i];
+}
+
/// GetInstance - GetInstance returns an instance of ARMAlgorithm given the
/// encoding Format. API clients should not free up the returned instance.
ARMAlgorithm *ARMAlgorithm::GetInstance(ARMFormat Format) {
@@ -3141,11 +3148,13 @@
Algorithms[i] = new ARMAlgorithm(FuncPtrs[i]);
else
Algorithms[i] = NULL;
+
+ // Register cleanup routine.
+ atexit(DoCleanup);
}
return Algorithms[Format];
}
-
/// BuildIt - BuildIt performs the build step for this ARM Basic MC Builder.
/// The general idea is to set the Opcode for the MCInst, followed by adding
/// the appropriate MCOperands to the MCInst. ARM Basic MC Builder delegates
Modified: llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.h?rev=100258&r1=100257&r2=100258&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.h (original)
+++ llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.h Fri Apr 2 20:09:47 2010
@@ -181,6 +181,9 @@
/// encoding Format. API clients should not free up the returned instance.
static ARMAlgorithm *GetInstance(ARMFormat Format);
+ /// DoCleanup - DoCleanup is meant to be called upon exit as an exit handler.
+ static void DoCleanup();
+
/// Return true if this algorithm successfully disassembles the instruction.
/// NumOpsAdded is updated to reflect the number of operands added by the
/// algorithm. NumOpsAdded may be less than NumOps, in which case, there are
More information about the llvm-commits
mailing list