diff --git a/llvm/test/BugPoint/crash-sameerror.ll b/llvm/test/BugPoint/crash-sameerror.ll new file mode 100644 --- /dev/null +++ b/llvm/test/BugPoint/crash-sameerror.ll @@ -0,0 +1,18 @@ +; Test that bugpoint can stick to same error (ignore non-relevant errors) +; +; RUN: bugpoint -llc-safe %s -output-prefix %t -silence-passes -same-error > /dev/null +; REQUIRES: powerpc-registered-target +target triple = "powerpc64le-unknown-linux-gnu" + +define dso_local void @test1(i32 signext %a) local_unnamed_addr #0 { +entry: +; This should case codegen error, the argument should be a constant. + tail call void @llvm.ppc.altivec.dss(i32 %a) #1 + ret void +} +declare void @llvm.ppc.altivec.dss(i32) #1 + +; This should trigger bugpoint limitation when reducing attributes +; veriy failed: Attribute 'optnone' requires 'noinline'! +attributes #0 = { optnone noinline nounwind} +attributes #1 = { nounwind } diff --git a/llvm/tools/bugpoint/CrashDebugger.cpp b/llvm/tools/bugpoint/CrashDebugger.cpp --- a/llvm/tools/bugpoint/CrashDebugger.cpp +++ b/llvm/tools/bugpoint/CrashDebugger.cpp @@ -63,6 +63,10 @@ cl::opt VerboseErrors("verbose-errors", cl::desc("Print the output of crashing program"), cl::init(false)); +cl::opt SameError("same-error", + cl::desc("Focus on 1st crash error, treat other new crash as success"), + cl::init(false)); + } namespace llvm { @@ -1294,11 +1298,27 @@ static bool TestForCodeGenCrash(const BugDriver &BD, Module *M) { if (Error E = BD.compileProgram(*M)) { - if (VerboseErrors) - errs() << toString(std::move(E)) << "\n"; - else { - consumeError(std::move(E)); - errs() << "\n"; + bool SameCrash = true; + handleAllErrors(std::move(E), [&](const ErrorInfoBase &EIB) { + static std::string CrashMsgs = ""; + if (SameError) { + StringRef str(EIB.message()); + auto Msgs = str.split("Error Message:\n"); + if (CrashMsgs.empty()) + CrashMsgs = Msgs.second; + else { + SameCrash = CrashMsgs.compare(Msgs.second.str()) == 0; + } + } + if (VerboseErrors) + errs() << EIB.message() << "\n"; + else { + errs() << "\n"; + } + }); + if (SameError) { + // Only retrun true when we are getting same crash + return SameCrash; } return true; // Tool is still crashing. } diff --git a/llvm/tools/bugpoint/ToolRunner.cpp b/llvm/tools/bugpoint/ToolRunner.cpp --- a/llvm/tools/bugpoint/ToolRunner.cpp +++ b/llvm/tools/bugpoint/ToolRunner.cpp @@ -109,7 +109,7 @@ OS << "\nError running tool:\n "; for (StringRef Arg : Args) OS << " " << Arg.str(); - OS << "\n"; + OS << "\nError Message:\n"; // Rerun the compiler, capturing any error messages to print them. SmallString<128> ErrorFilename;