[clang] [HLSL] Implement array temporary support (PR #79382)

Chris B via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 13 09:07:48 PDT 2024


================
@@ -4655,6 +4655,13 @@ void CodeGenFunction::EmitCallArg(CallArgList &args, const Expr *E,
     return emitWritebackArg(*this, args, CRE);
   }
 
+  // If an argument is an array paramter expression being passed through. Emit
+  // the argument to a temporary and pass the temporary as the call arg.
+  if (auto AT = dyn_cast<ArrayParameterType>(type)) {
+    args.add(EmitAnyExprToTemp(E), type);
----------------
llvm-beanz wrote:

Ah, yea, I think I need to fix this a different way.

The case where this happens is:

```c++
void fn(float x[2]);

void call(float Arr[2]) {
  fn(Arr);
}
```

In the CallExpr to fn, the argument is an lvalue DeclRefExpr to the ParmVar.

I think the right way to do this is to insert an ImplicitCastExpr for CK_HLSLArrayRValue or CK_LValueToRValue.

https://github.com/llvm/llvm-project/pull/79382


More information about the cfe-commits mailing list