llvm-project/llvm/test/Other/crash-stack-trace.ll
Nikita Popov 253a294b54
[PassManager] Add pretty stack frames (#96078)
In NewPM pass managers, add a "pretty stack frame" that tells you which
pass crashed while running which function.

For example `opt -O3 -passes-ep-peephole=trigger-crash-function test.ll`
will print something like this:

```
Stack dump:
0.	Program arguments: build/bin/opt -S -O3 -passes-ep-peephole=trigger-crash-function test.ll
1.	Running pass "function<eager-inv>(mem2reg,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,trigger-crash-function,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>)" on module "test.ll"
2.	Running pass "trigger-crash-function" on function "fshl_concat_i8_i8"
```

While the crashing pass is usually evident from the stack trace, this
also shows which function triggered the crash, as well as the pipeline
string for the pass (including options).

Similar functionality existed in the LegacyPM.
2024-06-27 12:16:30 +02:00

21 lines
793 B
LLVM

; REQUIRES: asserts
; RUN: not --crash opt -passes=trigger-crash-module %s -disable-output 2>&1 | \
; RUN: FileCheck %s --check-prefix=CHECK-MODULE
; CHECK-MODULE: Stack dump:
; CHECK-MODULE-NEXT: 0. Program arguments:
; CHECK-MODULE-NEXT: 1. Running pass "trigger-crash-module" on module "{{.*}}crash-stack-trace.ll"
; RUN: not --crash opt -passes='sroa,trigger-crash-function' %s -disable-output 2>&1 | \
; RUN: FileCheck %s --check-prefix=CHECK-FUNCTION
; CHECK-FUNCTION: Stack dump:
; CHECK-FUNCTION-NEXT: 0. Program arguments:
; CHECK-FUNCTION-NEXT: 1. Running pass "function(sroa<modify-cfg>,trigger-crash-function)" on module "{{.*}}crash-stack-trace.ll"
; CHECK-FUNCTION-NEXT: 2. Running pass "trigger-crash-function" on function "foo"
define void @foo() {
ret void
}