Index: lib/CodeGen/CGCall.cpp =================================================================== --- lib/CodeGen/CGCall.cpp +++ lib/CodeGen/CGCall.cpp @@ -1200,8 +1200,10 @@ llvm_unreachable("Invalid ABI kind for return argument"); } - if (RetTy->isReferenceType()) + if (RetTy->isReferenceType()) { + RetAttrs.addAttribute(llvm::Attribute::Dereferencable); RetAttrs.addAttribute(llvm::Attribute::NonNull); + } if (RetAttrs.hasAttributes()) PAL.push_back(llvm:: @@ -1291,8 +1293,10 @@ } } - if (ParamType->isReferenceType()) + if (ParamType->isReferenceType()) { + Attrs.addAttribute(llvm::Attribute::Dereferencable); Attrs.addAttribute(llvm::Attribute::NonNull); + } if (Attrs.hasAttributes()) PAL.push_back(llvm::AttributeSet::get(getLLVMContext(), Index, Attrs));