Simplify the allocated size calculation.
authorBill Wendling <isanbard@gmail.com>
Wed, 5 Nov 2008 00:54:27 +0000 (00:54 +0000)
committerBill Wendling <isanbard@gmail.com>
Wed, 5 Nov 2008 00:54:27 +0000 (00:54 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@58740 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/StackProtector.cpp

index 36ae2846a8123d4b4bde7748a426e04df2586441..631760ad822ce9d87a070b25812b01090d8a1e92 100644 (file)
@@ -201,9 +201,9 @@ bool StackProtector::RequiresStackProtector() const {
              II = BB->begin(), IE = BB->end(); II != IE; ++II)
         if (AllocaInst *AI = dyn_cast<AllocaInst>(II)) {
           if (ConstantInt *CI = dyn_cast<ConstantInt>(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;