HomePhabricator

Reapply "[DebugInfo] Use variadic debug values to salvage BinOps and GEP instrs…

Authored by StephenTozer on Mar 11 2021, 7:01 AM.

Description

Reapply "[DebugInfo] Use variadic debug values to salvage BinOps and GEP instrs with non-const operands"

The causes of the previous build errors have been fixed in revisions
aa3e78a59fdf3b211be72f1b3221af831665e67d, and
140757bfaaa00110a92d2247a910c847e6e3bcc8

This reverts commit f40976bd01032f4905dde361e709166704581077.

Event Timeline

fyi, it looks like this change is causing an assert when linking in ThinLTO builds in chromium (Assertion failed: ID < (MDStringRef.size()) + GlobalMetadataBitPosIndex.size())
Don't know if this is enough info for debugging or if you happen to know what's going on here; I can also try to come up with a better repro.

Here's the stack trace:

Assertion failed: ID < (MDStringRef.size()) + GlobalMetadataBitPosIndex.size(), file C:\src\llvm-project\llvm\lib\Bitcode\Reader\MetadataLoader.cpp, line 1071
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
 #0 0x00007ff64fa197bd HandleAbort C:\src\llvm-project\llvm\lib\Support\Windows\Signals.inc:408:0
 #1 0x00007ff64fa0cce9 (C:\WINDOWS\System32\ucrtbase.dll+0x6caad)
 #2 0x00007ff64fa032ab (C:\WINDOWS\System32\ucrtbase.dll+0x6dab1)
 #3 0x00007ff64e0f9e19 (C:\WINDOWS\System32\ucrtbase.dll+0x6f435)
 #4 0x00007ff64e10145c (C:\WINDOWS\System32\ucrtbase.dll+0x6f771)
 #5 0x00007ff64e0fa55d std::vector<llvm::StringRef,std::allocator<llvm::StringRef> >::size C:\src\llvm-project\mysysroot\VC\Tools\MSVC\14.28.29333\include\vector:1484:0
 #6 0x00007ff64e0fa55d llvm::MetadataLoader::MetadataLoaderImpl::lazyLoadOneMetadata C:\src\llvm-project\llvm\lib\Bitcode\Reader\MetadataLoader.cpp:1072:0
 #7 0x00007ff64e3dd3df llvm::SmallDenseMap<unsigned int,llvm::detail::DenseSetEmpty,1,llvm::DenseMapInfo<unsigned int>,llvm::detail::DenseSetPair<unsigned int> >::getNumEntries C:\src\llvm-project\llvm\include\llvm\ADT\DenseMap.h:1114:0
 #8 0x00007ff64e3dd3df llvm::DenseMapBase<llvm::SmallDenseMap<unsigned int,llvm::detail::DenseSetEmpty,1,llvm::DenseMapInfo<unsigned int>,llvm::detail::DenseSetPair<unsigned int> >,unsigned int,llvm::detail::DenseSetEmpty,llvm::DenseMapInfo<unsigned int>,llvm::detail::DenseSetPair<unsigned int> >::getNumEntries C:\src\llvm-project\llvm\include\llvm\ADT\DenseMap.h:485:0
 #9 0x00007ff64e3dd3df llvm::DenseMapBase<llvm::SmallDenseMap<unsigned int,llvm::detail::DenseSetEmpty,1,llvm::DenseMapInfo<unsigned int>,llvm::detail::DenseSetPair<unsigned int> >,unsigned int,llvm::detail::DenseSetEmpty,llvm::DenseMapInfo<unsigned int>,llvm::detail::DenseSetPair<unsigned int> >::empty C:\src\llvm-project\llvm\include\llvm\ADT\DenseMap.h:98:0
