[PATCH] D115888: [Attributor][Fix] Add default alignment to HeapToStack
Joseph Huber via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 16 10:25:52 PST 2021
jhuber6 added a comment.
In D115888#3198139 <https://reviews.llvm.org/D115888#3198139>, @lebedev.ri wrote:
> Shouldn't/can't you query the alignment for that pointer?
> Hardcoding anything like this is a sign of a problem.
I haven't found an interface in LLVM to query default alignment information from malloc. As far as I know, the malloc functions are defined by the GNU documentation to be aligned to 16 on 64-bit systems, and 8 on 32-bit systems and Clang behaves similarly. A more complete solution would be to change the `__kmpc_alloc_shared` RTL function to be an aligned malloc function. That way in Clang we can just use the natural alignment of the underlying type, or query the target info from there. But I don't think that is explicitly necessary because we just need to mimic the pointer's alignment as it would be from the malloc call since we're replacing it with an alloca. If you know of somewhere I can query the default malloc alignment from within LLVM I can add that, or I can just check the data layout and use the 8 / 16 distinction used in https://www.gnu.org/software/libc/manual/html_node/Aligned-Memory-Blocks.html#Aligned-Memory-Blocks. I'd prefer not to change the OpenMP RTL to include the alignment, as that would change a lot of tests and code for little gain I can see.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D115888/new/
https://reviews.llvm.org/D115888
More information about the llvm-commits
mailing list