Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4cb9624

Browse filesBrowse files
chandraghaleChandra Ghale
authored and
Chandra Ghale
committed
Merge branch 'main' into codegen_private_variable_reducn
2 parents 0b59740 + c4f7ab1 commit 4cb9624
Copy full SHA for 4cb9624

File tree

Expand file treeCollapse file tree

429 files changed

+12505
-6146
lines changed
Filter options

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree

429 files changed

+12505
-6146
lines changed

‎bolt/include/bolt/Profile/Heatmap.h

Copy file name to clipboardExpand all lines: bolt/include/bolt/Profile/Heatmap.h
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ class Heatmap {
5252
: BucketSize(BucketSize), MinAddress(MinAddress), MaxAddress(MaxAddress),
5353
TextSections(TextSections) {}
5454

55+
uint64_t HotStart{0};
56+
uint64_t HotEnd{0};
57+
5558
inline bool ignoreAddress(uint64_t Address) const {
5659
return (Address > MaxAddress) || (Address < MinAddress);
5760
}

‎bolt/lib/Profile/DataAggregator.cpp

Copy file name to clipboardExpand all lines: bolt/lib/Profile/DataAggregator.cpp
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1316,6 +1316,14 @@ std::error_code DataAggregator::printLBRHeatMap() {
13161316
}
13171317
Heatmap HM(opts::HeatmapBlock, opts::HeatmapMinAddress,
13181318
opts::HeatmapMaxAddress, getTextSections(BC));
1319+
auto getSymbolValue = [&](const MCSymbol *Symbol) -> uint64_t {
1320+
if (Symbol)
1321+
if (ErrorOr<uint64_t> SymValue = BC->getSymbolValue(*Symbol))
1322+
return SymValue.get();
1323+
return 0;
1324+
};
1325+
HM.HotStart = getSymbolValue(BC->getHotTextStartSymbol());
1326+
HM.HotEnd = getSymbolValue(BC->getHotTextEndSymbol());
13191327

13201328
if (!NumTotalSamples) {
13211329
if (opts::BasicAggregation) {

‎bolt/lib/Profile/Heatmap.cpp

Copy file name to clipboardExpand all lines: bolt/lib/Profile/Heatmap.cpp
+14-1Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include "bolt/Profile/Heatmap.h"
1010
#include "bolt/Utils/CommandLineOpts.h"
11+
#include "llvm/ADT/AddressRanges.h"
1112
#include "llvm/ADT/StringMap.h"
1213
#include "llvm/ADT/Twine.h"
1314
#include "llvm/Support/Debug.h"
@@ -313,6 +314,9 @@ void Heatmap::printSectionHotness(raw_ostream &OS) const {
313314
UnmappedHotness += Frequency;
314315
};
315316

317+
AddressRange HotTextRange(HotStart, HotEnd);
318+
StringRef HotTextName = "[hot text]";
319+
316320
for (const std::pair<const uint64_t, uint64_t> &KV : Map) {
317321
NumTotalCounts += KV.second;
318322
// We map an address bucket to the first section (lowest address)
@@ -328,15 +332,24 @@ void Heatmap::printSectionHotness(raw_ostream &OS) const {
328332
}
329333
SectionHotness[TextSections[TextSectionIndex].Name] += KV.second;
330334
++BucketUtilization[TextSections[TextSectionIndex].Name];
335+
if (HotTextRange.contains(Address)) {
336+
SectionHotness[HotTextName] += KV.second;
337+
++BucketUtilization[HotTextName];
338+
}
331339
}
332340

341+
std::vector<SectionNameAndRange> Sections(TextSections);
342+
// Append synthetic hot text section to TextSections
343+
if (!HotTextRange.empty())
344+
Sections.emplace_back(SectionNameAndRange{HotTextName, HotStart, HotEnd});
345+
333346
assert(NumTotalCounts > 0 &&
334347
"total number of heatmap buckets should be greater than 0");
335348

336349
OS << "Section Name, Begin Address, End Address, Percentage Hotness, "
337350
<< "Utilization Pct, Partition Score\n";
338351
const uint64_t MappedCounts = NumTotalCounts - UnmappedHotness;
339-
for (const auto [Name, Begin, End] : TextSections) {
352+
for (const auto [Name, Begin, End] : Sections) {
340353
const float Hotness = 1. * SectionHotness[Name] / NumTotalCounts;
341354
const float MappedHotness =
342355
MappedCounts ? 1. * SectionHotness[Name] / MappedCounts : 0;

‎bolt/lib/Rewrite/RewriteInstance.cpp

Copy file name to clipboardExpand all lines: bolt/lib/Rewrite/RewriteInstance.cpp
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -968,8 +968,9 @@ void RewriteInstance::discoverFileObjects() {
968968
continue;
969969
}
970970

971-
// Ignore input hot markers
972-
if (SymName == "__hot_start" || SymName == "__hot_end")
971+
// Ignore input hot markers unless in heatmap mode
972+
if ((SymName == "__hot_start" || SymName == "__hot_end") &&
973+
!opts::HeatmapMode)
973974
continue;
974975

975976
FileSymRefs.emplace(SymbolAddress, Symbol);

‎bolt/test/X86/callcont-fallthru.s

Copy file name to clipboardExpand all lines: bolt/test/X86/callcont-fallthru.s
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# RUN: %clangxx %cxxflags %s %t.so -o %t -Wl,-q -nostdlib
77
# RUN: link_fdata %s %t %t.pat PREAGGT1
88
# RUN: link_fdata %s %t %t.pat2 PREAGGT2
9-
# RUN: link_fdata %s %t %t.patplt PREAGGPLT
9+
# DONTRUN: link_fdata %s %t %t.patplt PREAGGPLT
1010

1111
# RUN: llvm-strip --strip-unneeded %t -o %t.strip
1212
# RUN: llvm-objcopy --remove-section=.eh_frame %t.strip %t.noeh
@@ -26,8 +26,8 @@
2626

2727
## Check pre-aggregated traces don't report zero-sized PLT fall-through as
2828
## invalid trace
29-
# RUN: llvm-bolt %t.strip --pa -p %t.patplt -o %t.out | FileCheck %s \
30-
# RUN: --check-prefix=CHECK-PLT
29+
# DONTRUN: llvm-bolt %t.strip --pa -p %t.patplt -o %t.out | FileCheck %s \
30+
# DONTRUN: --check-prefix=CHECK-PLT
3131
# CHECK-PLT: traces mismatching disassembled function contents: 0
3232

3333
.globl foo

‎bolt/test/X86/heatmap-preagg.test

Copy file name to clipboardExpand all lines: bolt/test/X86/heatmap-preagg.test
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ RUN: --reorder-functions=cdsort --enable-bat --dyno-stats --skip-funcs=main
1313
RUN: llvm-bolt-heatmap %t.out -o %t2 --pa -p %p/Inputs/blarge_new_bat.preagg.txt \
1414
RUN: 2>&1 | FileCheck --check-prefix CHECK-HEATMAP-BAT %s
1515
RUN: FileCheck %s --check-prefix CHECK-SEC-HOT-BAT --input-file %t2-section-hotness.csv
16+
RUN: llvm-nm -n %t.out | FileCheck %s --check-prefix=CHECK-HOT-SYMS
1617

1718
CHECK-HEATMAP: PERF2BOLT: read 81 aggregated LBR entries
1819
CHECK-HEATMAP: HEATMAP: invalid traces: 1
@@ -33,3 +34,6 @@ CHECK-SEC-HOT-BAT-NEXT: .bolt.org.text, 0x4010b0, 0x401c25, 38.3385, 51.0638, 0.
3334
CHECK-SEC-HOT-BAT-NEXT: .fini, 0x401c28, 0x401c35, 0.0000, 0.0000, 0.0000
3435
CHECK-SEC-HOT-BAT-NEXT: .text, 0x800000, 0x8002cc, 38.7595, 91.6667, 0.3553
3536
CHECK-SEC-HOT-BAT-NEXT: .text.cold, 0x800300, 0x800415, 0.0000, 0.0000, 0.0000
37+
CHECK-SEC-HOT-BAT-NEXT: [hot text], 0x800000, 0x8002cc, 38.7595, 91.6667, 0.3553
38+
CHECK-HOT-SYMS: 800000 W __hot_start
39+
CHECK-HOT-SYMS: 8002cc W __hot_end

‎clang/docs/CMakeLists.txt

Copy file name to clipboardExpand all lines: clang/docs/CMakeLists.txt
+28Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,34 @@ if (LLVM_ENABLE_SPHINX)
134134
gen_rst_file_from_td(DiagnosticsReference.rst -gen-diag-docs ../include/clang/Basic/Diagnostic.td "${docs_targets}")
135135
gen_rst_file_from_td(ClangCommandLineReference.rst -gen-opt-docs ../include/clang/Driver/ClangOptionDocs.td "${docs_targets}")
136136

137+
# Another generated file from a different source
138+
set(docs_tools_dir ${CMAKE_CURRENT_SOURCE_DIR}/tools)
139+
set(aopts_rst_rel_path analyzer/user-docs/Options.rst)
140+
set(aopts_rst "${CMAKE_CURRENT_BINARY_DIR}/${aopts_rst_rel_path}")
141+
set(analyzeroptions_def "${CMAKE_CURRENT_SOURCE_DIR}/../include/clang/StaticAnalyzer/Core/AnalyzerOptions.def")
142+
set(aopts_rst_in "${CMAKE_CURRENT_SOURCE_DIR}/${aopts_rst_rel_path}.in")
143+
add_custom_command(
144+
OUTPUT ${aopts_rst}
145+
COMMAND ${Python3_EXECUTABLE} generate_analyzer_options_docs.py
146+
--options-def "${analyzeroptions_def}"
147+
--template "${aopts_rst_in}"
148+
--out "${aopts_rst}"
149+
WORKING_DIRECTORY ${docs_tools_dir}
150+
VERBATIM
151+
COMMENT "Generating ${aopts_rst}"
152+
DEPENDS ${docs_tools_dir}/${generate_aopts_docs}
153+
${aopts_rst_in}
154+
copy-clang-rst-docs
155+
)
156+
add_custom_target(generate-analyzer-options-rst DEPENDS ${aopts_rst})
157+
foreach(target ${docs_targets})
158+
add_dependencies(${target} generate-analyzer-options-rst)
159+
endforeach()
160+
161+
# Technically this is redundant because generate-analyzer-options-rst
162+
# depends on the copy operation (because it wants to drop a generated file
163+
# into a subdirectory of the copied tree), but I'm leaving it here for the
164+
# sake of clarity.
137165
foreach(target ${docs_targets})
138166
add_dependencies(${target} copy-clang-rst-docs)
139167
endforeach()

‎clang/docs/ReleaseNotes.rst

Copy file name to clipboardExpand all lines: clang/docs/ReleaseNotes.rst
+17-4Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -520,15 +520,12 @@ Improvements to Clang's diagnostics
520520
- Several compatibility diagnostics that were incorrectly being grouped under
521521
``-Wpre-c++20-compat`` are now part of ``-Wc++20-compat``. (#GH138775)
522522

523-
- Improved the ``-Wtautological-overlap-compare`` diagnostics to warn about overlapping and non-overlapping ranges involving character literals and floating-point literals.
523+
- Improved the ``-Wtautological-overlap-compare`` diagnostics to warn about overlapping and non-overlapping ranges involving character literals and floating-point literals.
524524
The warning message for non-overlapping cases has also been improved (#GH13473).
525525

526526
- Fixed a duplicate diagnostic when performing typo correction on function template
527527
calls with explicit template arguments. (#GH139226)
528528

529-
- An error is now emitted when OpenMP ``collapse`` and ``ordered`` clauses have an
530-
argument larger than what can fit within a 64-bit integer.
531-
532529
- Explanatory note is printed when ``assert`` fails during evaluation of a
533530
constant expression. Prior to this, the error inaccurately implied that assert
534531
could not be used at all in a constant expression (#GH130458)
@@ -712,6 +709,7 @@ Bug Fixes to C++ Support
712709
- Fixed the handling of pack indexing types in the constraints of a member function redeclaration. (#GH138255)
713710
- Clang now correctly parses arbitrary order of ``[[]]``, ``__attribute__`` and ``alignas`` attributes for declarations (#GH133107)
714711
- Fixed a crash when forming an invalid function type in a dependent context. (#GH138657) (#GH115725) (#GH68852)
712+
- Clang no longer segfaults when there is a configuration mismatch between modules and their users (http://crbug.com/400353616).
715713

716714
Bug Fixes to AST Handling
717715
^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -937,6 +935,21 @@ OpenMP Support
937935
- Added support 'no_openmp_constructs' assumption clause.
938936
- Added support for 'self_maps' in map and requirement clause.
939937
- Added support for 'omp stripe' directive.
938+
- Fixed a crashing bug with ``omp unroll partial`` if the argument to
939+
``partial`` was an invalid expression. (#GH139267)
940+
- Fixed a crashing bug with ``omp tile sizes`` if the argument to ``sizes`` was
941+
an invalid expression. (#GH139073)
942+
- Fixed a crashing bug with ``omp simd collapse`` if the argument to
943+
``collapse`` was an invalid expression. (#GH138493)
944+
- Fixed a crashing bug with a malformed ``cancel`` directive. (#GH139360)
945+
- Fixed a crashing bug with ``omp distribute dist_schedule`` if the argument to
946+
``dist_schedule`` was not strictly positive. (#GH139266)
947+
- Fixed two crashing bugs with a malformed ``metadirective`` directive. One was
948+
a crash if the next token after ``metadirective`` was a paren, bracket, or
949+
brace. The other was if the next token after the meta directive was not an
950+
open parenthesis. (#GH139665)
951+
- An error is now emitted when OpenMP ``collapse`` and ``ordered`` clauses have
952+
an argument larger than what can fit within a 64-bit integer.
940953
- Added support for private variable reduction.
941954

942955
Improvements

‎clang/docs/analyzer/user-docs.rst

Copy file name to clipboardExpand all lines: clang/docs/analyzer/user-docs.rst
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Contents:
88

99
user-docs/Installation
1010
user-docs/CommandLineUsage
11+
user-docs/Options
1112
user-docs/UsingWithXCode
1213
user-docs/FilingBugs
1314
user-docs/CrossTranslationUnit

‎clang/docs/analyzer/user-docs/CommandLineUsage.rst

Copy file name to clipboardExpand all lines: clang/docs/analyzer/user-docs/CommandLineUsage.rst
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,8 @@ When compiling your application to run on the simulator, it is important that **
194194

195195
If you aren't certain which compiler Xcode uses to build your project, try just running ``xcodebuild`` (without **scan-build**). You should see the full path to the compiler that Xcode is using, and use that as an argument to ``--use-cc``.
196196

197+
.. _command-line-usage-CodeChecker:
198+
197199
CodeChecker
198200
-----------
199201

+114Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
========================
2+
Configuring the Analyzer
3+
========================
4+
5+
The clang static analyzer supports two kinds of options:
6+
7+
1. Global **analyzer options** influence the behavior of the analyzer engine.
8+
They are documented on this page, in the section :ref:`List of analyzer
9+
options<list-of-analyzer-options>`.
10+
2. The **checker options** belong to individual checkers (e.g.
11+
``core.BitwiseShift:Pedantic`` and ``unix.Stream:Pedantic`` are completely
12+
separate options) and customize the behavior of that particular checker.
13+
These are documented within the documentation of each individual checker at
14+
:doc:`../checkers`.
15+
16+
Assigning values to options
17+
===========================
18+
19+
With the compiler frontend
20+
--------------------------
21+
22+
All options can be configured by using the ``-analyzer-config`` flag of ``clang
23+
-cc1`` (the so-called *compiler frontend* part of clang). The values of the
24+
options are specified with the syntax ``-analyzer-config
25+
OPT=VAL,OPT2=VAL2,...`` which supports specifying multiple options, but
26+
separate flags like ``-analyzer-config OPT=VAL -analyzer-config OPT2=VAL2`` are
27+
also accepted (with equivalent behavior). Analyzer options and checker options
28+
can be freely intermixed here because it's easy to recognize that checker
29+
option names are always prefixed with ``some.groups.NameOfChecker:``.
30+
31+
.. warning::
32+
This is an internal interface, one should prefer `clang --analyze ...` for
33+
regular use. Clang does not intend to preserve backwards compatibility or
34+
announce breaking changes within the flags accepted by ``clang -cc1``
35+
(but ``-analyzer-config`` survived many years without major changes).
36+
37+
With the clang driver
38+
---------------------
39+
40+
In a conventional workflow ``clang -cc1`` (which is a low-level internal
41+
interface) is invoked indirectly by the clang *driver* (i.e. plain ``clang``
42+
without the ``-cc1`` flag), which acts as an "even more frontend" wrapper layer
43+
around the ``clang -cc1`` *compiler frontend*. In this situation **each**
44+
command line argument intended for the *compiler frontend* must be prefixed
45+
with ``-Xclang``.
46+
47+
For example the following command analyzes ``foo.c`` in :ref:`shallow mode
48+
<analyzer-option-mode>` with :ref:`loop unrolling
49+
<analyzer-option-unroll-loops>`:
50+
51+
::
52+
53+
clang --analyze -Xclang -analyzer-config -Xclang mode=shallow,unroll-loops=true foo.c
54+
55+
When this is executed, the *driver* will compose and execute the following
56+
``clang -cc1`` command (which can be inspected by passing the ``-v`` flag to
57+
the *driver*):
58+
59+
::
60+
61+
clang -cc1 -analyze [...] -analyzer-config mode=shallow,unroll-loops=true foo.c
62+
63+
Here ``[...]`` stands for dozens of low-level flags which ensure that ``clang
64+
-cc1`` does the right thing (e.g. ``-fcolor-diagnostics`` when it's suitable;
65+
``-analyzer-checker`` flags to enable the default set of checkers). Also
66+
note the distinction that the ``clang`` *driver* requires ``--analyze`` (double
67+
dashes) while the ``clang -cc1`` *compiler frontend* requires ``-analyze``
68+
(single dash).
69+
70+
.. note::
71+
The flag ``-Xanalyzer`` is equivalent to ``-Xclang`` in these situations
72+
(but doesn't forward other options of the clang frontend).
73+
74+
With CodeChecker
75+
----------------
76+
77+
If the analysis is performed through :ref:`CodeChecker
78+
<command-line-usage-CodeChecker>` (which e.g. supports the analysis of a whole
79+
project instead of a single file) then it will act as another indirection
80+
layer. CodeChecker provides separate command-line flags called
81+
``--analyzer-config`` (for analyzer options) and ``--checker-config`` (for
82+
checker options):
83+
84+
::
85+
86+
CodeChecker analyze -o outdir --checker-config clangsa:unix.Stream:Pedantic=true \
87+
--analyzer-config clangsa:mode=shallow clangsa:unroll-loops=true \
88+
-- compile_commands.json
89+
90+
These CodeChecker flags may be followed by multiple ``OPT=VAL`` pairs as
91+
separate arguments (and this is why the example needs to use ``--`` before
92+
``compile_commands.json``). The option names are all prefixed with ``clangsa:``
93+
to ensure that they are passed to the clang static analyzer (and not other
94+
analyzer tools that are also supported by CodeChecker).
95+
96+
.. _list-of-analyzer-options:
97+
98+
List of analyzer options
99+
========================
100+
101+
.. warning::
102+
These options are primarily intended for development purposes and
103+
non-default values are usually unsupported. Changing their values may
104+
drastically alter the behavior of the analyzer, and may even result in
105+
instabilities or crashes! Crash reports are welcome and depending on the
106+
severity they may be fixed.
107+
108+
..
109+
The contents of this section are automatically generated by the script
110+
clang/docs/tools/generate_analyzer_options_docs.py from the header file
111+
AnalyzerOptions.def to ensure that the RST/web documentation is synchronized
112+
with the command line help options.
113+
114+
.. OPTIONS_LIST_PLACEHOLDER

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.