#10 0x00007ff64e3dd3df llvm::detail::DenseSetImpl<unsigned int,llvm::SmallDenseMap<unsigned int,llvm::detail::DenseSetEmpty,1,llvm::DenseMapInfo<unsigned int>,llvm::detail::DenseSetPair<unsigned int> >,llvm::DenseMapInfo<unsigned int> >::empty C:\src\llvm-project\llvm\include\llvm\ADT\DenseSet.h:80:0
#11 0x00007ff64e3dd3df `anonymous namespace'::BitcodeReaderMetadataList::hasFwdRefs C:\src\llvm-project\llvm\lib\Bitcode\Reader\MetadataLoader.cpp:180:0
#12 0x00007ff64e3dd3df llvm::MetadataLoader::MetadataLoaderImpl::resolveForwardRefsAndPlaceholders C:\src\llvm-project\llvm\lib\Bitcode\Reader\MetadataLoader.cpp:1123:0
#13 0x00007ff64e3de27a std::vector<std::pair<llvm::DICompileUnit *,llvm::Metadata *>,std::allocator<std::pair<llvm::DICompileUnit *,llvm::Metadata *> > >::begin C:\src\llvm-project\mysysroot\VC\Tools\MSVC\14.28.29333\include\vector:1411:0
#14 0x00007ff64e3de27a llvm::MetadataLoader::MetadataLoaderImpl::upgradeCUSubprograms C:\src\llvm-project\llvm\lib\Bitcode\Reader\MetadataLoader.cpp:496:0
#15 0x00007ff64e3de27a llvm::MetadataLoader::MetadataLoaderImpl::upgradeDebugInfo C:\src\llvm-project\llvm\lib\Bitcode\Reader\MetadataLoader.cpp:640:0
#16 0x00007ff64e3de27a llvm::MetadataLoader::MetadataLoaderImpl::parseMetadata(bool) C:\src\llvm-project\llvm\lib\Bitcode\Reader\MetadataLoader.cpp:1039:0
#17 0x00007ff64e3de152 llvm::MetadataLoader::parseMetadata(bool) C:\src\llvm-project\llvm\lib\Bitcode\Reader\MetadataLoader.cpp:2311:0
#18 0x00007ff64dbb1d13 llvm::MetadataLoader::parseFunctionMetadata C:\src\llvm-project\llvm\lib\Bitcode\Reader\MetadataLoader.h:50:0
#19 0x00007ff64dbb1d13 `anonymous namespace'::BitcodeReader::parseFunctionBody C:\src\llvm-project\llvm\lib\Bitcode\Reader\BitcodeReader.cpp:3926:0
#20 0x00007ff64dbb1acb llvm::Error::getPtr C:\src\llvm-project\llvm\include\llvm\Support\Error.h:273:0
#21 0x00007ff64dbb1acb llvm::Error::operator bool C:\src\llvm-project\llvm\include\llvm\Support\Error.h:236:0
#22 0x00007ff64dbb1acb `anonymous namespace'::BitcodeReader::materialize C:\src\llvm-project\llvm\lib\Bitcode\Reader\BitcodeReader.cpp:5525:0
#23 0x00007ff64e3f4336 llvm::Error::getPtr C:\src\llvm-project\llvm\include\llvm\Support\Error.h:273:0
#24 0x00007ff64e3f4336 llvm::Error::operator bool C:\src\llvm-project\llvm\include\llvm\Support\Error.h:236:0
#25 0x00007ff64e3f4336 `anonymous namespace'::BitcodeReader::materializeModule C:\src\llvm-project\llvm\lib\Bitcode\Reader\BitcodeReader.cpp:5613:0
#26 0x00007ff64e3f41e9 std::default_delete<llvm::GVMaterializer>::operator() C:\src\llvm-project\mysysroot\VC\Tools\MSVC\14.28.29333\include\memory:2537:0
#27 0x00007ff64e3f41e9 std::unique_ptr<llvm::GVMaterializer,std::default_delete<llvm::GVMaterializer> >::~unique_ptr C:\src\llvm-project\mysysroot\VC\Tools\MSVC\14.28.29333\include\memory:2647:0
#28 0x00007ff64e3f41e9 llvm::Module::materializeAll(void) C:\src\llvm-project\llvm\lib\IR\Module.cpp:450:0
#29 0x00007ffc1b3a10b2 llvm::Error::getPtr C:\src\llvm-project\llvm\include\llvm\Support\Error.h:273:0
#30 0x00007ffc1b3a10b2 llvm::Error::operator bool C:\src\llvm-project\llvm\include\llvm\Support\Error.h:236:0
#31 0x00007ffc1b3a10b2 llvm::BitcodeModule::getModuleImpl(class llvm::LLVMContext &, bool, bool, bool, class llvm::function_ref<(class llvm::StringRef)>) C:\src\llvm-project\llvm\lib\Bitcode\Reader\BitcodeReader.cpp:6810:0
#32 0x00007ffc1d637c24 llvm::BitcodeModule::parseModule(class llvm::LLVMContext &, class llvm::function_ref<(class llvm::StringRef)>) C:\src\llvm-project\llvm\lib\Bitcode\Reader\BitcodeReader.cpp:6992:0
#33 0x00007ffc1ddad721 llvm::Expected<std::unique_ptr<llvm::Module,std::default_delete<llvm::Module> > >::operator bool C:\src\llvm-project\llvm\include\llvm\Support\Error.h:531:0
#34 0x00007ffc1ddad721 `anonymous namespace'::InProcessThinBackend::runThinLTOBackendThread::<lambda_1>::operator() C:\src\llvm-project\llvm\lib\LTO\LTO.cpp:1214:0
#35 0x00007ff64dbb1acb std::_Func_class<std::unique_ptr<llvm::lto::NativeObjectStream,std::default_delete<llvm::lto::NativeObjectStream> >,unsigned int>::_Getimpl C:\src\llvm-project\mysysroot\VC\Tools\MSVC\14.28.29333\include\functional:1115:0
#36 0x00007ff64dbb1acb std::_Func_class<std::unique_ptr<llvm::lto::NativeObjectStream,std::default_delete<llvm::lto::NativeObjectStream> >,unsigned int>::_Empty C:\src\llvm-project\mysysroot\VC\Tools\MSVC\14.28.29333\include\functional:1009:0
#37 0x00007ff64dbb1acb std::_Func_class<std::unique_ptr<llvm::lto::NativeObjectStream,std::default_delete<llvm::lto::NativeObjectStream> >,unsigned int>::_Tidy C:\src\llvm-project\mysysroot\VC\Tools\MSVC\14.28.29333\include\functional:1072:0
#38 0x00007ff64dbb1acb std::_Func_class<std::unique_ptr<llvm::lto::NativeObjectStream,std::default_delete<llvm::lto::NativeObjectStream> >,unsigned int>::~_Func_class C:\src\llvm-project\mysysroot\VC\Tools\MSVC\14.28.29333\include\functional:999:0
#39 0x00007ff64dbb1acb `anonymous namespace'::InProcessThinBackend::runThinLTOBackendThread C:\src\llvm-project\llvm\lib\LTO\LTO.cpp:1235:0
#40 0x00007ff64dbb1acb `anonymous namespace'::InProcessThinBackend::start::<lambda_1>::operator() C:\src\llvm-project\llvm\lib\LTO\LTO.cpp:1268:0
#41 0x00007ff64dbb1acb std::invoke C:\src\llvm-project\mysysroot\VC\Tools\MSVC\14.28.29333\include\type_traits:1595:0
#42 0x00007ff64dbb1acb std::_Invoker_ret<std::_Unforced,0>::_Call C:\src\llvm-project\mysysroot\VC\Tools\MSVC\14.28.29333\include\functional:772:0
#43 0x00007ff64dbb1acb std::_Call_binder C:\src\llvm-project\mysysroot\VC\Tools\MSVC\14.28.29333\include\functional:1439:0
#44 0x00007ff64dbb1acb std::_Binder<std::_Unforced,`lambda at C:\src\llvm-project\llvm\lib\LTO\LTO.cpp:1252:9',llvm::BitcodeModule &,std::reference_wrapper<llvm::ModuleSummaryIndex>,std::reference_wrapper<const llvm::StringMap<std::unordered_set<unsigned long long,std::hash<unsigned long long>,std::equal_to<unsigned long long>,std::allocator<unsigned long long> >,llvm::MallocAllocator> >,std::reference_wrapper<const llvm::DenseSet<llvm::ValueInfo,llvm::DenseMapInfo<llvm::ValueInfo> > >,std::reference_wrapper<const std::map<unsigned long long,llvm::GlobalValue::LinkageTypes,std::less<unsigned long long>,std::allocator<std::pair<const unsigned long long,llvm::GlobalValue::LinkageTypes> > > >,std::reference_wrapper<const llvm::DenseMap<unsigned long long,llvm::GlobalValueSummary *,llvm::DenseMapInfo<unsigned long long>,llvm::detail::DenseMapPair<unsigned long long,llvm::GlobalValueSummary *> > >,std::reference_wrapper<llvm::MapVector<llvm::StringRef,llvm::BitcodeModule,llvm::DenseMap<llvm::StringRef,unsigned int,llvm::DenseMapInfo<llvm::StringRef>,llvm::detail::DenseMapPair<llvm::StringRef,unsigned int> >,std::vector<std::pair<llvm::StringRef,llvm::BitcodeModule>,std::allocator<std::pair<llvm::StringRef,llvm::BitcodeModule> > > > > >::operator() C:\src\llvm-project\mysysroot\VC\Tools\MSVC\14.28.29333\include\functional:1495:0
#45 0x00007ff64dbb1acb std::invoke C:\src\llvm-project\mysysroot\VC\Tools\MSVC\14.28.29333\include\type_traits:1584:0
#46 0x00007ff64dbb1acb std::_Invoker_ret<void,1>::_Call C:\src\llvm-project\mysysroot\VC\Tools\MSVC\14.28.29333\include\functional:744:0
#47 0x00007ff64dbb1acb std::_Func_impl_no_alloc<std::_Binder<std::_Unforced,`lambda at C:\src\llvm-project\llvm\lib\LTO\LTO.cpp:1252:9',llvm::BitcodeModule &,std::reference_wrapper<llvm::ModuleSummaryIndex>,std::reference_wrapper<const llvm::StringMap<std::unordered_set<unsigned long long,std::hash<unsigned long long>,std::equal_to<unsigned long long>,std::allocator<unsigned long long> >,llvm::MallocAllocator> >,std::reference_wrapper<const llvm::DenseSet<llvm::ValueInfo,llvm::DenseMapInfo<llvm::ValueInfo> > >,std::reference_wrapper<const std::map<unsigned long long,llvm::GlobalValue::LinkageTypes,std::less<unsigned long long>,std::allocator<std::pair<const unsigned long long,llvm::GlobalValue::LinkageTypes> > > >,std::reference_wrapper<const llvm::DenseMap<unsigned long long,llvm::GlobalValueSummary *,llvm::DenseMapInfo<unsigned long long>,llvm::detail::DenseMapPair<unsigned long long,llvm::GlobalValueSummary *> > >,std::reference_wrapper<llvm::MapVector<llvm::StringRef,llvm::BitcodeModule,llvm::DenseMap<llvm::StringRef,unsigned int,llvm::DenseMapInfo<llvm::StringRef>,llvm::detail::DenseMapPair<llvm::StringRef,unsigned int> >,std::vector<std::pair<llvm::StringRef,llvm::BitcodeModule>,std::allocator<std::pair<llvm::StringRef,llvm::BitcodeModule> > > > > >,void>::_Do_call C:\src\llvm-project\mysysroot\VC\Tools\MSVC\14.28.29333\include\functional:947:0
#48 0x00007ff64e3f4336 std::_Packaged_state<void ()>::_Call_immediate C:\src\llvm-project\mysysroot\VC\Tools\MSVC\14.28.29333\include\future:604:0
#49 0x00007ff64e3f4336 std::packaged_task<(void)>::operator()(void) C:\src\llvm-project\mysysroot\VC\Tools\MSVC\14.28.29333\include\future:1386:0
#50 0x00007ff64e3f41e9 std::_Mutex_base::lock C:\src\llvm-project\mysysroot\VC\Tools\MSVC\14.28.29333\include\mutex:51:0
#51 0x00007ff64e3f41e9 std::lock_guard<std::mutex>::lock_guard C:\src\llvm-project\mysysroot\VC\Tools\MSVC\14.28.29333\include\mutex:429:0
#52 0x00007ff64e3f41e9 llvm::ThreadPool::ThreadPool::<lambda_0>::operator() C:\src\llvm-project\llvm\lib\Support\ThreadPool.cpp:56:0
#53 0x00007ff64e3f41e9 std::invoke C:\src\llvm-project\mysysroot\VC\Tools\MSVC\14.28.29333\include\type_traits:1584:0
#54 0x00007ff64e3f41e9 std::thread::_Invoke<std::tuple<`lambda at C:\src\llvm-project\llvm\lib\Support\ThreadPool.cpp:29:26'>,0> C:\src\llvm-project\mysysroot\VC\Tools\MSVC\14.28.29333\include\thread:43:0
#55 0x00007ffc1b3a10b2 (C:\WINDOWS\System32\ucrtbase.dll+0x210b2)
#56 0x00007ffc1d637c24 (C:\WINDOWS\System32\KERNEL32.DLL+0x17c24)
#57 0x00007ffc1ddad721 (C:\WINDOWS\SYSTEM32\ntdll.dll+0x6d721)
MaskRay added inline comments.
/llvm/test/Transforms/Reassociate/undef_intrinsics_when_deleting_instructions.ll
6

