[llvm-commits] [llvm] r58740 - /llvm/trunk/lib/CodeGen/StackProtector.cpp

Bill Wendling isanbard at gmail.com
Tue Nov 4 16:54:27 PST 2008


Author: void
Date: Tue Nov  4 18:54:27 2008
New Revision: 58740

URL: http://llvm.org/viewvc/llvm-project?rev=58740&view=rev
Log:
Simplify the allocated size calculation.

Modified:
    llvm/trunk/lib/CodeGen/StackProtector.cpp

Modified: llvm/trunk/lib/CodeGen/StackProtector.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/StackProtector.cpp?rev=58740&r1=58739&r2=58740&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/StackProtector.cpp (original)
+++ llvm/trunk/lib/CodeGen/StackProtector.cpp Tue Nov  4 18:54:27 2008
@@ -201,9 +201,9 @@
              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;





More information about the llvm-commits mailing list