Fix issues spotted by Valgrind
This patch has been merged into VIXL upstream(github).
Change-Id: I98e3bbd5fe06db8adf8a12f35fef2b0528915532
Signed-off-by: Serban Constantinescu <serban.constantinescu@arm.com>
diff --git a/src/vixl/a64/debugger-a64.cc b/src/vixl/a64/debugger-a64.cc
index 1a65bd3..2c29159 100644
--- a/src/vixl/a64/debugger-a64.cc
+++ b/src/vixl/a64/debugger-a64.cc
@@ -533,6 +533,11 @@
printer_->AppendVisitor(disasm_);
}
+Debugger::~Debugger() {
+ delete disasm_;
+ delete printer_;
+}
+
void Debugger::Run() {
pc_modified_ = false;
diff --git a/src/vixl/a64/debugger-a64.h b/src/vixl/a64/debugger-a64.h
index aecd620..f26d5eb 100644
--- a/src/vixl/a64/debugger-a64.h
+++ b/src/vixl/a64/debugger-a64.h
@@ -54,6 +54,7 @@
class Debugger : public Simulator {
public:
explicit Debugger(Decoder* decoder, FILE* stream = stdout);
+ ~Debugger();
virtual void Run();
virtual void VisitException(const Instruction* instr);
diff --git a/src/vixl/a64/disasm-a64.h b/src/vixl/a64/disasm-a64.h
index e203156..930df6e 100644
--- a/src/vixl/a64/disasm-a64.h
+++ b/src/vixl/a64/disasm-a64.h
@@ -165,7 +165,6 @@
class PrintDisassembler: public Disassembler {
public:
explicit PrintDisassembler(FILE* stream) : stream_(stream) { }
- virtual ~PrintDisassembler() { }
protected:
virtual void ProcessOutput(const Instruction* instr);
diff --git a/src/vixl/a64/macro-assembler-a64.cc b/src/vixl/a64/macro-assembler-a64.cc
index 49218b4..6921e60 100644
--- a/src/vixl/a64/macro-assembler-a64.cc
+++ b/src/vixl/a64/macro-assembler-a64.cc
@@ -44,7 +44,8 @@
LiteralPool::LiteralPool(MacroAssembler* masm)
- : Pool(masm), size_(0), first_use_(-1) {
+ : Pool(masm), size_(0), first_use_(-1),
+ recommended_checkpoint_(kNoCheckpointRequired) {
}
@@ -277,7 +278,8 @@
tmp_list_(ip0, ip1),
fptmp_list_(d31),
literal_pool_(this),
- veneer_pool_(this) {
+ veneer_pool_(this),
+ recommended_checkpoint_(Pool::kNoCheckpointRequired) {
checkpoint_ = NextCheckPoint();
}
@@ -293,7 +295,8 @@
tmp_list_(ip0, ip1),
fptmp_list_(d31),
literal_pool_(this),
- veneer_pool_(this) {
+ veneer_pool_(this),
+ recommended_checkpoint_(Pool::kNoCheckpointRequired) {
checkpoint_ = NextCheckPoint();
}
diff --git a/src/vixl/a64/macro-assembler-a64.h b/src/vixl/a64/macro-assembler-a64.h
index e94933c..fe38953 100644
--- a/src/vixl/a64/macro-assembler-a64.h
+++ b/src/vixl/a64/macro-assembler-a64.h
@@ -60,7 +60,8 @@
class Pool {
public:
- explicit Pool(MacroAssembler* masm) : masm_(masm) {
+ explicit Pool(MacroAssembler* masm)
+ : checkpoint_(kNoCheckpointRequired), masm_(masm) {
Reset();
}
diff --git a/src/vixl/a64/simulator-a64.cc b/src/vixl/a64/simulator-a64.cc
index 79256bb..13f208f 100644
--- a/src/vixl/a64/simulator-a64.cc
+++ b/src/vixl/a64/simulator-a64.cc
@@ -64,6 +64,8 @@
VIXL_ASSERT((static_cast<int32_t>(-1) >> 1) == -1);
VIXL_ASSERT((static_cast<uint32_t>(-1) >> 1) == 0x7fffffff);
+ instruction_stats_ = false;
+
// Set up the decoder.
decoder_ = decoder;
decoder_->AppendVisitor(this);
@@ -121,7 +123,7 @@
Simulator::~Simulator() {
- delete [] stack_;
+ delete[] stack_;
// The decoder may outlive the simulator.
decoder_->RemoveVisitor(print_disasm_);
delete print_disasm_;
diff --git a/test/test-assembler-a64.cc b/test/test-assembler-a64.cc
index 55e42ab..ab475d0 100644
--- a/test/test-assembler-a64.cc
+++ b/test/test-assembler-a64.cc
@@ -15134,6 +15134,8 @@
ASSERT_EQUAL_64(0, data[0]);
ASSERT_EQUAL_64(0, data[1]);
ASSERT_EQUAL_64(0, data[2]);
+
+ TEARDOWN();
}
@@ -15215,6 +15217,8 @@
// Check that the watchdog counter didn't run out.
ASSERT_EQUAL_64(0, x12);
+
+ TEARDOWN();
}
#endif
@@ -15297,6 +15301,8 @@
// Check that the watchdog counter didn't run out.
ASSERT_EQUAL_64(0, x12);
+
+ TEARDOWN();
}
#endif
@@ -15937,7 +15943,7 @@
ASSERT_EQUAL_64(1 << kAddressTagWidth, x1);
- TEARDOWN();
+ TEARDOWN_CUSTOM();
}
TEST(neon_3same_addp) {
diff --git a/test/test-disasm-a64.cc b/test/test-disasm-a64.cc
index 036d755..0f54288 100644
--- a/test/test-disasm-a64.cc
+++ b/test/test-disasm-a64.cc
@@ -102,7 +102,7 @@
delete disasm; \
delete decoder; \
delete masm; \
- delete buf
+ delete[] buf
namespace vixl {
diff --git a/test/test-simulator-a64.cc b/test/test-simulator-a64.cc
index b83642c..f263660 100644
--- a/test/test-simulator-a64.cc
+++ b/test/test-simulator-a64.cc
@@ -2484,6 +2484,11 @@
CALL_TEST_FP_HELPER(mnemonic, s, type, kInputFloat##input); \
}
+// TODO: Test with a newer version of valgrind.
+//
+// Note: valgrind-3.10.0 does not properly interpret libm's fma() on x86_64.
+// Therefore this test will be exiting though an ASSERT and thus leaking
+// memory.
DEFINE_TEST_FP(fmadd, 3Op, Basic)
DEFINE_TEST_FP(fmsub, 3Op, Basic)
DEFINE_TEST_FP(fnmadd, 3Op, Basic)