llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

"level out of range" assert fail in DependenceAnalysis

Open yotann opened this issue 5 years ago • 5 comments

Bugzilla Link 51268
Version 12.0
OS Linux
Attachments GCC-C-execute-960327-1.ll, GCC-C-execute-pr33870.ll, fasta.ll

Extended Description

Each of these three tests (fasta.ll, GCC-C-execute-960327-1.ll, GCC-C-execute-pr33870.ll) triggers an assertion failure when DependenceInfo is applied to every pair of instructions. For example:

opt --da --analyze GCC-C-execute-960327-1.ll ... Printing analysis 'Dependence Analysis' for function 'f': ... Src: %7 = load i8, i8* %6, align 1, !tbaa !​7 --> Dst: store i16 88, i16* %10, align 1 da analyze - opt: /build/llvm/lib/Analysis/DependenceAnalysis.cpp:1157: bool llvm::DependenceInfo::strongSIVtest(const llvm::SCEV*, const llvm::SCEV*, const llvm::SCEV*, const llvm::Loop*, unsigned int, llvm::FullDependence&, llvm::DependenceInfo::Constraint&) const: Assertion `0 < Level && Level <= CommonLevels && "level out of range"' failed. PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace. Stack dump: 0. Program arguments: opt --da --analyze GCC-C-execute-960327-1.ll

  1.  Running pass 'Function Pass Manager' on module 'GCC-C-execute-960327-1.ll'.
    
  2.  Running pass 'FunctionPass Printer: Dependence Analysis' on function '@f'
    

#​0 0x00007fb1b3a0135d llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/nix/store/iqm3zq1acrf4g922rgldc6h8jr9vl9cr-llvm-12.0.0-lib/lib/libLLVM-12.so+0xd8e35d) #​1 0x00007fb1b39ff5f4 llvm::sys::RunSignalHandlers() (/nix/store/iqm3zq1acrf4g922rgldc6h8jr9vl9cr-llvm-12.0.0-lib/lib/libLLVM-12.so+0xd8c5f4) #​2 0x00007fb1b39ff77e SignalHandler(int) (/nix/store/iqm3zq1acrf4g922rgldc6h8jr9vl9cr-llvm-12.0.0-lib/lib/libLLVM-12.so+0xd8c77e) #​3 0x00007fb1b2c65700 __restore_rt (/nix/store/sbbifs2ykc05inws26203h0xwcadnf0l-glibc-2.32-46/lib/libpthread.so.0+0x13700) #​4 0x00007fb1b279933a raise (/nix/store/sbbifs2ykc05inws26203h0xwcadnf0l-glibc-2.32-46/lib/libc.so.6+0x3c33a) #​5 0x00007fb1b2783523 abort (/nix/store/sbbifs2ykc05inws26203h0xwcadnf0l-glibc-2.32-46/lib/libc.so.6+0x26523) #​6 0x00007fb1b278341f _nl_load_domain.cold.0 (/nix/store/sbbifs2ykc05inws26203h0xwcadnf0l-glibc-2.32-46/lib/libc.so.6+0x2641f) #​7 0x00007fb1b2791d92 (/nix/store/sbbifs2ykc05inws26203h0xwcadnf0l-glibc-2.32-46/lib/libc.so.6+0x34d92) #​8 0x00007fb1b4fec109 llvm::DependenceInfo::strongSIVtest(llvm::SCEV const*, llvm::SCEV const*, llvm::SCEV const*, llvm::Loop const*, unsigned int, llvm::FullDependence&, llvm::DependenceInfo::Constraint&) const (/nix/store/iqm3zq1acrf4g922rgldc6h8jr9vl9cr-llvm-12.0.0-lib/lib/libLLVM-12.so+0x2379109) #​9 0x00007fb1b4ff29b3 llvm::DependenceInfo::testSIV(llvm::SCEV const*, llvm::SCEV const*, unsigned int&, llvm::FullDependence&, llvm::DependenceInfo::Constraint&, llvm::SCEV const*&) const (/nix/store/iqm3zq1acrf4g922rgldc6h8jr9vl9cr-llvm-12.0.0-lib/lib/libLLVM-12.so+0x237f9b3) #​10 0x00007fb1b4ff8e2c llvm::DependenceInfo::depends(llvm::Instruction*, llvm::Instruction*, bool) (/nix/store/iqm3zq1acrf4g922rgldc6h8jr9vl9cr-llvm-12.0.0-lib/lib/libLLVM-12.so+0x2385e2c) #​11 0x00007fb1b4ffc201 dumpExampleDependence(llvm::raw_ostream&, llvm::DependenceInfo*) (/nix/store/iqm3zq1acrf4g922rgldc6h8jr9vl9cr-llvm-12.0.0-lib/lib/libLLVM-12.so+0x2389201) #​12 0x00000000004310d7 (anonymous namespace)::FunctionPassPrinter::runOnFunction(llvm::Function&) (/nix/store/lpxb0f7wjfm69g9j7m2gncs1mgbx8q35-llvm-12.0.0/bin/opt+0x4310d7) #​13 0x00007fb1b3b66fad llvm::FPPassManager::runOnFunction(llvm::Function&) (/nix/store/iqm3zq1acrf4g922rgldc6h8jr9vl9cr-llvm-12.0.0-lib/lib/libLLVM-12.so+0xef3fad) #​14 0x00007fb1b3b67691 llvm::FPPassManager::runOnModule(llvm::Module&) (/nix/store/iqm3zq1acrf4g922rgldc6h8jr9vl9cr-llvm-12.0.0-lib/lib/libLLVM-12.so+0xef4691) #​15 0x00007fb1b3b66963 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/nix/store/iqm3zq1acrf4g922rgldc6h8jr9vl9cr-llvm-12.0.0-lib/lib/libLLVM-12.so+0xef3963) #​16 0x0000000000421799 main (/nix/store/lpxb0f7wjfm69g9j7m2gncs1mgbx8q35-llvm-12.0.0/bin/opt+0x421799) #​17 0x00007fb1b2784ded __libc_start_main (/nix/store/sbbifs2ykc05inws26203h0xwcadnf0l-glibc-2.32-46/lib/libc.so.6+0x27ded) #​18 0x000000000042234a _start (/nix/store/lpxb0f7wjfm69g9j7m2gncs1mgbx8q35-llvm-12.0.0/bin/opt+0x42234a)

yotann avatar Jul 29 '21 13:07 yotann

Still crashing: https://llvm.godbolt.org/z/5o9v1bWK8

Minimal IR reproducer: opt -passes='print<da>'

target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

define i32 @f([14 x i8]* %0, i8* %1) {
  %3 = alloca [14 x i8], i32 0, align 1
  %4 = getelementptr inbounds [14 x i8], [14 x i8]* %0, i64 0, i64 12
  br label %5

5:                                                ; preds = %5, %2
  %6 = phi i8* [ %1, %2 ], [ %7, %5 ]
  %7 = getelementptr inbounds i8, i8* %6, i64 -1
  %8 = load i8, i8* %6, align 1
  br i1 false, label %5, label %9

9:                                                ; preds = %5
  %10 = bitcast i8* %6 to i16*
  store i16 0, i16* %10, align 1
  ret i32 0
}

; Function Attrs: argmemonly nocallback nofree nosync nounwind willreturn
declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) #0

; Function Attrs: argmemonly nofree nounwind willreturn
declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #1

; Function Attrs: argmemonly nocallback nofree nosync nounwind willreturn
declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture) #0

attributes #0 = { argmemonly nocallback nofree nosync nounwind willreturn }
attributes #1 = { argmemonly nofree nounwind willreturn }

fhahn avatar May 12 '22 17:05 fhahn

cc @Meinersbur @bmahjour

fhahn avatar May 12 '22 17:05 fhahn

All the reproducers pass with the proposed patch in https://reviews.llvm.org/D110973.

bmahjour avatar May 16 '22 15:05 bmahjour

That's great, thanks @bmahjour!

fhahn avatar May 19 '22 19:05 fhahn

https://reviews.llvm.org/D110973 landed today. All three attached IR reproducers are now analyzed without crashing.

bmahjour avatar Jun 08 '22 20:06 bmahjour