Skip to content

Commit b294951

Browse files
authored
[clang][bytecode] Fix the handling of address of a vector (#106558)
The PR #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 <[email protected]>
1 parent 8f4aafb commit b294951

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5324,11 +5324,11 @@ bool Compiler<Emitter>::VisitVectorUnaryOperator(const UnaryOperator *E) {
53245324

53255325
auto UnaryOp = E->getOpcode();
53265326
if (UnaryOp != UO_Plus && UnaryOp != UO_Minus && UnaryOp != UO_LNot &&
5327-
UnaryOp != UO_Not)
5327+
UnaryOp != UO_Not && UnaryOp != UO_AddrOf)
53285328
return this->emitInvalid(E);
53295329

53305330
// Nothing to do here.
5331-
if (UnaryOp == UO_Plus)
5331+
if (UnaryOp == UO_Plus || UnaryOp == UO_AddrOf)
53325332
return this->delegate(SubExpr);
53335333

53345334
if (!Initializing) {

clang/test/CodeGen/compound-literal.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm %s -o - | FileCheck %s
2+
// RUN: %clang_cc1 -triple x86_64-apple-darwin -fexperimental-new-constant-interpreter -emit-llvm %s -o - | FileCheck %s
23

34
// Capture the type and name so matching later is cleaner.
45
struct CompoundTy { int a; };

0 commit comments

Comments
 (0)