[analyzer][NFC] BugReporterVisitors.h should include MemRegion.h
BugReporterVisitors.h includes RangedConstraintManager.h but uses
nothing it declares: RangeSet, Range, ConstraintMap and
SimpleConstraintManager appear nowhere in the file. What the header
actually needs is MemRegion.h, which supplies SubRegion,
MemRegionManager and MemRegion completeness for an inline constructor;
today those arrive only by accident, transitively through
RangedConstraintManager.h -> ProgramState.h. Swapping the include for
the one that carries the used declarations makes the dependency honest
and adds a forward declaration of CallEvent in namespace clang::ento
for the one name that only needs to be incomplete.
One header needs a compensating include: Z3CrosscheckVisitor.h uses
ConstraintMap and was getting RangedConstraintManager.h through
BugReporterVisitors.h, so it now includes it directly. No translation
unit in clangStaticAnalyzerCore, clangStaticAnalyzerCheckers or
clangStaticAnalyzerFrontend required any other change.
[3 lines not shown]
[analyzer][NFC] Forward-declare Preprocessor in AnalysisManager.h (#235282)
AnalysisManager.h includes clang/Lex/Preprocessor.h, and through that
one edge the whole Lex subtree -- roughly 34 headers, among them
Basic/Module.h, HeaderSearch.h and ModuleMap.h -- is parsed by 147 of
the 197 translation units in clangStaticAnalyzerCore,
clangStaticAnalyzerCheckers and clangStaticAnalyzerFrontend. The
mechanism is transitive inclusion: AnalysisManager.h sits under almost
every analyzer source, so almost every one of them pays for the
preprocessor without naming it.
Preprocessor is used here only as a reference member, a constructor
parameter and a reference-returning accessor; no member of it is ever
named, so a forward declaration in namespace clang suffices and the
generated code is identical. The include is replaced by
clang/Basic/SourceManager.h rather than simply dropped, because
isInCodeFile() calls SM.isInMainFile(), SM.getIncludeLoc(),
SM.getFileID() and SM.getFilename(), and SourceManager is otherwise
unreachable from this header once Preprocessor.h is gone. That swap is
[20 lines not shown]
[MemProf] Use consistent trim vs prune terminology in comments (NFC) (#235336)
Throughout the MemProf code, the intention is that "trimming" refers to
removing the portion of an allocation context toward the root that is
not needed to distinguish cold from non-cold contexts, while "pruning"
refers to removing entire unneeded contexts (e.g. small unimportant
non-cold contexts). Several comments in MemProfContextDisambiguation and
a few tests incorrectly used "pruning" when referring to context
trimming. Update them to use "trimming" for consistency with
MemoryProfileInfo.
Assisted-by: Gemini
[GlobalISel] Check binary flags before matching operands (#235451)
Reject instructions missing required flags before evaluating either
operand pattern in BinaryOp_match. This avoids unnecessary recursive
matching and output bindings for instructions that cannot match.
Assisted by: GPT 6.1-Sol
[BPF] Keep mov and shift that have other users when removing a zext (#235210)
BPFMIPeephole replaces
%2 = MOV_32_64 %1
%3 = SLL_ri %2, 32
%4 = SRL_ri %3, 32
with SUBREG_TO_REG when %1 is known to be zero extended, and erases all
three insns. %2 and %3 can have other users, which then read a register
that nothing defines: "Reading virtual register without a def" with
assertions, whatever the allocator picks without them.
Erase the mov and the left shift only when they have no other users
Co-authored-by: Alexei Starovoitov <ast at kernel.org>
[LoopInterchange] Rename perserve-lcssa.ll and regenerate test checks (NFC) (#235476)
This patch fixes the followings:
- Fix typo in the filename (perserve -> preserve)
- Use UTC instead of hand written CHECKs
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[analyzer][NFC] BugReporterVisitors.h should include MemRegion.h
BugReporterVisitors.h includes RangedConstraintManager.h but uses
nothing it declares: RangeSet, Range, ConstraintMap and
SimpleConstraintManager appear nowhere in the file. What the header
actually needs is MemRegion.h, which supplies SubRegion,
MemRegionManager and MemRegion completeness for an inline constructor;
today those arrive only by accident, transitively through
RangedConstraintManager.h -> ProgramState.h. Swapping the include for
the one that carries the used declarations makes the dependency honest
and adds a forward declaration of CallEvent in namespace clang::ento
for the one name that only needs to be incomplete.
One header needs a compensating include: Z3CrosscheckVisitor.h uses
ConstraintMap and was getting RangedConstraintManager.h through
BugReporterVisitors.h, so it now includes it directly. No translation
unit in clangStaticAnalyzerCore, clangStaticAnalyzerCheckers or
clangStaticAnalyzerFrontend required any other change.
[3 lines not shown]
[analyzer][NFC] Forward-declare Preprocessor in AnalysisManager.h
AnalysisManager.h includes clang/Lex/Preprocessor.h, and through that
one edge the whole Lex subtree -- roughly 34 headers, among them
Basic/Module.h, HeaderSearch.h and ModuleMap.h -- is parsed by 147 of
the 197 translation units in clangStaticAnalyzerCore,
clangStaticAnalyzerCheckers and clangStaticAnalyzerFrontend. The
mechanism is transitive inclusion: AnalysisManager.h sits under almost
every analyzer source, so almost every one of them pays for the
preprocessor without naming it.
Preprocessor is used here only as a reference member, a constructor
parameter and a reference-returning accessor; no member of it is ever
named, so a forward declaration in namespace clang suffices and the
generated code is identical. The include is replaced by
clang/Basic/SourceManager.h rather than simply dropped, because
isInCodeFile() calls SM.isInMainFile(), SM.getIncludeLoc(),
SM.getFileID() and SM.getFilename(), and SourceManager is otherwise
unreachable from this header once Preprocessor.h is gone. That swap is
[21 lines not shown]
[analyzer][NFC] Forward-declare Preprocessor in BugReporter.h (#235281)
BugReporter.h includes clang/Lex/Preprocessor.h, and that single edge
pulls the whole Lex subtree -- roughly 34 headers, among them
Basic/Module.h, HeaderSearch.h and ModuleMap.h -- into 161 of the 197
translation units that make up clangStaticAnalyzerCore,
clangStaticAnalyzerCheckers and clangStaticAnalyzerFrontend. The
mechanism is transitive inclusion, not any use of the preprocessor:
nearly every analyzer source reaches BugReporter.h, so nearly every one
of them parses Preprocessor.h and everything it brings with it.
The include is not needed. Preprocessor appears in this header only as a
reference return type in three declarations, and no member of it is ever
named, so a forward declaration in namespace clang suffices and the
generated code is identical. Eight .cpp files were relying on
SourceManager completeness arriving through Preprocessor.h and now
include clang/Basic/SourceManager.h directly; that is the only
compensating change, and no translation unit needed Preprocessor.h
added back.
[13 lines not shown]
[ELF] Resolve the CIE of each FDE when splitting .eh_frame. NFC (#235492)
EhFrameSection::addRecords and iterateFDEWithinLSDA look up each FDE's
CIE by input offset in a DenseMap/DenseSet. Simplify by recording the
CIE's index in the same section when splitting it.
Narrow inputOff to uint32_t and reject .eh_frame input sections larger
than 4GiB as for MergeInputSection.
[LLDB] Skip Undef Symbol when resolving ReExportedSymbol (#235387)
An undef symbol cannot be resolved. Skip it so that a symbol needs no
Resolve can pass. Without this, a symbol that needs no ReExport resolver
can choose the undef symbol incorrectly.
Assisted-by: Claude # Test
[RISCV][P-ext] Test cleanup and improvements. NFC (#235322)
-Use script to generate pnclip tests in rvp-intrinsics.c
-Add missing pnclip tests to riscv_packed_simd.c
-Add missing tests to rvp-intrinsics.c
TableGen: Narrow instregex matching to leading literal alternatives
instregex ran the regex on every instruction if a pattern had no literal
prefix, even when it started with literal alternatives like ^(S|U)CVTF
or [SU]ABD. Search for each prefix those allow, here SCVTF and UCVTF,
and keep the original instruction order. Add a test for which patterns
get prefixes.
AArch64GenSubtargetInfo.inc tablegen run:
Gigainstructions Gigacycles CPU seconds
Before 43.1 17.8 5.4
After 29.0 (-32.6%) 12.0 (-32.5%) 3.7 (-31.4%)
All 366 tablegen runs in an LLVM build with all targets, together with
the previous change to keep the prefix for patterns with a top-level ?:
Gigainstructions Gigacycles CPU seconds
Before 2189 1380 489
[3 lines not shown]
TableGen: Keep the instregex prefix for patterns with a top-level ?
instregex discarded a pattern's literal prefix, and ran the regex on
every instruction, if the pattern had a ? outside parentheses, as in
LDPS?Wi. A ? only makes the atom before it optional, and an atom
directly before it is already dropped from the prefix. Only a top-level
| makes the prefix unusable.
AArch64GenSubtargetInfo.inc tablegen run:
Gigainstructions Gigacycles CPU seconds
Before 44.6 18.8 5.7
After 43.1 (-3.4%) 17.8 (-4.9%) 5.4 (-4.6%)
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
TableGen: Match each instregex pattern only once
Scheduling models use the same instregex patterns many times, and every
use matched the pattern against the instruction names again. AArch64
evaluates 12501 patterns, only 4344 of them distinct, for a total of 34
million regex matches. Cache the instructions each pattern matches, so a
repeated pattern costs a lookup.
AArch64GenSubtargetInfo.inc tablegen run:
Gigainstructions Gigacycles CPU seconds
Before 67.9 31.1 9.4
After 44.6 (-34.3%) 18.8 (-39.6%) 5.7 (-39.1%)
All 366 tablegen runs in an LLVM build with all targets:
Gigainstructions Gigacycles CPU seconds
Before 2252 1409 499
After 2188 (-2.8%) 1380 (-2.1%) 489 (-1.9%)
[2 lines not shown]