From f1b4e2626bf1dfbbb9463a50afe115e65269d2e9 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Wed, 5 Nov 2008 00:54:27 +0000 Subject: Simplify the allocated size calculation. llvm-svn: 58740 --- llvm/lib/CodeGen/StackProtector.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'llvm/lib/CodeGen/StackProtector.cpp') diff --git a/llvm/lib/CodeGen/StackProtector.cpp b/llvm/lib/CodeGen/StackProtector.cpp index 36ae2846a812..631760ad822c 100644 --- a/llvm/lib/CodeGen/StackProtector.cpp +++ b/llvm/lib/CodeGen/StackProtector.cpp @@ -201,9 +201,9 @@ bool StackProtector::RequiresStackProtector() const { II = BB->begin(), IE = BB->end(); II != IE; ++II) if (AllocaInst *AI = dyn_cast(II)) { if (ConstantInt *CI = dyn_cast(AI->getArraySize())) { - uint64_t Bytes = TD->getTypeSizeInBits(AI->getAllocatedType()) / 8; - const APInt &Size = CI->getValue(); - StackSize += Bytes * Size.getZExtValue(); + const Type *Ty = AI->getAllocatedType(); + uint64_t TySize = TD->getABITypeSize(Ty); + StackSize += TySize * CI->getZExtValue(); // Total allocated size. if (SSPBufferSize <= StackSize) return true; -- cgit v1.2.3