Skip to content

Commit 4443767

Browse files
committed
[Support] ErrorHandling: Do not generate crash backtrace by default
1 parent dc326d0 commit 4443767

File tree

387 files changed

+673
-673
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

387 files changed

+673
-673
lines changed

llvm/include/llvm/Support/ErrorHandling.h

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -68,58 +68,58 @@ namespace llvm {
6868
/// After the error handler is called this function will call abort(), it
6969
/// does not return.
7070
/// NOTE: The std::string variant was removed to avoid a <string> dependency.
71-
[[noreturn]] void report_fatal_error(const char *reason,
72-
bool gen_crash_diag = true);
73-
[[noreturn]] void report_fatal_error(StringRef reason,
74-
bool gen_crash_diag = true);
75-
[[noreturn]] void report_fatal_error(const Twine &reason,
76-
bool gen_crash_diag = true);
77-
78-
/// Installs a new bad alloc error handler that should be used whenever a
79-
/// bad alloc error, e.g. failing malloc/calloc, is encountered by LLVM.
80-
///
81-
/// The user can install a bad alloc handler, in order to define the behavior
82-
/// in case of failing allocations, e.g. throwing an exception. Note that this
83-
/// handler must not trigger any additional allocations itself.
84-
///
85-
/// If no error handler is installed the default is to print the error message
86-
/// to stderr, and call exit(1). If an error handler is installed then it is
87-
/// the handler's responsibility to log the message, it will no longer be
88-
/// printed to stderr. If the error handler returns, then exit(1) will be
89-
/// called.
90-
///
91-
///
92-
/// \param user_data - An argument which will be passed to the installed error
93-
/// handler.
94-
void install_bad_alloc_error_handler(fatal_error_handler_t handler,
95-
void *user_data = nullptr);
71+
[[noreturn]] void report_fatal_error(const char *reason,
72+
bool gen_crash_diag = false);
73+
[[noreturn]] void report_fatal_error(StringRef reason,
74+
bool gen_crash_diag = false);
75+
[[noreturn]] void report_fatal_error(const Twine &reason,
76+
bool gen_crash_diag = false);
77+
78+
/// Installs a new bad alloc error handler that should be used whenever a
79+
/// bad alloc error, e.g. failing malloc/calloc, is encountered by LLVM.
80+
///
81+
/// The user can install a bad alloc handler, in order to define the behavior
82+
/// in case of failing allocations, e.g. throwing an exception. Note that this
83+
/// handler must not trigger any additional allocations itself.
84+
///
85+
/// If no error handler is installed the default is to print the error message
86+
/// to stderr, and call exit(1). If an error handler is installed then it is
87+
/// the handler's responsibility to log the message, it will no longer be
88+
/// printed to stderr. If the error handler returns, then exit(1) will be
89+
/// called.
90+
///
91+
///
92+
/// \param user_data - An argument which will be passed to the installed error
93+
/// handler.
94+
void install_bad_alloc_error_handler(fatal_error_handler_t handler,
95+
void *user_data = nullptr);
9696

97-
/// Restores default bad alloc error handling behavior.
98-
void remove_bad_alloc_error_handler();
97+
/// Restores default bad alloc error handling behavior.
98+
void remove_bad_alloc_error_handler();
9999

100-
void install_out_of_memory_new_handler();
100+
void install_out_of_memory_new_handler();
101101

102-
/// Reports a bad alloc error, calling any user defined bad alloc
103-
/// error handler. In contrast to the generic 'report_fatal_error'
104-
/// functions, this function might not terminate, e.g. the user
105-
/// defined error handler throws an exception, but it won't return.
106-
///
107-
/// Note: When throwing an exception in the bad alloc handler, make sure that
108-
/// the following unwind succeeds, e.g. do not trigger additional allocations
109-
/// in the unwind chain.
110-
///
111-
/// If no error handler is installed (default), throws a bad_alloc exception
112-
/// if LLVM is compiled with exception support. Otherwise prints the error
113-
/// to standard error and calls abort().
114-
[[noreturn]] void report_bad_alloc_error(const char *Reason,
115-
bool GenCrashDiag = true);
116-
117-
/// This function calls abort(), and prints the optional message to stderr.
118-
/// Use the llvm_unreachable macro (that adds location info), instead of
119-
/// calling this function directly.
120-
[[noreturn]] void
121-
llvm_unreachable_internal(const char *msg = nullptr, const char *file = nullptr,
122-
unsigned line = 0);
102+
/// Reports a bad alloc error, calling any user defined bad alloc
103+
/// error handler. In contrast to the generic 'report_fatal_error'
104+
/// functions, this function might not terminate, e.g. the user
105+
/// defined error handler throws an exception, but it won't return.
106+
///
107+
/// Note: When throwing an exception in the bad alloc handler, make sure that
108+
/// the following unwind succeeds, e.g. do not trigger additional allocations
109+
/// in the unwind chain.
110+
///
111+
/// If no error handler is installed (default), throws a bad_alloc exception
112+
/// if LLVM is compiled with exception support. Otherwise prints the error
113+
/// to standard error and calls abort().
114+
[[noreturn]] void report_bad_alloc_error(const char *Reason,
115+
bool GenCrashDiag = true);
116+
117+
/// This function calls abort(), and prints the optional message to stderr.
118+
/// Use the llvm_unreachable macro (that adds location info), instead of
119+
/// calling this function directly.
120+
[[noreturn]] void llvm_unreachable_internal(const char *msg = nullptr,
121+
const char *file = nullptr,
122+
unsigned line = 0);
123123
}
124124

