summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2015-12-27 08:13:45 +0000
committerChandler Carruth <chandlerc@gmail.com>2015-12-27 08:13:45 +0000
commitf49f1a87ef49150c33d0810b3e8b0d56e56f3d1f (patch)
tree188e517b88a15913e5dcfb59034e582281b34d5f /llvm/lib/Transforms/IPO/FunctionAttrs.cpp
parent48a065d2eaba92c5c1221dc32810522b7aad6745 (diff)
downloadbcm5719-llvm-f49f1a87ef49150c33d0810b3e8b0d56e56f3d1f.tar.gz
bcm5719-llvm-f49f1a87ef49150c33d0810b3e8b0d56e56f3d1f.zip
[attrs] Split off the forced attributes utility into its own pass that
is (by default) run much earlier than FuncitonAttrs proper. This allows forcing optnone or other widely impactful attributes. It is also a bit simpler as the force attribute behavior needs no specific iteration order. I've added the pass into the default module pass pipeline and LTO pass pipeline which mirrors where function attrs itself was being run. Differential Revision: http://reviews.llvm.org/D15668 llvm-svn: 256465
Diffstat (limited to 'llvm/lib/Transforms/IPO/FunctionAttrs.cpp')
-rw-r--r--llvm/lib/Transforms/IPO/FunctionAttrs.cpp66
1 files changed, 0 insertions, 66 deletions
diff --git a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
index e699c5e0df5..b268eff2592 100644
--- a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
+++ b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
@@ -53,13 +53,6 @@ STATISTIC(NumNonNullReturn, "Number of function returns marked nonnull");
STATISTIC(NumAnnotated, "Number of attributes added to library functions");
STATISTIC(NumNoRecurse, "Number of functions marked as norecurse");
-static cl::list<std::string>
-ForceAttributes("force-attribute", cl::Hidden,
- cl::desc("Add an attribute to a function. This should be a "
- "pair of 'function-name:attribute-name', for "
- "example -force-add-attribute=foo:noinline. This "
- "option can be specified multiple times."));
-
namespace {
typedef SmallSetVector<Function *, 8> SCCNodeSet;
}
@@ -1851,64 +1844,6 @@ static bool addNoRecurseAttrsTopDownOnly(Function *F) {
return false;
}
-static Attribute::AttrKind parseAttrKind(StringRef Kind) {
- return StringSwitch<Attribute::AttrKind>(Kind)
- .Case("alwaysinline", Attribute::AlwaysInline)
- .Case("builtin", Attribute::Builtin)
- .Case("cold", Attribute::Cold)
- .Case("convergent", Attribute::Convergent)
- .Case("inlinehint", Attribute::InlineHint)
- .Case("jumptable", Attribute::JumpTable)
- .Case("minsize", Attribute::MinSize)
- .Case("naked", Attribute::Naked)
- .Case("nobuiltin", Attribute::NoBuiltin)
- .Case("noduplicate", Attribute::NoDuplicate)
- .Case("noimplicitfloat", Attribute::NoImplicitFloat)
- .Case("noinline", Attribute::NoInline)
- .Case("nonlazybind", Attribute::NonLazyBind)
- .Case("noredzone", Attribute::NoRedZone)
- .Case("noreturn", Attribute::NoReturn)
- .Case("norecurse", Attribute::NoRecurse)
- .Case("nounwind", Attribute::NoUnwind)
- .Case("optnone", Attribute::OptimizeNone)
- .Case("optsize", Attribute::OptimizeForSize)
- .Case("readnone", Attribute::ReadNone)
- .Case("readonly", Attribute::ReadOnly)
- .Case("argmemonly", Attribute::ArgMemOnly)
- .Case("returns_twice", Attribute::ReturnsTwice)
- .Case("safestack", Attribute::SafeStack)
- .Case("sanitize_address", Attribute::SanitizeAddress)
- .Case("sanitize_memory", Attribute::SanitizeMemory)
- .Case("sanitize_thread", Attribute::SanitizeThread)
- .Case("ssp", Attribute::StackProtect)
- .Case("sspreq", Attribute::StackProtectReq)
- .Case("sspstrong", Attribute::StackProtectStrong)
- .Case("uwtable", Attribute::UWTable)
- .Default(Attribute::None);
-}
-
-/// If F has any forced attributes given on the command line, add them.
-static bool addForcedAttributes(Function *F) {
- bool Changed = false;
- for (auto &S : ForceAttributes) {
- auto KV = StringRef(S).split(':');
- if (KV.first != F->getName())
- continue;
-
- auto Kind = parseAttrKind(KV.second);
- if (Kind == Attribute::None) {
- DEBUG(dbgs() << "ForcedAttribute: " << KV.second
- << " unknown or not handled!\n");
- continue;
- }
- if (F->hasFnAttribute(Kind))
- continue;
- Changed = true;
- F->addFnAttr(Kind);
- }
- return Changed;
-}
-
bool FunctionAttrs::runOnSCC(CallGraphSCC &SCC) {
TLI = &getAnalysis<TargetLibraryInfoWrapperPass>().getTLI();
bool Changed = false;
@@ -1944,7 +1879,6 @@ bool FunctionAttrs::runOnSCC(CallGraphSCC &SCC) {
if (F->isDeclaration())
Changed |= inferPrototypeAttributes(*F, *TLI);
- Changed |= addForcedAttributes(F);
SCCNodes.insert(F);
}
OpenPOWER on IntegriCloud