; RUN: not llvm-as -data-layout=A5 < %s 2>&1 | FileCheck -check-prefixes=COMMON,AS %s
; RUN: not llc -mtriple amdgcn-amd-amdhsa < %s 2>&1 | FileCheck -check-prefixes=COMMON,LLC %s
; RUN: llvm-as < %s | not llc -mtriple amdgcn-amd-amdhsa 2>&1 | FileCheck -check-prefixes=MISMATCH %s
-; RUN: not opt -data-layout=A5 -S < %s 2>&1 | FileCheck -check-prefixes=COMMON,LLC %s
+; RUN: not opt -data-layout=A5 -S < %s 2>&1 | FileCheck -check-prefixes=COMMON,OPT %s
; RUN: llvm-as < %s | not opt -data-layout=A5 2>&1 | FileCheck -check-prefixes=MISMATCH %s
; AS: assembly parsed, but does not verify as correct!
; COMMON: Allocation instruction pointer not in the stack address space!
; COMMON: %tmp = alloca i32
; MISMATCH: Explicit load/store type does not match pointee type of pointer operand
-; LLC: error: input module is broken!
+; LLC: error: {{.*}}input module cannot be verified
+; OPT: error: input module is broken!
define amdgpu_kernel void @test() {
%tmp = alloca i32
static int compileModule(char **, LLVMContext &);
+LLVM_ATTRIBUTE_NORETURN static void reportError(Twine Msg,
+ StringRef Filename = "") {
+ SmallString<256> Prefix;
+ if (!Filename.empty()) {
+ if (Filename == "-")
+ Filename = "<stdin>";
+ ("'" + Twine(Filename) + "': ").toStringRef(Prefix);
+ }
+ WithColor::error(errs(), "llc") << Prefix << Msg << "\n";
+ exit(1);
+}
+
+LLVM_ATTRIBUTE_NORETURN static void reportError(Error Err, StringRef Filename) {
+ assert(Err);
+ handleAllErrors(createFileError(Filename, std::move(Err)),
+ [&](const ErrorInfoBase &EI) { reportError(EI.message()); });
+ llvm_unreachable("reportError() should not return");
+}
+
static std::unique_ptr<ToolOutputFile> GetOutputStream(const char *TargetName,
Triple::OSType OS,
const char *ProgName) {
OpenFlags |= sys::fs::OF_Text;
auto FDOut = std::make_unique<ToolOutputFile>(OutputFilename, EC, OpenFlags);
if (EC) {
- WithColor::error() << EC.message() << '\n';
+ reportError(EC.message());
return nullptr;
}
setupLLVMOptimizationRemarks(Context, RemarksFilename, RemarksPasses,
RemarksFormat, RemarksWithHotness,
RemarksHotnessThreshold);
- if (Error E = RemarksFileOrErr.takeError()) {
- WithColor::error(errs(), argv[0]) << toString(std::move(E)) << '\n';
- return 1;
- }
+ if (Error E = RemarksFileOrErr.takeError())
+ reportError(std::move(E), RemarksFilename);
std::unique_ptr<ToolOutputFile> RemarksFile = std::move(*RemarksFileOrErr);
- if (InputLanguage != "" && InputLanguage != "ir" &&
- InputLanguage != "mir") {
- WithColor::error(errs(), argv[0])
- << "input language must be '', 'IR' or 'MIR'\n";
- return 1;
- }
+ if (InputLanguage != "" && InputLanguage != "ir" && InputLanguage != "mir")
+ reportError("input language must be '', 'IR' or 'MIR'");
// Compile the module TimeCompilations times to give better compile time
// metrics.
// On AIX, setting the relocation model to anything other than PIC is
// considered a user error.
- if (TheTriple.isOSAIX() && RM.hasValue() && *RM != Reloc::PIC_) {
- WithColor::error(errs(), argv[0])
- << "invalid relocation model, AIX only supports PIC.\n";
- exit(1);
- }
+ if (TheTriple.isOSAIX() && RM.hasValue() && *RM != Reloc::PIC_)
+ reportError("invalid relocation model, AIX only supports PIC",
+ InputFilename);
InitializeOptions(TheTriple);
Target = std::unique_ptr<TargetMachine>(TheTarget->createTargetMachine(
std::error_code EC;
DwoOut = std::make_unique<ToolOutputFile>(SplitDwarfOutputFile, EC,
sys::fs::OF_None);
- if (EC) {
- WithColor::error(errs(), argv[0]) << EC.message() << '\n';
- return 1;
- }
+ if (EC)
+ reportError(EC.message(), SplitDwarfOutputFile);
}
// Build up all of the passes that we want to do to the module.
// Verify module immediately to catch problems before doInitialization() is
// called on any passes.
- if (!NoVerify && verifyModule(*M, &errs())) {
- std::string Prefix =
- (Twine(argv[0]) + Twine(": ") + Twine(InputFilename)).str();
- WithColor::error(errs(), Prefix) << "input module is broken!\n";
- return 1;
- }
+ if (!NoVerify && verifyModule(*M, &errs()))
+ reportError("input module cannot be verified", InputFilename);
// Override function attributes based on CPUStr, FeaturesStr, and command line
// flags.
} else if (Target->addPassesToEmitFile(
PM, *OS, DwoOut ? &DwoOut->os() : nullptr,
codegen::getFileType(), NoVerify, MMIWP)) {
- WithColor::warning(errs(), argv[0])
- << "target does not support generation of this"
- << " file type!\n";
- return 1;
+ reportError("target does not support generation of this file type");
}
const_cast<TargetLoweringObjectFile *>(LLVMTM.getObjFileLowering())