summaryrefslogtreecommitdiff
path: root/include/llvm/Transforms/IPO/DeadArgumentElimination.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/llvm/Transforms/IPO/DeadArgumentElimination.h')
-rw-r--r--include/llvm/Transforms/IPO/DeadArgumentElimination.h39
1 files changed, 25 insertions, 14 deletions
diff --git a/include/llvm/Transforms/IPO/DeadArgumentElimination.h b/include/llvm/Transforms/IPO/DeadArgumentElimination.h
index e179afa956f6e..ba5666f20a9bf 100644
--- a/include/llvm/Transforms/IPO/DeadArgumentElimination.h
+++ b/include/llvm/Transforms/IPO/DeadArgumentElimination.h
@@ -20,15 +20,21 @@
#ifndef LLVM_TRANSFORMS_IPO_DEADARGUMENTELIMINATION_H
#define LLVM_TRANSFORMS_IPO_DEADARGUMENTELIMINATION_H
-#include "llvm/IR/Module.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/Twine.h"
+#include "llvm/IR/Function.h"
#include "llvm/IR/PassManager.h"
-
#include <map>
#include <set>
#include <string>
+#include <tuple>
namespace llvm {
+class Module;
+class Use;
+class Value;
+
/// Eliminate dead arguments (and return values) from functions.
class DeadArgumentEliminationPass
: public PassInfoMixin<DeadArgumentEliminationPass> {
@@ -37,12 +43,13 @@ public:
/// argument. Used so that arguments and return values can be used
/// interchangeably.
struct RetOrArg {
- RetOrArg(const Function *F, unsigned Idx, bool IsArg)
- : F(F), Idx(Idx), IsArg(IsArg) {}
const Function *F;
unsigned Idx;
bool IsArg;
+ RetOrArg(const Function *F, unsigned Idx, bool IsArg)
+ : F(F), Idx(Idx), IsArg(IsArg) {}
+
/// Make RetOrArg comparable, so we can put it into a map.
bool operator<(const RetOrArg &O) const {
return std::tie(F, Idx, IsArg) < std::tie(O.F, O.Idx, O.IsArg);
@@ -67,16 +74,23 @@ public:
/// thus become dead in the end.
enum Liveness { Live, MaybeLive };
+ DeadArgumentEliminationPass(bool ShouldHackArguments_ = false)
+ : ShouldHackArguments(ShouldHackArguments_) {}
+
+ PreservedAnalyses run(Module &M, ModuleAnalysisManager &);
+
/// Convenience wrapper
RetOrArg CreateRet(const Function *F, unsigned Idx) {
return RetOrArg(F, Idx, false);
}
+
/// Convenience wrapper
RetOrArg CreateArg(const Function *F, unsigned Idx) {
return RetOrArg(F, Idx, true);
}
- typedef std::multimap<RetOrArg, RetOrArg> UseMap;
+ using UseMap = std::multimap<RetOrArg, RetOrArg>;
+
/// This maps a return value or argument to any MaybeLive return values or
/// arguments it uses. This allows the MaybeLive values to be marked live
/// when any of its users is marked live.
@@ -93,25 +107,21 @@ public:
/// directly to F.
UseMap Uses;
- typedef std::set<RetOrArg> LiveSet;
- typedef std::set<const Function *> LiveFuncSet;
+ using LiveSet = std::set<RetOrArg>;
+ using LiveFuncSet = std::set<const Function *>;
/// This set contains all values that have been determined to be live.
LiveSet LiveValues;
+
/// This set contains all values that are cannot be changed in any way.
LiveFuncSet LiveFunctions;
- typedef SmallVector<RetOrArg, 5> UseVector;
+ using UseVector = SmallVector<RetOrArg, 5>;
/// This allows this pass to do double-duty as the dead arg hacking pass
/// (used only by bugpoint).
bool ShouldHackArguments = false;
-public:
- DeadArgumentEliminationPass(bool ShouldHackArguments_ = false)
- : ShouldHackArguments(ShouldHackArguments_) {}
- PreservedAnalyses run(Module &M, ModuleAnalysisManager &);
-
private:
Liveness MarkIfNotLive(RetOrArg Use, UseVector &MaybeLiveUses);
Liveness SurveyUse(const Use *U, UseVector &MaybeLiveUses,
@@ -128,6 +138,7 @@ private:
bool DeleteDeadVarargs(Function &Fn);
bool RemoveDeadArgumentsFromCallers(Function &Fn);
};
-}
+
+} // end namespace llvm
#endif // LLVM_TRANSFORMS_IPO_DEADARGUMENTELIMINATION_H