125125
/// Marks that the current location is not supposed to be reachable.

llvm/test/CodeGen/AArch64/GlobalISel/arm64-fallback.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
; RUN: llc -O0 -global-isel -global-isel-abort=2 -pass-remarks-missed='gisel*' -verify-machineinstrs %s -o %t.out 2> %t.err
22
; RUN: FileCheck %s --check-prefix=FALLBACK-WITH-REPORT-OUT < %t.out
33
; RUN: FileCheck %s --check-prefix=FALLBACK-WITH-REPORT-ERR < %t.err
4-
; RUN: not --crash llc -global-isel -mtriple aarch64_be %s -o - 2>&1 | FileCheck %s --check-prefix=BIG-ENDIAN
4+
; RUN: not llc -global-isel -mtriple aarch64_be %s -o - 2>&1 | FileCheck %s --check-prefix=BIG-ENDIAN
55
; This file checks that the fallback path to selection dag works.
66
; The test is fragile in the sense that it must be updated to expose
77
; something that fails with global-isel.

llvm/test/CodeGen/AArch64/GlobalISel/call-translator-musttail.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: not --crash llc %s -mtriple aarch64-apple-darwin -debug-only=aarch64-call-lowering -global-isel -global-isel-abort=2 -o - 2>&1 | FileCheck %s
1+
; RUN: not llc %s -mtriple aarch64-apple-darwin -debug-only=aarch64-call-lowering -global-isel -global-isel-abort=2 -o - 2>&1 | FileCheck %s
22
; REQUIRES: asserts
33

44
; Verify that we fall back to SelectionDAG, and error out when we can't tail call musttail functions

llvm/test/CodeGen/AArch64/GlobalISel/legalize-inttoptr-xfail-1.mir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# RUN: not --crash llc -mtriple=aarch64-- -run-pass=legalizer %s -o - 2>&1 | FileCheck %s
1+
# RUN: not llc -mtriple=aarch64-- -run-pass=legalizer %s -o - 2>&1 | FileCheck %s
22

33
# This is to demonstrate what kind of bugs we're missing w/o some kind
44
# of validation for LegalizerInfo: G_INTTOPTR could only be legal /

