llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang-codegen Author: Farzon Lotfi (farzonl) <details> <summary>Changes</summary> 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`. --- Full diff: https://github.com/llvm/llvm-project/pull/135655.diff 2 Files Affected: - (modified) clang/lib/CodeGen/CodeGenAction.cpp (+5-6) - (added) clang/test/CodeGenDirectX/unsupported_reduc_mul.hlsl (+10) ``````````diff diff --git a/clang/lib/CodeGen/CodeGenAction.cpp b/clang/lib/CodeGen/CodeGenAction.cpp index 1f5eb427b566f..9d7a8b92f6616 100644 --- a/clang/lib/CodeGen/CodeGenAction.cpp +++ b/clang/lib/CodeGen/CodeGenAction.cpp @@ -605,13 +605,12 @@ 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..3d0462679f152 --- /dev/null +++ b/clang/test/CodeGenDirectX/unsupported_reduc_mul.hlsl @@ -0,0 +1,10 @@ +// RUN: not %clang_dxc -T lib_6_3 %s 2>&1 | FileCheck %s + +// Define a vector of 4 ints (Clang/LLVM extension) +typedef int int4 __attribute__((ext_vector_type(4))); + +// 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); +} `````````` </details> https://github.com/llvm/llvm-project/pull/135655 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits