diff options
author | Kewen Lin <linkw@linux.ibm.com> | 2020-11-06 14:45:06 +0100 |
---|---|---|
committer | Martin Liska <mliska@suse.cz> | 2020-11-06 14:47:44 +0100 |
commit | 15bcd01a94c23f312ac03b5faea29f18ef8d2a07 (patch) | |
tree | fb2822770cea64bc1356a93efbf8da3cc05ba820 /gcc | |
parent | 4c27f900950ed0ecb2897a8931c5cc348b1980be (diff) | |
download | gcc-15bcd01a94c23f312ac03b5faea29f18ef8d2a07.zip gcc-15bcd01a94c23f312ac03b5faea29f18ef8d2a07.tar.gz gcc-15bcd01a94c23f312ac03b5faea29f18ef8d2a07.tar.bz2 |
testsuite: fix malloc alignment in test
gcc/testsuite/ChangeLog:
PR gcov-profile/97461
* gcc.dg/tree-prof/pr97461.c: Return aligned memory.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/testsuite/gcc.dg/tree-prof/pr97461.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/gcc/testsuite/gcc.dg/tree-prof/pr97461.c b/gcc/testsuite/gcc.dg/tree-prof/pr97461.c index 8d21a3e..213fac9 100644 --- a/gcc/testsuite/gcc.dg/tree-prof/pr97461.c +++ b/gcc/testsuite/gcc.dg/tree-prof/pr97461.c @@ -20,7 +20,13 @@ static const fun_t funs[2] = { f1, f2, }; static void * malloc_impl(size_t size) { void * r = &memory[memory_p]; - memory_p += size; + /* The malloc() and calloc() functions return a pointer to the allocated + * memory, which is suitably aligned for any built-in type. Use 16 + * bytes here as the basic alignment requirement for user-defined malloc + * and calloc. See PR97594 for the details. */ + #define ROUND_UP_FOR_16B_ALIGNMENT(x) ((x + 15) & (-16)) + + memory_p += ROUND_UP_FOR_16B_ALIGNMENT(size); // force TOPN profile funs[size % 2](); |