llvm/test/CodeGen/AArch64/GlobalISel/legalize-inttoptr-xfail-2.mir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# RUN: not --crash llc -mtriple=aarch64-- -run-pass=legalizer %s -o - 2>&1 | FileCheck %s
1+
# RUN: not llc -mtriple=aarch64-- -run-pass=legalizer %s -o - 2>&1 | FileCheck %s
22

33
# This is to demonstrate what kind of bugs we're missing w/o some kind
44
# of validation for LegalizerInfo: G_INTTOPTR could only be legal /

llvm/test/CodeGen/AArch64/GlobalISel/ptrauth-constant-in-code.ll

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
;--- err1.ll
44

5-
; RUN: not --crash llc < err1.ll -mtriple aarch64-elf -mattr=+pauth \
5+
; RUN: not llc < err1.ll -mtriple aarch64-elf -mattr=+pauth \
66
; RUN: -global-isel=1 -verify-machineinstrs -global-isel-abort=1 2>&1 | \
77
; RUN: FileCheck --check-prefix=ERR1 %s
8-
; RUN: not --crash llc < err1.ll -mtriple arm64-apple-ios -mattr=+pauth \
8+
; RUN: not llc < err1.ll -mtriple arm64-apple-ios -mattr=+pauth \
99
; RUN: -global-isel=1 -verify-machineinstrs -global-isel-abort=1 2>&1 | \
1010
; RUN: FileCheck --check-prefix=ERR1 %s
1111

