Commit c8cabbe9 authored by Nguyen, Thien Minh's avatar Nguyen, Thien Minh
Browse files

Track Array dealloc at actual dtor and fixed unit test linking



Signed-off-by: default avatarThien Nguyen <nguyentm@ornl.gov>
parent 1e20aa47
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -129,14 +129,13 @@ struct Array {
  bool release_ref() {
    m_refCount -= 1;
    qcor::internal::AllocationTracker::get().updateCount(this, m_refCount);
    if (m_refCount == 0) {
      qcor::internal::AllocationTracker::get().onDeallocate(this);
    }
    return (m_refCount == 0);
  }

  int ref_count() const { return m_refCount; }

  ~Array() { qcor::internal::AllocationTracker::get().onDeallocate(this); }

private:
  // Must be const, i.e. changing the element size is NOT allowed.
  const int m_itemSizeInBytes;
+1 −0
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@ target_link_libraries(QirQrtTester ${XACC_TEST_LIBRARIES} xacc::xacc qir-qrt qrt
# Test compile a QASM -> QIR lowering
add_test(NAME mlir_qrt_compile COMMAND ${CMAKE_BINARY_DIR}/qcor ${CMAKE_CURRENT_SOURCE_DIR}/bell_qasm.qasm)

link_directories(${XACC_ROOT}/lib)
add_executable(QirQrtRefCountTester QirQrtRefCountTester.cpp)
add_test(NAME qcor_QirQrtRefCountTester COMMAND QirQrtRefCountTester)
target_include_directories(QirQrtRefCountTester PRIVATE . .. ${CMAKE_BINARY_DIR} ${XACC_ROOT}/include/gtest)