[clang] [HLSL] Implement output parameter (PR #101083)

John McCall via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 15 17:28:06 PDT 2024


================
@@ -4148,6 +4152,30 @@ static void emitWriteback(CodeGenFunction &CGF,
   assert(!isProvablyNull(srcAddr.getBasePointer()) &&
          "shouldn't have writeback for provably null argument");
 
+  if (CGF.getLangOpts().HLSL) {
+    if (!isa<OpaqueValueExpr>(writeback.CastExpr)) {
+      RValue TmpVal = CGF.EmitAnyExprToTemp(writeback.CastExpr);
+      if (TmpVal.isScalar())
+        CGF.EmitStoreThroughLValue(TmpVal, srcLV);
+      else {
+        llvm::Value *Val = CGF.Builder.CreateLoad(TmpVal.getAggregateAddress());
+        CGF.EmitAggregateStore(Val, srcLV.getAddress(), false);
+      }
+    } else {
+      llvm::Value *Val = CGF.Builder.CreateLoad(writeback.Temporary);
+      if (srcLV.isSimple()) {
+        CGF.EmitAggregateStore(Val, srcLV.getAddress(), false);
----------------
rjmccall wrote:

You're missing the `_Complex` case here.

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


More information about the cfe-commits mailing list