[llvm-dev] LoopIdiomRegognize vs Preserved

Mikael Holmén via llvm-dev llvm-dev at lists.llvm.org
Tue Feb 9 01:19:25 PST 2016


Hi Haicheng,

Originally I ran into this on our out-of-tree target but I managed to 
reproduce the crash on X86 as well now:

  build-all/bin/opt -S -sroa -loop-rotate -loop-deletion -licm 
-loop-idiom ../llvm/bugpoint-reduced-simplified.i8+.ll

gives:

While deleting: void %
An asserting value handle still pointed to this value!
UNREACHABLE executed at ../lib/IR/Value.cpp:696!
0  opt             0x0000000001752bc8 
llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1  opt             0x0000000001751376 llvm::sys::RunSignalHandlers() + 54
2  opt             0x00000000017537ca
3  libpthread.so.0 0x00007f1909a70340
4  libc.so.6       0x00007f1908c98cc9 gsignal + 57
5  libc.so.6       0x00007f1908c9c0d8 abort + 328
6  opt             0x000000000170cddd 
llvm::llvm_unreachable_internal(char const*, char const*, unsigned int) 
+ 461
7  opt             0x000000000137bd3b 
llvm::ValueHandleBase::ValueIsDeleted(llvm::Value*) + 1051
8  opt             0x000000000137b5db llvm::Value::~Value() + 43
9  opt             0x0000000001322319 llvm::CallInst::~CallInst() + 9
10 opt             0x000000000131e676 
llvm::Instruction::eraseFromParent() + 86
11 opt             0x00000000015e8d14
12 opt             0x00000000015e8630
13 opt             0x00000000015e4e6a
14 opt             0x0000000000f5404e 
llvm::LPPassManager::runOnFunction(llvm::Function&) + 1086
15 opt             0x000000000134a034 
llvm::FPPassManager::runOnFunction(llvm::Function&) + 516
16 opt             0x000000000134a27b 
llvm::FPPassManager::runOnModule(llvm::Module&) + 43
17 opt             0x000000000134a757 
llvm::legacy::PassManagerImpl::run(llvm::Module&) + 903
18 opt             0x000000000062aa9e main + 8782
19 libc.so.6       0x00007f1908c83ec5 __libc_start_main + 245
20 opt             0x0000000000618bcf
Stack dump:
0.      Program arguments: build-all/bin/opt -S -sroa -loop-rotate 
-loop-deletion -licm -loop-idiom ../llvm/bugpoint-reduced-simplified.i8+.ll
1.      Running pass 'Function Pass Manager' on module 
'../llvm/bugpoint-reduced-simplified.i8+.ll'.
2.      Running pass 'Loop Pass Manager' on function '@set_array'
3.      Running pass 'Recognize loop idioms' on basic block '%bb4'
Abort

/Mikael

On 02/08/2016 05:50 PM, Haicheng Wu wrote:
> Hi Mikael,
>
> What is your compilation command to trig the assert?  I am trying to reproduce your problem.
>
> Thank you,
>
> Haicheng
>
> -----Original Message-----
> From: llvm-dev [mailto:llvm-dev-bounces at lists.llvm.org] On Behalf Of Mikael Holmén via llvm-dev
> Sent: Monday, February 08, 2016 4:33 AM
> To: llvm-dev at lists.llvm.org
> Subject: [llvm-dev] LoopIdiomRegognize vs Preserved
>
> Hi,
>
> I'm having problems with the LoopIdiomRegognizer crashing on me with
>
> An asserting value handle still pointed to this value!
> UNREACHABLE executed at ../lib/IR/Value.cpp:695!
>
> If I remove
>
>       AU.addPreserved<LoopInfoWrapperPass>();
>
> or
>
>       AU.addPreserved<AAResultsWrapperPass>();
>
> everything goes well.
>
> The C-code triggering this is
>
> void foo(int a[10][10])
> {
>       int	i, j, k;
>
>       for (i = 0; i < 1; i++) {
>           for (j = 0; j < 2; j++) {
>               for (k = 0; k < 10; k++) {
>                   a[j][k] = 42;
>               }
>           }
>       }
> }
>
> First LoopIdiomRecognize replaces the store in the inner loop with a memset in the outer loop, and later, when examining the outer loop it tries to replace that memset with an even bigger memset in the outermost loop. But then, when removing the "old" memset, the assert blows.
>
> I don't know LoopIdiomRecognize very well at all, is it obvious that AAResultsWrapperPass and/or LoopInfoWrapperPass should not be preserved here?
>
> Regards,
> Mikael
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
>
-------------- next part --------------

define void @set_array() {
  %j.3 = alloca i8
  %k.4 = alloca i8
  br label %bb1

bb4:                                              ; preds = %bb3
  store i8 0, i8* %k.4
  br label %bb5

bb6:                                              ; preds = %bb5
  %_tmp31 = sext i8 %_tmp3 to i64
  %_tmp4 = mul i64 %_tmp31, 10
  %_tmp5 = getelementptr i8, i8* undef, i64 %_tmp4
  %_tmp6 = load i8, i8* %k.4
  %_tmp7 = getelementptr i8, i8* %_tmp5, i8 %_tmp6
  store i8 42, i8* %_tmp7
  %_tmp8 = load i8, i8* %k.4
  %_tmp9 = add i8 %_tmp8, 1
  store i8 %_tmp9, i8* %k.4
  br label %bb5

bb5:                                              ; preds = %bb6, %bb4
  %_tmp10 = load i8, i8* %k.4
  %_tmp11 = icmp slt i8 %_tmp10, 10
  %_tmp3 = load i8, i8* %j.3
  br i1 %_tmp11, label %bb6, label %bb7

bb7:                                              ; preds = %bb5
  %_tmp13 = add i8 %_tmp3, 1
  store i8 %_tmp13, i8* %j.3
  br label %bb3

bb3:                                              ; preds = %bb1, %bb7
  %_tmp14 = load i8, i8* %j.3
  %_tmp15 = icmp slt i8 %_tmp14, 2
  br i1 %_tmp15, label %bb4, label %bb1

bb1:                                              ; preds = %bb3, %0
  br i1 false, label %bb3, label %bb9

bb9:                                              ; preds = %bb1
  ret void
}

!llvm.ident = !{!0}

!0 = !{!"foo"}


More information about the llvm-dev mailing list