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

2024-04-02 Thread Haojian Wu via cfe-commits
@@ -0,0 +1,76 @@ +; ModuleID = '/Users/cbieneman/dev/llvm-project/clang/test/SemaHLSL/ArrayTemporary.hlsl' hokein wrote: IIUC, this file was added unintentionally, sent out https://github.com/llvm/llvm-project/pull/87346

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

2024-04-02 Thread Haojian Wu via cfe-commits
@@ -0,0 +1,76 @@ +; ModuleID = '/Users/cbieneman/dev/llvm-project/clang/test/SemaHLSL/ArrayTemporary.hlsl' hokein wrote: Is this `.ll` file necessary? It doesn't look like a lit test file, no `RUN` commands etc. https://github.com/llvm/llvm-project/pull/79382

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

2024-04-01 Thread Chris B via cfe-commits
https://github.com/llvm-beanz closed https://github.com/llvm/llvm-project/pull/79382 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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

2024-04-01 Thread Chris B via cfe-commits
https://github.com/llvm-beanz updated https://github.com/llvm/llvm-project/pull/79382 >From bd74d7db681cd07fda56f26e79e047c6d1a41f6b Mon Sep 17 00:00:00 2001 From: Chris Bieneman Date: Thu, 29 Feb 2024 15:37:50 -0600 Subject: [PATCH 1/9] [HLSL] Pass arrays by value HLSL constant sized array

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

2024-03-29 Thread Chris B via cfe-commits
https://github.com/llvm-beanz updated https://github.com/llvm/llvm-project/pull/79382 >From bd74d7db681cd07fda56f26e79e047c6d1a41f6b Mon Sep 17 00:00:00 2001 From: Chris Bieneman Date: Thu, 29 Feb 2024 15:37:50 -0600 Subject: [PATCH 1/8] [HLSL] Pass arrays by value HLSL constant sized array

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

2024-03-29 Thread Cooper Partin via cfe-commits
https://github.com/coopp approved this pull request. WOW.. This was pretty big. I went through it twice and didn't see anything that jumped out. Looks good to me. https://github.com/llvm/llvm-project/pull/79382 ___ cfe-commits mailing list

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

2024-03-29 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/79382 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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

2024-03-29 Thread Chris B via cfe-commits
https://github.com/llvm-beanz updated https://github.com/llvm/llvm-project/pull/79382 >From bd74d7db681cd07fda56f26e79e047c6d1a41f6b Mon Sep 17 00:00:00 2001 From: Chris Bieneman Date: Thu, 29 Feb 2024 15:37:50 -0600 Subject: [PATCH 1/7] [HLSL] Pass arrays by value HLSL constant sized array

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

2024-03-29 Thread Chris B via cfe-commits
https://github.com/llvm-beanz updated https://github.com/llvm/llvm-project/pull/79382 >From bd74d7db681cd07fda56f26e79e047c6d1a41f6b Mon Sep 17 00:00:00 2001 From: Chris Bieneman Date: Thu, 29 Feb 2024 15:37:50 -0600 Subject: [PATCH 1/6] [HLSL] Pass arrays by value HLSL constant sized array

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

