Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BFI][CGP] Assertion failed: (Match && "BFI mismatch"), function verifyMatch, file BlockFrequencyInfoImpl.h, line 1800. #64197

Open
PavelKopyl opened this issue Jul 28, 2023 · 2 comments
Assignees
Labels
llvm:crash llvm Umbrella label for LLVM issues

Comments

@PavelKopyl
Copy link
Contributor

Hello,

I faced with a failed assertion in BlockFrequencyInfoImpl on LLVM TOT.

Repro case: bfi-bug.ll

; Function Attrs: noreturn
define private fastcc void @__test() unnamed_addr #0 {
entry:
  br i1 undef, label %join, label %division
 
division:
  br label %join
 
join:
  tail call fastcc void @encode(i32 1024)
  unreachable
}
 
define private fastcc void @encode(i32 %0) unnamed_addr {
entry:
  unreachable
}
 
attributes #0 = { noreturn }

LLVM should be built in the debug mode.

opt --codegenprepare --mtriple=riscv32 --cgp-verify-bfi-updates bfi-bug3.ll -S
Freq mismatch: entry 8 vs 16
This
block-frequency-info: __test
 - entry: float = 1.0, int = 8

Other
block-frequency-info: __test
 - entry: float = 1.0, int = 16

Assertion failed: (Match && "BFI mismatch"), function verifyMatch, file BlockFrequencyInfoImpl.h, line 1800.

Please, note that the actual triplet value doesn't seem to matter, as the failed assertion is in target-independent part of the code.

As I understand, the issues happens because the BFI updates are not synced with actual code transformations performed by CodeGenPrepare pass. Namely, the BBs frequency info, expressed as FrequencyData::Integer, is not updated.

Does it make sense to compare Scaled values instead?

--- a/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h
+++ b/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h
@@ -1777,7 +1777,7 @@ void BlockFrequencyInfoImpl<BT>::verifyMatch(
         BlockNode OtherNode = OtherValidNodes[BB];
         const auto &Freq = Freqs[Node.Index];
         const auto &OtherFreq = Other.Freqs[OtherNode.Index];
-        if (Freq.Integer != OtherFreq.Integer) {
+        if (Freq.Scaled != OtherFreq.Scaled) {
           Match = false;
           dbgs() << "Freq mismatch: " << bfi_detail::getBlockName(BB) << " "
                  << Freq.Integer << " vs " << OtherFreq.Integer << "\n";
@PavelKopyl PavelKopyl added llvm:crash llvm Umbrella label for LLVM issues labels Jul 28, 2023
@hjyamauchi
Copy link
Contributor

hjyamauchi commented Aug 2, 2023 via email

@PavelKopyl
Copy link
Contributor Author

@hjyamauchi Thank you for the reply.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
llvm:crash llvm Umbrella label for LLVM issues
Projects
None yet
Development

No branches or pull requests

3 participants