[PATCH] D152401: CGExprCXX: emit family and allockind attributes

Augie Fackler via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 7 15:05:15 PDT 2023


durin42 created this revision.
Herald added subscribers: JDevlieghere, hiraditya.
Herald added a project: All.
durin42 requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

This allows us to remove most of the special knowledge about C++
allocation from LLVM, instead trusting attributes to communicate the
important properties.

Annoyingly, clang has to grow a little bit of hard-coded knowledge about
mangled symbol names in order to actually get the most-basic-matching
::operator::new when working out the alloc-family attribute. I spent
some time trying to do this "right" by looking up the available
operators new and finding the best one, but that's super tricky and this
has the virtue of working and being pretty obviously correct when
compared to the old code.

Happily, clang now emits allocator family attributes correctly even for
custom allocators like the one on new_hot_cold.cpp, which is similar
to tcmalloc per the comments. As a result, clang/llvm should correctly
optimize custom allocators like this without needing specialized
knowledge going forward.

Depends on D119271 <https://reviews.llvm.org/D119271>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152401

Files:
  clang/lib/CodeGen/CGExprCXX.cpp
  clang/test/CodeGenCXX/cxx1z-aligned-allocation.cpp
  clang/test/CodeGenCXX/new.cpp
  clang/test/CodeGenCXX/new_hot_cold.cpp
  llvm/lib/Analysis/MemoryBuiltins.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152401.529448.patch
Type: text/x-patch
Size: 23573 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230607/754ae62b/attachment-0001.bin>


More information about the cfe-commits mailing list