2024-03-29 Thread Eli Friedman via cfe-commits
@@ -10926,6 +10965,10 @@ QualType ASTContext::mergeTypes(QualType LHS, QualType RHS, bool OfBlockPointer, assert(LHS != RHS && "Equivalent pipe types should have already been handled!"); return {}; + case Type::ArrayParameter: +assert(LHS != RHS && +

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

2024-03-29 Thread Eli Friedman via cfe-commits
@@ -2331,6 +2332,11 @@ void CodeGenFunction::EmitVariablyModifiedType(QualType type) { type = cast(ty)->getPointeeType(); break; +case Type::ArrayParameter: efriedma-quic wrote: Can we just use the existing "case" for ConstantArray?

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

2024-03-29 Thread Chris B via cfe-commits
https://github.com/llvm-beanz updated https://github.com/llvm/llvm-project/pull/79382 >From bd74d7db681cd07fda56f26e79e047c6d1a41f6b Mon Sep 17 00:00:00 2001 From: Chris Bieneman Date: Thu, 29 Feb 2024 15:37:50 -0600 Subject: [PATCH 1/5] [HLSL] Pass arrays by value HLSL constant sized array

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

2024-03-13 Thread Chris B via cfe-commits
@@ -3173,41 +3174,46 @@ class ArrayType : public Type, public llvm::FoldingSetNode { return T->getTypeClass() == ConstantArray || T->getTypeClass() == VariableArray || T->getTypeClass() == IncompleteArray || - T->getTypeClass() ==

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

2024-03-13 Thread Richard Smith via cfe-commits
@@ -3173,41 +3174,46 @@ class ArrayType : public Type, public llvm::FoldingSetNode { return T->getTypeClass() == ConstantArray || T->getTypeClass() == VariableArray || T->getTypeClass() == IncompleteArray || - T->getTypeClass() ==

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

2024-03-13 Thread Chris B via cfe-commits
@@ -4655,6 +4655,13 @@ void CodeGenFunction::EmitCallArg(CallArgList , 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

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

2024-03-13 Thread Chris B via cfe-commits
@@ -3173,41 +3174,46 @@ class ArrayType : public Type, public llvm::FoldingSetNode { return T->getTypeClass() == ConstantArray || T->getTypeClass() == VariableArray || T->getTypeClass() == IncompleteArray || - T->getTypeClass() ==

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

2024-03-12 Thread Richard Smith via cfe-commits
@@ -3173,41 +3174,46 @@ class ArrayType : public Type, public llvm::FoldingSetNode { return T->getTypeClass() == ConstantArray || T->getTypeClass() == VariableArray || T->getTypeClass() == IncompleteArray || - T->getTypeClass() ==

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

2024-03-12 Thread Eli Friedman via cfe-commits
@@ -3173,41 +3174,46 @@ class ArrayType : public Type, public llvm::FoldingSetNode { return T->getTypeClass() == ConstantArray || T->getTypeClass() == VariableArray || T->getTypeClass() == IncompleteArray || - T->getTypeClass() ==

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

2024-03-12 Thread Eli Friedman via cfe-commits
@@ -2231,7 +2231,8 @@ Value *ScalarExprEmitter::VisitCastExpr(CastExpr *CE) { case CK_UserDefinedConversion: return Visit(const_cast(E)); - case CK_NoOp: { + case CK_NoOp: + case CK_HLSLArrayRValue: { efriedma-quic wrote: It shouldn't be possible to

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

2024-03-12 Thread Eli Friedman via cfe-commits
@@ -500,6 +500,7 @@ ComplexPairTy ComplexExprEmitter::EmitCast(CastKind CK, Expr *Op, case CK_NoOp: case CK_LValueToRValue: case CK_UserDefinedConversion: + case CK_HLSLArrayRValue: efriedma-quic wrote: The result of an CK_HLSLArrayRValue can't be a

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

2024-03-12 Thread Eli Friedman via cfe-commits
@@ -1442,6 +1445,7 @@ static bool castPreservesZero(const CastExpr *CE) { case CK_BitCast: case CK_ToUnion: case CK_ToVoid: + case CK_HLSLArrayRValue: efriedma-quic wrote: Probably should be false, like other lvalue-to-rvalue casts?

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

2024-03-12 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic commented: This seems like the right direction. https://github.com/llvm/llvm-project/pull/79382 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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

2024-03-12 Thread Eli Friedman via cfe-commits
@@ -10900,6 +10936,10 @@ QualType ASTContext::mergeTypes(QualType LHS, QualType RHS, bool OfBlockPointer, assert(LHS != RHS && "Equivalent pipe types should have already been handled!"); return {}; + case Type::ArrayParameter: +if (RHS != LHS)

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

2024-03-12 Thread Eli Friedman via cfe-commits
@@ -1126,6 +1126,7 @@ class ConstExprEmitter : case CK_NonAtomicToAtomic: case CK_NoOp: case CK_ConstructorConversion: +case CK_HLSLArrayRValue: efriedma-quic wrote: We shouldn't accept CK_HLSLArrayRValue casts here (or if we do, we need to do

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

2024-03-12 Thread Eli Friedman via cfe-commits
@@ -4655,6 +4655,13 @@ void CodeGenFunction::EmitCallArg(CallArgList , 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

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

2024-03-12 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic edited https://github.com/llvm/llvm-project/pull/79382 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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

2024-03-12 Thread Chris B via cfe-commits
https://github.com/llvm-beanz updated https://github.com/llvm/llvm-project/pull/79382 >From 762646ef1d95efa968199156b52a60c3472a7611 Mon Sep 17 00:00:00 2001 From: Chris Bieneman Date: Thu, 29 Feb 2024 15:37:50 -0600 Subject: [PATCH 1/3] [HLSL] Pass arrays by value HLSL constant sized array

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

2024-03-12 Thread Chris B via cfe-commits
https://github.com/llvm-beanz updated https://github.com/llvm/llvm-project/pull/79382 >From 762646ef1d95efa968199156b52a60c3472a7611 Mon Sep 17 00:00:00 2001 From: Chris Bieneman Date: Thu, 29 Feb 2024 15:37:50 -0600 Subject: [PATCH 1/2] [HLSL] Pass arrays by value HLSL constant sized array

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

2024-03-12 Thread Chris B via cfe-commits
llvm-beanz wrote: I force pushed an update here because the new implementation is basically a complete rewrite based on @efriedma-quic's suggestion. I think this is a significantly cleaner approach that more accurately models the behavior of HLSL.

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

2024-03-12 Thread Chris B via cfe-commits
https://github.com/llvm-beanz edited https://github.com/llvm/llvm-project/pull/79382 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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

2024-03-12 Thread Chris B via cfe-commits
https://github.com/llvm-beanz updated https://github.com/llvm/llvm-project/pull/79382 >From 762646ef1d95efa968199156b52a60c3472a7611 Mon Sep 17 00:00:00 2001 From: Chris Bieneman Date: Thu, 29 Feb 2024 15:37:50 -0600 Subject: [PATCH] [HLSL] Pass arrays by value HLSL constant sized array

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

2024-01-24 Thread Chris B via cfe-commits
@@ -10524,6 +10524,11 @@ Sema::PerformCopyInitialization(const InitializedEntity , Expr *InitE = Init.get(); assert(InitE && "No initialization expression?"); + if (LangOpts.HLSL) +if (auto AdjTy = dyn_cast(Entity.getType())) + if

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

2024-01-24 Thread Eli Friedman via cfe-commits
@@ -10524,6 +10524,11 @@ Sema::PerformCopyInitialization(const InitializedEntity , Expr *InitE = Init.get(); assert(InitE && "No initialization expression?"); + if (LangOpts.HLSL) +if (auto AdjTy = dyn_cast(Entity.getType())) + if

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

2024-01-24 Thread Eli Friedman via cfe-commits
@@ -3569,6 +3569,7 @@ bool Expr::HasSideEffects(const ASTContext , case ConceptSpecializationExprClass: case RequiresExprClass: case SYCLUniqueStableNameExprClass: + case HLSLArrayTemporaryExprClass: efriedma-quic wrote: This looks wrong; I think you

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

2024-01-24 Thread via cfe-commits
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff 6e4930c67508a90bdfd756f6e45417b5253cd741 d01d3dd8de6e955ad19a0ad8399547dbc59f7a52 --

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

2024-01-24 Thread via cfe-commits
llvmbot wrote: @llvm/pr-subscribers-clang-codegen Author: Chris B (llvm-beanz) Changes In HLSL function parameters are passed by value, including array parameters. This change introduces a new AST node to represent array temporary expressions. They behave as lvalues to temporary arrays

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

2024-01-24 Thread via cfe-commits
llvmbot wrote: @llvm/pr-subscribers-hlsl Author: Chris B (llvm-beanz) Changes In HLSL function parameters are passed by value, including array parameters. This change introduces a new AST node to represent array temporary expressions. They behave as lvalues to temporary arrays and decay

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

2024-01-24 Thread via cfe-commits
llvmbot wrote: @llvm/pr-subscribers-clang-static-analyzer-1 @llvm/pr-subscribers-clang-modules Author: Chris B (llvm-beanz) Changes In HLSL function parameters are passed by value, including array parameters. This change introduces a new AST node to represent array temporary expressions.

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

2024-01-24 Thread Chris B via cfe-commits
https://github.com/llvm-beanz created https://github.com/llvm/llvm-project/pull/79382 In HLSL function parameters are passed by value, including array parameters. This change introduces a new AST node to represent array temporary expressions. They behave as lvalues to temporary arrays and