[all-commits] [llvm/llvm-project] b8fdaf: [Sema] Perform call checking when building CXXNewExpr
Roman Lebedev via All-commits
all-commits at lists.llvm.org
Tue Feb 25 14:37:50 PST 2020
Branch: refs/heads/master
Home: https://github.com/llvm/llvm-project
Commit: b8fdafe68ce25b7ff4d31720548622e28db87ebf
https://github.com/llvm/llvm-project/commit/b8fdafe68ce25b7ff4d31720548622e28db87ebf
Author: Roman Lebedev <lebedev.ri at gmail.com>
Date: 2020-02-26 (Wed, 26 Feb 2020)
Changed paths:
M clang/lib/Sema/SemaChecking.cpp
M clang/lib/Sema/SemaExprCXX.cpp
M clang/test/SemaCXX/diagnose_if.cpp
A clang/test/SemaCXX/operator-new-size-diagnose_if.cpp
M clang/test/SemaCXX/std-align-val-t-in-operator-new.cpp
Log Message:
-----------
[Sema] Perform call checking when building CXXNewExpr
Summary:
There was even a TODO for this.
The main motivation is to make use of call-site based
`__attribute__((alloc_align(param_idx)))` validation (D72996).
Reviewers: rsmith, erichkeane, aaron.ballman, jdoerfert
Reviewed By: rsmith
Subscribers: cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D73020
Commit: 3dd5a298bfff48c0939448c9b4bc987cf6bb5385
https://github.com/llvm/llvm-project/commit/3dd5a298bfff48c0939448c9b4bc987cf6bb5385
Author: Roman Lebedev <lebedev.ri at gmail.com>
Date: 2020-02-26 (Wed, 26 Feb 2020)
Changed paths:
M clang/include/clang/AST/Decl.h
M clang/include/clang/Sema/Sema.h
M clang/lib/AST/Decl.cpp
M clang/lib/CodeGen/CGCall.cpp
M clang/lib/CodeGen/CodeGenModule.cpp
M clang/lib/Sema/SemaDecl.cpp
M clang/lib/Sema/SemaExprCXX.cpp
M clang/test/AST/ast-dump-stmt-json.cpp
M clang/test/Analysis/new-ctor-malloc.cpp
M clang/test/Analysis/new-ctor-null-throw.cpp
M clang/test/Analysis/new-ctor-null.cpp
M clang/test/CodeGenCXX/align-avx-complete-objects.cpp
M clang/test/CodeGenCXX/arm.cpp
M clang/test/CodeGenCXX/builtin-calling-conv.cpp
M clang/test/CodeGenCXX/builtin-is-constant-evaluated.cpp
M clang/test/CodeGenCXX/builtin-operator-new-delete.cpp
M clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp
M clang/test/CodeGenCXX/cxx11-initializer-array-new.cpp
M clang/test/CodeGenCXX/cxx1z-aligned-allocation.cpp
M clang/test/CodeGenCXX/delete-two-arg.cpp
M clang/test/CodeGenCXX/dllexport.cpp
M clang/test/CodeGenCXX/dllimport.cpp
M clang/test/CodeGenCXX/exceptions.cpp
M clang/test/CodeGenCXX/goto.cpp
M clang/test/CodeGenCXX/microsoft-abi-array-cookies.cpp
M clang/test/CodeGenCXX/mips-size_t-ptrdiff_t.cpp
M clang/test/CodeGenCXX/multi-dim-operator-new.cpp
M clang/test/CodeGenCXX/new-alias.cpp
M clang/test/CodeGenCXX/new-array-init.cpp
M clang/test/CodeGenCXX/new-overflow.cpp
M clang/test/CodeGenCXX/new.cpp
M clang/test/CodeGenCXX/operator-new.cpp
M clang/test/CodeGenCXX/runtime-dllstorage.cpp
M clang/test/CodeGenCXX/static-init.cpp
M clang/test/CodeGenCoroutines/coro-alloc.cpp
M clang/test/CodeGenCoroutines/coro-cleanup.cpp
M clang/test/CodeGenCoroutines/coro-gro-nrvo.cpp
M clang/test/CodeGenCoroutines/coro-gro.cpp
M clang/test/CodeGenCoroutines/coro-return.cpp
M clang/test/CodeGenObjCXX/arc-new-delete.mm
M clang/test/CodeGenObjCXX/copy.mm
M clang/test/SemaCXX/builtin-operator-new-delete.cpp
M clang/test/SemaCXX/new-delete.cpp
Log Message:
-----------
[clang] Annotating C++'s `operator new` with more attributes
Summary:
Right now we annotate C++'s `operator new` with `noalias` attribute,
which very much is healthy for optimizations.
However as per [[ http://eel.is/c++draft/basic.stc.dynamic.allocation | `[basic.stc.dynamic.allocation]` ]],
there are more promises on global `operator new`, namely:
* non-`std::nothrow_t` `operator new` *never* returns `nullptr`
* If `std::align_val_t align` parameter is taken, the pointer will also be `align`-aligned
* ~~global `operator new`-returned pointer is `__STDCPP_DEFAULT_NEW_ALIGNMENT__`-aligned ~~ It's more caveated than that.
Supplying this information may not cause immediate landslide effects
on any specific benchmarks, but it for sure will be healthy for optimizer
in the sense that the IR will better reflect the guarantees provided in the source code.
The caveat is `-fno-assume-sane-operator-new`, which currently prevents emitting `noalias`
attribute, and is automatically passed by Sanitizers ([[ https://bugs.llvm.org/show_bug.cgi?id=16386 | PR16386 ]]) - should it also cover these attributes?
The problem is that the flag is back-end-specific, as seen in `test/Modules/explicit-build-flags.cpp`.
But while it is okay to add `noalias` metadata in backend, we really should be adding at least
the alignment metadata to the AST, since that allows us to perform sema checks on it.
Reviewers: erichkeane, rjmccall, jdoerfert, eugenis, rsmith
Reviewed By: rsmith
Subscribers: xbolva00, jrtc27, atanasyan, nlopes, cfe-commits
Tags: #llvm, #clang
Differential Revision: https://reviews.llvm.org/D73380
Compare: https://github.com/llvm/llvm-project/compare/6d2372ce584f...3dd5a298bfff
More information about the All-commits
mailing list