[clang][bytecode] Fix tail padding with __builtin_object_size#209771
Conversation
|
@llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) ChangesThis fixes the new libcxx/atomics/builtin_clear_padding.pass.cpp Full diff: https://github.com/llvm/llvm-project/pull/209771.diff 2 Files Affected:
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);
+ }
+}
|
🪟 Windows x64 Test Results
✅ The build succeeded and all tests passed. |
This fixes the new libcxx/atomics/builtin_clear_padding.pass.cpp
|
LLVM Buildbot has detected a new failure on builder 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 |
…09771) This fixes the new libcxx/atomics/builtin_clear_padding.pass.cpp
|
LLVM Buildbot has detected a new failure on builder 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 |
…09771) This fixes the new libcxx/atomics/builtin_clear_padding.pass.cpp
Hi @tbaederr, can you take a look at the failure on the build bot and revert if you need time to investigate? |
|
Fix in #209930 |
This fixes the new libcxx/atomics/builtin_clear_padding.pass.cpp