[PATCH] D57335: [IR] Don't assume all functions are 4 byte aligned
Eli Friedman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 28 09:31:55 PST 2019
efriedma added reviewers: efriedma, chandlerc.
efriedma added a comment.
Missing update to PPC backend.
I'm not convinced that we should be modifying the datalayout here, as opposed to adding some sort of target hook for the optimizer.
It's a little unfortunate that there isn't any way to represent that the alignment of a function pointer is the same as the alignment of the function, but has some known minimum value.
================
Comment at: llvm/docs/LangRef.rst:2007
+``F<abi>``
+ This specifies the alignment for function pointers.
``m:<mangling>``
----------------
This needs more description.
================
Comment at: llvm/lib/IR/ConstantFold.cpp:1083
+ ? GV->getPointerAlignment(GV->getParent()->getDataLayout())
+ : 0U;
+
----------------
If you fail to find a datalayout, you have to assume the worst case (that the pointer isn't aligned at all).
================
Comment at: llvm/lib/IR/ConstantFold.cpp:1087
+ if (GVAlign == 0U && isa<Function>(GV))
+ GVAlign = 4U;
----------------
Using "4" as a default is dangerous; on x86, the alignment of the pointer corresponds to the alignment of the function, but might be less than 4 if it isn't explicitly specified.
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D57335/new/
https://reviews.llvm.org/D57335
More information about the llvm-commits
mailing list