llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.07k stars 11.99k forks source link

[AArch64] llc with LLVM_ENABLE_EXPENSIVE_CHECKS on build crash #58887

Open bcl5980 opened 2 years ago

bcl5980 commented 2 years ago
; RUN: llc -verify-machineinstrs < %s -mtriple=aarch64-linux-gnu -verify-machineinstrs | FileCheck %s

define i8 @commute_subop0_anyext(i16 %a, i16 %b, i32 %c) {
  %aa = mul i16 %a, 111
  %bb = mul i16 %b, 222
  %a_32 = zext i16 %aa to i32
  %b_32 = zext i16 %bb to i32
  %sub = sub i32 %a_32, %b_32
  %add = add i32 %sub, %c
  %trunc = trunc i32 %add to i8
  %r = shl i8 %trunc, 3
  ret i8 %r
}

Trigger assert:

Assertion failed: CurrentLatencyDiff <= PrevLatencyDiff && "Current pattern is better than previous pattern.", file D:\code\llvm-project\llvm\lib\CodeGen\MachineCombiner.cpp, line 572
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: buildbg\\bin\\llc -verify-machineinstrs -mtriple=aarch64-linux-gnu -verify-machineinstrs
1.      Running pass 'Function Pass Manager' on module '<stdin>'.
2.      Running pass 'Machine InstCombiner' on function '@commute_subop0_anyext'
Exception Code: 0x80000003
 #0 0x00007ff7ac3c155c HandleAbort D:\code\llvm-project\llvm\lib\Support\Windows\Signals.inc:414:0
 #1 0x00007ffc971390ed (C:\WINDOWS\SYSTEM32\ucrtbased.dll+0xa90ed)
 #2 0x00007ffc9713ae49 (C:\WINDOWS\SYSTEM32\ucrtbased.dll+0xaae49)
 #3 0x00007ffc97141345 (C:\WINDOWS\SYSTEM32\ucrtbased.dll+0xb1345)
 #4 0x00007ffc97140bd7 (C:\WINDOWS\SYSTEM32\ucrtbased.dll+0xb0bd7)
 #5 0x00007ffc9713eba1 (C:\WINDOWS\SYSTEM32\ucrtbased.dll+0xaeba1)
 #6 0x00007ffc971418af (C:\WINDOWS\SYSTEM32\ucrtbased.dll+0xb18af)
 #7 0x00007ff7aa5d06fd `anonymous namespace'::MachineCombiner::verifyPatternOrder D:\code\llvm-project\llvm\lib\CodeGen\MachineCombiner.cpp:571:0
 #8 0x00007ff7aa5cd99c `anonymous namespace'::MachineCombiner::combineInstructions D:\code\llvm-project\llvm\lib\CodeGen\MachineCombiner.cpp:640:0
 #9 0x00007ff7aa5cd4d7 `anonymous namespace'::MachineCombiner::runOnMachineFunction D:\code\llvm-project\llvm\lib\CodeGen\MachineCombiner.cpp:777:0
#10 0x00007ff7aa5173d4 llvm::MachineFunctionPass::runOnFunction(class llvm::Function &) D:\code\llvm-project\llvm\lib\CodeGen\MachineFunctionPass.cpp:91:0
llvmbot commented 2 years ago

@llvm/issue-subscribers-backend-aarch64

badger200 commented 1 year ago

I'm on HEAD and I get this same crash with LLVM_EXPENSIVE_CHECKS on arm64-apple-ios14.4 (jailbroken). My crash happened after MachineCombiner::runOnMachineFunction.

Oddly, if I change the crash script -emit-obj to -emit-llvm, and then clang -c filename.ll, it compiles to machine code object successfully.