[llvm] [SLP]Fix/improve getSpillCost analysis (PR #129258)

Alexey Bataev via llvm-commits llvm-commits at lists.llvm.org
Sat Mar 15 05:08:25 PDT 2025


alexey-bataev wrote:

> We've found a clang crash that seems to be introduced by this commit. The original build is using instrumented FDO + thinlto with a bunch of dependencies. I managed to get a standalone reproducer (hopefully, nothing important was lost during the automated reduction):
> 
> ```
> $ cat reduced.ll
> target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32"
> target triple = "aarch64-unknown-linux-gnu"
> 
> define void @_f(i64 %0) {
>   switch i32 0, label %.lr.ph126 [
>     i32 0, label %.loopexit35
>     i32 1, label %.loopexit35
>   ]
> 
> .loopexit46:                                      ; preds = %27
>   %2 = load i64, ptr getelementptr inbounds nuw (i8, ptr null, i64 72), align 8
>   %3 = or i64 %2, %21
>   store i64 %3, ptr getelementptr inbounds nuw (i8, ptr null, i64 72), align 8
>   %4 = load i64, ptr getelementptr inbounds nuw (i8, ptr null, i64 48), align 8
>   %5 = or i64 %4, %22
>   store i64 %5, ptr getelementptr inbounds nuw (i8, ptr null, i64 48), align 8
>   %6 = load i64, ptr getelementptr inbounds nuw (i8, ptr null, i64 64), align 8
>   %7 = or i64 %6, %23
>   store i64 %7, ptr getelementptr inbounds nuw (i8, ptr null, i64 64), align 8
>   %8 = load i64, ptr getelementptr inbounds nuw (i8, ptr null, i64 56), align 8
>   %9 = or i64 %8, %24
>   store i64 %9, ptr getelementptr inbounds nuw (i8, ptr null, i64 56), align 8
>   br label %.loopexit35
> 
> .lr.ph126:                                        ; preds = %27, %1
>   %10 = phi i64 [ %0, %27 ], [ 0, %1 ]
>   %11 = phi i64 [ 0, %27 ], [ 0, %1 ]
>   %12 = phi i64 [ 0, %27 ], [ 0, %1 ]
>   %13 = phi i64 [ 0, %27 ], [ 0, %1 ]
>   br i1 false, label %.loopexit39, label %.lr.ph
> 
> .lr.ph:                                           ; preds = %16, %.lr.ph126
>   %14 = phi i64 [ %17, %16 ], [ 0, %.lr.ph126 ]
>   %15 = phi i64 [ 0, %16 ], [ 0, %.lr.ph126 ]
>   br i1 false, label %.loopexit39, label %16
> 
> 16:                                               ; preds = %.lr.ph
>   %17 = add i64 0, 0
>   br i1 false, label %.lr.ph, label %.loopexit39
> 
> .loopexit39:                                      ; preds = %16, %.lr.ph, %.lr.ph126
>   %18 = phi i64 [ 0, %.lr.ph126 ], [ %15, %.lr.ph ], [ %14, %16 ]
>   %19 = phi i64 [ 0, %.lr.ph126 ], [ %14, %.lr.ph ], [ %17, %16 ]
>   %20 = phi i64 [ 0, %.lr.ph126 ], [ %14, %.lr.ph ], [ %14, %16 ]
>   %21 = or i64 %19, %13
>   %22 = or i64 %20, %12
>   %23 = or i64 %18, %11
>   %24 = or i64 %18, %10
>   br label %27
> 
> 25:                                               ; No predecessors!
>   %26 = call ptr null(i64 0)
>   br label %27
> 
> 27:                                               ; preds = %25, %.loopexit39
>   br i1 false, label %.lr.ph126, label %.loopexit46
> 
> .loopexit35:                                      ; preds = %.loopexit46, %1, %1
>   ret void
> }
> 
> ; uselistorder directives
> uselistorder ptr null, { 0, 4, 3, 2, 1 }
> $ opt -passes slp-vectorizer reduced.ll -o /dev/null
> Instruction does not dominate all uses!
>   %11 = insertelement <2 x i64> %10, i64 0, i32 1
>   %8 = shufflevector <2 x i64> %11, <2 x i64> poison, <2 x i32> <i32 1, i32 poison>
> LLVM ERROR: Broken module found, compilation aborted!
> ```

Checked it, unable to reproduce, most probably it was fixed yesterday

https://github.com/llvm/llvm-project/pull/129258


More information about the llvm-commits mailing list