-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[Clang][Interp] __builtin_os_log_format_buffer_size
should be an unevaluated builtin
#99895
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…aluated builtin Signed-off-by: yronglin <[email protected]>
@llvm/pr-subscribers-clang Author: None (yronglin) ChangesFollow the current behavior of constant evaluator, The following code is well-formed:
Full diff: https://github.com/llvm/llvm-project/pull/99895.diff 2 Files Affected:
diff --git a/clang/lib/AST/Interp/ByteCodeEmitter.cpp b/clang/lib/AST/Interp/ByteCodeEmitter.cpp
index a3d4c7d7392da..fee4432a8f661 100644
--- a/clang/lib/AST/Interp/ByteCodeEmitter.cpp
+++ b/clang/lib/AST/Interp/ByteCodeEmitter.cpp
@@ -27,7 +27,8 @@ using namespace clang::interp;
/// Similar information is available via ASTContext::BuiltinInfo,
/// but that is not correct for our use cases.
static bool isUnevaluatedBuiltin(unsigned BuiltinID) {
- return BuiltinID == Builtin::BI__builtin_classify_type;
+ return BuiltinID == Builtin::BI__builtin_classify_type ||
+ BuiltinID == Builtin::BI__builtin_os_log_format_buffer_size;
}
Function *ByteCodeEmitter::compileFunc(const FunctionDecl *FuncDecl) {
diff --git a/clang/test/CodeGen/builtins.c b/clang/test/CodeGen/builtins.c
index b41efb59e61db..1f998236501d2 100644
--- a/clang/test/CodeGen/builtins.c
+++ b/clang/test/CodeGen/builtins.c
@@ -1,6 +1,7 @@
// RUN: %clang_cc1 -emit-llvm -o %t %s
// RUN: not grep __builtin %t
// RUN: %clang_cc1 -emit-llvm -triple x86_64-darwin-apple -o - %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-darwin-apple -fexperimental-new-constant-interpreter -o - %s | FileCheck %s
int printf(const char *, ...);
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
Hi, Unfortunately this patch appears to have introduced a memory leak that was detected by the sanitizer buildbots (https://lab.llvm.org/buildbot/#/builders/52/builds/1079). The issue can be reproduced with a minimal ASan build configuration, like:
|
…evaluated builtin (#99895) Summary: Follow the current behavior of constant evaluator, `__builtin_os_log_format_buffer_size` should be an unevaluated builtin. The following code is well-formed: ``` void test_builtin_os_log(void *buf, int i, const char *data) { constexpr int len = __builtin_os_log_format_buffer_size("%d %{public}s %{private}.16P", i, data, data); } ``` Signed-off-by: yronglin <[email protected]> Test Plan: Reviewers: Subscribers: Tasks: Tags: Differential Revision: https://phabricator.intern.facebook.com/D60251336
…be an unevaluated builtin (#99895)" Summary: This reverts commit 4572efe. Reason: Introduced a memory leak that broke the sanitizer buildbots. More information available in the original pull request (#99895). Test Plan: Reviewers: Subscribers: Tasks: Tags: Differential Revision: https://phabricator.intern.facebook.com/D60251078
Follow the current behavior of constant evaluator,
__builtin_os_log_format_buffer_size
should be an unevaluated builtin.The following code is well-formed: