Skip to content

Revert "[LLVM] Use reportFatalUsageError for LTO usage errors" #141000

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lld/test/COFF/lto-cache-errors.ll
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
; RUN: rm -Rf %t.cache && mkdir %t.cache
; RUN: chmod 444 %t.cache

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

target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
Expand Down
4 changes: 2 additions & 2 deletions lld/test/ELF/lto/ltopasses-custom.ll
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ define void @barrier() {
; ATOMIC-NEXT: ret void

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

; Check that invalid AA pipelines are rejected gracefully.
; RUN: env LLD_IN_TEST=1 not ld.lld -m elf_x86_64 %t.o -o /dev/null \
; RUN: env LLD_IN_TEST=1 not --crash ld.lld -m elf_x86_64 %t.o -o /dev/null \
; RUN: --lto-newpm-passes=globaldce --lto-aa-pipeline=patatino \
; RUN: -shared 2>&1 | \
; RUN: FileCheck %s --check-prefix=INVALIDAA
Expand Down
19 changes: 9 additions & 10 deletions llvm/lib/LTO/LTOBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,8 @@ static void runNewPMPasses(const Config &Conf, Module &Mod, TargetMachine *TM,
if (!Conf.AAPipeline.empty()) {
AAManager AA;
if (auto Err = PB.parseAAPipeline(AA, Conf.AAPipeline)) {
reportFatalUsageError(Twine("unable to parse AA pipeline description '") +
Conf.AAPipeline + "': " + toString(std::move(Err)));
report_fatal_error(Twine("unable to parse AA pipeline description '") +
Conf.AAPipeline + "': " + toString(std::move(Err)));
}
// Register the AA manager first so that our version is the one used.
FAM.registerPass([&] { return std::move(AA); });
Expand Down Expand Up @@ -331,9 +331,8 @@ static void runNewPMPasses(const Config &Conf, Module &Mod, TargetMachine *TM,
// Parse a custom pipeline if asked to.
if (!Conf.OptPipeline.empty()) {
if (auto Err = PB.parsePassPipeline(MPM, Conf.OptPipeline)) {
reportFatalUsageError(
Twine("unable to parse pass pipeline description '") +
Conf.OptPipeline + "': " + toString(std::move(Err)));
report_fatal_error(Twine("unable to parse pass pipeline description '") +
Conf.OptPipeline + "': " + toString(std::move(Err)));
}
} else if (IsThinLTO) {
MPM.addPass(PB.buildThinLTODefaultPipeline(OL, ImportSummary));
Expand Down Expand Up @@ -416,8 +415,8 @@ static void codegen(const Config &Conf, TargetMachine *TM,
if (!Conf.DwoDir.empty()) {
std::error_code EC;
if (auto EC = llvm::sys::fs::create_directories(Conf.DwoDir))
reportFatalUsageError(Twine("Failed to create directory ") + Conf.DwoDir +
": " + EC.message());
report_fatal_error(Twine("Failed to create directory ") + Conf.DwoDir +
": " + EC.message());

DwoFile = Conf.DwoDir;
sys::path::append(DwoFile, std::to_string(Task) + ".dwo");
Expand All @@ -429,14 +428,14 @@ static void codegen(const Config &Conf, TargetMachine *TM,
std::error_code EC;
DwoOut = std::make_unique<ToolOutputFile>(DwoFile, EC, sys::fs::OF_None);
if (EC)
reportFatalUsageError(Twine("Failed to open ") + DwoFile + ": " +
EC.message());
report_fatal_error(Twine("Failed to open ") + DwoFile + ": " +
EC.message());
}

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

Expand Down
4 changes: 2 additions & 2 deletions llvm/test/tools/llvm-lto2/X86/pipeline.ll
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ define void @patatino() {
; CUSTOM-NEXT: }

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

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

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