There are \r characters in this file and many others. Please remove them when reapplying.

I'm also having problems with this commit, only I'm seeing it without assertions. Working on a smaller repro, but will revert soon.

Our failure involves building libc++abi with LTO. So the common issue seems to be lto.

#0 0x00000000010ff6ba llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /usr/local/google/home/saugustine/llvm-new/llvm-project/llvm/lib/Support/Unix/Signals.inc:565:11
#1 0x00000000010ff88b PrintStackTraceSignalHandler(void*) /usr/local/google/home/saugustine/llvm-new/llvm-project/llvm/lib/Support/Unix/Signals.inc:632:1
#2 0x00000000010fde5b llvm::sys::RunSignalHandlers() /usr/local/google/home/saugustine/llvm-new/llvm-project/llvm/lib/Support/Signals.cpp:75:5
#3 0x0000000001100001 SignalHandler(int) /usr/local/google/home/saugustine/llvm-new/llvm-project/llvm/lib/Support/Unix/Signals.inc:407:1
#4 0x00007f6e6bdb4140 restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14140)
#5 0x000000000192582c llvm::ValueAsMetadata::getValue() const /usr/local/google/home/saugustine/llvm-new/llvm-project/llvm/include/llvm/IR/Metadata.h:384:36
#6 0x00000000051fc1fa (anonymous namespace)::Mapper::mapValue(llvm::Value const*) /usr/local/google/home/saugustine/llvm-new/llvm-project/llvm/lib/Transforms/Utils/ValueMapper.cpp:404:46
#7 0x00000000051fd0c2 (anonymous namespace)::Mapper::remapInstruction(llvm::Instruction*) /usr/local/google/home/saugustine/llvm-new/llvm-project/llvm/lib/Transforms/Utils/ValueMapper.cpp:899:12
#8 0x00000000051fdbd6 (anonymous namespace)::Mapper::remapFunction(llvm::Function&) /usr/local/google/home/saugustine/llvm-new/llvm-project/llvm/lib/Transforms/Utils/ValueMapper.cpp:995:25
#9 0x00000000051ff34a (anonymous namespace)::Mapper::flush() /usr/local/google/home/saugustine/llvm-new/llvm-project/llvm/lib/Transforms/Utils/ValueMapper.cpp:855:3
#10 0x00000000051fbb98 (anonymous namespace)::FlushingMapper::~FlushingMapper() /usr/local/google/home/saugustine/llvm-new/llvm-project/llvm/lib/Transforms/Utils/ValueMapper.cpp:1114:34
#11 0x00000000051fbbe2 llvm::ValueMapper::mapValue(llvm::Value const&) /usr/local/google/home/saugustine/llvm-new/llvm-project/llvm/lib/Transforms/Utils/ValueMapper.cpp:1139:3
#12 0x0000000004e2a9bb (anonymous namespace)::IRLinker::run() /usr/local/google/home/saugustine/llvm-new/llvm-project/llvm/lib/Linker/IRMover.cpp:1478:12
#13 0x0000000004e29e2a llvm::IRMover::move(std::unique_ptr<llvm::Module, std::default_delete<llvm::Module> >, llvm::ArrayRef<llvm::GlobalValue*>, std::function<void (llvm::GlobalValue&, std::function<void (llvm::GlobalValue&)>)>, bool) /usr/local/google/home/saugustine/llvm-new/llvm-project/llvm/lib/Linker/IRMover.cpp:1618:25
#14 0x0000000003bbc8fb llvm::lto::LTO::linkRegularLTO(llvm::lto::LTO::RegularLTOState::AddedModule, bool) /usr/local/google/home/saugustine/llvm-new/llvm-project/llvm/lib/LTO/LTO.cpp:881:3
#15 0x0000000003bbd7dc llvm::lto::LTO::runRegularLTO(std::function<std::unique_ptr<llvm::lto::NativeObjectStream, std::default_delete<llvm::lto::NativeObjectStream> > (unsigned int)>) /usr/local/google/home/saugustine/llvm-new/llvm-project/llvm/lib/LTO/LTO.cpp:1054:21
#16 0x0000000003bbd2f3 llvm::lto::LTO::run(std::function<std::unique_ptr<llvm::lto::NativeObjectStream, std::default_delete<llvm::lto::NativeObjectStream> > (unsigned int)>, std::function<std::function<std::unique_ptr<llvm::lto::NativeObjectStream, std::default_delete<llvm::lto::NativeObjectStream> > (unsigned int)> (unsigned int, llvm::StringRef)>) /usr/local/google/home/saugustine/llvm-new/llvm-project/llvm/lib/LTO/LTO.cpp:1032:18
#17 0x00000000013c81f2 lld::elf::BitcodeCompiler::compile() /usr/local/google/home/saugustine/llvm-new/llvm-project/lld/ELF/LTO.cpp:316:5
#18 0x000000000131526c void lld::elf::LinkerDriver::compileBitcodeFiles<llvm::object::ELFType<(llvm::support::endianness)1, true> >() /usr/local/google/home/saugustine/llvm-new/llvm-project/lld/ELF/Driver.cpp:1911:26
#19 0x00000000012eaa2c void lld::elf::LinkerDriver::link<llvm::object::ELFType<(llvm::support::endianness)1, true> >(llvm::opt::InputArgList&) /usr/local/google/home/saugustine/llvm-new/llvm-project/lld/ELF/Driver.cpp:2236:7
#20 0x00000000012d17a5 lld::elf::LinkerDriver::linkerMain(llvm::ArrayRef<char const*>) /usr/local/google/home/saugustine/llvm-new/llvm-project/lld/ELF/Driver.cpp:565:7
#21 0x00000000012d1037 lld::elf::link(llvm::ArrayRef<char const*>, bool, llvm::raw_ostream&, llvm::raw_ostream&) /usr/local/google/home/saugustine/llvm-new/llvm-project/lld/ELF/Driver.cpp:127:7
#22 0x000000000103cfbb lldMain(int, char const**, llvm::raw_ostream&, llvm::raw_ostream&, bool) /usr/local/google/home/saugustine/llvm-new/llvm-project/lld/tools/lld/lld.cpp:154:12
#23 0x000000000103ccb7 main /usr/local/google/home/saugustine/llvm-new/llvm-project/lld/tools/lld/lld.cpp:212:5
#24 0x00007f6e6b877d0a
libc_start_main ./csu/../csu/libc-start.c:308:16
#25 0x000000000103c9aa _start (/usr/local/google/home/saugustine/llvm-new/build/bin/ld.lld+0x103c9aa)
Segmentation fault

I'll revert the change for now -

Ah sorry I came up with a repro but didn't find this phab review earlier. https://crbug.com/1198356#c1