[PATCH] D46685: [CodeGen] Disable structor optimizations at -O0

Pavel Labath via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu May 17 07:19:58 PDT 2018


labath updated this revision to Diff 147315.
labath added a comment.

Updating with a new version of the patch. The problem with the previous version
was that it caused us to use C5/https://reviews.llvm.org/D5 comdats very aggressively (at -O0), and this
is not always correct. This uses a more nuanced approach:

- for local symbols we can use aliases because we don't have to worry about comdats or other compilation units.
- for linkonce symbols, we must emit each structor separately. Theoretically it would be possible to emit a C5 comdat, but then we would need to make sure it contains both (in case of destructors, all three) symbols. As linkonce symbols are emitted lazily, I did not find an easy way to ensure that this is always the case.
- for available_externally, I also emit the structor, as the code seemed to be worried about emitting an alias in this case.
- other linkage types are not affected by the optimization level. They either get put into a comdat (weak) or get aliased (external).

I also add more thorough tests for this behavior.

Overall I am not sure if this extra complexity is worth the few extra aliases we
can emit this way at -O0. Let me know what you think.


Repository:
  rC Clang

https://reviews.llvm.org/D46685

Files:
  lib/CodeGen/ItaniumCXXABI.cpp
  test/CodeGenCXX/ctor-dtor-alias.cpp
  test/CodeGenCXX/float16-declarations.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46685.147315.patch
Type: text/x-patch
Size: 6415 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180517/933c8845/attachment.bin>


More information about the cfe-commits mailing list