llvm / llvm/llvm-project

[Attributor] Assertion `llvm::isPowerOf2_64(Value) && "Alignment is not a power of 2"' failed.

Open
#165,701 0 comments 0 reactions 0 assignees View on GitHub
crash llvm::Attributor
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

Reproducer:
https://godbolt.org/z/TddWPEWzG

Backtrace:
```console
opt: /root/llvm-project/llvm/include/llvm/Support/Alignment.h:70: llvm::Align::Align(uint64_t): Assertion `llvm::isPowerOf2_64(Value) && "Alignment is not a power of 2"' 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 0x00007c5201242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#3 0x00007c52012969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#4 0x00007c5201242476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#5 0x00007c52012287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#6 0x00007c520122871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#7 0x00007c5201239e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#8 0x0000000000c5f3af llvm::Align::Align(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xc5f3af)
#9 0x00000000031b6148 void (anonymous namespace)::followUsesInContext<(anonymous namespace)::AAAlignImpl, llvm::IncIntegerState>((anonymous namespace)::AAAlignImpl&, llvm::Attributor&, llvm::MustBeExecutedContextExplorer&, llvm::Instruction const*, llvm::SetVector, llvm::DenseSet>, 0u>&, llvm::IncIntegerState&) AttributorAttributes.cpp:0:0
#10 0x00000000031b6a88 (anonymous namespace)::AAAlignImpl::initialize(llvm::Attributor&) AttributorAttributes.cpp:0:0
#11 0x0000000003137888 llvm::AAAlign const* llvm::Attributor::getOrCreateAAFor(llvm::IRPosition, llvm::AbstractAttribute const*, llvm::DepClassTy, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3137888)
#12 0x00000000031389ff llvm::Attributor::identifyDefaultAbstractAttributes(llvm::Function&) (.part.0) Attributor.cpp:0:0
#13 0x0000000003139711 llvm::Attributor::identifyDefaultAbstractAttributes(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3139711)
#14 0x0000000003142d9b runAttributorOnFunctions(llvm::InformationCache&, llvm::SetVector, llvm::DenseSet>, 0u>&, llvm::AnalysisGetter&, llvm::CallGraphUpdater&, bool, bool) (.part.0) Attributor.cpp:0:0
#15 0x000000000314395f llvm::AttributorPass::run(llvm::Module&, llvm::AnalysisManager&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x314395f)
#16 0x0000000002fb687e llvm::detail::PassModel>::run(llvm::Module&, llvm::AnalysisManager&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2fb687e)
#17 0x00000000057656c1 llvm::PassManager>::run(llvm::Module&, llvm::AnalysisManager&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x57656c1)
#18 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)
#19 0x0000000000979dd1 optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x979dd1)
#20 0x00007c5201229d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#21 0x00007c5201229e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#22 0x00000000009711e5 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x9711e5)
Program terminated with signal: SIGSEGV
Compiler returned: 139
```

Contributor guide

Open the contributing guide

Research direction

Start with the Godbolt reproducer and run opt with the attributor pass to confirm the assertion. Trace AAAlignImpl::initialize and followUsesInContext in AttributorAttributes.cpp, then inspect the alignment invariant in llvm/include/llvm/Support/Alignment.h. Done means the reproducer no longer aborts on a non-power-of-two alignment and regression coverage is added.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.