aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/SafeStack.cpp
diff options
context:
space:
mode:
authorGuillaume Chatelet <gchatelet@google.com>2022-06-14 09:50:54 +0000
committerGuillaume Chatelet <gchatelet@google.com>2022-06-14 10:56:36 +0000
commitc0e85f1c3bb4cf683aff42eb179ad5643d9a434d (patch)
tree898ce5e327efb9457029de875cb8d57b30ba5a06 /llvm/lib/CodeGen/SafeStack.cpp
parent6725d806400e4071ebf32a95bb21466b32e52a76 (diff)
downloadllvm-c0e85f1c3bb4cf683aff42eb179ad5643d9a434d.zip
llvm-c0e85f1c3bb4cf683aff42eb179ad5643d9a434d.tar.gz
llvm-c0e85f1c3bb4cf683aff42eb179ad5643d9a434d.tar.bz2
[NFC][Alignment] Use Align in SafeStack
Diffstat (limited to 'llvm/lib/CodeGen/SafeStack.cpp')
-rw-r--r--llvm/lib/CodeGen/SafeStack.cpp13
1 files changed, 6 insertions, 7 deletions
diff --git a/llvm/lib/CodeGen/SafeStack.cpp b/llvm/lib/CodeGen/SafeStack.cpp
index 2c16c191..e7116ec 100644
--- a/llvm/lib/CodeGen/SafeStack.cpp
+++ b/llvm/lib/CodeGen/SafeStack.cpp
@@ -127,7 +127,7 @@ class SafeStack {
///
/// 16 seems like a reasonable upper bound on the alignment of objects that we
/// might expect to appear on the stack on most common targets.
- static constexpr uint64_t StackAlignment = 16;
+ static constexpr Align StackAlignment = Align::Constant<16>();
/// Return the value of the stack canary.
Value *getStackGuard(IRBuilder<> &IRB, Function &F);
@@ -201,7 +201,7 @@ public:
bool run();
};
-constexpr uint64_t SafeStack::StackAlignment;
+constexpr Align SafeStack::StackAlignment;
uint64_t SafeStack::getStaticAllocaAllocationSize(const AllocaInst* AI) {
uint64_t Size = DL.getTypeAllocSize(AI->getAllocatedType());
@@ -673,13 +673,12 @@ void SafeStack::moveDynamicAllocasToUnsafeStack(
SP = IRB.CreateSub(SP, Size);
// Align the SP value to satisfy the AllocaInst, type and stack alignments.
- uint64_t Align =
- std::max(std::max(DL.getPrefTypeAlignment(Ty), AI->getAlignment()),
- StackAlignment);
+ auto Align = std::max(std::max(DL.getPrefTypeAlign(Ty), AI->getAlign()),
+ StackAlignment);
- assert(isPowerOf2_32(Align));
Value *NewTop = IRB.CreateIntToPtr(
- IRB.CreateAnd(SP, ConstantInt::get(IntPtrTy, ~uint64_t(Align - 1))),
+ IRB.CreateAnd(SP,
+ ConstantInt::get(IntPtrTy, ~uint64_t(Align.value() - 1))),
StackPtrTy);
// Save the stack pointer.