Truncation warning message incorrectly references an invalid hlsl type
Description Dxc issues a confusing warning when an hlsl intrinsic that returns a 64-bit type is cast to a 32-bit type.
Steps to Reproduce https://godbolt.org/z/vo84G6nac
// dxc /Tvs_6_0 -spirv longlong.hlsl
uint main() : A {
return vk::ReadClock(vk::SubgroupScope);
}
Actual Behavior Produces the warning
warning: conversion from larger type 'unsigned long long' to smaller type 'uint', possible loss of data [-Wconversion]
return vk::ReadClock(vk::SubgroupScope);
The unsinged long long type is not valid in hlsl. I would expect the warning to refer to the type by the hlsl name of uint64_t.
It seems to only refer to the long long type for intrinsics. If I have variables that are uint64_t that are cast to uint the warning message refers to the correct type.
Environment
- dxcompiler.dll: 1.8 - 1.7.0.4383 (ad3958c2d); dxil.dll: 1.6(101.6.2104.33)
- Windows 11
The fix for this is extremely straightforward:
diff --git a/tools/clang/lib/AST/Type.cpp b/tools/clang/lib/AST/Type.cpp
index 06db4747ffe..e114f856859 100644
--- a/tools/clang/lib/AST/Type.cpp
+++ b/tools/clang/lib/AST/Type.cpp
@@ -2500,13 +2500,13 @@ StringRef BuiltinType::getName(const PrintingPolicy &Policy) const {
case Short: return /* "short" */ "int16_t" /* HLSL Change */;
case Int: return "int";
case Long: return "long";
- case LongLong: return "long long";
+ case LongLong: return "int64_t";
case Int128: return "__int128";
case UChar: return "unsigned char";
case UShort: return /* "unsigned short" */ "uint16_t" /* HLSL Change */;
case UInt: return "unsigned int";
case ULong: return "unsigned long";
- case ULongLong: return "unsigned long long";
+ case ULongLong: return "uint64_t";
case UInt128: return "unsigned __int128";
// HLSL Changes begin
case HalfFloat:
The unfortunate problem is that we have a significant number of tests that break if we make this change. We'll need to find time to update the tests appropriately.