Merge branch 'realazthat-nonnull-branch'
commit
db3b517639
|
@ -2876,6 +2876,7 @@ static void do_code_gen(CodeGen *g) {
|
|||
if (handle_is_ptr(fn_type->data.fn.fn_type_id.return_type)) {
|
||||
LLVMValueRef first_arg = LLVMGetParam(fn_table_entry->fn_value, 0);
|
||||
LLVMAddAttribute(first_arg, LLVMStructRetAttribute);
|
||||
LLVMZigAddNonNullAttr(fn_table_entry->fn_value, 1);
|
||||
}
|
||||
|
||||
// set parameter attributes
|
||||
|
@ -2903,8 +2904,7 @@ static void do_code_gen(CodeGen *g) {
|
|||
LLVMAddAttribute(argument_val, LLVMReadOnlyAttribute);
|
||||
}
|
||||
if (param_type->id == TypeTableEntryIdPointer) {
|
||||
// when https://github.com/andrewrk/zig/issues/82 is fixed, add
|
||||
// non null attribute here
|
||||
LLVMZigAddNonNullAttr(fn_table_entry->fn_value, gen_index + 1);
|
||||
}
|
||||
if (is_byval) {
|
||||
// TODO
|
||||
|
|
|
@ -140,6 +140,16 @@ LLVMValueRef LLVMZigBuildCall(LLVMBuilderRef B, LLVMValueRef Fn, LLVMValueRef *A
|
|||
return wrap(unwrap(B)->Insert(call_inst));
|
||||
}
|
||||
|
||||
void LLVMZigAddNonNullAttr(LLVMValueRef fn, unsigned i)
|
||||
{
|
||||
assert( isa<Function>(unwrap(fn)) );
|
||||
|
||||
Function *unwrapped_function = reinterpret_cast<Function*>(unwrap(fn));
|
||||
|
||||
unwrapped_function->addAttribute(i, Attribute::NonNull);
|
||||
}
|
||||
|
||||
|
||||
LLVMZigDIType *LLVMZigCreateDebugPointerType(LLVMZigDIBuilder *dibuilder, LLVMZigDIType *pointee_type,
|
||||
uint64_t size_in_bits, uint64_t align_in_bits, const char *name)
|
||||
{
|
||||
|
|
|
@ -39,6 +39,8 @@ void LLVMZigOptimizeModule(LLVMTargetMachineRef targ_machine_ref, LLVMModuleRef
|
|||
LLVMValueRef LLVMZigBuildCall(LLVMBuilderRef B, LLVMValueRef Fn, LLVMValueRef *Args,
|
||||
unsigned NumArgs, unsigned CC, const char *Name);
|
||||
|
||||
// 0 is return value, 1 is first arg
|
||||
void LLVMZigAddNonNullAttr(LLVMValueRef fn, unsigned i);
|
||||
|
||||
LLVMZigDIType *LLVMZigCreateDebugPointerType(LLVMZigDIBuilder *dibuilder, LLVMZigDIType *pointee_type,
|
||||
uint64_t size_in_bits, uint64_t align_in_bits, const char *name);
|
||||
|
|
Loading…
Reference in New Issue