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

Bill Wendling isanbard at gmail.com
Thu Nov 6 14:18:44 PST 2008


Author: void
Date: Thu Nov  6 16:18:44 2008
New Revision: 58819

URL: http://llvm.org/viewvc/llvm-project?rev=58819&view=rev
Log:
The size limit is for individual arrays. So if any array has more than 8 bytes
in it, then emit stack protectors.

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=58819&r1=58818&r2=58819&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/StackProtector.cpp (original)
+++ llvm/trunk/lib/CodeGen/StackProtector.cpp Thu Nov  6 16:18:44 2008
@@ -192,9 +192,6 @@
   default: return false;
   case SSP::ALL: return true;
   case SSP::SOME: {
-    // If the size of the local variables allocated on the stack is greater than
-    // SSPBufferSize, then we require a stack protector.
-    uint64_t StackSize = 0;
     const TargetData *TD = TLI->getTargetData();
 
     for (Function::iterator I = F->begin(), E = F->end(); I != E; ++I) {
@@ -208,9 +205,10 @@
           if (ConstantInt *CI = dyn_cast<ConstantInt>(AI->getArraySize())) {
             const Type *Ty = AI->getAllocatedType();
             uint64_t TySize = TD->getABITypeSize(Ty);
-            StackSize += TySize * CI->getZExtValue(); // Total allocated size.
 
-            if (SSPBufferSize <= StackSize)
+            // If an array has more than 8 bytes of allocated space, then we
+            // emit stack protectors.
+            if (SSPBufferSize <= TySize * CI->getZExtValue())
               return true;
           } else {
             // This is a call to alloca with a variable size. Default to adding





More information about the llvm-commits mailing list