https://github.com/aaupov updated https://github.com/llvm/llvm-project/pull/90807
>From acf58ceb37d2aa917e8d84d243faadc58f5f3a7d Mon Sep 17 00:00:00 2001 From: Amir Ayupov <aau...@fb.com> Date: Mon, 6 May 2024 13:35:04 -0700 Subject: [PATCH] Simplify IsReturn check Created using spr 1.3.4 --- bolt/lib/Profile/DataAggregator.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/bolt/lib/Profile/DataAggregator.cpp b/bolt/lib/Profile/DataAggregator.cpp index e4a7324c38175c..d02e4499014ed1 100644 --- a/bolt/lib/Profile/DataAggregator.cpp +++ b/bolt/lib/Profile/DataAggregator.cpp @@ -778,13 +778,13 @@ bool DataAggregator::doBranch(uint64_t From, uint64_t To, uint64_t Count, if (BinaryFunction *Func = getBinaryFunctionContainingAddress(Addr)) { Addr -= Func->getAddress(); if (IsFrom) { - if (Func->hasInstructions()) { - if (MCInst *Inst = Func->getInstructionAtOffset(Addr)) - IsReturn = BC->MIB->isReturn(*Inst); - } else if (std::optional<MCInst> Inst = - Func->disassembleInstructionAtOffset(Addr)) { - IsReturn = BC->MIB->isReturn(*Inst); - } + auto checkReturn = [&](auto MaybeInst) { + IsReturn = MaybeInst && BC->MIB->isReturn(*MaybeInst); + }; + if (Func->hasInstructions()) + checkReturn(Func->getInstructionAtOffset(Addr)); + else + checkReturn(Func->disassembleInstructionAtOffset(Addr)); } if (BAT) _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits