Issue 148433
Summary [LV] removed instruction should only be used by instructions inserted
Labels new issue
Assignees
Reporter sjoerdmeijer
    Compiling this:

```
extern short a[];
short b;
long c;
char d;
long *e;
void f(bool g, int h[][2]) {
 for (int i;;)
    for (bool j; j < b; j = c)
      for (short k = 0; k < d; k += (g && e[i]) + 2)
        a[k] = c ? h[i][k] : 0;
}
```

with `clang++  -std=c++11 --Ofast -mcpu=grace` results in this assert:

```
clang++: gllvm-project/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp:2398: void llvm::SCEVExpanderCleaner::cleanup(): Assertion `all_of(I->users(), [&InsertedSet](Value *U) { return InsertedSet.contains(cast<Instruction>(U)); }) && "removed instruction should only be used by instructions inserted " "during expansion"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: gllvm-project/build/bin/clang++ -std=c++11 -w -fPIC -Ofast -mllvm -enable-loopinterchange -mcpu=grace -o clang_ofast_func.o -c func.cpp
1. <eof> parser at end of file
2.      Optimizer
3.      Running pass "function<eager-inv>(float2int,lower-constant-intrinsics,chr,loop(loop-rotate<header-duplication;no-prepare-for-lto>,loop-deletion),loop-distribute,inject-tli-mappings,loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,infer-alignment,loop-load-elim,instcombine<max-iterations=1;no-verify-fixpoint>,simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,slp-vectorizer,vector-combine,instcombine<max-iterations=1;no-verify-fixpoint>,loop-unroll<O3>,transform-warning,sroa<preserve-cfg>,infer-alignment,instcombine<max-iterations=1;no-verify-fixpoint>,loop-mssa(licm<allowspeculation>),alignment-from-assumptions,loop-sink,instsimplify,div-rem-pairs,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;speculate-unpredictables>)" on module "func.cpp"
4.      Running pass "loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>" on function "_Z1fbPA2_i"
 #0 0x0000b94d5eb91150 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) gllvm-project/llvm/lib/Support/Unix/Signals.inc:834:13
 #1 0x0000b94d5eb8ebe8 std::atomic<CallbackAndCookie::Status>::store(CallbackAndCookie::Status, std::memory_order) /usr/lib/gcc/aarch64-linux-gnu/12/../../../../include/c++/12/atomic:271:2
 #2 0x0000b94d5eb8ebe8 llvm::sys::RunSignalHandlers() gllvm-project/llvm/lib/Support/Signals.cpp:106:16
 #3 0x0000b94d5eaff6d8 (anonymous namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long) gllvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:73:5
 #4 0x0000b94d5eaff6d8 CrashRecoverySignalHandler(int) gllvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:390:51
 #5 0x0000e1ca29fb09d0 (linux-vdso.so.1+0x9d0)
 #6 0x0000e1ca29a2f200 __pthread_kill_implementation ./nptl/./nptl/pthread_kill.c:44:76
 #7 0x0000e1ca299ea67c gsignal ./signal/../sysdeps/posix/raise.c:27:6
 #8 0x0000e1ca299d7130 abort ./stdlib/./stdlib/abort.c:81:7
 #9 0x0000e1ca299e3fd0 __assert_fail_base ./assert/./assert/assert.c:89:7
#10 0x0000e1ca299e4040 __assert_perror_fail ./assert/./assert/assert-perr.c:31:1
#11 0x0000b94d5eca45a0 llvm::SmallPtrSetImplBase::isSmall() const gllvm-project/llvm/include/llvm/ADT/SmallPtrSet.h:237:33
#12 0x0000b94d5eca45a0 llvm::SmallPtrSetImplBase::~SmallPtrSetImplBase() gllvm-project/llvm/include/llvm/ADT/SmallPtrSet.h:88:10
#13 0x0000b94d5eca45a0 llvm::SCEVExpanderCleaner::cleanup() gllvm-project/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp:2405:1
#14 0x0000b94d5fce1edc llvm::SCEVExpanderCleaner::~SCEVExpanderCleaner() gllvm-project/llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h:567:28
#15 0x0000b94d5fce1edc (anonymous namespace)::GeneratedRTChecks::create(llvm::Loop*, llvm::LoopAccessInfo const&, llvm::SCEVPredicate const&, llvm::ElementCount, unsigned int) gllvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:1823:7
#16 0x0000b94d5fce00f8 llvm::LoopVectorizeHints::getForce() const gllvm-project/llvm/include/llvm/Transforms/Vectorize/LoopVectorizationLegality.h:154:26
#17 0x0000b94d5fce00f8 llvm::LoopVectorizePass::processLoop(llvm::Loop*) gllvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:10095:15
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to