Bryce-MW updated this revision to Diff 403339. Bryce-MW marked an inline comment as done. Bryce-MW added a comment.
- Use proper attribute Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D117600/new/ https://reviews.llvm.org/D117600 Files: clang/include/clang/Driver/Options.td clang/lib/CodeGen/CGCall.cpp Index: clang/lib/CodeGen/CGCall.cpp =================================================================== --- clang/lib/CodeGen/CGCall.cpp +++ clang/lib/CodeGen/CGCall.cpp @@ -2062,11 +2062,14 @@ AddAttributesFromFunctionProtoType( getContext(), FuncAttrs, Fn->getType()->getAs<FunctionProtoType>()); if (AttrOnCallSite && Fn->isReplaceableGlobalAllocationFunction()) { - // A sane operator new returns a non-aliasing pointer. + // A sane operator new returns a non-aliasing pointer and is + // inaccessiblememonly auto Kind = Fn->getDeclName().getCXXOverloadedOperator(); if (getCodeGenOpts().AssumeSaneOperatorNew && - (Kind == OO_New || Kind == OO_Array_New)) + (Kind == OO_New || Kind == OO_Array_New)) { RetAttrs.addAttribute(llvm::Attribute::NoAlias); + FuncAttrs.addAttribute(llvm::Attribute::InacccessibleMemOnly); + } } const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(Fn); const bool IsVirtualCall = MD && MD->isVirtual(); Index: clang/include/clang/Driver/Options.td =================================================================== --- clang/include/clang/Driver/Options.td +++ clang/include/clang/Driver/Options.td @@ -2256,7 +2256,7 @@ def fno_asm : Flag<["-"], "fno-asm">, Group<f_Group>; def fno_asynchronous_unwind_tables : Flag<["-"], "fno-asynchronous-unwind-tables">, Group<f_Group>; def fno_assume_sane_operator_new : Flag<["-"], "fno-assume-sane-operator-new">, Group<f_Group>, - HelpText<"Don't assume that C++'s global operator new can't alias any pointer">, + HelpText<"Don't assume that C++'s global operator new can't alias any pointer or access accessible memory">, Flags<[CC1Option]>, MarshallingInfoNegativeFlag<CodeGenOpts<"AssumeSaneOperatorNew">>; def fno_builtin : Flag<["-"], "fno-builtin">, Group<f_Group>, Flags<[CC1Option, CoreOption]>, HelpText<"Disable implicit builtin knowledge of functions">;
Index: clang/lib/CodeGen/CGCall.cpp =================================================================== --- clang/lib/CodeGen/CGCall.cpp +++ clang/lib/CodeGen/CGCall.cpp @@ -2062,11 +2062,14 @@ AddAttributesFromFunctionProtoType( getContext(), FuncAttrs, Fn->getType()->getAs<FunctionProtoType>()); if (AttrOnCallSite && Fn->isReplaceableGlobalAllocationFunction()) { - // A sane operator new returns a non-aliasing pointer. + // A sane operator new returns a non-aliasing pointer and is + // inaccessiblememonly auto Kind = Fn->getDeclName().getCXXOverloadedOperator(); if (getCodeGenOpts().AssumeSaneOperatorNew && - (Kind == OO_New || Kind == OO_Array_New)) + (Kind == OO_New || Kind == OO_Array_New)) { RetAttrs.addAttribute(llvm::Attribute::NoAlias); + FuncAttrs.addAttribute(llvm::Attribute::InacccessibleMemOnly); + } } const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(Fn); const bool IsVirtualCall = MD && MD->isVirtual(); Index: clang/include/clang/Driver/Options.td =================================================================== --- clang/include/clang/Driver/Options.td +++ clang/include/clang/Driver/Options.td @@ -2256,7 +2256,7 @@ def fno_asm : Flag<["-"], "fno-asm">, Group<f_Group>; def fno_asynchronous_unwind_tables : Flag<["-"], "fno-asynchronous-unwind-tables">, Group<f_Group>; def fno_assume_sane_operator_new : Flag<["-"], "fno-assume-sane-operator-new">, Group<f_Group>, - HelpText<"Don't assume that C++'s global operator new can't alias any pointer">, + HelpText<"Don't assume that C++'s global operator new can't alias any pointer or access accessible memory">, Flags<[CC1Option]>, MarshallingInfoNegativeFlag<CodeGenOpts<"AssumeSaneOperatorNew">>; def fno_builtin : Flag<["-"], "fno-builtin">, Group<f_Group>, Flags<[CC1Option, CoreOption]>, HelpText<"Disable implicit builtin knowledge of functions">;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits