diff options
author | Adam Nemet <anemet@apple.com> | 2017-03-09 06:10:27 +0000 |
---|---|---|
committer | Adam Nemet <anemet@apple.com> | 2017-03-09 06:10:27 +0000 |
commit | 5361b82d5462a0368a6dfc6a1fa4e8ebbae34710 (patch) | |
tree | dbd2cbf8b4fa3504283afe35cf21f60ea118f9e8 /llvm/lib/CodeGen/StackProtector.cpp | |
parent | 8c83386f89a89ac23f98e585967400c0dbe2b940 (diff) | |
download | bcm5719-llvm-5361b82d5462a0368a6dfc6a1fa4e8ebbae34710.tar.gz bcm5719-llvm-5361b82d5462a0368a6dfc6a1fa4e8ebbae34710.zip |
[SSP] In opt remarks, stream Function directly
With this, it shows up as an attribute in YAML and non-printable characters
are properly removed by GlobalValue::getRealLinkageName.
llvm-svn: 297362
Diffstat (limited to 'llvm/lib/CodeGen/StackProtector.cpp')
-rw-r--r-- | llvm/lib/CodeGen/StackProtector.cpp | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/llvm/lib/CodeGen/StackProtector.cpp b/llvm/lib/CodeGen/StackProtector.cpp index 1753eda56d8..e3fdb96f620 100644 --- a/llvm/lib/CodeGen/StackProtector.cpp +++ b/llvm/lib/CodeGen/StackProtector.cpp @@ -234,13 +234,12 @@ bool StackProtector::RequiresStackProtector() { // using the analysis pass to avoid building DominatorTree and LoopInfo which // are not available this late in the IR pipeline. OptimizationRemarkEmitter ORE(F); - auto ReasonStub = - Twine("Stack protection applied to function " + F->getName() + " due to ") - .str(); if (F->hasFnAttribute(Attribute::StackProtectReq)) { ORE.emit(OptimizationRemark(DEBUG_TYPE, "StackProtectorRequested", F) - << ReasonStub << "a function attribute or command-line switch"); + << "Stack protection applied to function " + << ore::NV("Function", F) + << " due to a function attribute or command-line switch"); NeedsProtector = true; Strong = true; // Use the same heuristic as strong to determine SSPLayout } else if (F->hasFnAttribute(Attribute::StackProtectStrong)) @@ -256,8 +255,10 @@ bool StackProtector::RequiresStackProtector() { if (AI->isArrayAllocation()) { OptimizationRemark Remark(DEBUG_TYPE, "StackProtectorAllocaOrArray", &I); - Remark << ReasonStub - << "a call to alloca or use of a variable length array"; + Remark + << "Stack protection applied to function " + << ore::NV("Function", F) + << " due to a call to alloca or use of a variable length array"; if (const auto *CI = dyn_cast<ConstantInt>(AI->getArraySize())) { if (CI->getLimitedValue(SSPBufferSize) >= SSPBufferSize) { // A call to alloca with size >= SSPBufferSize requires @@ -285,8 +286,10 @@ bool StackProtector::RequiresStackProtector() { Layout.insert(std::make_pair(AI, IsLarge ? SSPLK_LargeArray : SSPLK_SmallArray)); ORE.emit(OptimizationRemark(DEBUG_TYPE, "StackProtectorBuffer", &I) - << ReasonStub - << "a stack allocated buffer or struct containing a buffer"); + << "Stack protection applied to function " + << ore::NV("Function", F) + << " due to a stack allocated buffer or struct containing a " + "buffer"); NeedsProtector = true; continue; } @@ -296,7 +299,9 @@ bool StackProtector::RequiresStackProtector() { Layout.insert(std::make_pair(AI, SSPLK_AddrOf)); ORE.emit( OptimizationRemark(DEBUG_TYPE, "StackProtectorAddressTaken", &I) - << ReasonStub << "the address of a local variable being taken"); + << "Stack protection applied to function " + << ore::NV("Function", F) + << " due to the address of a local variable being taken"); NeedsProtector = true; } } |