From 5f9d8e2229c265bbf907b3735a9cff2a889ec16d Mon Sep 17 00:00:00 2001 From: Sanne Wouda Date: Fri, 3 Feb 2017 11:14:39 +0000 Subject: [PATCH] [LLC] Add an inline assembly diagnostics handler. Summary: llc would hit a fatal error for errors in inline assembly. The diagnostics message is now printed. Reviewers: rengolin, MatzeB, javed.absar, anemet Reviewed By: anemet Subscribers: jyknight, nemanjai, llvm-commits Differential Revision: https://reviews.llvm.org/D29408 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@293999 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/CodeGen/AArch64/mature-mc-support.ll | 2 +- test/CodeGen/ARM/mature-mc-support.ll | 2 +- test/CodeGen/Mips/mature-mc-support.ll | 2 +- test/CodeGen/PowerPC/mature-mc-support.ll | 2 +- test/CodeGen/SPARC/mature-mc-support.ll | 2 +- test/CodeGen/SystemZ/mature-mc-support.ll | 2 +- test/CodeGen/Thumb/mature-mc-support.ll | 2 +- test/CodeGen/X86/mature-mc-support.ll | 2 +- tools/llc/llc.cpp | 11 +++++++++++ 9 files changed, 19 insertions(+), 8 deletions(-) diff --git a/test/CodeGen/AArch64/mature-mc-support.ll b/test/CodeGen/AArch64/mature-mc-support.ll index 276c54d2cc4..dbc027143f9 100644 --- a/test/CodeGen/AArch64/mature-mc-support.ll +++ b/test/CodeGen/AArch64/mature-mc-support.ll @@ -9,4 +9,4 @@ module asm " .this_directive_is_very_unlikely_to_exist" -; CHECK: LLVM ERROR: Error parsing inline asm +; CHECK: error: unknown directive diff --git a/test/CodeGen/ARM/mature-mc-support.ll b/test/CodeGen/ARM/mature-mc-support.ll index 0a7e5b91adc..f89657dd81a 100644 --- a/test/CodeGen/ARM/mature-mc-support.ll +++ b/test/CodeGen/ARM/mature-mc-support.ll @@ -9,4 +9,4 @@ module asm " .this_directive_is_very_unlikely_to_exist" -; CHECK: LLVM ERROR: Error parsing inline asm +; CHECK: error: unknown directive diff --git a/test/CodeGen/Mips/mature-mc-support.ll b/test/CodeGen/Mips/mature-mc-support.ll index 6e5998d8a7c..9c93e96a376 100644 --- a/test/CodeGen/Mips/mature-mc-support.ll +++ b/test/CodeGen/Mips/mature-mc-support.ll @@ -29,4 +29,4 @@ module asm " .this_directive_is_very_unlikely_to_exist" -; CHECK: LLVM ERROR: Error parsing inline asm +; CHECK: error: unknown directive diff --git a/test/CodeGen/PowerPC/mature-mc-support.ll b/test/CodeGen/PowerPC/mature-mc-support.ll index aa387f6e266..543877d60cf 100644 --- a/test/CodeGen/PowerPC/mature-mc-support.ll +++ b/test/CodeGen/PowerPC/mature-mc-support.ll @@ -28,4 +28,4 @@ module asm " .this_directive_is_very_unlikely_to_exist" -; CHECK: LLVM ERROR: Error parsing inline asm +; CHECK: error: unknown directive diff --git a/test/CodeGen/SPARC/mature-mc-support.ll b/test/CodeGen/SPARC/mature-mc-support.ll index 4ed33098051..3951ddd604c 100644 --- a/test/CodeGen/SPARC/mature-mc-support.ll +++ b/test/CodeGen/SPARC/mature-mc-support.ll @@ -17,4 +17,4 @@ module asm " .this_directive_is_very_unlikely_to_exist" -; CHECK: LLVM ERROR: Error parsing inline asm +; CHECK: error: unknown directive diff --git a/test/CodeGen/SystemZ/mature-mc-support.ll b/test/CodeGen/SystemZ/mature-mc-support.ll index 5520f55e1e2..a01716c2767 100644 --- a/test/CodeGen/SystemZ/mature-mc-support.ll +++ b/test/CodeGen/SystemZ/mature-mc-support.ll @@ -12,4 +12,4 @@ module asm " .this_directive_is_very_unlikely_to_exist" -; CHECK: LLVM ERROR: Error parsing inline asm +; CHECK: error: unknown directive diff --git a/test/CodeGen/Thumb/mature-mc-support.ll b/test/CodeGen/Thumb/mature-mc-support.ll index d7f8ae6c6c4..6a638d40506 100644 --- a/test/CodeGen/Thumb/mature-mc-support.ll +++ b/test/CodeGen/Thumb/mature-mc-support.ll @@ -9,4 +9,4 @@ module asm " .this_directive_is_very_unlikely_to_exist" -; CHECK: LLVM ERROR: Error parsing inline asm +; CHECK: error: unknown directive diff --git a/test/CodeGen/X86/mature-mc-support.ll b/test/CodeGen/X86/mature-mc-support.ll index 9d956f46bec..3d6f0f66c18 100644 --- a/test/CodeGen/X86/mature-mc-support.ll +++ b/test/CodeGen/X86/mature-mc-support.ll @@ -15,4 +15,4 @@ module asm " .this_directive_is_very_unlikely_to_exist" -; CHECK: LLVM ERROR: Error parsing inline asm +; CHECK: error: unknown directive diff --git a/tools/llc/llc.cpp b/tools/llc/llc.cpp index 597504c08fb..b8c613d5099 100644 --- a/tools/llc/llc.cpp +++ b/tools/llc/llc.cpp @@ -253,6 +253,15 @@ static void DiagnosticHandler(const DiagnosticInfo &DI, void *Context) { errs() << "\n"; } +static void InlineAsmDiagHandler(const SMDiagnostic &SMD, void *Context, + unsigned) { + bool *HasError = static_cast(Context); + if (SMD.getKind() == SourceMgr::DK_Error) + *HasError = true; + + SMD.print(nullptr, errs()); +} + // main - Entry point for the llc compiler. // int main(int argc, char **argv) { @@ -294,6 +303,8 @@ int main(int argc, char **argv) { // Set a diagnostic handler that doesn't exit on the first error bool HasError = false; Context.setDiagnosticHandler(DiagnosticHandler, &HasError); + Context.setInlineAsmDiagnosticHandler(InlineAsmDiagHandler, &HasError); + if (PassRemarksWithHotness) Context.setDiagnosticHotnessRequested(true);