[PATCH] D115907: [misexpect] Re-implement MisExpect Diagnostics
Jorge Gorbe Moya via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 31 14:51:19 PDT 2022
jgorbe added a comment.
Hi, this patch is causing floating point exceptions for us during profile generation. On a debug build I get this assertion failure (see stack trace below):
clang: /usr/local/google/home/jgorbe/code/llvm/llvm/lib/Support/BranchProbability.cpp:41: llvm::BranchProbability::BranchProbability(uint32_t, uint32_t): Assertion `Denominator > 0 && "Denominator cannot be 0!"' failed.
Printing some values around the problem I got
TotalBranchWeight = 4294967296
LikelyBranchWeight = 2147483648
UnlikelyBranchWeight = 2147483648
NumUnlikelyTargets = 1
I see the `BranchProbability` constructor takes `uint32_t`s, so this looks like it's overflowing to 0 (4294967296 is exactly 2**32).
I'm going to revert the patch to unbreak our build. Please let me know if you need more details and I'll try to come up with a reproducer I can share. Here's the stack trace for the assertion.
#0 0x000000000a7f992a llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /usr/local/google/home/jgorbe/code/llvm/llvm/lib/Support/Unix/Signals.inc:565:11
#1 0x000000000a7f9afb PrintStackTraceSignalHandler(void*) /usr/local/google/home/jgorbe/code/llvm/llvm/lib/Support/Unix/Signals.inc:632:1
#2 0x000000000a7f80bb llvm::sys::RunSignalHandlers() /usr/local/google/home/jgorbe/code/llvm/llvm/lib/Support/Signals.cpp:102:5
#3 0x000000000a7fa271 SignalHandler(int) /usr/local/google/home/jgorbe/code/llvm/llvm/lib/Support/Unix/Signals.inc:407:1
#4 0x00007ff57cfe2200 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x13200)
#5 0x00007ff57ca678a1 raise ./signal/../sysdeps/unix/sysv/linux/raise.c:50:1
#6 0x00007ff57ca51546 abort ./stdlib/abort.c:81:7
#7 0x00007ff57ca5142f get_sysdep_segment_value ./intl/loadmsgcat.c:509:8
#8 0x00007ff57ca5142f _nl_load_domain ./intl/loadmsgcat.c:970:34
#9 0x00007ff57ca60222 (/lib/x86_64-linux-gnu/libc.so.6+0x35222)
#10 0x000000000a6cb517 llvm::BranchProbability::BranchProbability(unsigned int, unsigned int) /usr/local/google/home/jgorbe/code/llvm/llvm/lib/Support/BranchProbability.cpp:0:3
#11 0x000000000a937a4d llvm::misexpect::verifyMisExpect(llvm::Instruction&, llvm::ArrayRef<unsigned int>, llvm::ArrayRef<unsigned int>) /usr/local/google/home/jgorbe/code/llvm/llvm/lib/Transforms/Utils/MisExpect.cpp:190:54
#12 0x000000000a937ef3 llvm::misexpect::checkBackendInstrumentation(llvm::Instruction&, llvm::ArrayRef<unsigned int>) /usr/local/google/home/jgorbe/code/llvm/llvm/lib/Transforms/Utils/MisExpect.cpp:217:1
#13 0x000000000a93807b llvm::misexpect::checkExpectAnnotations(llvm::Instruction&, llvm::ArrayRef<unsigned int>, bool) /usr/local/google/home/jgorbe/code/llvm/llvm/lib/Transforms/Utils/MisExpect.cpp:236:1
#14 0x0000000009e1339c (anonymous namespace)::SampleProfileLoader::generateMDProfMetadata(llvm::Function&) /usr/local/google/home/jgorbe/code/llvm/llvm/lib/Transforms/IPO/SampleProfile.cpp:1755:19
#15 0x0000000009e10d94 (anonymous namespace)::SampleProfileLoader::emitAnnotations(llvm::Function&) /usr/local/google/home/jgorbe/code/llvm/llvm/lib/Transforms/IPO/SampleProfile.cpp:0:5
#16 0x0000000009e1022b (anonymous namespace)::SampleProfileLoader::runOnFunction(llvm::Function&, llvm::AnalysisManager<llvm::Module>*) /usr/local/google/home/jgorbe/code/llvm/llvm/lib/Transforms/IPO/SampleProfile.cpp:2199:5
#17 0x0000000009e0ce8b (anonymous namespace)::SampleProfileLoader::runOnModule(llvm::Module&, llvm::AnalysisManager<llvm::Module>*, llvm::ProfileSummaryInfo*, llvm::CallGraph*) /usr/local/google/home/jgorbe/code/llvm/llvm/lib/Transforms/IPO/SampleProfile.cpp:2113:15
#18 0x0000000009e0b882 llvm::SampleProfileLoaderPass::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) /usr/local/google/home/jgorbe/code/llvm/llvm/lib/Transforms/IPO/SampleProfile.cpp:2229:7
#19 0x000000000c6e35c5 llvm::detail::PassModel<llvm::Module, llvm::SampleProfileLoaderPass, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) /usr/local/google/home/jgorbe/code/llvm/llvm/include/llvm/IR/PassManagerInternal.h:88:17
#20 0x0000000009a7ee41 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) /usr/local/google/home/jgorbe/code/llvm/llvm/include/llvm/IR/PassManager.h:522:16
#21 0x000000000c5c9ae1 runNewPMPasses(llvm::lto::Config const&, llvm::Module&, llvm::TargetMachine*, unsigned int, bool, llvm::ModuleSummaryIndex*, llvm::ModuleSummaryIndex const*) /usr/local/google/home/jgorbe/code/llvm/llvm/lib/LTO/LTOBackend.cpp:312:3
#22 0x000000000c5c8cfe llvm::lto::opt(llvm::lto::Config const&, llvm::TargetMachine*, unsigned int, llvm::Module&, bool, llvm::ModuleSummaryIndex*, llvm::ModuleSummaryIndex const*, std::vector<unsigned char, std::allocator<unsigned char> > const&) /usr/local/google/home/jgorbe/code/llvm/llvm/lib/LTO/LTOBackend.cpp:373:3
#23 0x000000000c5cba45 llvm::lto::thinBackend(llvm::lto::Config const&, unsigned int, std::function<llvm::Expected<std::unique_ptr<llvm::CachedFileStream, std::default_delete<llvm::CachedFileStream> > > (unsigned int)>, llvm::Module&, llvm::ModuleSummaryIndex const&, llvm::StringMap<std::unordered_set<unsigned long, std::hash<unsigned long>, std::equal_to<unsigned long>, std::allocator<unsigned long> >, llvm::MallocAllocator> const&, llvm::DenseMap<unsigned long, llvm::GlobalValueSummary*, llvm::DenseMapInfo<unsigned long, void>, llvm::detail::DenseMapPair<unsigned long, llvm::GlobalValueSummary*> > const&, llvm::MapVector<llvm::StringRef, llvm::BitcodeModule, llvm::DenseMap<llvm::StringRef, unsigned int, llvm::DenseMapInfo<llvm::StringRef, void>, llvm::detail::DenseMapPair<llvm::StringRef, unsigned int> >, std::vector<std::pair<llvm::StringRef, llvm::BitcodeModule>, std::allocator<std::pair<llvm::StringRef, llvm::BitcodeModule> > > >*, std::vector<unsigned char, std::allocator<unsigned char> > const&)::$_6::operator()(llvm::Module&, llvm::TargetMachine*, std::unique_ptr<llvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile> >) const /usr/local/google/home/jgorbe/code/llvm/llvm/lib/LTO/LTOBackend.cpp:594:13
#24 0x000000000c5cb971 llvm::lto::thinBackend(llvm::lto::Config const&, unsigned int, std::function<llvm::Expected<std::unique_ptr<llvm::CachedFileStream, std::default_delete<llvm::CachedFileStream> > > (unsigned int)>, llvm::Module&, llvm::ModuleSummaryIndex const&, llvm::StringMap<std::unordered_set<unsigned long, std::hash<unsigned long>, std::equal_to<unsigned long>, std::allocator<unsigned long> >, llvm::MallocAllocator> const&, llvm::DenseMap<unsigned long, llvm::GlobalValueSummary*, llvm::DenseMapInfo<unsigned long, void>, llvm::detail::DenseMapPair<unsigned long, llvm::GlobalValueSummary*> > const&, llvm::MapVector<llvm::StringRef, llvm::BitcodeModule, llvm::DenseMap<llvm::StringRef, unsigned int, llvm::DenseMapInfo<llvm::StringRef, void>, llvm::detail::DenseMapPair<llvm::StringRef, unsigned int> >, std::vector<std::pair<llvm::StringRef, llvm::BitcodeModule>, std::allocator<std::pair<llvm::StringRef, llvm::BitcodeModule> > > >*, std::vector<unsigned char, std::allocator<unsigned char> > const&) /usr/local/google/home/jgorbe/code/llvm/llvm/lib/LTO/LTOBackend.cpp:670:3
#25 0x000000000ad17e95 runThinLTOBackend(clang::DiagnosticsEngine&, llvm::ModuleSummaryIndex*, llvm::Module*, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, clang::BackendAction) /usr/local/google/home/jgorbe/code/llvm/clang/lib/CodeGen/BackendUtil.cpp:1670:11
#26 0x000000000ad174c8 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream> >) /usr/local/google/home/jgorbe/code/llvm/clang/lib/CodeGen/BackendUtil.cpp:1711:9
#27 0x000000000bbd802f clang::CodeGenAction::ExecuteAction() /usr/local/google/home/jgorbe/code/llvm/clang/lib/CodeGen/CodeGenAction.cpp:1209:3
#28 0x000000000b9f1368 clang::FrontendAction::Execute() /usr/local/google/home/jgorbe/code/llvm/clang/lib/Frontend/FrontendAction.cpp:1036:7
#29 0x000000000b9206ab clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /usr/local/google/home/jgorbe/code/llvm/clang/lib/Frontend/CompilerInstance.cpp:1036:23
#30 0x000000000bbc34b9 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /usr/local/google/home/jgorbe/code/llvm/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:266:8
#31 0x0000000006c0de77 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) /usr/local/google/home/jgorbe/code/llvm/clang/tools/driver/cc1_main.cpp:248:13
#32 0x0000000006c0076b ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) /usr/local/google/home/jgorbe/code/llvm/clang/tools/driver/driver.cpp:317:5
#33 0x0000000006bff778 main /usr/local/google/home/jgorbe/code/llvm/clang/tools/driver/driver.cpp:388:5
#34 0x00007ff57ca527fd __libc_start_main ./csu/../csu/libc-start.c:332:16
#35 0x0000000006bfef3a _start (/usr/local/google/home/jgorbe/code/llvm-build/bin/clang+0x6bfef3a)
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D115907/new/
https://reviews.llvm.org/D115907
More information about the cfe-commits
mailing list