[all-commits] [llvm/llvm-project] bf434a: Improve the representation of <compare>'s zero-onl...
Richard Smith via All-commits
all-commits at lists.llvm.org
Tue Sep 29 15:44:55 PDT 2020
Branch: refs/heads/master
Home: https://github.com/llvm/llvm-project
Commit: bf434a5f173eed4112a10e28e8a6236d48f9da07
https://github.com/llvm/llvm-project/commit/bf434a5f173eed4112a10e28e8a6236d48f9da07
Author: Richard Smith <richard at metafoo.co.uk>
Date: 2020-09-29 (Tue, 29 Sep 2020)
Changed paths:
M libcxx/include/__config
M libcxx/include/compare
A libcxx/test/std/language.support/cmp/cmp.categories.pre/zero_type.verify.cpp
Log Message:
-----------
Improve the representation of <compare>'s zero-only type.
* Use an empty struct instead of a member pointer to represent this
type, so that we don't actually pass a zero member pointer at runtime.
* Mark the constructor as consteval to ensure that no code is emitted
for it whenever possible.
* Add a honeypot constructor to reject all non-int arguments, so that
the only argument that can arrive at the real constructor is the
literal 0.
This results in better generated code, and rejecting invalid comparisons
against nullptr, 0L, and so on, while also rejecting invalid comparisons
against (1-1) and similar that would be allowed if we required an
integer constant expression with value 0.
Differential Revision: https://reviews.llvm.org/D85051
More information about the All-commits
mailing list