Verify bitcode before write, minor fixes. (#21)
This commit is contained in:
+8
@@ -24,6 +24,14 @@ fun emitLLVM(module: IrModuleFragment, runtimeFile: String, outFile: String) {
|
|||||||
module.acceptVoid(RTTIGeneratorVisitor(context))
|
module.acceptVoid(RTTIGeneratorVisitor(context))
|
||||||
context.runtime.importRuntime(llvmModule)
|
context.runtime.importRuntime(llvmModule)
|
||||||
module.acceptVoid(CodeGeneratorVisitor(context))
|
module.acceptVoid(CodeGeneratorVisitor(context))
|
||||||
|
memScoped {
|
||||||
|
val errorRef = alloc(Int8Box.ref)
|
||||||
|
// TODO: use LLVMDisposeMessage() on errorRef, once possible in interop.
|
||||||
|
if (LLVMVerifyModule(
|
||||||
|
llvmModule, LLVMVerifierFailureAction.LLVMPrintMessageAction, errorRef) == 1) {
|
||||||
|
throw Error("Invalid module");
|
||||||
|
}
|
||||||
|
}
|
||||||
LLVMWriteBitcodeToFile(llvmModule, outFile)
|
LLVMWriteBitcodeToFile(llvmModule, outFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -85,7 +85,7 @@ internal fun getLlvmFunctionType(function: FunctionDescriptor): LLVMOpaqueType?
|
|||||||
|
|
||||||
if (extraParam.size == 0) return LLVMFunctionType(returnType, null, 0, 0)
|
if (extraParam.size == 0) return LLVMFunctionType(returnType, null, 0, 0)
|
||||||
memScoped {
|
memScoped {
|
||||||
val paramTypesPtr = mallocNativeArrayOf(LLVMOpaqueType, *extraParam.toTypedArray())[0] // TODO: dispose
|
val paramTypesPtr = allocNativeArrayOf(LLVMOpaqueType, *extraParam.toTypedArray())[0] // TODO: dispose
|
||||||
return LLVMFunctionType(returnType, paramTypesPtr, extraParam.size, 0)
|
return LLVMFunctionType(returnType, paramTypesPtr, extraParam.size, 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,8 @@ ArenaContainer::ArenaContainer(uint32_t size) {
|
|||||||
calloc(size + sizeof(ArenaContainerHeader), 1));
|
calloc(size + sizeof(ArenaContainerHeader), 1));
|
||||||
header_ = header;
|
header_ = header;
|
||||||
header->ref_count_ = CONTAINER_TAG_INCREMENT;
|
header->ref_count_ = CONTAINER_TAG_INCREMENT;
|
||||||
header->current_ = reinterpret_cast<uint8_t*>(header_) + sizeof(ArenaContainerHeader);
|
header->current_ =
|
||||||
|
reinterpret_cast<uint8_t*>(header_) + sizeof(ArenaContainerHeader);
|
||||||
header->end_ = header->current_ + size;
|
header->end_ = header->current_ + size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
int foo() { return 1; }
|
|
||||||
int bar() {return 2;}
|
|
||||||
int sum() {return foo() + bar();}
|
|
||||||
Reference in New Issue
Block a user