Author: yronglin Date: 2024-08-30T17:34:00+08:00 New Revision: b294951e3967730ffad14d51297694b1411d7af6
URL: https://github.com/llvm/llvm-project/commit/b294951e3967730ffad14d51297694b1411d7af6 DIFF: https://github.com/llvm/llvm-project/commit/b294951e3967730ffad14d51297694b1411d7af6.diff LOG: [clang][bytecode] Fix the handling of address of a vector (#106558) The PR https://github.com/llvm/llvm-project/pull/105996 broke taking the address of a vector: **compound-literal.c** ```C typedef int v4i32 __attribute((vector_size(16))); v4i32 *y = &(v4i32){1,2,3,4}; ``` That because the current interpreter handle vector unary operator as a fallback when the generic code path fail. but the new interpreter was not. we need to handle `UO_AddrOf` in `Compiler<Emitter>::VisitVectorUnaryOperator`. Signed-off-by: yronglin <yronglin...@gmail.com> Added: Modified: clang/lib/AST/ByteCode/Compiler.cpp clang/test/CodeGen/compound-literal.c Removed: ################################################################################ diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp index 6a77323d939791..9bd77edb0a550f 100644 --- a/clang/lib/AST/ByteCode/Compiler.cpp +++ b/clang/lib/AST/ByteCode/Compiler.cpp @@ -5324,11 +5324,11 @@ bool Compiler<Emitter>::VisitVectorUnaryOperator(const UnaryOperator *E) { auto UnaryOp = E->getOpcode(); if (UnaryOp != UO_Plus && UnaryOp != UO_Minus && UnaryOp != UO_LNot && - UnaryOp != UO_Not) + UnaryOp != UO_Not && UnaryOp != UO_AddrOf) return this->emitInvalid(E); // Nothing to do here. - if (UnaryOp == UO_Plus) + if (UnaryOp == UO_Plus || UnaryOp == UO_AddrOf) return this->delegate(SubExpr); if (!Initializing) { diff --git a/clang/test/CodeGen/compound-literal.c b/clang/test/CodeGen/compound-literal.c index 5b3cebb7c6ae6a..5fe9594c0f954f 100644 --- a/clang/test/CodeGen/compound-literal.c +++ b/clang/test/CodeGen/compound-literal.c @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm %s -o - | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin -fexperimental-new-constant-interpreter -emit-llvm %s -o - | FileCheck %s // Capture the type and name so matching later is cleaner. struct CompoundTy { int a; }; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits