llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) <details> <summary>Changes</summary> In the current interpreter, removing the equivalent if statement breaks this test: + gi = __builtin_object_size(&t[1].v[14], 3); but in the bytecode interpeter, removing this if does not break anything as it's unreachable, see https://github.com/llvm/llvm-project/pull/213017/changes#r4475679359 --- Full diff: https://github.com/llvm/llvm-project/pull/240742.diff 2 Files Affected: - (modified) clang/lib/AST/ByteCode/InterpBuiltinObjectSize.cpp (-4) - (modified) clang/test/AST/ByteCode/builtin-object-size-codegen.c (+14) ``````````diff diff --git a/clang/lib/AST/ByteCode/InterpBuiltinObjectSize.cpp b/clang/lib/AST/ByteCode/InterpBuiltinObjectSize.cpp index 41b347150886f8..18dfc8e8e1b92d 100644 --- a/clang/lib/AST/ByteCode/InterpBuiltinObjectSize.cpp +++ b/clang/lib/AST/ByteCode/InterpBuiltinObjectSize.cpp @@ -432,10 +432,6 @@ UnsignedOrNone evaluateBuiltinObjectSize(const ASTContext &ASTCtx, } if (!UseClosestSurroundingVariable || DetermineForCompleteObject) { - // Kind=3 wants a lower bound, so we can't fall back to this. - if (Kind == 3 && !DetermineForCompleteObject) - return std::nullopt; - if (InvalidBase) return std::nullopt; diff --git a/clang/test/AST/ByteCode/builtin-object-size-codegen.c b/clang/test/AST/ByteCode/builtin-object-size-codegen.c index d1880e803c0972..932793c5988199 100644 --- a/clang/test/AST/ByteCode/builtin-object-size-codegen.c +++ b/clang/test/AST/ByteCode/builtin-object-size-codegen.c @@ -146,3 +146,17 @@ void f18(void) { // CHECK: store i32 3 gi = __builtin_object_size((char*)&_P + 5, 0); } + +void test26(void) { + struct { int v[10]; } t[10]; + + // CHECK: store i32 316 + gi = __builtin_object_size(&t[1].v[11], 0); + // FIXME: Not sure why this should return 312. GCC also returns 0. + // store i32 312 + // gi = __builtin_object_size(&t[1].v[12], 1); + // CHECK: store i32 308 + gi = __builtin_object_size(&t[1].v[13], 2); + // CHECK: store i32 0 + gi = __builtin_object_size(&t[1].v[14], 3); +} `````````` </details> https://github.com/llvm/llvm-project/pull/240742 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
