File tree 2 files changed +31
-0
lines changed
test/CodeGenHLSL/BasicFeatures 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change 13
13
#include " CGCXXABI.h"
14
14
#include " CGCleanup.h"
15
15
#include " CGDebugInfo.h"
16
+ #include " CGHLSLRuntime.h"
16
17
#include " CGObjCRuntime.h"
17
18
#include " CGOpenMPRuntime.h"
18
19
#include " CGRecordLayout.h"
@@ -2095,6 +2096,18 @@ Value *ScalarExprEmitter::VisitInitListExpr(InitListExpr *E) {
2095
2096
assert (Ignore == false && " init list ignored" );
2096
2097
unsigned NumInitElements = E->getNumInits ();
2097
2098
2099
+ // HLSL initialization lists in the AST are an expansion which can contain
2100
+ // side-effecting expressions wrapped in opaque value expressions. To properly
2101
+ // emit these we need to emit the opaque values before we emit the argument
2102
+ // expressions themselves. This is a little hacky, but it prevents us needing
2103
+ // to do a bigger AST-level change for a language feature that we need
2104
+ // deprecate in the near future. See related HLSL language proposals in the
2105
+ // proposals (https://github.com/microsoft/hlsl-specs/blob/main/proposals):
2106
+ // * 0005-strict-initializer-lists.md
2107
+ // * 0032-constructors.md
2108
+ if (CGF.getLangOpts ().HLSL )
2109
+ CGF.CGM .getHLSLRuntime ().emitInitListOpaqueValues (CGF, E);
2110
+
2098
2111
if (E->hadArrayRangeDesignator ())
2099
2112
CGF.ErrorUnsupported (E, " GNU array range designator extension" );
2100
2113
Original file line number Diff line number Diff line change @@ -941,3 +941,21 @@ FourFloats case16() {
941
941
FourFloats FF = {0 , makeTwo (X), 3 };
942
942
return FF;
943
943
}
944
+
945
+
946
+ int case17Helper (int x) {
947
+ return x;
948
+ }
949
+
950
+ // InitList with OpaqueValueExpr
951
+ // CHECK-LABEL: define void {{.*}}case17
952
+ // CHECK: [[X:%.*]] = alloca <2 x i32>, align 8
953
+ // CHECK-NEXT: [[C:%.*]] = call noundef i32 {{.*}}case17Helper{{.*}}(i32 noundef 0)
954
+ // CHECK-NEXT: [[C1:%.*]] = call noundef i32 {{.*}}case17Helper{{.*}}(i32 noundef 1)
955
+ // CHECK-NEXT: [[VI:%.*]] = insertelement <2 x i32> poison, i32 [[C]], i32 0
956
+ // CHECK-NEXT: [[VI2:%.*]] = insertelement <2 x i32> [[VI]], i32 [[C1]], i32 1
957
+ // CHECK-NEXT: store <2 x i32> [[VI2]], ptr [[X]], align 8
958
+ // CHECK-NEXT: ret void
959
+ void case17 () {
960
+ int2 X = {case17Helper (0 ), case17Helper (1 )};
961
+ }
You can’t perform that action at this time.
0 commit comments