Skip to content

Commit ef89676

Browse files
author
Luna Nielsen
committedDec 14, 2019
GEP and more LLVM disposing
1 parent 5476b58 commit ef89676

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed
 

‎source/dllvm/builder.d

+20-3
Original file line numberDiff line numberDiff line change
@@ -563,12 +563,29 @@ public:
563563
}
564564

565565
/**
566-
Builds a Struct GEP instruction
566+
Builds a GEP instruction
567567
568568
I don't know what this does yet.
569569
*/
570-
Value BuildStructGEP(Type type, Value addr, uint idx, string name = "") {
571-
return new Value(LLVMBuildStructGEP2(ptr, type.ptr, addr.ptr, idx, name.toStringz));
570+
Value BuildGEP(Value addr, Value[] indices, string name = "") {
571+
// Convert D Value to LLVM native types
572+
LLVMValueRef[] refs = new LLVMValueRef[indices.length];
573+
foreach(i, item; indices) refs[i] = item.ptr;
574+
575+
return new Value(LLVMBuildGEP(ptr, addr.ptr, refs.ptr, cast(uint)refs.length, name.toStringz));
576+
}
577+
578+
/**
579+
Builds a GEP instruction
580+
581+
I don't know what this does yet.
582+
*/
583+
Value BuildInboundsGEP(Value addr, Value[] indices, string name = "") {
584+
// Convert D Value to LLVM native types
585+
LLVMValueRef[] refs = new LLVMValueRef[indices.length];
586+
foreach(i, item; indices) refs[i] = item.ptr;
587+
588+
return new Value(LLVMBuildInBoundsGEP(ptr, addr.ptr, refs.ptr, cast(uint)refs.length, name.toStringz));
572589
}
573590

574591
/**

‎source/dllvm/exengine.d

+4
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ public:
8383
}
8484

8585
~this() {
86+
foreach(mod; managedModules) {
87+
RemoveModule(mod);
88+
}
89+
LLVMDisposePassManager(pass);
8690
LLVMDisposeExecutionEngine(ptr);
8791
}
8892

0 commit comments

Comments
 (0)