Skip to content

[clang][bytecode] Fix tail padding with __builtin_object_size#209771

Merged
tbaederr merged 1 commit into
llvm:mainfrom
tbaederr:bos-padding
Jul 15, 2026
Merged

[clang][bytecode] Fix tail padding with __builtin_object_size#209771
tbaederr merged 1 commit into
llvm:mainfrom
tbaederr:bos-padding

Conversation

@tbaederr

Copy link
Copy Markdown
Contributor

This fixes the new libcxx/atomics/builtin_clear_padding.pass.cpp

@llvmorg-github-actions llvmorg-github-actions Bot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" clang:bytecode Issues for the clang bytecode constexpr interpreter labels Jul 15, 2026
@llvmorg-github-actions

Copy link
Copy Markdown

@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)

Changes

This fixes the new libcxx/atomics/builtin_clear_padding.pass.cpp


Full diff: https://github.com/llvm/llvm-project/pull/209771.diff

2 Files Affected:

  • (modified) clang/lib/AST/ByteCode/InterpBuiltin.cpp (+2-4)
  • (modified) clang/test/AST/ByteCode/builtin-object-size.cpp (+8)
diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
index 70717720c592d..a539fb26abc08 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
@@ -2299,11 +2299,9 @@ static bool interp__builtin_memchr(InterpState &S, CodePtr OpPC,
 
 static std::optional<unsigned> computeFullDescSize(const ASTContext &ASTCtx,
                                                    const Descriptor *Desc) {
-  if (Desc->isPrimitive())
+  if (Desc->isPrimitive() || Desc->isArray())
     return ASTCtx.getTypeSizeInChars(Desc->getType()).getQuantity();
-  if (Desc->isArray())
-    return ASTCtx.getTypeSizeInChars(Desc->getElemQualType()).getQuantity() *
-           Desc->getNumElems();
+
   if (Desc->isRecord()) {
     // Can't use Descriptor::getType() as that may return a pointer type. Look
     // at the decl directly.
diff --git a/clang/test/AST/ByteCode/builtin-object-size.cpp b/clang/test/AST/ByteCode/builtin-object-size.cpp
index e4433ea700ccb..295b6b4717740 100644
--- a/clang/test/AST/ByteCode/builtin-object-size.cpp
+++ b/clang/test/AST/ByteCode/builtin-object-size.cpp
@@ -55,3 +55,11 @@ namespace InvalidBase {
   constexpr size_t bos_dtor = __builtin_object_size(&(T&)(T&&)invalid_base_2(), 0); // expected-error {{must be initialized by a constant expression}} \
                                                                                     // expected-note {{non-literal type 'T'}}
 }
+
+namespace Padding {
+  typedef long double LongDouble3Vec __attribute__((ext_vector_type(3)));
+  void foo() {
+      LongDouble3Vec v1, v2;
+      static_assert(__builtin_object_size(&v1, 0) == 64);
+  }
+}

@github-actions

github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown

🪟 Windows x64 Test Results

  • 57397 tests passed
  • 2748 tests skipped

✅ The build succeeded and all tests passed.

This fixes the new libcxx/atomics/builtin_clear_padding.pass.cpp
@tbaederr
tbaederr merged commit 5c0dfce into llvm:main Jul 15, 2026
11 checks passed
@llvm-ci

llvm-ci commented Jul 15, 2026

Copy link
Copy Markdown

LLVM Buildbot has detected a new failure on builder llvm-clang-aarch64-darwin running on doug-worker-4 while building clang at step 6 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/190/builds/45911

Here is the relevant piece of the build log for the reference
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'Clang :: AST/ByteCode/builtin-object-size.cpp' FAILED ********************
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 1
/Volumes/RAMDisk/buildbot-root/aarch64-darwin/build/bin/clang -cc1 -internal-isystem /Volumes/RAMDisk/buildbot-root/aarch64-darwin/build/lib/clang/24/include -nostdsysteminc -fexperimental-new-constant-interpreter -verify=both,expected /Users/buildbot/buildbot-root/llvm-project/clang/test/AST/ByteCode/builtin-object-size.cpp
# executed command: /Volumes/RAMDisk/buildbot-root/aarch64-darwin/build/bin/clang -cc1 -internal-isystem /Volumes/RAMDisk/buildbot-root/aarch64-darwin/build/lib/clang/24/include -nostdsysteminc -fexperimental-new-constant-interpreter -verify=both,expected /Users/buildbot/buildbot-root/llvm-project/clang/test/AST/ByteCode/builtin-object-size.cpp
# .---command stderr------------
# | error: diagnostics with 'error' severity seen but not expected: 
# |   File /Users/buildbot/buildbot-root/llvm-project/clang/test/AST/ByteCode/builtin-object-size.cpp Line 65: static assertion failed due to requirement '__builtin_object_size(&v1, 0) == 64'
# | error: diagnostics with 'note' severity seen but not expected: 
# |   File /Users/buildbot/buildbot-root/llvm-project/clang/test/AST/ByteCode/builtin-object-size.cpp Line 65: expression evaluates to '32 == 64'
# | 2 errors generated.
# `-----------------------------
# error: command failed with exit status: 1

--

********************


Logans-olo pushed a commit to Logans-olo/llvm-project that referenced this pull request Jul 15, 2026
…09771)

This fixes the new libcxx/atomics/builtin_clear_padding.pass.cpp
@llvm-ci

llvm-ci commented Jul 15, 2026

Copy link
Copy Markdown

LLVM Buildbot has detected a new failure on builder llvm-clang-aarch64-darwin running on doug-worker-4 while building clang at step 6 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/190/builds/45911

Here is the relevant piece of the build log for the reference
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'Clang :: AST/ByteCode/builtin-object-size.cpp' FAILED ********************
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 1
/Volumes/RAMDisk/buildbot-root/aarch64-darwin/build/bin/clang -cc1 -internal-isystem /Volumes/RAMDisk/buildbot-root/aarch64-darwin/build/lib/clang/24/include -nostdsysteminc -fexperimental-new-constant-interpreter -verify=both,expected /Users/buildbot/buildbot-root/llvm-project/clang/test/AST/ByteCode/builtin-object-size.cpp
# executed command: /Volumes/RAMDisk/buildbot-root/aarch64-darwin/build/bin/clang -cc1 -internal-isystem /Volumes/RAMDisk/buildbot-root/aarch64-darwin/build/lib/clang/24/include -nostdsysteminc -fexperimental-new-constant-interpreter -verify=both,expected /Users/buildbot/buildbot-root/llvm-project/clang/test/AST/ByteCode/builtin-object-size.cpp
# .---command stderr------------
# | error: diagnostics with 'error' severity seen but not expected: 
# |   File /Users/buildbot/buildbot-root/llvm-project/clang/test/AST/ByteCode/builtin-object-size.cpp Line 65: static assertion failed due to requirement '__builtin_object_size(&v1, 0) == 64'
# | error: diagnostics with 'note' severity seen but not expected: 
# |   File /Users/buildbot/buildbot-root/llvm-project/clang/test/AST/ByteCode/builtin-object-size.cpp Line 65: expression evaluates to '32 == 64'
# | 2 errors generated.
# `-----------------------------
# error: command failed with exit status: 1

--

********************


pedroMVicente pushed a commit to pedroMVicente/llvm-project that referenced this pull request Jul 15, 2026
…09771)

This fixes the new libcxx/atomics/builtin_clear_padding.pass.cpp
@dyung

dyung commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

LLVM Buildbot has detected a new failure on builder llvm-clang-aarch64-darwin running on doug-worker-4 while building clang at step 6 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/190/builds/45911

Here is the relevant piece of the build log for the reference

Step 6 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'Clang :: AST/ByteCode/builtin-object-size.cpp' FAILED ********************
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 1
/Volumes/RAMDisk/buildbot-root/aarch64-darwin/build/bin/clang -cc1 -internal-isystem /Volumes/RAMDisk/buildbot-root/aarch64-darwin/build/lib/clang/24/include -nostdsysteminc -fexperimental-new-constant-interpreter -verify=both,expected /Users/buildbot/buildbot-root/llvm-project/clang/test/AST/ByteCode/builtin-object-size.cpp
# executed command: /Volumes/RAMDisk/buildbot-root/aarch64-darwin/build/bin/clang -cc1 -internal-isystem /Volumes/RAMDisk/buildbot-root/aarch64-darwin/build/lib/clang/24/include -nostdsysteminc -fexperimental-new-constant-interpreter -verify=both,expected /Users/buildbot/buildbot-root/llvm-project/clang/test/AST/ByteCode/builtin-object-size.cpp
# .---command stderr------------
# | error: diagnostics with 'error' severity seen but not expected: 
# |   File /Users/buildbot/buildbot-root/llvm-project/clang/test/AST/ByteCode/builtin-object-size.cpp Line 65: static assertion failed due to requirement '__builtin_object_size(&v1, 0) == 64'
# | error: diagnostics with 'note' severity seen but not expected: 
# |   File /Users/buildbot/buildbot-root/llvm-project/clang/test/AST/ByteCode/builtin-object-size.cpp Line 65: expression evaluates to '32 == 64'
# | 2 errors generated.
# `-----------------------------
# error: command failed with exit status: 1

--

********************

Hi @tbaederr, can you take a look at the failure on the build bot and revert if you need time to investigate?

@hnrklssn

Copy link
Copy Markdown
Member

Fix in #209930

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:bytecode Issues for the clang bytecode constexpr interpreter clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants