File tree Expand file tree Collapse file tree
tools/clang/test/HLSLFileCheck/shader_targets/library Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2743,6 +2743,14 @@ void SROA_Helper::RewriteBitCast(BitCastInst *BCI) {
27432743 }
27442744
27452745 if (!bTypeMatch) {
2746+ // If the layouts match, just replace the type
2747+ SrcST = cast<StructType>(SrcTy);
2748+ if (SrcST->isLayoutIdentical (DstST)) {
2749+ BCI->mutateType (Val->getType ());
2750+ BCI->replaceAllUsesWith (Val);
2751+ BCI->eraseFromParent ();
2752+ return ;
2753+ }
27462754 assert (0 && " Type mismatch." );
27472755 return ;
27482756 }
Original file line number Diff line number Diff line change 1+ // RUN: %dxc -T lib_6_x -default-linkage external %s | FileCheck %s
2+
3+ // CHECK: define <4 x float>
4+ // CHECK-SAME: main
5+ // CHECK-NOT: bitcast
6+ // CHECK-NOT: CallStruct
7+ // CHECK: ParamStruct
8+ // CHECK-NOT: bitcast
9+ // CHECK-NOT: CallStruct
10+ // CHECK-LABEL: ret <4 x float>
11+
12+ struct ParamStruct {
13+ int i;
14+ float f;
15+ };
16+
17+ struct CallStruct {
18+ int i;
19+ float f;
20+ };
21+
22+ void modify (inout ParamStruct s) {
23+ s.f += 1 ;
24+ }
25+
26+ void modify_ext (inout ParamStruct s);
27+
28+ CallStruct g_struct;
29+
30+ float4 main () : SV_Target {
31+ CallStruct local = g_struct;
32+ modify (local);
33+ modify_ext (local);
34+ return local.f;
35+ }
You can’t perform that action at this time.
0 commit comments