================
@@ -4498,6 +4498,9 @@ Address CodeGenFunction::EmitArrayToPointerDecay(const
Expr *E,
if (!E->getType()->isVariableArrayType()) {
assert(isa<llvm::ArrayType>(Addr.getElementType()) &&
"Expected pointer to array");
+
+ if (getLangOpts().HLSL && getLangOpts().EmitStructuredGEP)
+ return Addr;
----------------
Keenuts wrote:
The test going through this bit is the
`clang/test/CodeGenHLSL/sgep/load_global.hlsl`
Here is the AST:
```
ArraySubscriptExpr 0x555564eb3a48 'const hlsl_constant uint':'const
hlsl_constant unsigned int' lvalue
|-ImplicitCastExpr 0x555564eb3a30 'const hlsl_constant uint *'
<ArrayToPointerDecay>
| `-DeclRefExpr 0x555564eb3958 'hlsl_constant const uint[4]' lvalue Var
0x555564eaeff8 'a' 'hlsl_constant const uint[4]'
`-IntegerLiteral 0x555564eb3978 'int' 2
```
Here AFAIK, the `uint array[2]` is transformed into a `uint *ptr = array; *(ptr
+ 2);`
This however is not the right lowering if you want to target SGEP: we want to
keep the original type (`uint[2]`) and emit an instruction accessing the second
element of the array.
https://github.com/llvm/llvm-project/pull/177332
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits