[llvm] [NFC]Update test case (PR #117584)

Mingming Liu via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 25 09:34:08 PST 2024


https://github.com/mingmingl-llvm created https://github.com/llvm/llvm-project/pull/117584

The ThinLTO indexing step can import a function alias without importing its aliasee, making `aliasee:null` in the summary. The backend compile will crash in function-import pass when trying to get aliasee of the alias. The crash stack up to `FunctionImportPass::run` is pasted below.

This patch updates the existing tests to reflect this.

```
0.      Program arguments: /home/tmp/llvm-type-profiling/llvm-project/build/bin/opt -passes=function-import -summary-file=/home/tmp/llvm-type-profiling/llvm-project/build/test/ThinLTO/X86/Output/distributed_indexes.ll.tmp1.bc.thinlto.bc /home/tmp/llvm-type-profiling/llvm-project/build/test/ThinLTO/X86/Output/distributed_indexes.ll.tmp1.bc -o /dev/null
1.      Running pass "function-import" on module "/home/tmp/llvm-type-profiling/llvm-project/build/test/ThinLTO/X86/Output/distributed_indexes.ll.tmp1.bc"
 #0 0x0000563eaf4dbf74 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/tmp/llvm-type-profiling/llvm-project/llvm/lib/Support/Unix/Signals.inc:723:22
 #1 0x0000563eaf4dc3b2 PrintStackTraceSignalHandler(void*) /home/tmp/llvm-type-profiling/llvm-project/llvm/lib/Support/Unix/Signals.inc:798:1
 #2 0x0000563eaf4d9b38 llvm::sys::RunSignalHandlers() /home/tmp/llvm-type-profiling/llvm-project/llvm/lib/Support/Signals.cpp:105:20
 #3 0x0000563eaf4db950 SignalHandler(int) /home/tmp/llvm-type-profiling/llvm-project/llvm/lib/Support/Unix/Signals.inc:413:1
 #4 0x00007f8cdef74590 (/lib/x86_64-linux-gnu/libc.so.6+0x3f590)
 #5 0x00007f8cdefc33ac __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #6 0x00007f8cdef744f2 raise ./signal/../sysdeps/posix/raise.c:27:6
 #7 0x00007f8cdef5d4ed abort ./stdlib/abort.c:81:7
 #8 0x00007f8cdef5d415 _nl_load_domain ./intl/loadmsgcat.c:1177:9
 #9 0x00007f8cdef6d012 (/lib/x86_64-linux-gnu/libc.so.6+0x38012)
#10 0x0000563eaf66150b llvm::AliasSummary::getAliasee() const /home/tmp/llvm-type-profiling/llvm-project/llvm/include/llvm/IR/ModuleSummaryIndex.h:689:13
#11 0x0000563eaf8bff26 llvm::AliasSummary::getAliasee() /home/tmp/llvm-type-profiling/llvm-project/llvm/include/llvm/IR/ModuleSummaryIndex.h:695:3
#12 0x0000563eaf8c008d llvm::GlobalValueSummary::getBaseObject() /home/tmp/llvm-type-profiling/llvm-project/llvm/include/llvm/IR/ModuleSummaryIndex.h:714:28
#13 0x0000563eb1ccbcf7 qualifyCalleeCandidates(llvm::ModuleSummaryIndex const&, llvm::ArrayRef<std::unique_ptr<llvm::GlobalValueSummary, std::default_delete<llvm::GlobalValueSummary>>>, llvm::StringRef)::'lambda'(std::unique_ptr<llvm::GlobalValueSummary, std::default_delete<llvm::GlobalValueSummary>> const&)::operator()(std::unique_ptr<llvm::GlobalValueSummary, std::default_delete<llvm::GlobalValueSummary>> const&) const /home/tmp/llvm-type-profiling/llvm-project/llvm/lib/Transforms/IPO/FunctionImport.cpp:238:50
#14 0x0000563eb1cd45ff decltype(auto) llvm::callable_detail::Callable<qualifyCalleeCandidates(llvm::ModuleSummaryIndex const&, llvm::ArrayRef<std::unique_ptr<llvm::GlobalValueSummary, std::default_delete<llvm::GlobalValueSummary>>>, llvm::StringRef)::'lambda'(std::unique_ptr<llvm::GlobalValueSummary, std::default_delete<llvm::GlobalValueSummary>> const&), false>::operator()<std::unique_ptr<llvm::GlobalValueSummary, std::default_delete<llvm::GlobalValueSummary>> const&, 0>(std::unique_ptr<llvm::GlobalValueSummary, std::default_delete<llvm::GlobalValueSummary>> const&) const /home/tmp/llvm-type-profiling/llvm-project/llvm/include/llvm/ADT/STLExtras.h:250:18
#15 0x0000563eb1cd4636 llvm::mapped_iterator<std::unique_ptr<llvm::GlobalValueSummary, std::default_delete<llvm::GlobalValueSummary>> const*, qualifyCalleeCandidates(llvm::ModuleSummaryIndex const&, llvm::ArrayRef<std::unique_ptr<llvm::GlobalValueSummary, std::default_delete<llvm::GlobalValueSummary>>>, llvm::StringRef)::'lambda'(std::unique_ptr<llvm::GlobalValueSummary, std::default_delete<llvm::GlobalValueSummary>> const&), std::pair<llvm::FunctionImporter::ImportFailureReason, llvm::GlobalValueSummary const*>>::operator*() const /home/tmp/llvm-type-profiling/llvm-project/llvm/include/llvm/ADT/STLExtras.h:363:43
#16 0x0000563eb1ccc0f6 selectCallee(llvm::ModuleSummaryIndex const&, llvm::ArrayRef<std::unique_ptr<llvm::GlobalValueSummary, std::default_delete<llvm::GlobalValueSummary>>>, unsigned int, llvm::StringRef, llvm::GlobalValueSummary const*&, llvm::FunctionImporter::ImportFailureReason&) /home/tmp/llvm-type-profiling/llvm-project/llvm/lib/Transforms/IPO/FunctionImport.cpp:301:30
#17 0x0000563eb1ccd436 computeImportForFunction(llvm::FunctionSummary const&, llvm::ModuleSummaryIndex const&, unsigned int, llvm::DenseMap<unsigned long, llvm::GlobalValueSummary*, llvm::DenseMapInfo<unsigned long, void>, llvm::detail::DenseMapPair<unsigned long, llvm::GlobalValueSummary*>> const&, llvm::function_ref<bool (unsigned long, llvm::GlobalValueSummary const*)>, llvm::SmallVectorImpl<std::tuple<llvm::FunctionSummary const*, unsigned int>>&, GlobalsImporter&, llvm::FunctionImporter::ImportMapTy&, llvm::DenseMap<llvm::StringRef, llvm::DenseSet<llvm::ValueInfo, llvm::DenseMapInfo<llvm::ValueInfo, void>>, llvm::DenseMapInfo<llvm::StringRef, void>, llvm::detail::DenseMapPair<llvm::StringRef, llvm::DenseSet<llvm::ValueInfo, llvm::DenseMapInfo<llvm::ValueInfo, void>>>>*, llvm::DenseMap<unsigned long, std::tuple<unsigned int, llvm::GlobalValueSummary const*, std::unique_ptr<llvm::FunctionImporter::ImportFailureInfo, std::default_delete<llvm::FunctionImporter::ImportFailureInfo>>>, llvm::DenseMapInfo<unsigned long, void>, llvm::detail::DenseMapPair<unsigned long, std::tuple<unsigned int, llvm::GlobalValueSummary const*, std::unique_ptr<llvm::FunctionImporter::ImportFailureInfo, std::default_delete<llvm::FunctionImporter::ImportFailureInfo>>>>>&) /home/tmp/llvm-type-profiling/llvm-project/llvm/lib/Transforms/IPO/FunctionImport.cpp:916:23
#18 0x0000563eb1ccdde5 ModuleImportsManager::computeImportForModule(llvm::DenseMap<unsigned long, llvm::GlobalValueSummary*, llvm::DenseMapInfo<unsigned long, void>, llvm::detail::DenseMapPair<unsigned long, llvm::GlobalValueSummary*>> const&, llvm::StringRef, llvm::FunctionImporter::ImportMapTy&) /home/tmp/llvm-type-profiling/llvm-project/llvm/lib/Transforms/IPO/FunctionImport.cpp:1037:29
#19 0x0000563eb1ccf9fa ComputeCrossModuleImportForModuleForTest(llvm::StringRef, llvm::function_ref<bool (unsigned long, llvm::GlobalValueSummary const*)>, llvm::ModuleSummaryIndex const&, llvm::FunctionImporter::ImportMapTy&) /home/tmp/llvm-type-profiling/llvm-project/llvm/lib/Transforms/IPO/FunctionImport.cpp:1309:26
#20 0x0000563eb1cd3e1b doImportingForModuleForTest(llvm::Module&, llvm::function_ref<bool (unsigned long, llvm::GlobalValueSummary const*)>) /home/tmp/llvm-type-profiling/llvm-project/llvm/lib/Transforms/IPO/FunctionImport.cpp:2013:19
#21 0x0000563eb1cd4189 llvm::FunctionImportPass::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) /home/tmp/llvm-type-profiling/llvm-project/llvm/lib/Transforms/IPO/FunctionImport.cpp:2055:7
```

>From 83c2755e64d9e6492426c967b32c9cf53744b494 Mon Sep 17 00:00:00 2001
From: mingmingl <mingmingl at google.com>
Date: Mon, 25 Nov 2024 09:23:29 -0800
Subject: [PATCH] [NFC]Update test case

---
 llvm/test/ThinLTO/X86/distributed_indexes.ll       | 4 ++++
 llvm/test/ThinLTO/X86/import_callee_declaration.ll | 4 ++++
 2 files changed, 8 insertions(+)

diff --git a/llvm/test/ThinLTO/X86/distributed_indexes.ll b/llvm/test/ThinLTO/X86/distributed_indexes.ll
index 4f2662b1b34e1b..b70342fd0c96f5 100644
--- a/llvm/test/ThinLTO/X86/distributed_indexes.ll
+++ b/llvm/test/ThinLTO/X86/distributed_indexes.ll
@@ -48,6 +48,10 @@
 ; RUN: llvm-dis %t1.bc.thinlto.bc -o - | FileCheck %s --check-prefix=DIS
 ; DIS: aliasee: null
 
+; function-import pass crashed when alias is imported but aliasee doesn't.
+; TODO: Import both alias and aliasee, or neither of them.
+; RUN: not --crash opt -passes=function-import -summary-file=%t1.bc.thinlto.bc %t1.bc -o /dev/null 2>&1
+
 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
 
 declare void @g(...)
diff --git a/llvm/test/ThinLTO/X86/import_callee_declaration.ll b/llvm/test/ThinLTO/X86/import_callee_declaration.ll
index 246920e5db0dc8..96257214c0a1af 100644
--- a/llvm/test/ThinLTO/X86/import_callee_declaration.ll
+++ b/llvm/test/ThinLTO/X86/import_callee_declaration.ll
@@ -62,6 +62,10 @@
 ; these two GUIDs are declaration.
 ;
 ; RUN: llvm-dis main.bc.thinlto.bc -o - | FileCheck %s --check-prefix=MAIN-DIS
+
+; function-import pass crashed when alias is imported but aliasee doesn't.
+; TODO: Import both alias and aliasee, or neither of them.
+; RUN: not --crash opt -passes=function-import -summary-file=main.bc.thinlto.bc main.bc -o /dev/null 2>&1
 ;
 ; MAIN-DIS: [[LIBMOD:\^[0-9]+]] = module: (path: "lib.bc", hash: (0, 0, 0, 0, 0))
 ; MAIN-DIS: gv: (guid: 2418497564662708935, summaries: (function: (module: [[LIBMOD]], flags: ({{.*}} importType: declaration), insts: 8, {{.*}})))



More information about the llvm-commits mailing list