character arrays. This is in line with what GCC does.
<rdar://problem/
10529227>
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@161446
91177308-0d34-0410-b5e6-
96231b3b80d8
#include "llvm/Support/CommandLine.h"
#include "llvm/Target/TargetData.h"
#include "llvm/Target/TargetLowering.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Target/TargetData.h"
#include "llvm/Target/TargetLowering.h"
+#include "llvm/ADT/Triple.h"
using namespace llvm;
// SSPBufferSize - The lower bound for a buffer to be considered for stack
using namespace llvm;
// SSPBufferSize - The lower bound for a buffer to be considered for stack
return false;
const TargetData *TD = TLI->getTargetData();
return false;
const TargetData *TD = TLI->getTargetData();
+ const TargetMachine &TM = TLI->getTargetMachine();
+ Triple Trip(TM.getTargetTriple());
for (Function::iterator I = F->begin(), E = F->end(); I != E; ++I) {
BasicBlock *BB = I;
for (Function::iterator I = F->begin(), E = F->end(); I != E; ++I) {
BasicBlock *BB = I;
// protectors.
return true;
// protectors.
return true;
- if (ArrayType *AT = dyn_cast<ArrayType>(AI->getAllocatedType()))
+ if (ArrayType *AT = dyn_cast<ArrayType>(AI->getAllocatedType())) {
+ // If we're on a non-Darwin platform, don't add stack protectors
+ // unless the array is a character array.
+ if (!Trip.isOSDarwin() && !AT->getElementType()->isIntegerTy(8))
+ continue;
+
// If an array has more than SSPBufferSize bytes of allocated space,
// then we emit stack protectors.
if (SSPBufferSize <= TD->getTypeAllocSize(AT))
return true;
// If an array has more than SSPBufferSize bytes of allocated space,
// then we emit stack protectors.
if (SSPBufferSize <= TD->getTypeAllocSize(AT))
return true;