Skip to content

[LV] Crash in llvm::DemandedBits::performAnalysis() #149727

@sjoerdmeijer

Description

@sjoerdmeijer

See also: https://godbolt.org/z/TezabjsPe

This input:

char a;
int b, f, g;
extern char c;
short d;
extern short e[];
void h(bool i[][4], int j[][4][24], int k[][4][4]) {
  for (int l;; l += 3) {
    for (signed char m = 0; m < 4; m++)
#pragma clang loop vectorize(enable)
      for (int n(i[g][l] - 1); n < 24U; n += 3) {
        d = e[m] = j[2][g][m] ?: j[1][l][m];
        if (f)
          a += b = i[2][g];
        c += 0 < j[l][m][n] & k[g][3][3];
      }
    for (int o; o; o += 3)
      ;
    for (int p; p; p += 3)
      ;
  }
}

Crashes with:

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: /opt/compiler-explorer/clang-trunk/bin/clang++ -gdwarf-4 -g -o /app/output.s -fno-verbose-asm -S -target aarch64-linux-gnu --gcc-toolchain=/opt/compiler-explorer/arm64/gcc-12.2.0/aarch64-unknown-linux-gnu --sysroot=/opt/compiler-explorer/arm64/gcc-12.2.0/aarch64-unknown-linux-gnu/aarch64-unknown-linux-gnu/sysroot -fcolor-diagnostics -fno-crash-diagnostics -std=c++11 -Ofast -mcpu=grace <source>
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 "<source>"
4.	Running pass "loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>" on function "_Z1hPA4_bPA4_A24_iPA4_A4_i"
 #0 0x0000000003c90a38 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3c90a38)
 #1 0x0000000003c8e40c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3c8e40c)
 #2 0x0000000003bde738 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007f2188e42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x0000000002e55ae3 llvm::DemandedBits::performAnalysis() (.part.0) DemandedBits.cpp:0:0
 #5 0x0000000002e591b5 llvm::DemandedBits::getDemandedBits(llvm::Instruction*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x2e591b5)
 #6 0x0000000002e40ff5 llvm::computeMinimumValueSizes(llvm::ArrayRef<llvm::BasicBlock*>, llvm::DemandedBits&, llvm::TargetTransformInfo const*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x2e40ff5)
 #7 0x000000000572a67f llvm::LoopVectorizationCostModel::computeFeasibleMaxVF(unsigned int, llvm::ElementCount, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x572a67f)
 #8 0x000000000572b0c1 llvm::LoopVectorizationCostModel::computeMaxVF(llvm::ElementCount, unsigned int) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x572b0c1)
 #9 0x000000000574d51b llvm::LoopVectorizationPlanner::plan(llvm::ElementCount, unsigned int) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x574d51b)

Metadata

Metadata

Assignees

No one assigned

    Labels

    crashPrefer [crash-on-valid] or [crash-on-invalid]vectorizers

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions