diff options
author | shadchin <shadchin@yandex-team.ru> | 2022-02-10 16:44:30 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:44:30 +0300 |
commit | 2598ef1d0aee359b4b6d5fdd1758916d5907d04f (patch) | |
tree | 012bb94d777798f1f56ac1cec429509766d05181 /contrib/libs/llvm12/lib/Transforms/IPO/ForceFunctionAttrs.cpp | |
parent | 6751af0b0c1b952fede40b19b71da8025b5d8bcf (diff) | |
download | ydb-2598ef1d0aee359b4b6d5fdd1758916d5907d04f.tar.gz |
Restoring authorship annotation for <shadchin@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/libs/llvm12/lib/Transforms/IPO/ForceFunctionAttrs.cpp')
-rw-r--r-- | contrib/libs/llvm12/lib/Transforms/IPO/ForceFunctionAttrs.cpp | 72 |
1 files changed, 36 insertions, 36 deletions
diff --git a/contrib/libs/llvm12/lib/Transforms/IPO/ForceFunctionAttrs.cpp b/contrib/libs/llvm12/lib/Transforms/IPO/ForceFunctionAttrs.cpp index 1a8bb225a6..39f643632e 100644 --- a/contrib/libs/llvm12/lib/Transforms/IPO/ForceFunctionAttrs.cpp +++ b/contrib/libs/llvm12/lib/Transforms/IPO/ForceFunctionAttrs.cpp @@ -26,13 +26,13 @@ static cl::list<std::string> "example -force-attribute=foo:noinline. This " "option can be specified multiple times.")); -static cl::list<std::string> ForceRemoveAttributes( - "force-remove-attribute", cl::Hidden, - cl::desc("Remove an attribute from a function. This should be a " - "pair of 'function-name:attribute-name', for " - "example -force-remove-attribute=foo:noinline. This " - "option can be specified multiple times.")); - +static cl::list<std::string> ForceRemoveAttributes( + "force-remove-attribute", cl::Hidden, + cl::desc("Remove an attribute from a function. This should be a " + "pair of 'function-name:attribute-name', for " + "example -force-remove-attribute=foo:noinline. This " + "option can be specified multiple times.")); + static Attribute::AttrKind parseAttrKind(StringRef Kind) { return StringSwitch<Attribute::AttrKind>(Kind) .Case("alwaysinline", Attribute::AlwaysInline) @@ -77,49 +77,49 @@ static Attribute::AttrKind parseAttrKind(StringRef Kind) { } /// If F has any forced attributes given on the command line, add them. -/// If F has any forced remove attributes given on the command line, remove -/// them. When both force and force-remove are given to a function, the latter -/// takes precedence. -static void forceAttributes(Function &F) { - auto ParseFunctionAndAttr = [&](StringRef S) { - auto Kind = Attribute::None; +/// If F has any forced remove attributes given on the command line, remove +/// them. When both force and force-remove are given to a function, the latter +/// takes precedence. +static void forceAttributes(Function &F) { + auto ParseFunctionAndAttr = [&](StringRef S) { + auto Kind = Attribute::None; auto KV = StringRef(S).split(':'); if (KV.first != F.getName()) - return Kind; - Kind = parseAttrKind(KV.second); + return Kind; + Kind = parseAttrKind(KV.second); if (Kind == Attribute::None) { LLVM_DEBUG(dbgs() << "ForcedAttribute: " << KV.second << " unknown or not handled!\n"); } - return Kind; - }; - - for (auto &S : ForceAttributes) { - auto Kind = ParseFunctionAndAttr(S); - if (Kind == Attribute::None || F.hasFnAttribute(Kind)) + return Kind; + }; + + for (auto &S : ForceAttributes) { + auto Kind = ParseFunctionAndAttr(S); + if (Kind == Attribute::None || F.hasFnAttribute(Kind)) continue; F.addFnAttr(Kind); } - - for (auto &S : ForceRemoveAttributes) { - auto Kind = ParseFunctionAndAttr(S); - if (Kind == Attribute::None || !F.hasFnAttribute(Kind)) - continue; - F.removeFnAttr(Kind); - } -} - -static bool hasForceAttributes() { - return !ForceAttributes.empty() || !ForceRemoveAttributes.empty(); + + for (auto &S : ForceRemoveAttributes) { + auto Kind = ParseFunctionAndAttr(S); + if (Kind == Attribute::None || !F.hasFnAttribute(Kind)) + continue; + F.removeFnAttr(Kind); + } } +static bool hasForceAttributes() { + return !ForceAttributes.empty() || !ForceRemoveAttributes.empty(); +} + PreservedAnalyses ForceFunctionAttrsPass::run(Module &M, ModuleAnalysisManager &) { - if (!hasForceAttributes()) + if (!hasForceAttributes()) return PreservedAnalyses::all(); for (Function &F : M.functions()) - forceAttributes(F); + forceAttributes(F); // Just conservatively invalidate analyses, this isn't likely to be important. return PreservedAnalyses::none(); @@ -134,11 +134,11 @@ struct ForceFunctionAttrsLegacyPass : public ModulePass { } bool runOnModule(Module &M) override { - if (!hasForceAttributes()) + if (!hasForceAttributes()) return false; for (Function &F : M.functions()) - forceAttributes(F); + forceAttributes(F); // Conservatively assume we changed something. return true; |