Skip to content

Commit 36b710a

Browse files
authored
CodeGen: Convert some assorted errors to use reportFatalUsageError (#142031)
The test coverage is lacking for many of these errors.
1 parent 72a3c76 commit 36b710a

File tree

11 files changed

+38
-34
lines changed

11 files changed

+38
-34
lines changed

llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2322,7 +2322,7 @@ void AsmPrinter::emitGlobalIFunc(Module &M, const GlobalIFunc &GI) {
23222322
}
23232323

23242324
if (!TM.getTargetTriple().isOSBinFormatMachO() || !getIFuncMCSubtargetInfo())
2325-
llvm::report_fatal_error("IFuncs are not supported on this platform");
2325+
reportFatalUsageError("IFuncs are not supported on this platform");
23262326

23272327
// On Darwin platforms, emit a manually-constructed .symbol_resolver that
23282328
// implements the symbol resolution duties of the IFunc.

llvm/lib/CodeGen/LiveVariables.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ void LiveVariables::analyze(MachineFunction &mf) {
632632
// LiveVariables to improve compilation time and eliminate bizarre pass
633633
// dependencies. Until then, we can't change much in -O0.
634634
if (!MRI->isSSA())
635-
report_fatal_error("regalloc=... not currently supported with -O0");
635+
reportFatalUsageError("regalloc=... not currently supported with -O0");
636636

637637
analyzePHINodes(mf);
638638

llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ bool SelectionDAGISelLegacy::runOnMachineFunction(MachineFunction &MF) {
349349

350350
// Do some sanity-checking on the command-line options.
351351
if (EnableFastISelAbort && !Selector->TM.Options.EnableFastISel)
352-
report_fatal_error("-fast-isel-abort > 0 requires -fast-isel");
352+
reportFatalUsageError("-fast-isel-abort > 0 requires -fast-isel");
353353

354354
// Decide what flavour of variable location debug-info will be used, before
355355
// we change the optimisation level.
@@ -424,7 +424,7 @@ SelectionDAGISelPass::run(MachineFunction &MF,
424424

425425
// Do some sanity-checking on the command-line options.
426426
if (EnableFastISelAbort && !Selector->TM.Options.EnableFastISel)
427-
report_fatal_error("-fast-isel-abort > 0 requires -fast-isel");
427+
reportFatalUsageError("-fast-isel-abort > 0 requires -fast-isel");
428428

429429
// Decide what flavour of variable location debug-info will be used, before
430430
// we change the optimisation level.
@@ -797,7 +797,7 @@ static void reportFastISelFailure(MachineFunction &MF,
797797
R << (" (in function: " + MF.getName() + ")").str();
798798

799799
if (ShouldAbort)
800-
report_fatal_error(Twine(R.getMsg()));
800+
reportFatalUsageError(Twine(R.getMsg()));
801801

802802
ORE.emit(R);
803803
LLVM_DEBUG(dbgs() << R.getMsg() << "\n");

llvm/lib/CodeGen/TargetPassConfig.cpp

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -421,8 +421,8 @@ static const PassInfo *getPassInfo(StringRef PassName) {
421421
const PassRegistry &PR = *PassRegistry::getPassRegistry();
422422
const PassInfo *PI = PR.getPassInfo(PassName);
423423
if (!PI)
424-
report_fatal_error(Twine('\"') + Twine(PassName) +
425-
Twine("\" pass is not registered."));
424+
reportFatalUsageError(Twine('\"') + Twine(PassName) +
425+
Twine("\" pass is not registered."));
426426
return PI;
427427
}
428428

@@ -438,7 +438,7 @@ getPassNameAndInstanceNum(StringRef PassName) {
438438

439439
unsigned InstanceNum = 0;
440440
if (!InstanceNumStr.empty() && InstanceNumStr.getAsInteger(10, InstanceNum))
441-
report_fatal_error("invalid pass instance specifier " + PassName);
441+
reportFatalUsageError("invalid pass instance specifier " + PassName);
442442

443443
return std::make_pair(Name, InstanceNum);
444444
}
@@ -465,11 +465,11 @@ void TargetPassConfig::setStartStopPasses() {
465465
StopBefore = getPassIDFromName(StopBeforeName);
466466
StopAfter = getPassIDFromName(StopAfterName);
467467
if (StartBefore && StartAfter)
468-
report_fatal_error(Twine(StartBeforeOptName) + Twine(" and ") +
469-
Twine(StartAfterOptName) + Twine(" specified!"));
468+
reportFatalUsageError(Twine(StartBeforeOptName) + Twine(" and ") +
469+
Twine(StartAfterOptName) + Twine(" specified!"));
470470
if (StopBefore && StopAfter)
471-
report_fatal_error(Twine(StopBeforeOptName) + Twine(" and ") +
472-
Twine(StopAfterOptName) + Twine(" specified!"));
471+
reportFatalUsageError(Twine(StopBeforeOptName) + Twine(" and ") +
472+
Twine(StopAfterOptName) + Twine(" specified!"));
473473
Started = (StartAfter == nullptr) && (StartBefore == nullptr);
474474
}
475475

@@ -635,9 +635,9 @@ CodeGenTargetMachineImpl::createPassConfig(PassManagerBase &PM) {
635635

636636
TargetPassConfig::TargetPassConfig()
637637
: ImmutablePass(ID) {
638-
report_fatal_error("Trying to construct TargetPassConfig without a target "
639-
"machine. Scheduling a CodeGen pass without a target "
640-
"triple set?");
638+
reportFatalUsageError("trying to construct TargetPassConfig without a target "
639+
"machine. Scheduling a CodeGen pass without a target "
640+
"triple set?");
641641
}
642642

643643
bool TargetPassConfig::willCompleteCodeGenPipeline() {
@@ -738,7 +738,7 @@ void TargetPassConfig::addPass(Pass *P) {
738738
if (StartAfter == PassID && StartAfterCount++ == StartAfterInstanceNum)
739739
Started = true;
740740
if (Stopped && !Started)
741-
report_fatal_error("Cannot stop compilation after pass that is not run");
741+
reportFatalUsageError("Cannot stop compilation after pass that is not run");
742742
}
743743

744744
/// Add a CodeGen pass at this point in the pipeline after checking for target
@@ -1408,7 +1408,8 @@ bool TargetPassConfig::isCustomizedRegAlloc() {
14081408
bool TargetPassConfig::addRegAssignAndRewriteFast() {
14091409
if (RegAlloc != (RegisterRegAlloc::FunctionPassCtor)&useDefaultRegisterAllocator &&
14101410
RegAlloc != (RegisterRegAlloc::FunctionPassCtor)&createFastRegisterAllocator)
1411-
report_fatal_error("Must use fast (default) register allocator for unoptimized regalloc.");
1411+
reportFatalUsageError(
1412+
"Must use fast (default) register allocator for unoptimized regalloc.");
14121413

14131414
addPass(createRegAllocPass(false));
14141415

llvm/test/CodeGen/AArch64/fast-isel-sp-adjust.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
; RUN: llc -O0 -fast-isel -mtriple=aarch64-apple-ios -o - %s | FileCheck %s
2-
; RUN: not --crash llc -O0 -mtriple=aarch64-apple-ios -o /dev/null -fast-isel -fast-isel-abort=3 %s 2> %t
2+
; RUN: not llc -O0 -mtriple=aarch64-apple-ios -o /dev/null -fast-isel -fast-isel-abort=3 %s 2> %t
33
; RUN: FileCheck %s --check-prefix=CHECK-ERRORS < %t
44

55
; The issue here is that FastISel cannot emit an ADDrr where one of the inputs
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: not --crash llc -debug-pass=Structure -stop-after=dead-mi-elimination,arst %s -o /dev/null 2>&1 \
1+
; RUN: not llc -debug-pass=Structure -stop-after=dead-mi-elimination,arst %s -o /dev/null 2>&1 \
22
; RUN: | FileCheck -check-prefix=NOT-NUM %s
33

44
; NOT-NUM: LLVM ERROR: invalid pass instance specifier dead-mi-elimination,arst

llvm/test/CodeGen/Generic/llc-start-stop.ll

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,16 @@
2929
; START-BEFORE: Loop Strength Reduction
3030
; START-BEFORE-NEXT: {{Loop Terminator Folding|Basic Alias Analysis \(stateless AA impl\)}}
3131

32-
; RUN: not --crash llc < %s -start-before=nonexistent -o /dev/null 2>&1 | FileCheck %s -check-prefix=NONEXISTENT-START-BEFORE
33-
; RUN: not --crash llc < %s -stop-before=nonexistent -o /dev/null 2>&1 | FileCheck %s -check-prefix=NONEXISTENT-STOP-BEFORE
34-
; RUN: not --crash llc < %s -start-after=nonexistent -o /dev/null 2>&1 | FileCheck %s -check-prefix=NONEXISTENT-START-AFTER
35-
; RUN: not --crash llc < %s -stop-after=nonexistent -o /dev/null 2>&1 | FileCheck %s -check-prefix=NONEXISTENT-STOP-AFTER
32+
; RUN: not llc < %s -start-before=nonexistent -o /dev/null 2>&1 | FileCheck %s -check-prefix=NONEXISTENT-START-BEFORE
33+
; RUN: not llc < %s -stop-before=nonexistent -o /dev/null 2>&1 | FileCheck %s -check-prefix=NONEXISTENT-STOP-BEFORE
34+
; RUN: not llc < %s -start-after=nonexistent -o /dev/null 2>&1 | FileCheck %s -check-prefix=NONEXISTENT-START-AFTER
35+
; RUN: not llc < %s -stop-after=nonexistent -o /dev/null 2>&1 | FileCheck %s -check-prefix=NONEXISTENT-STOP-AFTER
3636
; NONEXISTENT-START-BEFORE: "nonexistent" pass is not registered.
3737
; NONEXISTENT-STOP-BEFORE: "nonexistent" pass is not registered.
3838
; NONEXISTENT-START-AFTER: "nonexistent" pass is not registered.
3939
; NONEXISTENT-STOP-AFTER: "nonexistent" pass is not registered.
4040

41-
; RUN: not --crash llc < %s -start-before=loop-reduce -start-after=loop-reduce -o /dev/null 2>&1 | FileCheck %s -check-prefix=DOUBLE-START
42-
; RUN: not --crash llc < %s -stop-before=loop-reduce -stop-after=loop-reduce -o /dev/null 2>&1 | FileCheck %s -check-prefix=DOUBLE-STOP
41+
; RUN: not llc < %s -start-before=loop-reduce -start-after=loop-reduce -o /dev/null 2>&1 | FileCheck %s -check-prefix=DOUBLE-START
42+
; RUN: not llc < %s -stop-before=loop-reduce -stop-after=loop-reduce -o /dev/null 2>&1 | FileCheck %s -check-prefix=DOUBLE-STOP
4343
; DOUBLE-START: start-before and start-after specified!
4444
; DOUBLE-STOP: stop-before and stop-after specified!
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
; RUN: not --crash opt %s -dwarf-eh-prepare -o - 2>&1 | FileCheck %s
1+
; RUN: not opt %s -dwarf-eh-prepare -o - 2>&1 | FileCheck %s
22

3-
; CHECK: Trying to construct TargetPassConfig without a target machine. Scheduling a CodeGen pass without a target triple set?
3+
; CHECK: LLVM ERROR: trying to construct TargetPassConfig without a target machine. Scheduling a CodeGen pass without a target triple set?

llvm/test/CodeGen/Mips/Fast-ISel/double-arg.ll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
; RUN: not --crash llc -mtriple=mipsel -mcpu=mips32r2 -mattr=+fp64 \
2-
; RUN: -O0 -relocation-model=pic -fast-isel-abort=3 < %s
1+
; RUN: not llc -mtriple=mipsel -mcpu=mips32r2 -mattr=+fp64 \
2+
; RUN: -O0 -relocation-model=pic -fast-isel-abort=3 -filetype=null %s 2>&1 | FileCheck %s
33

44
; Check that FastISel aborts when we have 64bit FPU registers. FastISel currently
55
; supports AFGR64 only, which uses paired 32 bit registers.
66

7+
; CHECK: LLVM ERROR: FastISel didn't lower all arguments: i1 (double) (in function: f)
8+
79
define zeroext i1 @f(double %value) {
810
entry:
9-
; CHECK-LABEL: f:
10-
; CHECK: sdc1
1111
%value.addr = alloca double, align 8
1212
store double %value, ptr %value.addr, align 8
1313
ret i1 false

llvm/test/CodeGen/Mips/Fast-ISel/fast-isel-softfloat-lower-args.ll

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
; RUN: not --crash llc -mtriple=mipsel -mcpu=mips32r2 -mattr=+soft-float \
2-
; RUN: -O0 -fast-isel-abort=3 -relocation-model=pic < %s
1+
; RUN: not llc -mtriple=mipsel -mcpu=mips32r2 -mattr=+soft-float \
2+
; RUN: -O0 -fast-isel-abort=3 -relocation-model=pic < %s 2>&1 | FileCheck %s
33

44
; Test that FastISel aborts instead of trying to lower arguments for soft-float.
55

6+
; CHECK: LLVM ERROR: FastISel didn't lower all arguments: void (double) (in function: __signbit)
67
define void @__signbit(double %__x) {
78
entry:
89
%__x.addr = alloca double, align 8

llvm/test/CodeGen/X86/fast-isel-args-fail2.ll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
; RUN: not --crash llc < %s -fast-isel -fast-isel-abort=2 -mtriple=x86_64-apple-darwin10
1+
; RUN: not llc < %s -fast-isel -fast-isel-abort=2 -mtriple=x86_64-apple-darwin10 2>&1 | FileCheck %s
2+
3+
; CHECK: LLVM ERROR: FastISel didn't lower all arguments: ptr (ptr) (in function: args_fail)
24

35
%struct.s0 = type { x86_fp80, x86_fp80 }
46

0 commit comments

Comments
 (0)