aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
authorAndrew Savonichev <andrew.savonichev@gmail.com>2022-12-15 18:16:45 +0300
committerAndrew Savonichev <andrew.savonichev@gmail.com>2022-12-15 18:18:12 +0300
commitffedf47d8b793e07317f82f9c2a5f5425ebb71ad (patch)
tree77d83d2859ab9fc7bd6b10cca98e7e80ae33182d /llvm/lib/CodeGen
parentfaa1b57d16009790ed6fd59342b12607c5460b49 (diff)
downloadllvm-ffedf47d8b793e07317f82f9c2a5f5425ebb71ad.zip
llvm-ffedf47d8b793e07317f82f9c2a5f5425ebb71ad.tar.gz
llvm-ffedf47d8b793e07317f82f9c2a5f5425ebb71ad.tar.bz2
[SelectionDAG] Do not second-guess alignment for alloca
Alignment of an alloca in IR can be lower than the preferred alignment on purpose, but this override essentially treats the preferred alignment as the minimum alignment. The patch changes this behavior to always use the specified alignment. If alignment is not set explicitly in LLVM IR, it is set to DL.getPrefTypeAlign(Ty) in computeAllocaDefaultAlign. Tests are changed as well: explicit alignment is increased to match the preferred alignment if it changes output, or omitted when it is hard to determine the right value (e.g. for pointers, some structs, or weird types). Differential Revision: https://reviews.llvm.org/D135462
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp15
1 files changed, 1 insertions, 14 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp b/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
index 3e59d0d..3a1a237 100644
--- a/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
@@ -128,20 +128,7 @@ void FunctionLoweringInfo::set(const Function &fn, MachineFunction &mf,
for (const Instruction &I : BB) {
if (const AllocaInst *AI = dyn_cast<AllocaInst>(&I)) {
Type *Ty = AI->getAllocatedType();
- Align TyPrefAlign = MF->getDataLayout().getPrefTypeAlign(Ty);
- // The "specified" alignment is the alignment written on the alloca,
- // or the preferred alignment of the type if none is specified.
- //
- // (Unspecified alignment on allocas will be going away soon.)
- Align SpecifiedAlign = AI->getAlign();
-
- // If the preferred alignment of the type is higher than the specified
- // alignment of the alloca, promote the alignment, as long as it doesn't
- // require realigning the stack.
- //
- // FIXME: Do we really want to second-guess the IR in isel?
- Align Alignment =
- std::max(std::min(TyPrefAlign, StackAlign), SpecifiedAlign);
+ Align Alignment = AI->getAlign();
// Static allocas can be folded into the initial stack frame
// adjustment. For targets that don't realign the stack, don't