authorgravatar for realazthat@gmail.comrealazthat <realazthat@gmail.com> 2016-02-05 16:29:26-05:00
committergravatar for realazthat@gmail.comrealazthat <realazthat@gmail.com> 2016-02-05 16:29:26-05:00
log54fbe7560ec0f3a9d5016f2058b07463767bf6e1
tree5c76ac86048834ec9dca4144dc4e651c51b01c03
parentff5673ae1b74b8ad59ee23921e0bb4e25349d10f

Added code for generating nonnull attributes


3 files changed, 15 insertions(+), 0 deletions(-)

src/codegen.cpp+4
......@@ -2905,6 +2905,10 @@ static void do_code_gen(CodeGen *g) {
29052905 if (param_type->id == TypeTableEntryIdPointer) {
29062906 // when https://github.com/andrewrk/zig/issues/82 is fixed, add
29072907 // non null attribute here
2908
2909 ///`i` is arg index + 1
2910 ///I think that 0 is the return index, but it has a named LLVM constant variable
2911 LLVMZigAddNonNullAttr(fn_table_entry->fn_value, param_decl_i + 1);
29082912 }
29092913 if (is_byval) {
29102914 // TODO
src/zig_llvm.cpp+10
......@@ -140,6 +140,16 @@ LLVMValueRef LLVMZigBuildCall(LLVMBuilderRef B, LLVMValueRef Fn, LLVMValueRef *A
140140 return wrap(unwrap(B)->Insert(call_inst));
141141}
142142
143void LLVMZigAddNonNullAttr(LLVMValueRef fn, unsigned i)
144{
145 assert( isa<Function>(unwrap(fn)) );
146
147 Function *unwrapped_function = reinterpret_cast<Function*>(unwrap(fn));
148
149 unwrapped_function->addAttribute(i, Attribute::NonNull);
150}
151
152
143153LLVMZigDIType *LLVMZigCreateDebugPointerType(LLVMZigDIBuilder *dibuilder, LLVMZigDIType *pointee_type,
144154 uint64_t size_in_bits, uint64_t align_in_bits, const char *name)
145155{
src/zig_llvm.hpp+1
......@@ -39,6 +39,7 @@ void LLVMZigOptimizeModule(LLVMTargetMachineRef targ_machine_ref, LLVMModuleRef
3939LLVMValueRef LLVMZigBuildCall(LLVMBuilderRef B, LLVMValueRef Fn, LLVMValueRef *Args,
4040 unsigned NumArgs, unsigned CC, const char *Name);
4141
42void LLVMZigAddNonNullAttr(LLVMValueRef fn, unsigned i);
4243
4344LLVMZigDIType *LLVMZigCreateDebugPointerType(LLVMZigDIBuilder *dibuilder, LLVMZigDIType *pointee_type,
4445 uint64_t size_in_bits, uint64_t align_in_bits, const char *name);