|
@@ -1734,6 +1734,8 @@ void CodeGenModule::ConstructDefaultFnAttrList(StringRef Name, bool HasOptnone,
|
|
FuncAttrs.addAttribute("less-precise-fpmad",
|
|
FuncAttrs.addAttribute("less-precise-fpmad",
|
|
llvm::toStringRef(CodeGenOpts.LessPreciseFPMAD));
|
|
llvm::toStringRef(CodeGenOpts.LessPreciseFPMAD));
|
|
|
|
|
|
|
|
+ if (CodeGenOpts.NullPointerIsValid)
|
|
|
|
+ FuncAttrs.addAttribute("null-pointer-is-valid", "true");
|
|
if (!CodeGenOpts.FPDenormalMode.empty())
|
|
if (!CodeGenOpts.FPDenormalMode.empty())
|
|
FuncAttrs.addAttribute("denormal-fp-math", CodeGenOpts.FPDenormalMode);
|
|
FuncAttrs.addAttribute("denormal-fp-math", CodeGenOpts.FPDenormalMode);
|
|
|
|
|
|
@@ -1867,7 +1869,8 @@ void CodeGenModule::ConstructAttributeList(
|
|
}
|
|
}
|
|
if (TargetDecl->hasAttr<RestrictAttr>())
|
|
if (TargetDecl->hasAttr<RestrictAttr>())
|
|
RetAttrs.addAttribute(llvm::Attribute::NoAlias);
|
|
RetAttrs.addAttribute(llvm::Attribute::NoAlias);
|
|
- if (TargetDecl->hasAttr<ReturnsNonNullAttr>())
|
|
|
|
|
|
+ if (TargetDecl->hasAttr<ReturnsNonNullAttr>() &&
|
|
|
|
+ !CodeGenOpts.NullPointerIsValid)
|
|
RetAttrs.addAttribute(llvm::Attribute::NonNull);
|
|
RetAttrs.addAttribute(llvm::Attribute::NonNull);
|
|
if (TargetDecl->hasAttr<AnyX86NoCallerSavedRegistersAttr>())
|
|
if (TargetDecl->hasAttr<AnyX86NoCallerSavedRegistersAttr>())
|
|
FuncAttrs.addAttribute("no_caller_saved_registers");
|
|
FuncAttrs.addAttribute("no_caller_saved_registers");
|
|
@@ -1974,7 +1977,8 @@ void CodeGenModule::ConstructAttributeList(
|
|
if (!PTy->isIncompleteType() && PTy->isConstantSizeType())
|
|
if (!PTy->isIncompleteType() && PTy->isConstantSizeType())
|
|
RetAttrs.addDereferenceableAttr(getContext().getTypeSizeInChars(PTy)
|
|
RetAttrs.addDereferenceableAttr(getContext().getTypeSizeInChars(PTy)
|
|
.getQuantity());
|
|
.getQuantity());
|
|
- else if (getContext().getTargetAddressSpace(PTy) == 0)
|
|
|
|
|
|
+ else if (getContext().getTargetAddressSpace(PTy) == 0 &&
|
|
|
|
+ !CodeGenOpts.NullPointerIsValid)
|
|
RetAttrs.addAttribute(llvm::Attribute::NonNull);
|
|
RetAttrs.addAttribute(llvm::Attribute::NonNull);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -2083,7 +2087,8 @@ void CodeGenModule::ConstructAttributeList(
|
|
if (!PTy->isIncompleteType() && PTy->isConstantSizeType())
|
|
if (!PTy->isIncompleteType() && PTy->isConstantSizeType())
|
|
Attrs.addDereferenceableAttr(getContext().getTypeSizeInChars(PTy)
|
|
Attrs.addDereferenceableAttr(getContext().getTypeSizeInChars(PTy)
|
|
.getQuantity());
|
|
.getQuantity());
|
|
- else if (getContext().getTargetAddressSpace(PTy) == 0)
|
|
|
|
|
|
+ else if (getContext().getTargetAddressSpace(PTy) == 0 &&
|
|
|
|
+ !CodeGenOpts.NullPointerIsValid)
|
|
Attrs.addAttribute(llvm::Attribute::NonNull);
|
|
Attrs.addAttribute(llvm::Attribute::NonNull);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -2343,7 +2348,8 @@ void CodeGenFunction::EmitFunctionProlog(const CGFunctionInfo &FI,
|
|
|
|
|
|
if (const ParmVarDecl *PVD = dyn_cast<ParmVarDecl>(Arg)) {
|
|
if (const ParmVarDecl *PVD = dyn_cast<ParmVarDecl>(Arg)) {
|
|
if (getNonNullAttr(CurCodeDecl, PVD, PVD->getType(),
|
|
if (getNonNullAttr(CurCodeDecl, PVD, PVD->getType(),
|
|
- PVD->getFunctionScopeIndex()))
|
|
|
|
|
|
+ PVD->getFunctionScopeIndex()) &&
|
|
|
|
+ !CGM.getCodeGenOpts().NullPointerIsValid)
|
|
AI->addAttr(llvm::Attribute::NonNull);
|
|
AI->addAttr(llvm::Attribute::NonNull);
|
|
|
|
|
|
QualType OTy = PVD->getOriginalType();
|
|
QualType OTy = PVD->getOriginalType();
|
|
@@ -2362,7 +2368,8 @@ void CodeGenFunction::EmitFunctionProlog(const CGFunctionInfo &FI,
|
|
Attrs.addDereferenceableAttr(
|
|
Attrs.addDereferenceableAttr(
|
|
getContext().getTypeSizeInChars(ETy).getQuantity()*ArrSize);
|
|
getContext().getTypeSizeInChars(ETy).getQuantity()*ArrSize);
|
|
AI->addAttrs(Attrs);
|
|
AI->addAttrs(Attrs);
|
|
- } else if (getContext().getTargetAddressSpace(ETy) == 0) {
|
|
|
|
|
|
+ } else if (getContext().getTargetAddressSpace(ETy) == 0 &&
|
|
|
|
+ !CGM.getCodeGenOpts().NullPointerIsValid) {
|
|
AI->addAttr(llvm::Attribute::NonNull);
|
|
AI->addAttr(llvm::Attribute::NonNull);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -2372,7 +2379,8 @@ void CodeGenFunction::EmitFunctionProlog(const CGFunctionInfo &FI,
|
|
// we can't use the dereferenceable attribute, but in addrspace(0)
|
|
// we can't use the dereferenceable attribute, but in addrspace(0)
|
|
// we know that it must be nonnull.
|
|
// we know that it must be nonnull.
|
|
if (ArrTy->getSizeModifier() == VariableArrayType::Static &&
|
|
if (ArrTy->getSizeModifier() == VariableArrayType::Static &&
|
|
- !getContext().getTargetAddressSpace(ArrTy->getElementType()))
|
|
|
|
|
|
+ !getContext().getTargetAddressSpace(ArrTy->getElementType()) &&
|
|
|
|
+ !CGM.getCodeGenOpts().NullPointerIsValid)
|
|
AI->addAttr(llvm::Attribute::NonNull);
|
|
AI->addAttr(llvm::Attribute::NonNull);
|
|
}
|
|
}
|
|
|
|
|