llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Aleksandr Nogikh (a-nogikh) <details> <summary>Changes</summary> The alloc-token-lower.c test only covered standard (and non-standard) malloc-annotated allocation function. Ensure that the code generation works as intended also for the standard malloc_span-annotated functions with the example of __size_returning_new. --- Full diff: https://github.com/llvm/llvm-project/pull/183049.diff 1 Files Affected: - (modified) clang/test/CodeGen/alloc-token-lower.c (+16) ``````````diff diff --git a/clang/test/CodeGen/alloc-token-lower.c b/clang/test/CodeGen/alloc-token-lower.c index 2d87b02c6a288..9ab50ca7cd938 100644 --- a/clang/test/CodeGen/alloc-token-lower.c +++ b/clang/test/CodeGen/alloc-token-lower.c @@ -36,4 +36,20 @@ void *test_nonlibcall_malloc() { return nonstandard_malloc(sizeof(int)); } +// Ensure that the standard allocation functions annotated with malloc_span +// are properly instrumented as well. +typedef struct { + void *p; + size_t n; +} __sized_ptr_t; +__sized_ptr_t __size_returning_new(size_t size) __attribute__((malloc_span)); + +// CHECK-LABEL: @test_size_returning_new +// DEFAULT: call{{.*}} { ptr, i64 } @__alloc_token___size_returning_new(i64 noundef 4, i64 2689373973731826898){{.*}} !alloc_token [[META_INT]] +// FASTABI: call{{.*}} { ptr, i64 } @__alloc_token_2689373973731826898___size_returning_new(i64 noundef 4){{.*}} !alloc_token [[META_INT]] +void *test_size_returning_new() { + __sized_ptr_t ret = __size_returning_new(sizeof(int)); + return ret.p; +} + // CHECK: [[META_INT]] = !{!"int", i1 false} `````````` </details> https://github.com/llvm/llvm-project/pull/183049 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
