Issue 176628
Summary SROA crashes with "Not byte-addressable" assertion
Labels new issue
Assignees
Reporter sairam2661
    **Fuzzer Generated Test** 
**Test Commit**
[0b2f3cfb72a76fa90f3ec2a234caabe0d0712590](https://github.com/llvm/llvm-project/commit/0b2f3cfb72a76fa90f3ec2a234caabe0d0712590)

**Description**
SROA crashes when processing an alloca of `<2 x i1>` with a GEP that indexes into the vector. The assertion fails because `<2 x i1>` is not byte-addressable. Related issue: https://github.com/llvm/llvm-project/issues/90695

**Steps to reproduce**
-  Test case, `input.ll`
```
define <2 x i1> @test(<2 x i1> %a) {
  %a.priv = alloca <2 x i1>, align 2
  store <2 x i1> %a, ptr %a.priv, align 2
  %a.priv.0.1 = getelementptr <2 x i1>, ptr %a.priv, i64 0, i64 1
  store <2 x i1> %a, ptr %a.priv.0.1, align 2
  ret <2 x i1> zeroinitializer
}
```

**Command**
```
opt -passes='default<O2>' -S input.ll
```

**Output**
```
opt: /workdir/llvm-project/llvm/include/llvm/IR/GetElementPtrTypeIterator.h:158: TypeSize llvm::generic_gep_type_iterator<const llvm::Value *const *>::getSequentialElementStride(const DataLayout &) const [ItTy = const llvm::Value *const *]: Assertion `DL.typeSizeEqualsStoreSize(ElemTy) && "Not byte-addressable"' 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 -passes=default<O2> -S input.ll
1.	Running pass "function<eager-inv>(ee-instrument<>,lower-expect,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;no-switch-range-to-icmp;no-switch-to-arithmetic;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,sroa<modify-cfg>,early-cse<>)" on module "/tmp/tmphhex477e.ll"
2.	Running pass "sroa<modify-cfg>" on function "fuzz_target_b349c7"
 #0 0x00007f0d779ba728 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/workdir/llvm-project/build-libcxx/bin/../lib/libLLVMSupport.so.22.0git+0x1d3728)
 #1 0x00007f0d779b79d5 llvm::sys::RunSignalHandlers() (/workdir/llvm-project/build-libcxx/bin/../lib/libLLVMSupport.so.22.0git+0x1d09d5)
 #2 0x00007f0d779bb3c6 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
 #3 0x00007f0d81ae3420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #4 0x00007f0d774ce00b raise /build/glibc-B3wQXB/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
 #5 0x00007f0d774ad859 abort /build/glibc-B3wQXB/glibc-2.31/stdlib/abort.c:81:7
 #6 0x00007f0d774ad729 get_sysdep_segment_value /build/glibc-B3wQXB/glibc-2.31/intl/loadmsgcat.c:509:8
 #7 0x00007f0d774ad729 _nl_load_domain /build/glibc-B3wQXB/glibc-2.31/intl/loadmsgcat.c:970:34
 #8 0x00007f0d774befd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
 #9 0x00007f0d77e47662 (/workdir/llvm-project/build-libcxx/bin/../lib/libLLVMCore.so.22.0git+0x2db662)
#10 0x00007f0d77e470bd llvm::GEPOperator::accumulateConstantOffset(llvm::Type*, llvm::ArrayRef<llvm::Value const*>, llvm::DataLayout const&, llvm::APInt&, llvm::function_ref<bool (llvm::Value&, llvm::APInt&)>) (/workdir/llvm-project/build-libcxx/bin/../lib/libLLVMCore.so.22.0git+0x2db0bd)
#11 0x00007f0d77e46bae llvm::GEPOperator::accumulateConstantOffset(llvm::DataLayout const&, llvm::APInt&, llvm::function_ref<bool (llvm::Value&, llvm::APInt&)>) const (/workdir/llvm-project/build-libcxx/bin/../lib/libLLVMCore.so.22.0git+0x2dabae)
#12 0x00007f0d7872ffc4 llvm::detail::PtrUseVisitorBase::adjustOffsetForGEP(llvm::GetElementPtrInst&) (/workdir/llvm-project/build-libcxx/bin/../lib/libLLVMAnalysis.so.22.0git+0x3bafc4)
#13 0x00007f0d7944badd (anonymous namespace)::SROA::runOnAlloca(llvm::AllocaInst&) SROA.cpp:0:0
#14 0x00007f0d79447b7f (anonymous namespace)::SROA::runSROA(llvm::Function&) SROA.cpp:0:0
#15 0x00007f0d79447680 llvm::SROAPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/workdir/llvm-project/build-libcxx/bin/../lib/libLLVMScalarOpts.so.22.0git+0x2f7680)
#16 0x00007f0d77e4ff6b llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/workdir/llvm-project/build-libcxx/bin/../lib/libLLVMCore.so.22.0git+0x2e3f6b)
#17 0x00007f0d77e54f9f llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/workdir/llvm-project/build-libcxx/bin/../lib/libLLVMCore.so.22.0git+0x2e8f9f)
#18 0x00007f0d77e4ed4b llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/workdir/llvm-project/build-libcxx/bin/../lib/libLLVMCore.so.22.0git+0x2e2d4b)
#19 0x00007f0d81a989fd llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::__1::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool, bool) (/workdir/llvm-project/build-libcxx/bin/../lib/libLLVMOptDriver.so.22.0git+0x269fd)
#20 0x00007f0d81aa9ae4 optMain (/workdir/llvm-project/build-libcxx/bin/../lib/libLLVMOptDriver.so.22.0git+0x37ae4)
#21 0x00007f0d774af083 __libc_start_main /build/glibc-B3wQXB/glibc-2.31/csu/../csu/libc-start.c:342:3
#22 0x000055faad03307e _start (/workdir/llvm-project/build-libcxx/bin/opt+0x207e)
```



_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to