json_view: keep GCC from cloning scan_string_vector
With the builder of accept() in the same translation unit, GCC 16's interprocedural constant propagation cloned scan_string_vector without its plain argument (always string_plain()). The parse loop of json_document::parse() then called the clone, and GCC generated different code for the whole loop: 0.7-1.2 % more instructions (twitter, citm_catalog, instruments, tree-pretty, canada) and up to +13 % time on citm_catalog. NLOHMANN_VIEW_NOCLONE (GCC only) keeps the function as written; the instruction counts of parse() are then those of develop again. Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
5 files changed
+31
-5
No files matched your search
@@ -40,6 +40,15 @@
|
||||
#define NLOHMANN_VIEW_NOINLINE
|
||||
#endif
|
||||
|
||||
// GCC: a function compiled as written, without the clones in which interprocedural
|
||||
// constant propagation drops an argument that every caller passes as the same constant
|
||||
// (calling such a clone changes the code GCC generates for the parse loop that calls it)
|
||||
#if defined(__GNUC__) && !defined(__clang__)
|
||||
#define NLOHMANN_VIEW_NOCLONE __attribute__((noclone))
|
||||
#else
|
||||
#define NLOHMANN_VIEW_NOCLONE
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
#define NLOHMANN_VIEW_NODISCARD __attribute__((warn_unused_result))
|
||||
#elif defined(_MSC_VER)
|
||||
|
||||
Reference in new issue
Block a user