Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
143 commits
Select commit Hold shift + click to select a range
399d7cc
[CodeGen] Use MachineInstr::all_defs (NFC) (#106017)
kazutakahirata Aug 26, 2024
d9e7286
[NFC][clang][bytecode] Rename `clang::interp::State::getCtx` to `clan…
yronglin Aug 26, 2024
06ccd32
[lldb][NFC] Moved the SharedSocket class to Socket.* (#104787)
slydiman Aug 26, 2024
41f2f1f
[SCCP] Add tests for non-null pointers (NFC)
nikic Aug 26, 2024
46a4132
[Instrumentation] Fix EdgeCounts vector size in SetBranchWeights (#99…
avikivity Aug 26, 2024
a195e2d
[MLIR][OpenMP] Handle privatization for global values in MLIR->LLVM t…
ergawy Aug 26, 2024
0e24c32
[SCCP] Avoid some uses of SCCPSolver::isOverdefined (NFCI)
nikic Aug 26, 2024
ea625f4
[Xtensa] Implement sextload i8 (#106053)
andreisfr Aug 26, 2024
762cb44
[Mips] Use a range-based for loop (NFC) (#106004)
kazutakahirata Aug 26, 2024
bc695f5
[libc++][test] Add missing <concepts> in is_always_lock_free test (#1…
StephanTLavavej Aug 26, 2024
5a288b9
[Clang] Evaluate dependent indexes of pack indexing in a constant con…
cor3ntin Aug 26, 2024
0f58ab8
[libc++] Undo unintended renaming in bc695f522743
ldionne Aug 26, 2024
ee737c3
[mlir][linalg] Exclude non-convolutional ops from isaConvolutionOpInt…
yifeizh2 Aug 26, 2024
e04d124
[libc++] Call basic_string_view's assume-valid constructor from basic…
cjdb Aug 26, 2024
121ed07
[MC][NFC] Count pseudo probes and function records
aaupov Aug 26, 2024
04ebd19
[MC][NFC] Statically allocate storage for decoded pseudo probes and f…
aaupov Aug 26, 2024
ee09f7d
[MC][NFC] Reduce Address2ProbesMap size
aaupov Aug 26, 2024
a79cf02
[MC][NFC] Use vector for GUIDProbeFunctionMap
aaupov Aug 26, 2024
c1b3ebb
[MC] Update MCOperand::getReg/setReg/createReg and MCInstBuilder::add…
topperc Aug 26, 2024
625e929
[SLP][NFC]Add a test with incorrect reduced gather node with extra us…
alexey-bataev Aug 26, 2024
2e426fe
Add unit tests for size returning new funcs in the MemProf use pass. …
Aug 26, 2024
7106643
[libc++][NFC] Don't explicitly provide propagate_on_container_swap wh…
philnik777 Aug 26, 2024
7af61d5
[flang][cuda] Add shape to cuf.data_transfer operation (#104631)
clementval Aug 26, 2024
bbf2781
[lldb] Reformat comment (NFC)
adrian-prantl Aug 26, 2024
c073821
[RISCV] Reduce VL of vmerge.vvm's true operand (#105786)
lukel97 Aug 26, 2024
2ef3dcf
[mlir] Fix a warning
kazutakahirata Aug 26, 2024
ec4d5a6
[LLD][COFF] Preserve original symbol name when resolving weak aliases…
cjacek Aug 26, 2024
4bab038
[HLSL] Add __builtin_hlsl_is_scalarized_layout_compatible (#102227)
llvm-beanz Aug 26, 2024
ff5816a
[DirectX] Add `all` lowering (#105787)
farzonl Aug 26, 2024
643bf6c
[scudo] Add partial chunk heuristic to retrieval algorithm. (#105009)
JoshuaMBa Aug 26, 2024
1387ba4
[MLIR][AMDGPU] Introduce fp16 packed arithmetic (#105688)
giuseros Aug 26, 2024
924a7d8
Use CLANG_RESOURCE_DIR more consistently (#103388)
kimgr Aug 26, 2024
f099f76
[flang] Handle pp-directives better in line continuation (#105572)
klausler Aug 26, 2024
2326a02
[flang] Support read-only access to an anonymous unit (#105859)
klausler Aug 26, 2024
b52728d
[flang] Silence warning when inappropriate (#105867)
klausler Aug 26, 2024
047168d
[flang] Fix parser crash (#105875)
klausler Aug 26, 2024
f428f5f
[flang][runtime] Add alternate SELECTED_(INT|REAL)_KIND APIs (#105887)
klausler Aug 26, 2024
c4b7c47
[scudo] Fix expectation in ScudoTimingTest.VerifyMax (#106062)
fabio-d Aug 26, 2024
961a138
[flang] Silence spurious error (#106086)
klausler Aug 26, 2024
7cc789b
[flang] Silence spurious errors from benign USE errors (#106097)
klausler Aug 26, 2024
4e30cf7
[LTO] Introduce getSourceModules (NFC) (#105955)
kazutakahirata Aug 26, 2024
7fc67b5
[bazel] Port 1387ba48a312b6e9b174d850f8c9a1322f44c623
d0k Aug 26, 2024
9b00ef5
Revert "Add unit tests for size returning new funcs in the MemProf us…
Aug 26, 2024
d88876e
[SandboxIR] Implement FenceInst (#105920)
Aug 26, 2024
4b0c0ec
[CodeGen] Use MCRegister for CCState::AllocateReg and CCValAssign::ge…
topperc Aug 26, 2024
e1d2251
[SLP]Fix minbitwidth analysis for gather nodes with icmp users.
alexey-bataev Aug 26, 2024
89c27d6
[lldb-dap] Enabling instruction breakpoint support to lldb-dap. (#105…
santhoshe447 Aug 26, 2024
2d37e48
[compiler-rt][test] Add REQUIRES: shell in tests that use the `ulimit…
Harini0924 Aug 26, 2024
a35398d
[LLD][COFF] Generate redirection metadata for custom ARM64EC export t…
cjacek Aug 26, 2024
bfc7540
[libc] Fix file collision causing test flake (#106119)
michaelrj-google Aug 26, 2024
b1e0589
[SPIRV][test] Make debug info test robust to unix/windows differences…
bogner Aug 26, 2024
34dee0a
[TableGen] Allow emitter callbacks to use `const RecordKeeper &` (#10…
jurahul Aug 26, 2024
178fc47
[LLVM][rtsan] Add LLVM nosanitize_realtime attribute (#105447)
cjappl Aug 26, 2024
e1cf849
[LLD][COFF] Use parentName for import files in toString. (#106104)
cjacek Aug 26, 2024
7945435
[clang] Add support for omitting only global destructors (#104899)
smeenai Aug 26, 2024
f05145c
[docs] Modernize statepoint documentation
preames Aug 26, 2024
e8b93ce
[SandboxIR] Implement LandingPadInst (#106116)
Aug 26, 2024
2e0583e
[AMDGPU][CodeGen][NFC] update a mir test file with latest update_mir_…
broxigarchen Aug 26, 2024
c821cc3
[Clang] Correctly finds subexpressions of immediate invocations (#106…
cor3ntin Aug 26, 2024
a959d70
[MLGO] Remove Python <3.8 from unsupported config (#106132)
boomanaiden154 Aug 26, 2024
70ffcfe
[SPIRV] Fix build after change in transitive includes (#106140)
bogner Aug 26, 2024
824cffe
[GC] Rename gc_args to gc_live [nfc]
preames Aug 26, 2024
7134d2e
[SimplifyLibCalls] Fix memchr misoptimization (#106121)
s-barannikov Aug 26, 2024
8e3aa7e
[libc++] Fix CMake cache for the hardening with ABI breaks CI (#105864)
ldionne Aug 26, 2024
85561dd
[libc++] Fix bounded iterator hardening mode in C++03 mode
ldionne Aug 26, 2024
2a5ac9d
[SandboxIR] Implement FreezeInst (#106133)
Aug 26, 2024
06edc1c
[libc++] Avoid including <__config> directly in the test suite (#106080)
ldionne Aug 26, 2024
3b0a1ec
[SandboxIR] Implement PossiblyDisjointInst (#106148)
Aug 26, 2024
31204b4
[scudo] Make comment compatible with gcc (#106137)
Caslyn Aug 26, 2024
af4a82e
[SandboxIR] Implement PossiblyNonNegInst (#106149)
Aug 26, 2024
82579f9
[mlir][Python] Make `PyShapedType` public (#106105)
matthias-springer Aug 26, 2024
9007864
[compiler-rt][tests] Fix env command not found errors with lit intern…
Harini0924 Aug 26, 2024
7f04a8a
[mlir][func][bufferization] Fix cast incompatible when bufferize call…
CoTinker Aug 26, 2024
32acf1e
[RISCV] Use XLenVT as LocVT for f16/f32/f164 with Zfinx in CC_RISCV_F…
topperc Aug 26, 2024
c3776c1
Revert "[MLGO] Remove Python <3.8 from unsupported config (#106132)"
boomanaiden154 Aug 26, 2024
58eec85
[DirectX] Move resource logic into PrettyPrinter and TranslateMetadat…
bogner Aug 26, 2024
4b3f147
[rtsan][compiler-rt] Add missing calloc unit test (#106159)
cjappl Aug 26, 2024
bcde45b
[NFC][TableGen] Refactor JSON and detailed record emitter (#105770)
jurahul Aug 26, 2024
79154a9
[docs] Document the missing availability platforms and environments (…
ian-twilightcoder Aug 27, 2024
daa7923
[DirectX] Implement metadata lowering for resources
bogner Aug 27, 2024
296ffc1
[RISCV] Don't check hasStdExtZfh and hasStdExtZfhmin. NFC
topperc Aug 26, 2024
2a50dac
[RISCV][TTI]Fix the cost estimation for long select shuffle.
alexey-bataev Aug 27, 2024
87157ab
[DirectX] Add resource handling to the DXIL pretty printer
bogner Aug 27, 2024
b412ec5
[Clang][Sema] Revisit the fix for the lambda within a type alias temp…
zyn0217 Aug 27, 2024
8e901c2
[PowerPC] Retire PPCExpandISel pass (#84289)
bzEq Aug 27, 2024
085587e
Reland "[MLGO] Remove Python <3.8 from unsupported config (#106132)"
boomanaiden154 Aug 27, 2024
1200d35
[IR] Bump AttributeBitSet width to 16 bytes (#106138)
yuxuanchen1997 Aug 27, 2024
b01c006
[TII][RISCV] Add renamable bit to copyPhysReg (#91179)
BeMg Aug 27, 2024
38c3855
[NFC] Remove unused argument (FuncName) for parseMIR (#106144)
kyulee-com Aug 27, 2024
c8cac33
[MLIR][Python] add f8E5M2 and tests for np_to_memref (#106028)
PhrygianGates Aug 27, 2024
ce2b488
[mlir] ThreadLocalCache: make TSAN happy about destructors (#106170)
Aug 27, 2024
1990d8d
[llvm-lit][test] Resolved typo in raising InternalShellError for expo…
connieyzhu Aug 27, 2024
952b133
[clang][compiler-rt][test] Removed dirname command substitutions from…
connieyzhu Aug 27, 2024
d28c0fb
[compiler-rt][tests] Removed the use of parentheses in compiler-rt te…
Harini0924 Aug 27, 2024
823e942
[compiler-rt][test] Expand and Rewrite Tests for lit Internal Shell C…
Harini0924 Aug 27, 2024
3b79468
[compiler-rt][test] Add REQUIRES: shell to focus-function.test with f…
Harini0924 Aug 27, 2024
f54ae6d
[RISCV] Merge duplicate switch cases. NFC
topperc Aug 27, 2024
0ef8e71
[RISCV] Custom legalize vXbf16 BUILD_VECTOR without Zfbfmin.
topperc Aug 27, 2024
1cea5c2
[SCCP] Propagate non-null pointers (#106090)
nikic Aug 27, 2024
b45527d
[clang-tidy] Add UseUpperCaseLiteralSuffix option to readability-impl…
da-viper Aug 27, 2024
57c1e21
pre-commit test for #106195 (#106196)
FreddyLeaf Aug 27, 2024
3d1c63e
[SLP][REVEC] Expand getelementptr into vector form. (#103704)
HanKuanChen Aug 27, 2024
cb9267f
[mlir][vector] Rename LowerVectorToLLVM to ConvertVectorToLLVM (NFC) …
nujaa Aug 27, 2024
73834f4
[SPIR-V] Fix vload_half builtin argument count (#105585)
konrad11901 Aug 27, 2024
0caa909
[Analysis][NFC] Use SmallVectorImpl consistently in ScalarEvolution (…
david-arm Aug 27, 2024
8f6864e
[gn build] Port 5f6172f0684b
nico Aug 27, 2024
27ec464
[gn build] Port 7bc9d95b7e5a
nico Aug 27, 2024
1deae20
[gn build] Port 89c27d6b07dd
nico Aug 27, 2024
df00828
[gn build] Port 8e901c255df4
nico Aug 27, 2024
9a4bf2c
[gn build] Port cbf34a5f7701
nico Aug 27, 2024
4b7f07a
[gn build] Port db94852b9b4c
nico Aug 27, 2024
d4f97da
[mlir] Support emit fp16 and bf16 type to cpp (#105803)
jacquesguan Aug 27, 2024
0ea0ecd
[flang][driver] apply mlir pass options immediately after lowering (#…
jeanPerier Aug 27, 2024
fac484c
[clang-format-diff.py][NFC] Document _stderr as unused
Aug 27, 2024
1e15346
MIPS: Add fcanonicalize for pre-R6 (#104554)
wzssyqa Aug 27, 2024
d07dc73
[flang][debug] Support derived types. (#99476)
abidh Aug 27, 2024
fbef4c2
[lldb][lldb-dap] Fix for TestDAP_instruction_breakpoint.py test failu…
santhoshe447 Aug 27, 2024
ca3b9af
Add logs for SymbolFileDWARF::FindTypes (#106030)
DmT021 Aug 27, 2024
a2088a2
[ARM] musttail fixes
kiran-isaac Aug 8, 2024
1a908c6
Seperate frontend changes, add debug directives, remove redundant stu…
kiran-isaac Aug 27, 2024
ad468da
Revert "Seperate frontend changes, add debug directives, remove redun…
kiran-isaac Aug 27, 2024
bc4bedd
[mlir][debug] Handle DIImportedEntity. (#103055)
abidh Aug 27, 2024
c50d11e
Revert "[ARM] musttail fixes"
kiran-isaac Aug 27, 2024
7c188ab
[mlir][LLVMIR][OpenMP] Move reduction allocas before stores (#105683)
tblah Aug 27, 2024
d43a809
Revert "[LAA] Remove loop-invariant check added in 234cc40adc61."
fhahn Aug 27, 2024
f8b4460
[LLVM][AArch64] Improve big endian code generation for SVE BITCASTs. …
paulwalker-arm Aug 27, 2024
063e0bd
[MLIR][DLTI] Enable types as keys in DLTI-query utils (#105995)
rolfmorel Aug 27, 2024
6f62757
[MLIR][OpenMP] NFC: Update parallel workshare loop reduction tests (#…
skatrak Aug 27, 2024
4f33e7c
[analyzer] Report violations of the "returns_nonnull" attribute (#106…
necto Aug 27, 2024
b1b24d7
[clang][ExtractAPI] Fix quirks in interaction with submodules (#105868)
daniel-grumberg Aug 27, 2024
44d527c
NFC: precommit test for [ArgPromotion] Perform alias analysis on actu…
hazzlim Aug 22, 2024
974d8f6
[docs] Fix a documentation link (#105795)
pfusik Aug 27, 2024
9b4a8f4
[SLP][NFC]Improve auto types, NFC.
alexey-bataev Aug 27, 2024
ed1c1da
[SCCP] Add tests for more non-null roots (NFC)
nikic Aug 27, 2024
3d2fd31
[clang] Add nuw attribute to GEPs (#105496)
hazzlim Aug 27, 2024
78505ad
[AMDGPU] Use range-based for loops (NFC) (#106184)
kazutakahirata Aug 27, 2024
71eebe9
[llvm] Prefer StringRef::substr to StringRef::slice (NFC) (#106190)
kazutakahirata Aug 27, 2024
721fdf1
[LoopUnrollAnalyzer] Store SimplifiedAddress offset as APInt (NFC)
nikic Aug 27, 2024
3250305
[LoopUnrollAnalyzer] Use computeConstantDifference()
nikic Aug 27, 2024
657f26f
[SCCP] Add more non-null roots
nikic Aug 27, 2024
c992690
Revert "[nfc][mlgo] Incrementally update DominatorTreeAnalysis in Fun…
zmodem Aug 27, 2024
556e9d0
[rtsan][compiler-rt] Add read, write, pread, pwrite, readv, and write…
cjappl Aug 27, 2024
ee564ab
[LLVM][rtsan] Add nosanitize_realtime instrumentation
cjappl Aug 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
14 changes: 6 additions & 8 deletions bolt/lib/Profile/DataAggregator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2415,17 +2415,15 @@ std::error_code DataAggregator::writeBATYAML(BinaryContext &BC,
Fragments.insert(BF);
for (const BinaryFunction *F : Fragments) {
const uint64_t FuncAddr = F->getAddress();
const auto &FragmentProbes =
llvm::make_range(ProbeMap.lower_bound(FuncAddr),
ProbeMap.lower_bound(FuncAddr + F->getSize()));
for (const auto &[OutputAddress, Probes] : FragmentProbes) {
for (const MCDecodedPseudoProbe &Probe :
ProbeMap.find(FuncAddr, FuncAddr + F->getSize())) {
const uint32_t OutputAddress = Probe.getAddress();
const uint32_t InputOffset = BAT->translate(
FuncAddr, OutputAddress - FuncAddr, /*IsBranchSrc=*/true);
const unsigned BlockIndex = getBlock(InputOffset).second;
for (const MCDecodedPseudoProbe &Probe : Probes)
YamlBF.Blocks[BlockIndex].PseudoProbes.emplace_back(
yaml::bolt::PseudoProbeInfo{Probe.getGuid(), Probe.getIndex(),
Probe.getType()});
YamlBF.Blocks[BlockIndex].PseudoProbes.emplace_back(
yaml::bolt::PseudoProbeInfo{Probe.getGuid(), Probe.getIndex(),
Probe.getType()});
}
}
}
Expand Down
11 changes: 4 additions & 7 deletions bolt/lib/Profile/YAMLProfileWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,10 @@ YAMLProfileWriter::convert(const BinaryFunction &BF, bool UseDFS,
const uint64_t FuncAddr = BF.getAddress();
const std::pair<uint64_t, uint64_t> &BlockRange =
BB->getInputAddressRange();
const auto &BlockProbes =
llvm::make_range(ProbeMap.lower_bound(FuncAddr + BlockRange.first),
ProbeMap.lower_bound(FuncAddr + BlockRange.second));
for (const auto &[_, Probes] : BlockProbes)
for (const MCDecodedPseudoProbe &Probe : Probes)
YamlBB.PseudoProbes.emplace_back(yaml::bolt::PseudoProbeInfo{
Probe.getGuid(), Probe.getIndex(), Probe.getType()});
for (const MCDecodedPseudoProbe &Probe : ProbeMap.find(
FuncAddr + BlockRange.first, FuncAddr + BlockRange.second))
YamlBB.PseudoProbes.emplace_back(yaml::bolt::PseudoProbeInfo{
Probe.getGuid(), Probe.getIndex(), Probe.getType()});
}

YamlBF.Blocks.emplace_back(YamlBB);
Expand Down
109 changes: 53 additions & 56 deletions bolt/lib/Rewrite/PseudoProbeRewriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ void PseudoProbeRewriter::parsePseudoProbe() {
if (!ProbeDecoder.buildAddress2ProbeMap(
reinterpret_cast<const uint8_t *>(Contents.data()), Contents.size(),
GuidFilter, FuncStartAddrs)) {
ProbeDecoder.getAddress2ProbesMap().clear();
errs() << "BOLT-WARNING: fail in building Address2ProbeMap\n";
return;
}
Expand All @@ -156,7 +155,8 @@ void PseudoProbeRewriter::parsePseudoProbe() {
ProbeDecoder.printProbesForAllAddresses(outs());
}

for (const auto &[GUID, FuncDesc] : ProbeDecoder.getGUID2FuncDescMap()) {
for (const auto &FuncDesc : ProbeDecoder.getGUID2FuncDescMap()) {
uint64_t GUID = FuncDesc.FuncGUID;
if (!FuncStartAddrs.contains(GUID))
continue;
BinaryFunction *BF = BC.getBinaryFunctionAtAddress(FuncStartAddrs[GUID]);
Expand All @@ -174,59 +174,50 @@ void PseudoProbeRewriter::updatePseudoProbes() {
AddressProbesMap &Address2ProbesMap = ProbeDecoder.getAddress2ProbesMap();
const GUIDProbeFunctionMap &GUID2Func = ProbeDecoder.getGUID2FuncDescMap();

for (auto &AP : Address2ProbesMap) {
BinaryFunction *F = BC.getBinaryFunctionContainingAddress(AP.first);
for (MCDecodedPseudoProbe &Probe : Address2ProbesMap) {
uint64_t Address = Probe.getAddress();
BinaryFunction *F = BC.getBinaryFunctionContainingAddress(Address);
// If F is removed, eliminate all probes inside it from inline tree
// Setting probes' addresses as INT64_MAX means elimination
if (!F) {
for (MCDecodedPseudoProbe &Probe : AP.second)
Probe.setAddress(INT64_MAX);
Probe.setAddress(INT64_MAX);
continue;
}
// If F is not emitted, the function will remain in the same address as its
// input
if (!F->isEmitted())
continue;

uint64_t Offset = AP.first - F->getAddress();
uint64_t Offset = Address - F->getAddress();
const BinaryBasicBlock *BB = F->getBasicBlockContainingOffset(Offset);
uint64_t BlkOutputAddress = BB->getOutputAddressRange().first;
// Check if block output address is defined.
// If not, such block is removed from binary. Then remove the probes from
// inline tree
if (BlkOutputAddress == 0) {
for (MCDecodedPseudoProbe &Probe : AP.second)
Probe.setAddress(INT64_MAX);
Probe.setAddress(INT64_MAX);
continue;
}

unsigned ProbeTrack = AP.second.size();
std::list<MCDecodedPseudoProbe>::iterator Probe = AP.second.begin();
while (ProbeTrack != 0) {
if (Probe->isBlock()) {
Probe->setAddress(BlkOutputAddress);
} else if (Probe->isCall()) {
// A call probe may be duplicated due to ICP
// Go through output of InputOffsetToAddressMap to collect all related
// probes
auto CallOutputAddresses = BC.getIOAddressMap().lookupAll(AP.first);
auto CallOutputAddress = CallOutputAddresses.first;
if (CallOutputAddress == CallOutputAddresses.second) {
Probe->setAddress(INT64_MAX);
} else {
Probe->setAddress(CallOutputAddress->second);
CallOutputAddress = std::next(CallOutputAddress);
}

while (CallOutputAddress != CallOutputAddresses.second) {
AP.second.push_back(*Probe);
AP.second.back().setAddress(CallOutputAddress->second);
Probe->getInlineTreeNode()->addProbes(&(AP.second.back()));
CallOutputAddress = std::next(CallOutputAddress);
}
if (Probe.isBlock()) {
Probe.setAddress(BlkOutputAddress);
} else if (Probe.isCall()) {
// A call probe may be duplicated due to ICP
// Go through output of InputOffsetToAddressMap to collect all related
// probes
auto CallOutputAddresses = BC.getIOAddressMap().lookupAll(Address);
auto CallOutputAddress = CallOutputAddresses.first;
if (CallOutputAddress == CallOutputAddresses.second) {
Probe.setAddress(INT64_MAX);
} else {
Probe.setAddress(CallOutputAddress->second);
CallOutputAddress = std::next(CallOutputAddress);
}

while (CallOutputAddress != CallOutputAddresses.second) {
ProbeDecoder.addInjectedProbe(Probe, CallOutputAddress->second);
CallOutputAddress = std::next(CallOutputAddress);
}
Probe = std::next(Probe);
ProbeTrack--;
}
}

Expand All @@ -242,22 +233,16 @@ void PseudoProbeRewriter::updatePseudoProbes() {
BinaryBlock.getName();

// scan all addresses -> correlate probe to block when print out
std::vector<uint64_t> Addresses;
for (auto &Entry : Address2ProbesMap)
Addresses.push_back(Entry.first);
llvm::sort(Addresses);
for (uint64_t Key : Addresses) {
for (MCDecodedPseudoProbe &Probe : Address2ProbesMap[Key]) {
if (Probe.getAddress() == INT64_MAX)
outs() << "Deleted Probe: ";
else
outs() << "Address: " << format_hex(Probe.getAddress(), 8) << " ";
Probe.print(outs(), GUID2Func, true);
// print block name only if the probe is block type and undeleted.
if (Probe.isBlock() && Probe.getAddress() != INT64_MAX)
outs() << format_hex(Probe.getAddress(), 8) << " Probe is in "
<< Addr2BlockNames[Probe.getAddress()] << "\n";
}
for (MCDecodedPseudoProbe &Probe : Address2ProbesMap) {
if (Probe.getAddress() == INT64_MAX)
outs() << "Deleted Probe: ";
else
outs() << "Address: " << format_hex(Probe.getAddress(), 8) << " ";
Probe.print(outs(), GUID2Func, true);
// print block name only if the probe is block type and undeleted.
if (Probe.isBlock() && Probe.getAddress() != INT64_MAX)
outs() << format_hex(Probe.getAddress(), 8) << " Probe is in "
<< Addr2BlockNames[Probe.getAddress()] << "\n";
}
outs() << "=======================================\n";
}
Expand Down Expand Up @@ -333,7 +318,7 @@ void PseudoProbeRewriter::encodePseudoProbes() {
ProbeDecoder.getDummyInlineRoot();
for (auto Child = Root.getChildren().begin();
Child != Root.getChildren().end(); ++Child)
Inlinees[Child->first] = Child->second.get();
Inlinees[Child->getInlineSite()] = &*Child;

for (auto Inlinee : Inlinees)
// INT64_MAX is "placeholder" of unused callsite index field in the pair
Expand All @@ -359,25 +344,37 @@ void PseudoProbeRewriter::encodePseudoProbes() {
EmitInt(Cur->Guid, 8);
// Emit number of probes in this node
uint64_t Deleted = 0;
for (MCDecodedPseudoProbe *&Probe : Cur->getProbes())
for (MCDecodedPseudoProbe *&Probe :
llvm::make_pointer_range(Cur->getProbes()))
if (Probe->getAddress() == INT64_MAX)
Deleted++;
LLVM_DEBUG(dbgs() << "Deleted Probes:" << Deleted << "\n");
uint64_t ProbesSize = Cur->getProbes().size() - Deleted;
size_t InjectedProbes = ProbeDecoder.getNumInjectedProbes(Cur);
uint64_t ProbesSize = Cur->getProbes().size() - Deleted + InjectedProbes;
EmitULEB128IntValue(ProbesSize);
// Emit number of direct inlinees
EmitULEB128IntValue(Cur->getChildren().size());
// Emit probes in this group
for (MCDecodedPseudoProbe *&Probe : Cur->getProbes()) {
for (MCDecodedPseudoProbe *&Probe :
llvm::make_pointer_range(Cur->getProbes())) {
if (Probe->getAddress() == INT64_MAX)
continue;
EmitDecodedPseudoProbe(Probe);
LastProbe = Probe;
}
if (InjectedProbes) {
for (MCDecodedPseudoProbe *&Probe :
llvm::make_pointer_range(ProbeDecoder.getInjectedProbes(Cur))) {
if (Probe->getAddress() == INT64_MAX)
continue;
EmitDecodedPseudoProbe(Probe);
LastProbe = Probe;
}
}

for (auto Child = Cur->getChildren().begin();
Child != Cur->getChildren().end(); ++Child)
Inlinees[Child->first] = Child->second.get();
Inlinees[Child->getInlineSite()] = &*Child;
for (const auto &Inlinee : Inlinees) {
assert(Cur->Guid != 0 && "non root tree node must have nonzero Guid");
NextNodes.push_back({std::get<1>(Inlinee.first), Inlinee.second});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ bool isUnaryLogicalNotOperator(const Stmt *Statement) {

void fixGenericExprCastToBool(DiagnosticBuilder &Diag,
const ImplicitCastExpr *Cast, const Stmt *Parent,
ASTContext &Context) {
ASTContext &Context,
bool UseUpperCaseLiteralSuffix) {
// In case of expressions like (! integer), we should remove the redundant not
// operator and use inverted comparison (integer == 0).
bool InvertComparison =
Expand Down Expand Up @@ -112,9 +113,14 @@ void fixGenericExprCastToBool(DiagnosticBuilder &Diag,
EndLocInsertion += " != ";
}

EndLocInsertion += getZeroLiteralToCompareWithForType(
const StringRef ZeroLiteral = getZeroLiteralToCompareWithForType(
Cast->getCastKind(), SubExpr->getType(), Context);

if (UseUpperCaseLiteralSuffix)
EndLocInsertion += ZeroLiteral.upper();
else
EndLocInsertion += ZeroLiteral;

if (NeedOuterParens) {
EndLocInsertion += ")";
}
Expand Down Expand Up @@ -248,12 +254,15 @@ ImplicitBoolConversionCheck::ImplicitBoolConversionCheck(
StringRef Name, ClangTidyContext *Context)
: ClangTidyCheck(Name, Context),
AllowIntegerConditions(Options.get("AllowIntegerConditions", false)),
AllowPointerConditions(Options.get("AllowPointerConditions", false)) {}
AllowPointerConditions(Options.get("AllowPointerConditions", false)),
UseUpperCaseLiteralSuffix(
Options.get("UseUpperCaseLiteralSuffix", false)) {}

void ImplicitBoolConversionCheck::storeOptions(
ClangTidyOptions::OptionMap &Opts) {
Options.store(Opts, "AllowIntegerConditions", AllowIntegerConditions);
Options.store(Opts, "AllowPointerConditions", AllowPointerConditions);
Options.store(Opts, "UseUpperCaseLiteralSuffix", UseUpperCaseLiteralSuffix);
}

void ImplicitBoolConversionCheck::registerMatchers(MatchFinder *Finder) {
Expand Down Expand Up @@ -378,7 +387,8 @@ void ImplicitBoolConversionCheck::handleCastToBool(const ImplicitCastExpr *Cast,
if (!EquivalentLiteral.empty()) {
Diag << tooling::fixit::createReplacement(*Cast, EquivalentLiteral);
} else {
fixGenericExprCastToBool(Diag, Cast, Parent, Context);
fixGenericExprCastToBool(Diag, Cast, Parent, Context,
UseUpperCaseLiteralSuffix);
}
}

Expand All @@ -392,8 +402,16 @@ void ImplicitBoolConversionCheck::handleCastFromBool(

if (const auto *BoolLiteral =
dyn_cast<CXXBoolLiteralExpr>(Cast->getSubExpr()->IgnoreParens())) {
Diag << tooling::fixit::createReplacement(
*Cast, getEquivalentForBoolLiteral(BoolLiteral, DestType, Context));

const auto EquivalentForBoolLiteral =
getEquivalentForBoolLiteral(BoolLiteral, DestType, Context);
if (UseUpperCaseLiteralSuffix)
Diag << tooling::fixit::createReplacement(
*Cast, EquivalentForBoolLiteral.upper());
else
Diag << tooling::fixit::createReplacement(*Cast,
EquivalentForBoolLiteral);

} else {
fixGenericExprCastFromBool(Diag, Cast, Context, DestType.getAsString());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class ImplicitBoolConversionCheck : public ClangTidyCheck {

const bool AllowIntegerConditions;
const bool AllowPointerConditions;
const bool UseUpperCaseLiteralSuffix;
};

} // namespace clang::tidy::readability
Expand Down
5 changes: 5 additions & 0 deletions clang-tools-extra/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ Changes in existing checks
<clang-tidy/checks/modernize/use-std-print>` check to support replacing
member function calls too.

- Improved :doc:`readablility-implicit-bool-conversion
<clang-tidy/checks/readability/implicit-bool-conversion>` check
by adding the option `UseUpperCaseLiteralSuffix` to select the
case of the literal suffix in fixes.

- Improved :doc:`readability-redundant-smartptr-get
<clang-tidy/checks/readability/redundant-smartptr-get>` check to
remove `->`, when redundant `get()` is removed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,17 @@ Options

When `true`, the check will allow conditional pointer conversions. Default
is `false`.

.. option:: UseUpperCaseLiteralSuffix

When `true`, the replacements will use an uppercase literal suffix in the
provided fixes. Default is `false`.

Example

.. code-block:: c++

uint32_t foo;
if (foo) {}
// ^ propose replacement default: if (foo != 0u) {}
// ^ propose replacement with option `UseUpperCaseLiteralSuffix`: if (foo != 0U) {}
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
// RUN: %check_clang_tidy %s readability-implicit-bool-conversion %t -- -- -std=c23
// RUN: %check_clang_tidy -check-suffix=UPPER-CASE %s readability-implicit-bool-conversion %t -- \
// RUN: -config='{CheckOptions: { \
// RUN: readability-implicit-bool-conversion.UseUpperCaseLiteralSuffix: true \
// RUN: }}' -- -std=c23

#undef NULL
#define NULL 0L
Expand Down Expand Up @@ -95,6 +99,7 @@ void implicitConversionFromBoolLiterals() {
functionTakingUnsignedLong(false);
// CHECK-MESSAGES: :[[@LINE-1]]:30: warning: implicit conversion 'bool' -> 'unsigned long'
// CHECK-FIXES: functionTakingUnsignedLong(0u);
// CHECK-FIXES-UPPER-CASE: functionTakingUnsignedLong(0U);

functionTakingSignedChar(true);
// CHECK-MESSAGES: :[[@LINE-1]]:28: warning: implicit conversion 'bool' -> 'signed char'
Expand All @@ -103,6 +108,7 @@ void implicitConversionFromBoolLiterals() {
functionTakingFloat(false);
// CHECK-MESSAGES: :[[@LINE-1]]:23: warning: implicit conversion 'bool' -> 'float'
// CHECK-FIXES: functionTakingFloat(0.0f);
// CHECK-FIXES-UPPER-CASE: functionTakingFloat(0.0F);

functionTakingDouble(true);
// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: implicit conversion 'bool' -> 'double'
Expand Down Expand Up @@ -160,11 +166,13 @@ void implicitConversionToBoolSimpleCases() {
functionTakingBool(unsignedLong);
// CHECK-MESSAGES: :[[@LINE-1]]:22: warning: implicit conversion 'unsigned long' -> 'bool'
// CHECK-FIXES: functionTakingBool(unsignedLong != 0u);
// CHECK-FIXES-UPPER-CASE: functionTakingBool(unsignedLong != 0U);

float floating = 0.0f;
functionTakingBool(floating);
// CHECK-MESSAGES: :[[@LINE-1]]:22: warning: implicit conversion 'float' -> 'bool'
// CHECK-FIXES: functionTakingBool(floating != 0.0f);
// CHECK-FIXES-UPPER-CASE: functionTakingBool(floating != 0.0F);

double doubleFloating = 1.0f;
functionTakingBool(doubleFloating);
Expand Down Expand Up @@ -194,6 +202,7 @@ void implicitConversionToBoolInSingleExpressions() {
boolComingFromFloat = floating;
// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: implicit conversion 'float' -> 'bool'
// CHECK-FIXES: boolComingFromFloat = (floating != 0.0f);
// CHECK-FIXES-UPPER-CASE: boolComingFromFloat = (floating != 0.0F);

signed char character = 'a';
bool boolComingFromChar;
Expand Down Expand Up @@ -288,6 +297,7 @@ void implicitConversionToBoolFromUnaryMinusAndZeroLiterals() {
functionTakingBool(-0.0f);
// CHECK-MESSAGES: :[[@LINE-1]]:22: warning: implicit conversion 'float' -> 'bool'
// CHECK-FIXES: functionTakingBool((-0.0f) != 0.0f);
// CHECK-FIXES-UPPER-CASE: functionTakingBool((-0.0f) != 0.0F);

functionTakingBool(-0.0);
// CHECK-MESSAGES: :[[@LINE-1]]:22: warning: implicit conversion 'double' -> 'bool'
Expand Down
Loading