Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions src/Qir/Runtime/lib/QIR/bridge-rt.ll
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@
;------------------------------------------------------------------------------
; classical
;
declare i8* @quantum__rt__heap_alloc(i64)
declare void @quantum__rt__heap_free(i8*)
declare i8* @quantum__rt__memory_allocate(i64)
declare void @quantum__rt__fail(%"struct.QirString"*)

Expand Down Expand Up @@ -121,15 +119,6 @@ declare void @quantum__rt__message(%"struct.QirString"* %str)
;------------------------------------------------------------------------------
; classical bridge
;
define dllexport i8* @__quantum__rt__heap_alloc(i64 %size) {
%mem = call i8* @quantum__rt__heap_alloc(i64 %size)
ret i8* %mem
}

define dllexport void @__quantum__rt__heap_free(i8* %mem) {
call void @quantum__rt__heap_free(i8* %mem)
ret void
}

; Returns a pointer to the malloc-allocated block.
define dllexport i8* @__quantum__rt__memory_allocate(i64 %size) {
Expand Down
30 changes: 0 additions & 30 deletions src/Qir/Runtime/lib/QIR/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,39 +13,9 @@
#include "QirRuntime.hpp"
#include "OutputStream.hpp"

static std::unordered_set<char*>& UseMemoryTracker()
{
static std::unordered_set<char*> memoryTracker;
return memoryTracker;
}

extern "C"
{
// Allocate a block of memory on the heap.
char* quantum__rt__heap_alloc(uint64_t size) // NOLINT
{
char* buffer = new (std::nothrow) char[size];
if(buffer == nullptr)
{
quantum__rt__fail(quantum__rt__string_create("Allocation Failed"));
}
#ifndef NDEBUG
UseMemoryTracker().insert(buffer);
#endif
return buffer;
}

// Release a block of allocated heap memory.
void quantum__rt__heap_free(char* buffer) // NOLINT
{
#ifndef NDEBUG
auto iter = UseMemoryTracker().find(buffer);
assert(iter != UseMemoryTracker().end());
UseMemoryTracker().erase(iter);
#endif
delete[] buffer;
}

char* quantum__rt__memory_allocate(uint64_t size)
{
return (char *)malloc((size_t)size);
Expand Down