llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.25k stars 12.08k forks source link

ModuleSummaryIndex::print() crashes when printing a thinlto test summary #42393

Open llvmbot opened 5 years ago

llvmbot commented 5 years ago
Bugzilla Link 43048
Version trunk
OS MacOS X
Reporter LLVM Bugzilla Contributor

Extended Description

Repro:

Run llvm-as -d on /llvm/test/Assembler/thinlto-summary.ll

Reproduced on master at commit ee6700f69766b57849f483f471387229e495e311

kmanivannan@kmanivannan-mbp:~/local/llvm-project-master/build$ bin/llvm-as -d ../llvm/test/Assembler/thinlto-summary.ll

Here's the assembly: ; ModuleID = '../llvm/test/Assembler/thinlto-summary.ll' source_filename = "../llvm/test/Assembler/thinlto-summary.ll"

^0 = module: (path: "thinlto-summary1.o", hash: (1369602428, 2747878711, 259090915, 2507395659, 1141468049)) ^1 = module: (path: "thinlto-summary2.o", hash: (2998369023, 4283347029, 1195487472, 2757298015, 1852134156)) ^2 = gv: (Stack dump:

  1. Program arguments: bin/llvm-as -d ../llvm/test/Assembler/thinlto-summary.ll 0 llvm-as 0x0000000106b4afbc llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 60 1 llvm-as 0x0000000106b4b579 PrintStackTraceSignalHandler(void*) + 25 2 llvm-as 0x0000000106b49116 llvm::sys::RunSignalHandlers() + 118 3 llvm-as 0x0000000106b4f572 SignalHandler(int) + 210 4 libsystem_platform.dylib 0x00007fff66542b5d _sigtramp + 29 5 libsystem_platform.dylib 000000000000000000 _sigtramp + 18446603338799371456 6 llvm-as 0x0000000106955a89 llvm::Value::getName() const + 25 7 llvm-as 0x000000010666300b llvm::ValueInfo::name() const + 59 8 llvm-as 0x000000010666049a (anonymous namespace)::AssemblyWriter::printSummaryInfo(unsigned int, llvm::ValueInfo const&) + 90 9 llvm-as 0x000000010663c550 (anonymous namespace)::AssemblyWriter::printModuleSummaryIndex() + 1664 10 llvm-as 0x000000010663be47 llvm::ModuleSummaryIndex::print(llvm::raw_ostream&, bool) const + 119 11 llvm-as 0x00000001064feac1 main + 1121 12 libdyld.dylib 0x00007fff663573d5 start + 1 13 libdyld.dylib 0x0000000000000003 start + 18446603338801384495 Segmentation fault: 11
llvmbot commented 5 years ago

This might be the problem:

llvm-as, via llvm::parseAssemblyWithIndex, builds a ModuleSummaryIndex with HaveGVs always set to true.

The input .ll file I was trying to run 'llvm-as -d' on, has no IR. GlobalValueSummaryInfo.U.GV seem to be set only when GVs in the IR are parsed.

In the absence of IR, and having HaveGVs always set to true, we end up in a situation where a null GlobalValueSummaryInfo.U.GV gets dereferenced.

For this test case, HaveGVs should have been false.

Should there be a way for llvm-as to be able to construct a ModuleSummaryIndex where HaveGVs is set conditionally via an option?