[Attributor] Assertion `(Offset == RangeTy::Unassigned) == (Size == RangeTy::Unassigned) && "Inconsistent state!"' failed.
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
Reproducer:
https://godbolt.org/z/vbfnd94Ef
Backtrace:
```console
opt: /root/llvm-project/llvm/include/llvm/Transforms/IPO/Attributor.h:262: bool llvm::AA::RangeTy::isUnassigned() const: Assertion `(Offset == RangeTy::Unassigned) == (Size == RangeTy::Unassigned) && "Inconsistent state!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.
Stack dump:
0. Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=attributor
1. Running pass "attributor" on module ""
#0 0x000000000598f068 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x598f068)
#1 0x000000000598bf14 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
#2 0x000078acbec42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#3 0x000078acbec969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#4 0x000078acbec42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#5 0x000078acbec287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#6 0x000078acbec2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#7 0x000078acbec39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#8 0x0000000003145d03 (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3145d03)
#9 0x000000000316729d llvm::AAPointerInfo::Access::operator&=(llvm::AAPointerInfo::Access const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x316729d)
#10 0x000000000318411e llvm::AA::PointerInfo::State::addAccess(llvm::Attributor&, llvm::AAPointerInfo::RangeList const&, llvm::Instruction&, std::optional, llvm::AAPointerInfo::AccessKind, llvm::Type*, llvm::Instruction*) (.constprop.0) AttributorAttributes.cpp:0:0
#11 0x0000000003184bf3 (anonymous namespace)::AAPointerInfoFloating::handleAccess(llvm::Attributor&, llvm::Instruction&, std::optional, llvm::AAPointerInfo::AccessKind, llvm::SmallSet>&, llvm::ChangeStatus&, llvm::Type&) AttributorAttributes.cpp:0:0
#12 0x000000000318517e (anonymous namespace)::AAPointerInfoFloating::updateImpl(llvm::Attributor&)::'lambda0'(llvm::Use const&, bool&)::operator()(llvm::Use const&, bool&) const::'lambda2'(llvm::Instruction&, llvm::Value*, llvm::Type&, llvm::ArrayRef, llvm::AAPointerInfo::AccessKind)::operator()(llvm::Instruction&, llvm::Value*, llvm::Type&, llvm::ArrayRef, llvm::AAPointerInfo::AccessKind) const AttributorAttributes.cpp:0:0
#13 0x00000000031c3209 (anonymous namespace)::AAPointerInfoFloating::updateImpl(llvm::Attributor&)::'lambda0'(llvm::Use const&, bool&)::operator()(llvm::Use const&, bool&) const AttributorAttributes.cpp:0:0
#14 0x000000000313f4e7 llvm::Attributor::checkForAllUses(llvm::function_ref, llvm::AbstractAttribute const&, llvm::Value const&, bool, llvm::DepClassTy, bool, llvm::function_ref) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x313f4e7)
#15 0x000000000317fb6f (anonymous namespace)::AAPointerInfoFloating::updateImpl(llvm::Attributor&) AttributorAttributes.cpp:0:0
#16 0x000000000310c916 llvm::AbstractAttribute::update(llvm::Attributor&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x310c916)
#17 0x0000000003121483 llvm::Attributor::updateAA(llvm::AbstractAttribute&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3121483)
#18 0x00000000011be203 llvm::AAPointerInfo const* llvm::Attributor::getOrCreateAAFor(llvm::IRPosition, llvm::AbstractAttribute const*, llvm::DepClassTy, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x11be203)
#19 0x000000000312d010 bool llvm::function_ref::callback_fn(llvm::Attributor&, llvm::StoreInst&, llvm::SmallSetVector&, llvm::SmallSetVector*, llvm::AbstractAttribute const&, bool&, bool)::'lambda'(llvm::Value&)>(long, llvm::Value&) Attributor.cpp:0:0
#20 0x000000000315d481 (anonymous namespace)::AAUnderlyingObjectsImpl::forallUnderlyingObjects(llvm::function_ref, llvm::AA::ValueScope) const AttributorAttributes.cpp:0:0
#21 0x000000000313e6da bool getPotentialCopiesOfMemoryValue(llvm::Attributor&, llvm::StoreInst&, llvm::SmallSetVector&, llvm::SmallSetVector*, llvm::AbstractAttribute const&, bool&, bool) (.constprop.0) Attributor.cpp:0:0
#22 0x0000000003192d76 (anonymous namespace)::AAIsDeadFloating::isDeadStore(llvm::Attributor&, llvm::StoreInst&, llvm::SmallSetVector*) AttributorAttributes.cpp:0:0
#23 0x00000000031a051a (anonymous namespace)::AAIsDeadFloating::updateImpl(llvm::Attributor&) AttributorAttributes.cpp:0:0
#24 0x000000000310c916 llvm::AbstractAttribute::update(llvm::Attributor&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x310c916)
#25 0x00000000031212b0 llvm::Attributor::updateAA(llvm::AbstractAttribute&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x31212b0)
#26 0x0000000003121a8b llvm::AAIsDead const* llvm::Attributor::getOrCreateAAFor(llvm::IRPosition, llvm::AbstractAttribute const*, llvm::DepClassTy, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3121a8b)
#27 0x0000000003121ed3 llvm::Attributor::isAssumedDead(llvm::IRPosition const&, llvm::AbstractAttribute const*, llvm::AAIsDead const*, bool&, bool, llvm::DepClassTy) (.part.0) Attributor.cpp:0:0
#28 0x00000000031296b1 llvm::Attributor::checkForAllReadWriteInstructions(llvm::function_ref, llvm::AbstractAttribute&, bool&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x31296b1)
#29 0x0000000003146dda (anonymous namespace)::AANoSyncImpl::updateImpl(llvm::Attributor&) AttributorAttributes.cpp:0:0
#30 0x000000000310c916 llvm::AbstractAttribute::update(llvm::Attributor&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x310c916)
#31 0x00000000031212b0 llvm::Attributor::updateAA(llvm::AbstractAttribute&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x31212b0)
#32 0x000000000312e7bb llvm::AANoSync const* llvm::Attributor::getOrCreateAAFor(llvm::IRPosition, llvm::AbstractAttribute const*, llvm::DepClassTy, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x312e7bb)
#33 0x0000000003138732 llvm::Attributor::identifyDefaultAbstractAttributes(llvm::Function&) (.part.0) Attributor.cpp:0:0
#34 0x0000000003139711 llvm::Attributor::identifyDefaultAbstractAttributes(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3139711)
#35 0x0000000003142d9b runAttributorOnFunctions(llvm::InformationCache&, llvm::SetVector, llvm::DenseSet>, 0u>&, llvm::AnalysisGetter&, llvm::CallGraphUpdater&, bool, bool) (.part.0) Attributor.cpp:0:0
#36 0x000000000314395f llvm::AttributorPass::run(llvm::Module&, llvm::AnalysisManager&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x314395f)
#37 0x0000000002fb687e llvm::detail::PassModel>::run(llvm::Module&, llvm::AnalysisManager&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2fb687e)
#38 0x00000000057656c1 llvm::PassManager>::run(llvm::Module&, llvm::AnalysisManager&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x57656c1)
#39 0x0000000000985b5a llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef, llvm::ArrayRef>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x985b5a)
#40 0x0000000000979dd1 optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x979dd1)
#41 0x000078acbec29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#42 0x000078acbec29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#43 0x00000000009711e5 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x9711e5)
Program terminated with signal: SIGSEGV
Compiler returned: 139
```
Contributor guide
Research direction
Start with the reproducer and run opt with -passes=attributor, then read llvm/include/llvm/Transforms/IPO/Attributor.h and the AttributorAttributes.cpp paths shown in the backtrace. Trace the AAPointerInfo::Access operation that reaches RangeTy::isUnassigned; done means the reproducer no longer aborts with the inconsistent-state assertion.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100