Skip to content

Commit 7ec850f

Browse files
committed
[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`.
1 parent b04045c commit 7ec850f

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

clang/lib/CodeGen/CodeGenAction.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -605,13 +605,11 @@ void BackendConsumer::UnsupportedDiagHandler(
605605

606606
// Context will be nullptr for IR input files, we will construct the diag
607607
// message from llvm::DiagnosticInfoUnsupported.
608-
if (Context != nullptr) {
608+
if (Context != nullptr)
609609
Loc = getBestLocationFromDebugLoc(D, BadDebugInfo, Filename, Line, Column);
610-
MsgStream << D.getMessage();
611-
} else {
612-
DiagnosticPrinterRawOStream DP(MsgStream);
613-
D.print(DP);
614-
}
610+
611+
DiagnosticPrinterRawOStream DP(MsgStream);
612+
D.print(DP);
615613

616614
auto DiagType = D.getSeverity() == llvm::DS_Error
617615
? diag::err_fe_backend_unsupported
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// RUN: not %clang_dxc -T lib_6_3 %s 2>&1 | FileCheck %s
2+
3+
// CHECK: error: <unknown>:0:0: in function llvm.vector.reduce.mul.v4i32 i32 (<4 x i32>): Unsupported intrinsic for DXIL lowering
4+
5+
export int vecReduceMulTest(int4 vec) {
6+
return __builtin_reduce_mul(vec);
7+
}

0 commit comments

Comments
 (0)