[llvm-bugs] [Bug 48733] New: __config_site concatenation at build time means that clang's include guard heuristic doesn't fire for libc++s __config

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Jan 12 19:15:26 PST 2021


https://bugs.llvm.org/show_bug.cgi?id=48733

            Bug ID: 48733
           Summary: __config_site concatenation at build time means that
                    clang's include guard heuristic doesn't fire for
                    libc++s __config
           Product: libc++
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: All Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: nicolasweber at gmx.de
                CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com

After https://reviews.llvm.org/D80927 we always generate __config_site and then
always prepend it to __config in a build step. That means __config looks like
so

#ifndef _LIBCPP_CONFIG_SITE
#define _LIBCPP_CONFIG_SITE
...
#endif // _LIBCPP_CONFIG_SITE
#ifndef _LIBCPP_CONFIG
#define _LIBCPP_CONFIG
...
#endif // _LIBCPP_CONFIG


clang (and other compilers) has an include guard heuristic that looks for

#ifndef A
#define A
...
#endif // ...


and if it sees this, it handles the file if it was `#pragma once`. libc++s
current setup defeats this optimization.

For n=30, ministat finds a -2.57491% +/- 1.12726% reduction in compile time for
compiling a file that does nothing but #include <vector> if I manually modify
the generated ___config to trigger the optimization (I verified with `-H
-Xclang -print-stats` that the optimization did kick in after editing the
generated file).

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210113/fb1d193f/attachment.html>


More information about the llvm-bugs mailing list