28
28
#include " llvm/IR/Instruction.h"
29
29
#include " llvm/IR/Instructions.h"
30
30
#include " llvm/IR/IntrinsicInst.h"
31
- #include " llvm/InitializePasses.h"
32
31
#include " llvm/Support/Debug.h"
33
32
#include " llvm/Support/raw_ostream.h"
34
33
#include " llvm/Transforms/Scalar.h"
35
34
36
- #define AA_NAME " alignment-from-assumptions"
37
- #define DEBUG_TYPE AA_NAME
35
+ #define DEBUG_TYPE " alignment-from-assumptions"
38
36
using namespace llvm ;
39
37
40
38
STATISTIC (NumLoadAlignChanged,
@@ -44,46 +42,6 @@ STATISTIC(NumStoreAlignChanged,
44
42
STATISTIC (NumMemIntAlignChanged,
45
43
" Number of memory intrinsics changed by alignment assumptions" );
46
44
47
- namespace {
48
- struct AlignmentFromAssumptions : public FunctionPass {
49
- static char ID; // Pass identification, replacement for typeid
50
- AlignmentFromAssumptions () : FunctionPass(ID) {
51
- initializeAlignmentFromAssumptionsPass (*PassRegistry::getPassRegistry ());
52
- }
53
-
54
- bool runOnFunction (Function &F) override ;
55
-
56
- void getAnalysisUsage (AnalysisUsage &AU) const override {
57
- AU.addRequired <AssumptionCacheTracker>();
58
- AU.addRequired <ScalarEvolutionWrapperPass>();
59
- AU.addRequired <DominatorTreeWrapperPass>();
60
-
61
- AU.setPreservesCFG ();
62
- AU.addPreserved <AAResultsWrapperPass>();
63
- AU.addPreserved <GlobalsAAWrapperPass>();
64
- AU.addPreserved <LoopInfoWrapperPass>();
65
- AU.addPreserved <DominatorTreeWrapperPass>();
66
- AU.addPreserved <ScalarEvolutionWrapperPass>();
67
- }
68
-
69
- AlignmentFromAssumptionsPass Impl;
70
- };
71
- }
72
-
73
- char AlignmentFromAssumptions::ID = 0 ;
74
- static const char aip_name[] = " Alignment from assumptions" ;
75
- INITIALIZE_PASS_BEGIN (AlignmentFromAssumptions, AA_NAME,
76
- aip_name, false , false )
77
- INITIALIZE_PASS_DEPENDENCY(AssumptionCacheTracker)
78
- INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
79
- INITIALIZE_PASS_DEPENDENCY(ScalarEvolutionWrapperPass)
80
- INITIALIZE_PASS_END(AlignmentFromAssumptions, AA_NAME,
81
- aip_name, false , false )
82
-
83
- FunctionPass *llvm::createAlignmentFromAssumptionsPass() {
84
- return new AlignmentFromAssumptions ();
85
- }
86
-
87
45
// Given an expression for the (constant) alignment, AlignSCEV, and an
88
46
// expression for the displacement between a pointer and the aligned address,
89
47
// DiffSCEV, compute the alignment of the displaced pointer if it can be reduced
@@ -317,17 +275,6 @@ bool AlignmentFromAssumptionsPass::processAssumption(CallInst *ACall,
317
275
return true ;
318
276
}
319
277
320
- bool AlignmentFromAssumptions::runOnFunction (Function &F) {
321
- if (skipFunction (F))
322
- return false ;
323
-
324
- auto &AC = getAnalysis<AssumptionCacheTracker>().getAssumptionCache (F);
325
- ScalarEvolution *SE = &getAnalysis<ScalarEvolutionWrapperPass>().getSE ();
326
- DominatorTree *DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree ();
327
-
328
- return Impl.runImpl (F, AC, SE, DT);
329
- }
330
-
331
278
bool AlignmentFromAssumptionsPass::runImpl (Function &F, AssumptionCache &AC,
332
279
ScalarEvolution *SE_,
333
280
DominatorTree *DT_) {
0 commit comments