summaryrefslogtreecommitdiff
path: root/lib/Target/AArch64/AArch64PromoteConstant.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Target/AArch64/AArch64PromoteConstant.cpp')
-rw-r--r--lib/Target/AArch64/AArch64PromoteConstant.cpp23
1 files changed, 16 insertions, 7 deletions
diff --git a/lib/Target/AArch64/AArch64PromoteConstant.cpp b/lib/Target/AArch64/AArch64PromoteConstant.cpp
index 8693f76d7c324..a8dc6e74ef6ab 100644
--- a/lib/Target/AArch64/AArch64PromoteConstant.cpp
+++ b/lib/Target/AArch64/AArch64PromoteConstant.cpp
@@ -1,4 +1,4 @@
-//=- AArch64PromoteConstant.cpp --- Promote constant to global for AArch64 -==//
+//==- AArch64PromoteConstant.cpp - Promote constant to global for AArch64 --==//
//
// The LLVM Compiler Infrastructure
//
@@ -22,23 +22,31 @@
#include "AArch64.h"
#include "llvm/ADT/DenseMap.h"
-#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
+#include "llvm/IR/BasicBlock.h"
+#include "llvm/IR/Constant.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/Dominators.h"
#include "llvm/IR/Function.h"
+#include "llvm/IR/GlobalValue.h"
#include "llvm/IR/GlobalVariable.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/InlineAsm.h"
#include "llvm/IR/InstIterator.h"
+#include "llvm/IR/Instruction.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Module.h"
+#include "llvm/IR/Type.h"
#include "llvm/Pass.h"
+#include "llvm/Support/Casting.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
+#include <algorithm>
+#include <cassert>
+#include <utility>
using namespace llvm;
@@ -56,6 +64,7 @@ STATISTIC(NumPromotedUses, "Number of promoted constants uses");
//===----------------------------------------------------------------------===//
namespace {
+
/// Promotes interesting constant into global variables.
/// The motivating example is:
/// static const uint16_t TableA[32] = {
@@ -83,13 +92,12 @@ namespace {
/// Therefore the final assembly final has 4 different loads. With this pass
/// enabled, only one load is issued for the constants.
class AArch64PromoteConstant : public ModulePass {
-
public:
struct PromotedConstant {
bool ShouldConvert = false;
GlobalVariable *GV = nullptr;
};
- typedef SmallDenseMap<Constant *, PromotedConstant, 16> PromotionCacheTy;
+ using PromotionCacheTy = SmallDenseMap<Constant *, PromotedConstant, 16>;
struct UpdateRecord {
Constant *C;
@@ -101,6 +109,7 @@ public:
};
static char ID;
+
AArch64PromoteConstant() : ModulePass(ID) {
initializeAArch64PromoteConstantPass(*PassRegistry::getPassRegistry());
}
@@ -135,9 +144,9 @@ private:
}
/// Type to store a list of Uses.
- typedef SmallVector<std::pair<Instruction *, unsigned>, 4> Uses;
+ using Uses = SmallVector<std::pair<Instruction *, unsigned>, 4>;
/// Map an insertion point to all the uses it dominates.
- typedef DenseMap<Instruction *, Uses> InsertionPoints;
+ using InsertionPoints = DenseMap<Instruction *, Uses>;
/// Find the closest point that dominates the given Use.
Instruction *findInsertionPoint(Instruction &User, unsigned OpNo);
@@ -212,6 +221,7 @@ private:
InsertPts.erase(OldInstr);
}
};
+
} // end anonymous namespace
char AArch64PromoteConstant::ID = 0;
@@ -357,7 +367,6 @@ Instruction *AArch64PromoteConstant::findInsertionPoint(Instruction &User,
bool AArch64PromoteConstant::isDominated(Instruction *NewPt, Instruction *User,
unsigned OpNo,
InsertionPoints &InsertPts) {
-
DominatorTree &DT = getAnalysis<DominatorTreeWrapperPass>(
*NewPt->getParent()->getParent()).getDomTree();