https://github.com/farzonl updated https://github.com/llvm/llvm-project/pull/135655
>From 7ec850f4a31cdd4554d813f759f519cb688652f9 Mon Sep 17 00:00:00 2001 From: Farzon Lotfi <farzonlo...@microsoft.com> Date: Mon, 14 Apr 2025 14:07:30 -0400 Subject: [PATCH] [Clang][DirectX] Always use Diagnostic Printer fixes #135654 In #128613 we added safe guards to prevent the lowering of just any intrinsic in the backend. We used `DiagnosticInfoUnsupported` to do this. What we found was when using `opt` the diagnostic printer was called but when using clang the diagnostic message was called. Printing message in the clang version means we miss valuable debugging information like function name and function type when LLVMContext was only needed to call `getBestLocationFromDebugLoc`. --- clang/lib/CodeGen/CodeGenAction.cpp | 10 ++++------ clang/test/CodeGenDirectX/unsupported_reduc_mul.hlsl | 7 +++++++ 2 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 clang/test/CodeGenDirectX/unsupported_reduc_mul.hlsl diff --git a/clang/lib/CodeGen/CodeGenAction.cpp b/clang/lib/CodeGen/CodeGenAction.cpp index 1f5eb427b566f..fbf7700d80a93 100644 --- a/clang/lib/CodeGen/CodeGenAction.cpp +++ b/clang/lib/CodeGen/CodeGenAction.cpp @@ -605,13 +605,11 @@ void BackendConsumer::UnsupportedDiagHandler( // Context will be nullptr for IR input files, we will construct the diag // message from llvm::DiagnosticInfoUnsupported. - if (Context != nullptr) { + if (Context != nullptr) Loc = getBestLocationFromDebugLoc(D, BadDebugInfo, Filename, Line, Column); - MsgStream << D.getMessage(); - } else { - DiagnosticPrinterRawOStream DP(MsgStream); - D.print(DP); - } + + DiagnosticPrinterRawOStream DP(MsgStream); + D.print(DP); auto DiagType = D.getSeverity() == llvm::DS_Error ? diag::err_fe_backend_unsupported diff --git a/clang/test/CodeGenDirectX/unsupported_reduc_mul.hlsl b/clang/test/CodeGenDirectX/unsupported_reduc_mul.hlsl new file mode 100644 index 0000000000000..e2f8907c14d6d --- /dev/null +++ b/clang/test/CodeGenDirectX/unsupported_reduc_mul.hlsl @@ -0,0 +1,7 @@ +// RUN: not %clang_dxc -T lib_6_3 %s 2>&1 | FileCheck %s + +// CHECK: error: <unknown>:0:0: in function llvm.vector.reduce.mul.v4i32 i32 (<4 x i32>): Unsupported intrinsic for DXIL lowering + +export int vecReduceMulTest(int4 vec) { + return __builtin_reduce_mul(vec); +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits