r265038 - Diagnostics: remove dodgy handler for bitcode inlineasm diagnostics.

Steven Wu via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 31 16:51:49 PDT 2016


The original handler is not there to workaround a crash. It is to avoid generate a crash report (report_fatal_error) when the input bitcode contains invalid assembly. 
It is an oversight to exit(0) even when it failed. Can you make the diagnostic handler fatal for Errors kinds instead of removing it? or set the gen_crash_diag to false in report_fatal_error in the AsmPrinterInlineAsm.cpp.

Steven

> On Mar 31, 2016, at 12:19 PM, Tim Northover via cfe-commits <cfe-commits at lists.llvm.org> wrote:
> 
> Author: tnorthover
> Date: Thu Mar 31 14:19:24 2016
> New Revision: 265038
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=265038&view=rev
> Log:
> Diagnostics: remove dodgy handler for bitcode inlineasm diagnostics.
> 
> Whatever crash it was there to present appears to have been fixed in the
> backend now, and it had the nasty side-effect of causing clang to exit(0) and
> leave a .o containing goodness knows what even when an error hit.
> 
> Modified:
>    cfe/trunk/lib/CodeGen/CodeGenAction.cpp
>    cfe/trunk/test/CodeGen/asm-errors.c
> 
> Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenAction.cpp?rev=265038&r1=265037&r2=265038&view=diff
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CodeGenAction.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp Thu Mar 31 14:19:24 2016
> @@ -756,12 +756,6 @@ CodeGenAction::CreateASTConsumer(Compile
>   return std::move(Result);
> }
> 
> -static void BitcodeInlineAsmDiagHandler(const llvm::SMDiagnostic &SM,
> -                                         void *Context,
> -                                         unsigned LocCookie) {
> -  SM.print(nullptr, llvm::errs());
> -}
> -
> void CodeGenAction::ExecuteAction() {
>   // If this is an IR file, we have to treat it specially.
>   if (getCurrentFileKind() == IK_LLVM_IR) {
> @@ -810,8 +804,6 @@ void CodeGenAction::ExecuteAction() {
>       TheModule->setTargetTriple(TargetOpts.Triple);
>     }
> 
> -    LLVMContext &Ctx = TheModule->getContext();
> -    Ctx.setInlineAsmDiagnosticHandler(BitcodeInlineAsmDiagHandler);
>     EmitBackendOutput(CI.getDiagnostics(), CI.getCodeGenOpts(), TargetOpts,
>                       CI.getLangOpts(), CI.getTarget().getDataLayout(),
>                       TheModule.get(), BA, OS);
> 
> Modified: cfe/trunk/test/CodeGen/asm-errors.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/asm-errors.c?rev=265038&r1=265037&r2=265038&view=diff
> ==============================================================================
> --- cfe/trunk/test/CodeGen/asm-errors.c (original)
> +++ cfe/trunk/test/CodeGen/asm-errors.c Thu Mar 31 14:19:24 2016
> @@ -3,7 +3,7 @@
> // RUN: not %clang_cc1 -triple i386-apple-darwin10 -emit-obj %s -o /dev/null > %t 2>&1
> // RUN: FileCheck %s < %t
> // RUN: %clang_cc1 -triple i386-apple-darwin10 -emit-llvm-bc %s -o %t.bc
> -// RUN: %clang_cc1 -triple i386-apple-darwin10 -emit-obj %t.bc -o /dev/null 2>&1 | \
> +// RUN: not %clang_cc1 -triple i386-apple-darwin10 -emit-obj %t.bc -o /dev/null 2>&1 | \
> // RUN:   FileCheck --check-prefix=CRASH-REPORT %s
> // CRASH-REPORT: <inline asm>:
> // CRASH-REPORT: error: invalid instruction mnemonic 'abc'
> 
> 
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits



More information about the cfe-commits mailing list