Skip to content

Commit aae4329

Browse files
committed
[LLVM] Use reportFatalUsageError for LTO usage errors
Usage errors in `LTOBackend.cpp` were previously, misleadingly, reported as internal crashes. This patch updates `LTOBackend.cpp` to use `reportFatalUsageError` for reporting usage-related issues. LLVM Issue: #140953 Internal Tracker: TOOLCHAIN-17744
1 parent 3a86e0b commit aae4329

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

lld/test/COFF/lto-cache-errors.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
; RUN: rm -Rf %t.cache && mkdir %t.cache
88
; RUN: chmod 444 %t.cache
99

10-
;; Check emit warnings when we can't create the cache dir
11-
; RUN: not --crash lld-link /lldltocache:%t.cache/nonexistant/ /out:%t3 /entry:main %t2.o %t.o 2>&1 | FileCheck %s
10+
;; Check fatal usage error emitted when the cache dir can't be created.
11+
; RUN: not lld-link /lldltocache:%t.cache/nonexistant/ /out:%t3 /entry:main %t2.o %t.o 2>&1 | FileCheck %s
1212
; CHECK: LLVM ERROR: can't create cache directory {{.*}}/nonexistant/: Permission denied
1313

1414
target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"

lld/test/ELF/lto/ltopasses-custom.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ define void @barrier() {
2424
; ATOMIC-NEXT: ret void
2525

2626
; Check that invalid passes are rejected gracefully.
27-
; RUN: env LLD_IN_TEST=1 not --crash ld.lld -m elf_x86_64 %t.o -o /dev/null \
27+
; RUN: env LLD_IN_TEST=1 not ld.lld -m elf_x86_64 %t.o -o /dev/null \
2828
; RUN: --lto-newpm-passes=iamnotapass -shared 2>&1 | \
2929
; RUN: FileCheck %s --check-prefix=INVALID
3030
; INVALID: unable to parse pass pipeline description 'iamnotapass': unknown pass name 'iamnotapass'
3131

3232
; Check that invalid AA pipelines are rejected gracefully.
33-
; RUN: env LLD_IN_TEST=1 not --crash ld.lld -m elf_x86_64 %t.o -o /dev/null \
33+
; RUN: env LLD_IN_TEST=1 not ld.lld -m elf_x86_64 %t.o -o /dev/null \
3434
; RUN: --lto-newpm-passes=globaldce --lto-aa-pipeline=patatino \
3535
; RUN: -shared 2>&1 | \
3636
; RUN: FileCheck %s --check-prefix=INVALIDAA

llvm/lib/LTO/LTOBackend.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ static void runNewPMPasses(const Config &Conf, Module &Mod, TargetMachine *TM,
290290
if (!Conf.AAPipeline.empty()) {
291291
AAManager AA;
292292
if (auto Err = PB.parseAAPipeline(AA, Conf.AAPipeline)) {
293-
report_fatal_error(Twine("unable to parse AA pipeline description '") +
293+
reportFatalUsageError(Twine("unable to parse AA pipeline description '") +
294294
Conf.AAPipeline + "': " + toString(std::move(Err)));
295295
}
296296
// Register the AA manager first so that our version is the one used.
@@ -331,7 +331,7 @@ static void runNewPMPasses(const Config &Conf, Module &Mod, TargetMachine *TM,
331331
// Parse a custom pipeline if asked to.
332332
if (!Conf.OptPipeline.empty()) {
333333
if (auto Err = PB.parsePassPipeline(MPM, Conf.OptPipeline)) {
334-
report_fatal_error(Twine("unable to parse pass pipeline description '") +
334+
reportFatalUsageError(Twine("unable to parse pass pipeline description '") +
335335
Conf.OptPipeline + "': " + toString(std::move(Err)));
336336
}
337337
} else if (IsThinLTO) {
@@ -415,7 +415,7 @@ static void codegen(const Config &Conf, TargetMachine *TM,
415415
if (!Conf.DwoDir.empty()) {
416416
std::error_code EC;
417417
if (auto EC = llvm::sys::fs::create_directories(Conf.DwoDir))
418-
report_fatal_error(Twine("Failed to create directory ") + Conf.DwoDir +
418+
reportFatalUsageError(Twine("Failed to create directory ") + Conf.DwoDir +
419419
": " + EC.message());
420420

421421
DwoFile = Conf.DwoDir;
@@ -428,14 +428,14 @@ static void codegen(const Config &Conf, TargetMachine *TM,
428428
std::error_code EC;
429429
DwoOut = std::make_unique<ToolOutputFile>(DwoFile, EC, sys::fs::OF_None);
430430
if (EC)
431-
report_fatal_error(Twine("Failed to open ") + DwoFile + ": " +
431+
reportFatalUsageError(Twine("Failed to open ") + DwoFile + ": " +
432432
EC.message());
433433
}
434434

435435
Expected<std::unique_ptr<CachedFileStream>> StreamOrErr =
436436
AddStream(Task, Mod.getModuleIdentifier());
437437
if (Error Err = StreamOrErr.takeError())
438-
report_fatal_error(std::move(Err));
438+
reportFatalUsageError(std::move(Err));
439439
std::unique_ptr<CachedFileStream> &Stream = *StreamOrErr;
440440
TM->Options.ObjectFilenameForDebug = Stream->ObjectPathName;
441441

llvm/test/tools/llvm-lto2/X86/pipeline.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ define void @patatino() {
2828
; CUSTOM-NEXT: }
2929

3030
; Check that invalid pipelines are caught as errors.
31-
; RUN: not --crash llvm-lto2 run %t1.bc -o %t.o \
31+
; RUN: not llvm-lto2 run %t1.bc -o %t.o \
3232
; RUN: -r %t1.bc,patatino,px -opt-pipeline foogoo 2>&1 | \
3333
; RUN: FileCheck %s --check-prefix=ERR
3434

3535
; ERR: LLVM ERROR: unable to parse pass pipeline description 'foogoo': unknown pass name 'foogoo'
3636

37-
; RUN: not --crash llvm-lto2 run %t1.bc -o %t.o \
37+
; RUN: not llvm-lto2 run %t1.bc -o %t.o \
3838
; RUN: -r %t1.bc,patatino,px -aa-pipeline patatino \
3939
; RUN: -opt-pipeline lower-atomic 2>&1 | \
4040
; RUN: FileCheck %s --check-prefix=AAERR

0 commit comments

Comments
 (0)