@@ -18,10 +18,10 @@ define ptr @foo() {
1818

1919
;--- err2.ll
2020

21-
; RUN: not --crash llc < err2.ll -mtriple aarch64-elf -mattr=+pauth \
21+
; RUN: not llc < err2.ll -mtriple aarch64-elf -mattr=+pauth \
2222
; RUN: -global-isel=1 -verify-machineinstrs -global-isel-abort=1 2>&1 | \
2323
; RUN: FileCheck --check-prefix=ERR2 %s
24-
; RUN: not --crash llc < err2.ll -mtriple arm64-apple-ios -mattr=+pauth \
24+
; RUN: not llc < err2.ll -mtriple arm64-apple-ios -mattr=+pauth \
2525
; RUN: -global-isel=1 -verify-machineinstrs -global-isel-abort=1 2>&1 | \
2626
; RUN: FileCheck --check-prefix=ERR2 %s
2727

@@ -34,10 +34,10 @@ define ptr @foo() {
3434

3535
;--- err3.ll
3636

37-
; RUN: not --crash llc < err3.ll -mtriple aarch64-elf -mattr=+pauth \
37+
; RUN: not llc < err3.ll -mtriple aarch64-elf -mattr=+pauth \
3838
; RUN: -global-isel=1 -verify-machineinstrs -global-isel-abort=1 2>&1 | \
3939
; RUN: FileCheck --check-prefix=ERR3 %s
40-
; RUN: not --crash llc < err3.ll -mtriple arm64-apple-ios -mattr=+pauth \
40+
; RUN: not llc < err3.ll -mtriple arm64-apple-ios -mattr=+pauth \
4141
; RUN: -global-isel=1 -verify-machineinstrs -global-isel-abort=1 2>&1 | \
4242
; RUN: FileCheck --check-prefix=ERR3 %s
4343

@@ -50,10 +50,10 @@ define ptr @foo() {
5050

5151
;--- err4.ll
5252

53-
; RUN: not --crash llc < err4.ll -mtriple aarch64-elf -mattr=+pauth \
53+
; RUN: not llc < err4.ll -mtriple aarch64-elf -mattr=+pauth \
5454
; RUN: -global-isel=1 -verify-machineinstrs -global-isel-abort=1 2>&1 | \
5555
; RUN: FileCheck --check-prefix=ERR4 %s
56-
; RUN: not --crash llc < err4.ll -mtriple arm64-apple-ios -mattr=+pauth \
56+
; RUN: not llc < err4.ll -mtriple arm64-apple-ios -mattr=+pauth \
5757
; RUN: -global-isel=1 -verify-machineinstrs -global-isel-abort=1 2>&1 | \
5858
; RUN: FileCheck --check-prefix=ERR4 %s
5959

@@ -67,7 +67,7 @@ define ptr @foo() {
6767

6868
;--- err5.ll
6969

70-
; RUN: not --crash llc < err5.ll -mtriple aarch64-windows -mattr=+pauth \
70+
; RUN: not llc < err5.ll -mtriple aarch64-windows -mattr=+pauth \
7171
; RUN: -global-isel=1 -verify-machineinstrs -global-isel-abort=1 2>&1 | \
7272
; RUN: FileCheck --check-prefix=ERR5 %s
7373

llvm/test/CodeGen/AArch64/arm64-darwin-cc.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
; RUN: sed -e "s,CC,cfguard_checkcc,g" %s | not --crash llc -mtriple=arm64-apple-darwin -o - 2>&1 | FileCheck %s --check-prefix=CFGUARD
2-
; RUN: sed -e "s,CC,aarch64_sve_vector_pcs,g" %s | not --crash llc -mtriple=arm64-apple-darwin -o - 2>&1 | FileCheck %s --check-prefix=SVE_VECTOR_PCS
1+
; RUN: sed -e "s,CC,cfguard_checkcc,g" %s | not llc -mtriple=arm64-apple-darwin -o - 2>&1 | FileCheck %s --check-prefix=CFGUARD
2+
; RUN: sed -e "s,CC,aarch64_sve_vector_pcs,g" %s | not llc -mtriple=arm64-apple-darwin -o - 2>&1 | FileCheck %s --check-prefix=SVE_VECTOR_PCS
33

44
define CC void @f0() {
55
unreachable

llvm/test/CodeGen/AArch64/arm64-named-reg-alloc.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
; RUN: not --crash llc < %s -mtriple=arm64-apple-darwin 2>&1 | FileCheck %s
2-
; RUN: not --crash llc < %s -mtriple=arm64-linux-gnueabi 2>&1 | FileCheck %s
1+
; RUN: not llc < %s -mtriple=arm64-apple-darwin 2>&1 | FileCheck %s
2+
; RUN: not llc < %s -mtriple=arm64-linux-gnueabi 2>&1 | FileCheck %s
33

44
define i32 @get_stack() nounwind {
55
entry:

llvm/test/CodeGen/AArch64/arm64-named-reg-notareg.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
; RUN: not --crash llc < %s -mtriple=arm64-apple-darwin 2>&1 | FileCheck %s
2-
; RUN: not --crash llc < %s -mtriple=arm64-linux-gnueabi 2>&1 | FileCheck %s
1+
; RUN: not llc < %s -mtriple=arm64-apple-darwin 2>&1 | FileCheck %s
2+
; RUN: not llc < %s -mtriple=arm64-linux-gnueabi 2>&1 | FileCheck %s
33

44
define i32 @get_stack() nounwind {
55
entry:

llvm/test/CodeGen/AArch64/arm64-tls-dynamics.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
; FIXME: We currently produce "small" code for the tiny model
1010
; RUN: llc -mtriple=arm64-none-linux-gnu -relocation-model=pic -aarch64-elf-ldtls-generation=1 -code-model=tiny -verify-machineinstrs < %s | FileCheck %s
1111
; FIXME: We currently error for the large code model
12-
; RUN: not --crash llc -mtriple=arm64-none-linux-gnu -relocation-model=pic -aarch64-elf-ldtls-generation=1 -code-model=large -verify-machineinstrs < %s 2>&1 | FileCheck %s --check-prefix=CHECK-LARGE
12+
; RUN: not llc -mtriple=arm64-none-linux-gnu -relocation-model=pic -aarch64-elf-ldtls-generation=1 -code-model=large -verify-machineinstrs < %s 2>&1 | FileCheck %s --check-prefix=CHECK-LARGE
1313

1414
; CHECK-LARGE: ELF TLS only supported in small memory model
1515

0 commit comments

Comments
 (0)