-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[HLSL] Do not print details in IR for target extension types #115971
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 9 commits
7413ceb
69d90f2
3a1bdba
c3e6120
0d2579a
b24c6d7
e3f9344
97b0745
c68234e
e4c9bf5
a612ace
ac26aa6
e6a9219
e013c09
2c37c3c
907465b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| // RUN: %clang_cc1 -triple dxil-pc-shadermodel6.6-compute -emit-llvm -finclude-default-header -o - %s | FileCheck %s | ||
|
|
||
| // The purpose of this test is to ensure that the target | ||
| // extension type associated with the structured buffer only | ||
| // contains anonymous struct types, rather than named | ||
| // struct types | ||
|
|
||
| // note that "{ <4 x float> }" in the check below is a struct type, but only the | ||
| // body is emitted on the RHS because we are already in the context of a | ||
| // target extension type definition (class.hlsl::StructuredBuffer) | ||
|
|
||
| // CHECK: %"class.hlsl::StructuredBuffer" = type { target("dx.RawBuffer", %struct.mystruct, 0, 0), %struct.mystruct } | ||
| // CHECK: %struct.mystruct = type { <4 x float> } | ||
|
|
||
| struct mystruct | ||
| { | ||
| float4 Color; | ||
| }; | ||
|
|
||
| StructuredBuffer<mystruct> my_buffer : register(t2, space4); | ||
|
|
||
| export float4 test() | ||
| { | ||
| return my_buffer[0].Color; | ||
| } | ||
|
|
||
| [numthreads(1,1,1)] | ||
| void main() {} |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -40,10 +40,43 @@ TEST(TypesTest, TargetExtType) { | |||||||||
| Type *A = TargetExtType::get(Context, "typea"); | ||||||||||
| Type *Aparam = TargetExtType::get(Context, "typea", {}, {0, 1}); | ||||||||||
| Type *Aparam2 = TargetExtType::get(Context, "typea", {}, {0, 1}); | ||||||||||
|
|
||||||||||
| // Opaque types with same parameters are identical... | ||||||||||
| EXPECT_EQ(Aparam, Aparam2); | ||||||||||
| // ... but just having the same name is not enough. | ||||||||||
| EXPECT_NE(A, Aparam); | ||||||||||
|
|
||||||||||
| // ensure struct types in targest extension types | ||||||||||
| // only show the struct name, not the struct body | ||||||||||
| Type *Int32Type = Type::getInt32Ty(Context); | ||||||||||
| Type *FloatType = Type::getFloatTy(Context); | ||||||||||
| std::vector<Type *> OriginalElements = {Int32Type, FloatType}; | ||||||||||
|
||||||||||
| std::vector<Type *> OriginalElements = {Int32Type, FloatType}; | |
| std::array<Type *, 2> Elements{Int32Type, FloatType}; |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's an overload of create that sets the elements directly:
| StructType *Struct = llvm::StructType::create(Context, "MyStruct"); | |
| Struct->setBody(OriginalElements); | |
| StructType *Struct = llvm::StructType::create(Context, Elements, "MyStruct", | |
| /*isPacked=*/false); |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The StructType docs call an unnamed struct a "literal struct" rather than anonymous: https://llvm.org/doxygen/classllvm_1_1StructType.html#details.
I would probably just say something to the effect of "ensure that literal structs in the target extension type print the struct body" to mirror the comment earlier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd be better to do all of the work to test the identified struct, and then do the work for the literal struct as a second step. This way you can avoid the duplicate StructType *, TargetExtensionType *, SmallVector, and raw_svector_ostream variables, and it will be clearer that these are two related but entirely independent tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't testing the AST, so it shouldn't be in the
test/ASTfolder. In any case, I think there's sufficient coverage by the changes to theCodeGenHLSL/builtinstests andTypesTest, so this one can probably just be removed.