[llvm] r186217 - Use the function attributes to pass along the stack protector buffer size.

Bill Wendling isanbard at gmail.com
Mon Jul 22 13:06:14 PDT 2013


Sorry. :-(

-bw

On Jul 12, 2013, at 6:02 PM, Chandler Carruth <chandlerc at google.com> wrote:

> I've gone ahead and reverted this in r186234 after two hours with no update. =/
> 
> Please folks, watch the build bots after you commit.
> 
> 
> On Fri, Jul 12, 2013 at 5:07 PM, Quentin Colombet <qcolombet at apple.com> wrote:
> Hi Bill,
> 
> This breaks some buildbots:
> http://lab.llvm.org:8013/builders/clang-x86_64-darwin11-nobootstrap-RAincremental/builds/4328
> ******************** TEST 'LLVM :: DebugInfo/X86/dbg_value_direct.ll' FAILED ********************
> Script:
> --
> /Users/buildslave/zorg/buildbot/smooshlab/slave-0.8/build.clang-x86_64-darwin11-nobootstrap-RAincremental/clang-build/Release+Asserts/bin/llc -filetype=obj -O0 -stack-protector-buffer-size=1 < /Users/buildslave/zorg/buildbot/smooshlab/slave-0.8/build.clang-x86_64-darwin11-nobootstrap-RAincremental/llvm/test/DebugInfo/X86/dbg_value_direct.ll
> --
> Exit Code: 1
> Command Output (stderr):
> --
> llc: Unknown command line argument '-stack-protector-buffer-size=1'.  Try: '/Users/buildslave/zorg/buildbot/smooshlab/slave-0.8/build.clang-x86_64-darwin11-nobootstrap-RAincremental/clang-build/Release+Asserts/bin/llc -help'
> llc: Did you mean '-debug-buffer-size=1'?
> --
> 
> ********************
> 
> 
> 
> -Quentin
> 
> On Jul 12, 2013, at 3:25 PM, Bill Wendling <isanbard at gmail.com> wrote:
> 
>> Author: void
>> Date: Fri Jul 12 17:25:20 2013
>> New Revision: 186217
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=186217&view=rev
>> Log:
>> Use the function attributes to pass along the stack protector buffer size.
>> 
>> Now that we have robust function attributes, don't use a command line option to
>> specify the stack protecto buffer size.
>> 
>> Modified:
>>    llvm/trunk/include/llvm/CodeGen/CommandFlags.h
>>    llvm/trunk/include/llvm/Target/TargetOptions.h
>>    llvm/trunk/lib/CodeGen/StackProtector.cpp
>>    llvm/trunk/tools/llc/llc.cpp
>>    llvm/trunk/tools/lto/LTOModule.cpp
>>    llvm/trunk/tools/opt/opt.cpp
>> 
>> Modified: llvm/trunk/include/llvm/CodeGen/CommandFlags.h
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/CommandFlags.h?rev=186217&r1=186216&r2=186217&view=diff
>> ==============================================================================
>> --- llvm/trunk/include/llvm/CodeGen/CommandFlags.h (original)
>> +++ llvm/trunk/include/llvm/CodeGen/CommandFlags.h Fri Jul 12 17:25:20 2013
>> @@ -220,8 +220,4 @@ cl::opt<std::string> StartAfter("start-a
>>                           cl::value_desc("pass-name"),
>>                           cl::init(""));
>> 
>> -cl::opt<unsigned>
>> -SSPBufferSize("stack-protector-buffer-size", cl::init(8),
>> -              cl::desc("Lower bound for a buffer to be considered for "
>> -                       "stack protection"));
>> #endif
>> 
>> Modified: llvm/trunk/include/llvm/Target/TargetOptions.h
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetOptions.h?rev=186217&r1=186216&r2=186217&view=diff
>> ==============================================================================
>> --- llvm/trunk/include/llvm/Target/TargetOptions.h (original)
>> +++ llvm/trunk/include/llvm/Target/TargetOptions.h Fri Jul 12 17:25:20 2013
>> @@ -48,7 +48,7 @@ namespace llvm {
>>           UseSoftFloat(false), NoZerosInBSS(false),
>>           JITEmitDebugInfo(false), JITEmitDebugInfoToDisk(false),
>>           GuaranteedTailCallOpt(false), DisableTailCalls(false),
>> -          StackAlignmentOverride(0), RealignStack(true), SSPBufferSize(0),
>> +          StackAlignmentOverride(0), RealignStack(true),
>>           EnableFastISel(false), PositionIndependentExecutable(false),
>>           EnableSegmentedStacks(false), UseInitArray(false), TrapFuncName(""),
>>           FloatABIType(FloatABI::Default), AllowFPOpFusion(FPOpFusion::Standard)
>> @@ -151,10 +151,6 @@ namespace llvm {
>>     /// automatically realigned, if needed.
>>     unsigned RealignStack : 1;
>> 
>> -    /// SSPBufferSize - The minimum size of buffers that will receive stack
>> -    /// smashing protection when -fstack-protection is used.
>> -    unsigned SSPBufferSize;
>> -
>>     /// EnableFastISel - This flag enables fast-path instruction selection
>>     /// which trades away generated code quality in favor of reducing
>>     /// compile time.
>> @@ -224,7 +220,6 @@ inline bool operator==(const TargetOptio
>>     ARE_EQUAL(DisableTailCalls) &&
>>     ARE_EQUAL(StackAlignmentOverride) &&
>>     ARE_EQUAL(RealignStack) &&
>> -    ARE_EQUAL(SSPBufferSize) &&
>>     ARE_EQUAL(EnableFastISel) &&
>>     ARE_EQUAL(PositionIndependentExecutable) &&
>>     ARE_EQUAL(EnableSegmentedStacks) &&
>> 
>> Modified: llvm/trunk/lib/CodeGen/StackProtector.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/StackProtector.cpp?rev=186217&r1=186216&r2=186217&view=diff
>> ==============================================================================
>> --- llvm/trunk/lib/CodeGen/StackProtector.cpp (original)
>> +++ llvm/trunk/lib/CodeGen/StackProtector.cpp Fri Jul 12 17:25:20 2013
>> @@ -33,6 +33,7 @@
>> #include "llvm/Pass.h"
>> #include "llvm/Support/CommandLine.h"
>> #include "llvm/Target/TargetLowering.h"
>> +#include <cstdlib>
>> using namespace llvm;
>> 
>> STATISTIC(NumFunProtected, "Number of functions protected");
>> @@ -53,6 +54,10 @@ namespace {
>> 
>>     DominatorTree *DT;
>> 
>> +    /// \brief The minimum size of buffers that will receive stack smashing
>> +    /// protection when -fstack-protection is used.
>> +    unsigned SSPBufferSize;
>> +
>>     /// VisitedPHIs - The set of PHI nodes visited when determining
>>     /// if a variable's reference has been taken.  This set 
>>     /// is maintained to ensure we don't visit the same PHI node multiple
>> @@ -85,11 +90,12 @@ namespace {
>>     bool RequiresStackProtector();
>>   public:
>>     static char ID;             // Pass identification, replacement for typeid.
>> -    StackProtector() : FunctionPass(ID), TM(0), TLI(0) {
>> +    StackProtector() : FunctionPass(ID), TM(0), TLI(0), SSPBufferSize(0) {
>>       initializeStackProtectorPass(*PassRegistry::getPassRegistry());
>>     }
>>     StackProtector(const TargetMachine *TM)
>> -      : FunctionPass(ID), TM(TM), TLI(0), Trip(TM->getTargetTriple()) {
>> +      : FunctionPass(ID), TM(TM), TLI(0), Trip(TM->getTargetTriple()),
>> +        SSPBufferSize(8) {
>>       initializeStackProtectorPass(*PassRegistry::getPassRegistry());
>>     }
>> 
>> @@ -117,6 +123,12 @@ bool StackProtector::runOnFunction(Funct
>> 
>>   if (!RequiresStackProtector()) return false;
>> 
>> +  Attribute Attr =
>> +    Fn.getAttributes().getAttribute(AttributeSet::FunctionIndex,
>> +                                    "ssp-buffer-size");
>> +  if (Attr.isStringAttribute())
>> +    SSPBufferSize = atoi(Attr.getValueAsString().data());
>> +
>>   ++NumFunProtected;
>>   return InsertStackProtectors();
>> }
>> @@ -132,7 +144,6 @@ bool StackProtector::ContainsProtectable
>>     // protector
>>     if (Strong)
>>       return true;
>> -    const TargetMachine &TM = TLI->getTargetMachine();
>>     if (!AT->getElementType()->isIntegerTy(8)) {
>>       // If we're on a non-Darwin platform or we're inside of a structure, don't
>>       // add stack protectors unless the array is a character array.
>> @@ -142,7 +153,7 @@ bool StackProtector::ContainsProtectable
>> 
>>     // If an array has more than SSPBufferSize bytes of allocated space, then we
>>     // emit stack protectors.
>> -    if (TM.Options.SSPBufferSize <= TLI->getDataLayout()->getTypeAllocSize(AT))
>> +    if (SSPBufferSize <= TLI->getDataLayout()->getTypeAllocSize(AT))
>>       return true;
>>   }
>> 
>> @@ -230,13 +241,14 @@ bool StackProtector::RequiresStackProtec
>> 
>>           if (const ConstantInt *CI =
>>                dyn_cast<ConstantInt>(AI->getArraySize())) {
>> -            unsigned BufferSize = TLI->getTargetMachine().Options.SSPBufferSize;
>> -            if (CI->getLimitedValue(BufferSize) >= BufferSize)
>> +            if (CI->getLimitedValue(SSPBufferSize) >= SSPBufferSize)
>>               // A call to alloca with size >= SSPBufferSize requires
>>               // stack protectors.
>>               return true;
>> -          } else // A call to alloca with a variable size requires protectors.
>> +          } else {
>> +            // A call to alloca with a variable size requires protectors.
>>             return true;
>> +          }
>>         }
>> 
>>         if (ContainsProtectableArray(AI->getAllocatedType(), Strong))
>> 
>> Modified: llvm/trunk/tools/llc/llc.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llc/llc.cpp?rev=186217&r1=186216&r2=186217&view=diff
>> ==============================================================================
>> --- llvm/trunk/tools/llc/llc.cpp (original)
>> +++ llvm/trunk/tools/llc/llc.cpp Fri Jul 12 17:25:20 2013
>> @@ -280,7 +280,6 @@ static int compileModule(char **argv, LL
>>   Options.PositionIndependentExecutable = EnablePIE;
>>   Options.EnableSegmentedStacks = SegmentedStacks;
>>   Options.UseInitArray = UseInitArray;
>> -  Options.SSPBufferSize = SSPBufferSize;
>> 
>>   OwningPtr<TargetMachine>
>>     target(TheTarget->createTargetMachine(TheTriple.getTriple(),
>> 
>> Modified: llvm/trunk/tools/lto/LTOModule.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOModule.cpp?rev=186217&r1=186216&r2=186217&view=diff
>> ==============================================================================
>> --- llvm/trunk/tools/lto/LTOModule.cpp (original)
>> +++ llvm/trunk/tools/lto/LTOModule.cpp Fri Jul 12 17:25:20 2013
>> @@ -151,11 +151,6 @@ UseInitArray("use-init-array",
>>   cl::desc("Use .init_array instead of .ctors."),
>>   cl::init(false));
>> 
>> -static cl::opt<unsigned>
>> -SSPBufferSize("stack-protector-buffer-size", cl::init(8),
>> -              cl::desc("Lower bound for a buffer to be considered for "
>> -                       "stack protection"));
>> -
>> LTOModule::LTOModule(llvm::Module *m, llvm::TargetMachine *t)
>>   : _module(m), _target(t),
>>     _context(_target->getMCAsmInfo(), _target->getRegisterInfo(), NULL),
>> @@ -261,7 +256,6 @@ void LTOModule::getTargetOptions(TargetO
>>   Options.PositionIndependentExecutable = EnablePIE;
>>   Options.EnableSegmentedStacks = SegmentedStacks;
>>   Options.UseInitArray = UseInitArray;
>> -  Options.SSPBufferSize = SSPBufferSize;
>> }
>> 
>> LTOModule *LTOModule::makeLTOModule(MemoryBuffer *buffer,
>> 
>> Modified: llvm/trunk/tools/opt/opt.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/opt/opt.cpp?rev=186217&r1=186216&r2=186217&view=diff
>> ==============================================================================
>> --- llvm/trunk/tools/opt/opt.cpp (original)
>> +++ llvm/trunk/tools/opt/opt.cpp Fri Jul 12 17:25:20 2013
>> @@ -510,7 +510,6 @@ static TargetOptions GetTargetOptions()
>>   Options.PositionIndependentExecutable = EnablePIE;
>>   Options.EnableSegmentedStacks = SegmentedStacks;
>>   Options.UseInitArray = UseInitArray;
>> -  Options.SSPBufferSize = SSPBufferSize;
>>   return Options;
>> }
>> 
>> 
>> 
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
> 
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
> 
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits





More information about the llvm-commits mailing list