You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This updates the implementation of the built-in string type to be an intangible type. Aligning on the intangible semantics allows strings to be used in contexts that were allowed in FXC and some contexts supported by SPIRV.
This change does not expose any new things users can do with strings, but it is a neccessary basis for extending string operations.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Critical issues remain: non-literal local string initializers crash the SPIR-V backend, and casts between structs containing strings generate invalid GEP indices during code generation.
This PR aligns HLSL string handling with intangible-type semantics, laying groundwork for broader string support while restricting use in externally visible storage.
Changes:
Allows string locals, fields, and parameters, with storage-context validation.
Updates code generation and type annotations to preserve string values in aggregates.
Adds regression tests, updates diagnostic expectations, and documents the change.
This updates the implementation of the built-in `string` type to be an
intangible type. Aligning on the intangible semantics allows strings to
be used in contexts that were allowed in FXC and some contexts supported
by SPIRV.
This change does not expose any new things users can do with strings,
but it is a neccessary basis for extending string operations.
../tools/clang/test/CodeGenSPIRV/type.string.initializer.hlsl
../tools/clang/test/HLSLFileCheckLit/hlsl/intrinsics/string-constant-ini
tializers.hlsl
../tools/clang/test/HLSLFileCheckLit/hlsl/intrinsics/string-empty-aggreg
ates.hlsl
../tools/clang/test/SemaHLSL/subobjects-ast-dump.hlsl
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
String-parameter calls can generate invalid SPIR-V, and referencing a rejected local can trigger a fatal unregistered-declaration error instead of recovering cleanly.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
String parameters can now produce invalid SPIR-V, while scalar-string-to-aggregate casts can generate invalid GEPs, leaving critical correctness issues unresolved.
Handle string leaves when splatting into aggregates
tools/clang/lib/CodeGen/CGHLSLMS.cpp:4163
For struct StringOnly { string Text; };, casting a string variable with (StringOnly)text now reaches the single-value splat path in EmitHLSLFlatConversion. EmitHLSLSplat descends into the field's i8* and builds an invalid GEP instead of copying the string value. Handle string leaves with a direct store before pointer recursion, bypassing the numeric conversion helper, and add a scalar-string-to-aggregate cast regression test.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Casting a string literal to an aggregate with a string field flattens it into characters instead of a string pointer, causing an assertion failure or a type-mismatched store in release builds.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Human assessment is needed because the changes can produce invalid SPIR-V for string fields and reject previously accepted forward-declared buffer element types.
Disallow strings as fields when targeting spirv
Fix up handling of typedefs
../tools/clang/include/clang/Basic/DiagnosticSemaKinds.td
../tools/clang/test/CodeGenSPIRV/type.string.field.hlsl
../tools/clang/test/HLSLFileCheckLit/hlsl/intrinsics/structured-buffer-f
orward-declaration.hlsl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This updates the implementation of the built-in
stringtype to be an intangible type. Aligning on the intangible semantics allows strings to be used in contexts that were allowed in FXC and some contexts supported by SPIRV.This change does not expose any new things users can do with strings, but it is a neccessary basis for extending string operations.