llvm.org GIT mirror llvm / 57edc9d
Make DataLayout a plain object, not a pass. Instead, have a DataLayoutPass that holds one. This will allow parts of LLVM don't don't handle passes to also use DataLayout. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202168 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 5 years ago
60 changed file(s) with 195 addition(s) and 144 deletion(s). Raw diff Collapse all Expand all
19751975 // Set up the optimizer pipeline.
19761976 // Start with registering info about how the
19771977 // target lays out data structures.
1978 fpm.add(new llvm::DataLayout(*executionEngine->getDataLayout()));
1978 fpm.add(new llvm::DataLayoutPass(*executionEngine->getDataLayout()));
19791979
19801980 // Optimizations turned on
19811981 #ifdef ADD_OPT_PASSES
585585
586586 // Set up the optimizer pipeline. Start with registering info about how the
587587 // target lays out data structures.
588 OurFPM.add(new DataLayout(*TheExecutionEngine->getDataLayout()));
588 OurFPM.add(new DataLayoutPass(*TheExecutionEngine->getDataLayout()));
589589 // Provide basic AliasAnalysis support for GVN.
590590 OurFPM.add(createBasicAliasAnalysisPass());
591591 // Do simple "peephole" optimizations and bit-twiddling optzns.
830830
831831 // Set up the optimizer pipeline. Start with registering info about how the
832832 // target lays out data structures.
833 OurFPM.add(new DataLayout(*TheExecutionEngine->getDataLayout()));
833 OurFPM.add(new DataLayoutPass(*TheExecutionEngine->getDataLayout()));
834834 // Provide basic AliasAnalysis support for GVN.
835835 OurFPM.add(createBasicAliasAnalysisPass());
836836 // Do simple "peephole" optimizations and bit-twiddling optzns.
948948
949949 // Set up the optimizer pipeline. Start with registering info about how the
950950 // target lays out data structures.
951 OurFPM.add(new DataLayout(*TheExecutionEngine->getDataLayout()));
951 OurFPM.add(new DataLayoutPass(*TheExecutionEngine->getDataLayout()));
952952 // Provide basic AliasAnalysis support for GVN.
953953 OurFPM.add(createBasicAliasAnalysisPass());
954954 // Do simple "peephole" optimizations and bit-twiddling optzns.
11121112
11131113 // Set up the optimizer pipeline. Start with registering info about how the
11141114 // target lays out data structures.
1115 OurFPM.add(new DataLayout(*TheExecutionEngine->getDataLayout()));
1115 OurFPM.add(new DataLayoutPass(*TheExecutionEngine->getDataLayout()));
11161116 // Provide basic AliasAnalysis support for GVN.
11171117 OurFPM.add(createBasicAliasAnalysisPass());
11181118 // Promote allocas to registers.
8787 bool operator==(const PointerAlignElem &rhs) const;
8888 };
8989
90
91 /// DataLayout - This class holds a parsed version of the target data layout
92 /// string in a module and provides methods for querying it. The target data
93 /// layout string is specified *by the target* - a frontend generating LLVM IR
94 /// is required to generate the right target data for the target being codegen'd
95 /// to. If some measure of portability is desired, an empty string may be
96 /// specified in the module.
97 class DataLayout : public ImmutablePass {
90 /// This class holds a parsed version of the target data layout string in a
91 /// module and provides methods for querying it. The target data layout string
92 /// is specified *by the target* - a frontend generating LLVM IR is required to
93 /// generate the right target data for the target being codegen'd to.
94 class DataLayout {
9895 private:
9996 bool LittleEndian; ///< Defaults to false
10097 unsigned StackNaturalAlign; ///< Stack natural alignment
164161 void parseSpecifier(StringRef LayoutDescription);
165162
166163 public:
167 /// Default ctor.
168 ///
169 /// @note This has to exist, because this is a pass, but it should never be
170 /// used.
171 DataLayout();
172
173164 /// Constructs a DataLayout from a specification string. See init().
174 explicit DataLayout(StringRef LayoutDescription)
175 : ImmutablePass(ID) {
176 init(LayoutDescription);
177 }
165 explicit DataLayout(StringRef LayoutDescription) { init(LayoutDescription); }
178166
179167 /// Initialize target data from properties stored in the module.
180168 explicit DataLayout(const Module *M);
181169
182 DataLayout(const DataLayout &DL) :
183 ImmutablePass(ID),
184 LittleEndian(DL.isLittleEndian()),
185 StackNaturalAlign(DL.StackNaturalAlign),
186 ManglingMode(DL.ManglingMode),
187 LegalIntWidths(DL.LegalIntWidths),
188 Alignments(DL.Alignments),
189 Pointers(DL.Pointers),
190 LayoutMap(0)
191 { }
170 DataLayout(const DataLayout &DL) { *this = DL; }
171
172 DataLayout &operator=(const DataLayout &DL) {
173 LittleEndian = DL.isLittleEndian();
174 StackNaturalAlign = DL.StackNaturalAlign;
175 ManglingMode = DL.ManglingMode;
176 LegalIntWidths = DL.LegalIntWidths;
177 Alignments = DL.Alignments;
178 Pointers = DL.Pointers;
179 LayoutMap = 0;
180 return *this;
181 }
192182
193183 ~DataLayout(); // Not virtual, do not subclass this class
194184
195 /// DataLayout is an immutable pass, but holds state. This allows the pass
196 /// manager to clear its mutable state.
197 bool doFinalization(Module &M);
198
199 /// Parse a data layout string (with fallback to default values). Ensure that
200 /// the data layout pass is registered.
185 /// Parse a data layout string (with fallback to default values).
201186 void init(StringRef LayoutDescription);
202187
203188 /// Layout endianness...
457442 assert((Alignment & (Alignment-1)) == 0 && "Alignment must be power of 2!");
458443 return (Val + (Alignment-1)) & ~UIntTy(Alignment-1);
459444 }
445 };
446
447 class DataLayoutPass : public ImmutablePass {
448 DataLayout DL;
449
450 public:
451 /// This has to exist, because this is a pass, but it should never be used.
452 DataLayoutPass();
453 ~DataLayoutPass();
454
455 const DataLayout &getDataLayout() const { return DL; }
456
457 explicit DataLayoutPass(const DataLayout &DL);
458
459 explicit DataLayoutPass(StringRef LayoutDescription);
460
461 explicit DataLayoutPass(const Module *M);
460462
461463 static char ID; // Pass identification, replacement for typeid
462464 };
247247 void initializeTailCallElimPass(PassRegistry&);
248248 void initializeTailDuplicatePassPass(PassRegistry&);
249249 void initializeTargetPassConfigPass(PassRegistry&);
250 void initializeDataLayoutPass(PassRegistry&);
250 void initializeDataLayoutPassPass(PassRegistry &);
251251 void initializeTargetTransformInfoAnalysisGroup(PassRegistry&);
252252 void initializeNoTTIPass(PassRegistry&);
253253 void initializeTargetLibraryInfoPass(PassRegistry&);
471471 /// AliasAnalysis interface before any other methods are called.
472472 ///
473473 void AliasAnalysis::InitializeAliasAnalysis(Pass *P) {
474 DL = P->getAnalysisIfAvailable>();
474 DataLayoutPass *DLP = P->getAnalysisIfAvailable>();
475 DL = DLP ? &DLP->getDataLayout() : 0;
475476 TLI = P->getAnalysisIfAvailable();
476477 AA = &P->getAnalysis();
477478 }
12131213 }
12141214
12151215 bool InlineCostAnalysis::runOnSCC(CallGraphSCC &SCC) {
1216 DL = getAnalysisIfAvailable>();
1216 DataLayoutPass *DLP = getAnalysisIfAvailable>();
1217 DL = DLP ? &DLP->getDataLayout() : 0;
12171218 TTI = &getAnalysis();
12181219 return false;
12191220 }
233233 LI = &getAnalysis();
234234 DT = &getAnalysis().getDomTree();
235235 SE = &getAnalysis();
236 DL = getAnalysisIfAvailable>();
236 DataLayoutPass *DLP = getAnalysisIfAvailable>();
237 DL = DLP ? &DLP->getDataLayout() : 0;
237238
238239 // Find all uses of induction variables in this loop, and categorize
239240 // them by stride. Start by finding all of the PHI nodes in the header for
10121012 if (PImpl)
10131013 getCache(PImpl).clear();
10141014
1015 DL = getAnalysisIfAvailable>();
1015 DataLayoutPass *DLP = getAnalysisIfAvailable>();
1016 DL = DLP ? &DLP->getDataLayout() : 0;
10161017 TLI = &getAnalysis();
10171018
10181019 // Fully lazy.
175175 Mod = F.getParent();
176176 AA = &getAnalysis();
177177 DT = &getAnalysis().getDomTree();
178 DL = getAnalysisIfAvailable>();
178 DataLayoutPass *DLP = getAnalysisIfAvailable>();
179 DL = DLP ? &DLP->getDataLayout() : 0;
179180 TLI = &getAnalysis();
180181 visit(F);
181182 dbgs() << MessagesStr.str();
8686
8787 bool MemoryDependenceAnalysis::runOnFunction(Function &) {
8888 AA = &getAnalysis();
89 DL = getAnalysisIfAvailable>();
89 DataLayoutPass *DLP = getAnalysisIfAvailable>();
90 DL = DLP ? &DLP->getDataLayout() : 0;
9091 DominatorTreeWrapperPass *DTWP =
9192 getAnalysisIfAvailable();
9293 DT = DTWP ? &DTWP->getDomTree() : 0;
3535 virtual void initializePass() {
3636 // Note: NoAA does not call InitializeAliasAnalysis because it's
3737 // special and does not support chaining.
38 DL = getAnalysisIfAvailable>();
38 DataLayoutPass *DLP = getAnalysisIfAvailable>();
39 DL = DLP ? &DLP->getDataLayout() : 0;
3940 }
4041
4142 virtual AliasResult alias(const Location &LocA, const Location &LocB) {
73757375 bool ScalarEvolution::runOnFunction(Function &F) {
73767376 this->F = &F;
73777377 LI = &getAnalysis();
7378 DL = getAnalysisIfAvailable>();
7378 DataLayoutPass *DLP = getAnalysisIfAvailable>();
7379 DL = DLP ? &DLP->getDataLayout() : 0;
73797380 TLI = &getAnalysis();
73807381 DT = &getAnalysis().getDomTree();
73817382 return false;
252252 // it does not chain.
253253 TopTTI = this;
254254 PrevTTI = 0;
255 DL = getAnalysisIfAvailable>();
255 DataLayoutPass *DLP = getAnalysisIfAvailable>();
256 DL = DLP ? &DLP->getDataLayout() : 0;
256257 }
257258
258259 virtual void getAnalysisUsage(AnalysisUsage &AU) const LLVM_OVERRIDE {
150150 // Add target data
151151 MutexGuard locked(lock);
152152 FunctionPassManager &PM = jitstate->getPM(locked);
153 PM.add(new DataLayout(*TM.getDataLayout()));
153 PM.add(new DataLayoutPass(*TM.getDataLayout()));
154154
155155 // Turn the machine code intermediate representation into bytes in memory that
156156 // may be executed.
182182 jitstate = new JITState(M);
183183
184184 FunctionPassManager &PM = jitstate->getPM(locked);
185 PM.add(new DataLayout(*TM.getDataLayout()));
185 PM.add(new DataLayoutPass(*TM.getDataLayout()));
186186
187187 // Turn the machine code intermediate representation into bytes in memory
188188 // that may be executed.
213213 jitstate = new JITState(Modules[0]);
214214
215215 FunctionPassManager &PM = jitstate->getPM(locked);
216 PM.add(new DataLayout(*TM.getDataLayout()));
216 PM.add(new DataLayoutPass(*TM.getDataLayout()));
217217
218218 // Turn the machine code intermediate representation into bytes in memory
219219 // that may be executed.
141141
142142 PassManager PM;
143143
144 PM.add(new DataLayout(*TM->getDataLayout()));
144 PM.add(new DataLayoutPass(*TM->getDataLayout()));
145145
146146 // The RuntimeDyld will take ownership of this shortly
147147 OwningPtr CompiledObject(new ObjectBufferStream());
3434
3535 // Handle the Pass registration stuff necessary to use DataLayout's.
3636
37 // Register the default SparcV9 implementation...
38 INITIALIZE_PASS(DataLayout, "datalayout", "Data Layout", false, true)
39 char DataLayout::ID = 0;
37 INITIALIZE_PASS(DataLayoutPass, "datalayout", "Data Layout", false, true)
38 char DataLayoutPass::ID = 0;
4039
4140 //===----------------------------------------------------------------------===//
4241 // Support for StructLayout
177176 };
178177
179178 void DataLayout::init(StringRef Desc) {
180 initializeDataLayoutPass(*PassRegistry::getPassRegistry());
181
182179 LayoutMap = 0;
183180 LittleEndian = false;
184181 StackNaturalAlign = 0;
346343 }
347344 }
348345
349 /// Default ctor.
350 ///
351 /// @note This has to exist, because this is a pass, but it should never be
352 /// used.
353 DataLayout::DataLayout() : ImmutablePass(ID) {
354 report_fatal_error("Bad DataLayout ctor used. "
355 "Tool did not specify a DataLayout to use?");
356 }
357
358 DataLayout::DataLayout(const Module *M)
359 : ImmutablePass(ID) {
360 init(M->getDataLayout());
361 }
346 DataLayout::DataLayout(const Module *M) { init(M->getDataLayout()); }
362347
363348 void
364349 DataLayout::setAlignment(AlignTypeEnum align_type, unsigned abi_align,
479464
480465 DataLayout::~DataLayout() {
481466 delete static_cast(LayoutMap);
482 }
483
484 bool DataLayout::doFinalization(Module &M) {
485 delete static_cast(LayoutMap);
486 LayoutMap = 0;
487 return false;
488467 }
489468
490469 const StructLayout *DataLayout::getStructLayout(StructType *Ty) const {
777756 unsigned DataLayout::getPreferredAlignmentLog(const GlobalVariable *GV) const {
778757 return Log2_32(getPreferredAlignment(GV));
779758 }
759
760 DataLayoutPass::DataLayoutPass() : ImmutablePass(ID), DL("") {
761 report_fatal_error("Bad DataLayoutPass ctor used. Tool did not specify a "
762 "DataLayout to use?");
763 }
764
765 DataLayoutPass::~DataLayoutPass() {}
766
767 DataLayoutPass::DataLayoutPass(const DataLayout &DL)
768 : ImmutablePass(ID), DL(DL) {
769 initializeDataLayoutPassPass(*PassRegistry::getPassRegistry());
770 }
771
772 DataLayoutPass::DataLayoutPass(StringRef Str) : ImmutablePass(ID), DL(Str) {
773 initializeDataLayoutPassPass(*PassRegistry::getPassRegistry());
774 }
775
776 DataLayoutPass::DataLayoutPass(const Module *M) : ImmutablePass(ID), DL(M) {
777 initializeDataLayoutPassPass(*PassRegistry::getPassRegistry());
778 }
481481 passes.add(createVerifierPass());
482482
483483 // Add an appropriate DataLayout instance for this module...
484 passes.add(new DataLayout(*TargetMach->getDataLayout()));
484 passes.add(new DataLayoutPass(*TargetMach->getDataLayout()));
485485
486486 // Add appropriate TargetLibraryInfo for this module.
487487 passes.add(new TargetLibraryInfo(Triple(TargetMach->getTargetTriple())));
502502
503503 PassManager codeGenPasses;
504504
505 codeGenPasses.add(new DataLayout(*TargetMach->getDataLayout()));
505 codeGenPasses.add(new DataLayoutPass(*TargetMach->getDataLayout()));
506506
507507 formatted_raw_ostream Out(out);
508508
3030 NVPTXAllocaHoisting() : FunctionPass(ID) {}
3131
3232 void getAnalysisUsage(AnalysisUsage &AU) const {
33 AU.addRequired>();
33 AU.addRequiredPass>();
3434 AU.addPreserved("stack-protector");
3535 AU.addPreserved();
3636 }
103103 SmallVector aggrMemcpys;
104104 SmallVector aggrMemsets;
105105
106 const DataLayout *DL = &getAnalysis>();
106 const DataLayout *DL = &getAnalysisPass>().getDataLayout();
107107 LLVMContext &Context = F.getParent()->getContext();
108108
109109 //
2727 NVPTXLowerAggrCopies() : FunctionPass(ID) {}
2828
2929 void getAnalysisUsage(AnalysisUsage &AU) const {
30 AU.addRequired>();
30 AU.addRequiredPass>();
3131 AU.addPreserved("stack-protector");
3232 AU.addPreserved();
3333 }
170170 LI = &getAnalysis();
171171 SE = &getAnalysis();
172172 DT = &getAnalysis().getDomTree();
173 DL = getAnalysisIfAvailable>();
173 DataLayoutPass *DLP = getAnalysisIfAvailable>();
174 DL = DLP ? &DLP->getDataLayout() : 0;
174175 LibInfo = getAnalysisIfAvailable();
175176
176177 bool MadeChange = false;
4141 }
4242
4343 void llvm::initializeTarget(PassRegistry &Registry) {
44 initializeDataLayoutPass(Registry);
44 initializeDataLayoutPassPass(Registry);
4545 initializeTargetLibraryInfoPass(Registry);
4646 }
4747
5454 }
5555
5656 void LLVMAddTargetData(LLVMTargetDataRef TD, LLVMPassManagerRef PM) {
57 unwrap(PM)->add(new DataLayout(*unwrap(TD)));
57 unwrap(PM)->add(new DataLayoutPass(*unwrap(TD)));
5858 }
5959
6060 void LLVMAddTargetLibraryInfo(LLVMTargetLibraryInfoRef TLI,
211211 *ErrorMessage = strdup(error.c_str());
212212 return true;
213213 }
214 pass.add(new DataLayout(*td));
214 pass.add(new DataLayoutPass(*td));
215215
216216 TargetMachine::CodeGenFileType ft;
217217 switch (codegen) {
101101 }
102102
103103 bool ConstantMerge::runOnModule(Module &M) {
104 DL = getAnalysisIfAvailable>();
104 DataLayoutPass *DLP = getAnalysisIfAvailable>();
105 DL = DLP ? &DLP->getDataLayout() : 0;
105106
106107 // Find all the globals that are marked "used". These cannot be merged.
107108 SmallPtrSet UsedGlobals;
18141814 ++NumMarked;
18151815 return true;
18161816 } else if (!GV->getInitializer()->getType()->isSingleValueType()) {
1817 if (DataLayout *DL = getAnalysisIfAvailable())
1818 if (GlobalVariable *FirstNewGV = SRAGlobal(GV, *DL)) {
1817 if (DataLayoutPass *DLP = getAnalysisIfAvailable()) {
1818 const DataLayout &DL = DLP->getDataLayout();
1819 if (GlobalVariable *FirstNewGV = SRAGlobal(GV, DL)) {
18191820 GVI = FirstNewGV; // Don't skip the newly produced globals!
18201821 return true;
18211822 }
1823 }
18221824 } else if (GS.StoredType == GlobalStatus::StoredOnce) {
18231825 // If the initial value for the global was an undef value, and if only
18241826 // one other value was stored into it, we can just change the
31603162 bool GlobalOpt::runOnModule(Module &M) {
31613163 bool Changed = false;
31623164
3163 DL = getAnalysisIfAvailable>();
3165 DataLayoutPass *DLP = getAnalysisIfAvailable>();
3166 DL = DLP ? &DLP->getDataLayout() : 0;
31643167 TLI = &getAnalysis();
31653168
31663169 // Try to find the llvm.globalctors list.
409409
410410 bool Inliner::runOnSCC(CallGraphSCC &SCC) {
411411 CallGraph &CG = getAnalysis().getCallGraph();
412 const DataLayout *DL = getAnalysisIfAvailable>();
412 DataLayoutPass *DLP = getAnalysisIfAvailable>();
413 const DataLayout *DL = DLP ? &DLP->getDataLayout() : 0;
413414 const TargetLibraryInfo *TLI = getAnalysisIfAvailable();
414415
415416 SmallPtrSet SCCFunctions;
622622
623623 bool MergeFunctions::runOnModule(Module &M) {
624624 bool Changed = false;
625 DL = getAnalysisIfAvailable>();
625 DataLayoutPass *DLP = getAnalysisIfAvailable>();
626 DL = DLP ? &DLP->getDataLayout() : 0;
626627
627628 for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) {
628629 if (!I->isDeclaration() && !I->hasAvailableExternallyLinkage())
25172517 if (skipOptnoneFunction(F))
25182518 return false;
25192519
2520 DL = getAnalysisIfAvailable>();
2520 DataLayoutPass *DLP = getAnalysisIfAvailable>();
2521 DL = DLP ? &DLP->getDataLayout() : 0;
25212522 TLI = &getAnalysis();
25222523 // Minimizing size?
25232524 MinimizeSize = F.getAttributes().hasAttribute(AttributeSet::FunctionIndex,
909909 // redzones and inserts this function into llvm.global_ctors.
910910 bool AddressSanitizerModule::runOnModule(Module &M) {
911911 if (!ClGlobals) return false;
912 DL = getAnalysisIfAvailable();
913 if (!DL)
912
913 DataLayoutPass *DLP = getAnalysisIfAvailable();
914 if (!DLP)
914915 return false;
916 DL = &DLP->getDataLayout();
917
915918 BL.reset(SpecialCaseList::createOrDie(BlacklistFile));
916919 if (BL->isIn(M)) return false;
917920 C = &(M.getContext());
10851088 // virtual
10861089 bool AddressSanitizer::doInitialization(Module &M) {
10871090 // Initialize the private fields. No one has accessed them before.
1088 DL = getAnalysisIfAvailable();
1089
1090 if (!DL)
1091 DataLayoutPass *DLP = getAnalysisIfAvailable();
1092 if (!DLP)
10911093 return false;
1094 DL = &DLP->getDataLayout();
1095
10921096 BL.reset(SpecialCaseList::createOrDie(BlacklistFile));
10931097 DynamicallyInitializedGlobals.Init(M);
10941098
4747 virtual bool runOnFunction(Function &F);
4848
4949 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
50 AU.addRequired>();
50 AU.addRequiredPass>();
5151 AU.addRequired();
5252 }
5353
165165 }
166166
167167 bool BoundsChecking::runOnFunction(Function &F) {
168 DL = &getAnalysis>();
168 DL = &getAnalysisPass>().getDataLayout();
169169 TLI = &getAnalysis();
170170
171171 TrapBB = 0;
342342 }
343343
344344 bool DataFlowSanitizer::doInitialization(Module &M) {
345 DL = getAnalysisIfAvailable();
346 if (!DL)
345 DataLayoutPass *DLP = getAnalysisIfAvailable();
346 if (!DLP)
347347 return false;
348 DL = &DLP->getDataLayout();
348349
349350 Mod = &M;
350351 Ctx = &M.getContext();
398398 ///
399399 /// inserts a call to __msan_init to the module's constructor list.
400400 bool MemorySanitizer::doInitialization(Module &M) {
401 DL = getAnalysisIfAvailable();
402 if (!DL)
401 DataLayoutPass *DLP = getAnalysisIfAvailable();
402 if (!DLP)
403403 return false;
404 DL = &DLP->getDataLayout();
405
404406 BL.reset(SpecialCaseList::createOrDie(BlacklistFile));
405407 C = &(M.getContext());
406408 unsigned PtrSize = DL->getPointerSizeInBits(/* AddressSpace */0);
223223 }
224224
225225 bool ThreadSanitizer::doInitialization(Module &M) {
226 DL = getAnalysisIfAvailable();
227 if (!DL)
226 DataLayoutPass *DLP = getAnalysisIfAvailable();
227 if (!DLP)
228228 return false;
229 DL = &DLP->getDataLayout();
229230 BL.reset(SpecialCaseList::createOrDie(BlacklistFile));
230231
231232 // Always insert a call to __tsan_init into the module's CTORs.
6666 WorkList.insert(&*i);
6767 }
6868 bool Changed = false;
69 const DataLayout *DL = getAnalysisIfAvailable>();
69 DataLayoutPass *DLP = getAnalysisIfAvailable>();
70 const DataLayout *DL = DLP ? &DLP->getDataLayout() : 0;
7071 TargetLibraryInfo *TLI = &getAnalysis();
7172
7273 while (!WorkList.empty()) {
556556
557557 std::vector nodesToProcess;
558558
559 DL = getAnalysisIfAvailable>();
559 DataLayoutPass *DLP = getAnalysisIfAvailable>();
560 DL = DLP ? &DLP->getDataLayout() : 0;
560561 TLI = &getAnalysis();
561562 DT = &getAnalysis().getDomTree();
562563
23172317 if (!NoLoads)
23182318 MD = &getAnalysis();
23192319 DT = &getAnalysis().getDomTree();
2320 DL = getAnalysisIfAvailable>();
2320 DataLayoutPass *DLP = getAnalysisIfAvailable>();
2321 DL = DLP ? &DLP->getDataLayout() : 0;
23212322 TLI = &getAnalysis();
23222323 VN.setAliasAnalysis(&getAnalysis());
23232324 VN.setMemDep(MD);
18171817 LI = &getAnalysis();
18181818 SE = &getAnalysis();
18191819 DT = &getAnalysis().getDomTree();
1820 DL = getAnalysisIfAvailable>();
1820 DataLayoutPass *DLP = getAnalysisIfAvailable>();
1821 DL = DLP ? &DLP->getDataLayout() : 0;
18211822 TLI = getAnalysisIfAvailable();
18221823
18231824 DeadInsts.clear();
151151 return false;
152152
153153 DEBUG(dbgs() << "Jump threading on function '" << F.getName() << "'\n");
154 DL = getAnalysisIfAvailable>();
154 DataLayoutPass *DLP = getAnalysisIfAvailable>();
155 DL = DLP ? &DLP->getDataLayout() : 0;
155156 TLI = &getAnalysis();
156157 LVI = &getAnalysis();
157158
220220 AA = &getAnalysis();
221221 DT = &getAnalysis().getDomTree();
222222
223 DL = getAnalysisIfAvailable>();
223 DataLayoutPass *DLP = getAnalysisIfAvailable>();
224 DL = DLP ? &DLP->getDataLayout() : 0;
224225 TLI = &getAnalysis();
225226
226227 assert(L->isLCSSAForm(*DT) && "Loop is not in LCSSA form.");
181181 }
182182
183183 const DataLayout *getDataLayout() {
184 return DL ? DL : DL=getAnalysisIfAvailable();
184 if (DL)
185 return DL;
186 DataLayoutPass *DLP = getAnalysisIfAvailable();
187 DL = DLP ? &DLP->getDataLayout() : 0;
188 return DL;
185189 }
186190
187191 DominatorTree *getDominatorTree() {
7171 getAnalysisIfAvailable();
7272 DominatorTree *DT = DTWP ? &DTWP->getDomTree() : 0;
7373 LoopInfo *LI = &getAnalysis();
74 const DataLayout *DL = getAnalysisIfAvailable>();
74 DataLayoutPass *DLP = getAnalysisIfAvailable>();
75 const DataLayout *DL = DLP ? &DLP->getDataLayout() : 0;
7576 const TargetLibraryInfo *TLI = &getAnalysis();
7677
7778 SmallVector ExitBlocks;
11401140 LI = &getAnalysis();
11411141 SE = &getAnalysis();
11421142 TLI = &getAnalysis();
1143 DL = getAnalysisIfAvailable>();
1143 DataLayoutPass *DLP = getAnalysisIfAvailable>();
1144 DL = DLP ? &DLP->getDataLayout() : 0;
11441145 DT = &getAnalysis().getDomTree();
11451146
11461147 BasicBlock *Header = L->getHeader();
10241024
10251025 bool MadeChange = false;
10261026 MD = &getAnalysis();
1027 DL = getAnalysisIfAvailable>();
1027 DataLayoutPass *DLP = getAnalysisIfAvailable>();
1028 DL = DLP ? &DLP->getDataLayout() : 0;
10281029 TLI = &getAnalysis();
10291030
10301031 // If we don't have at least memset and memcpy, there is little point of doing
15561556 return false;
15571557
15581558 DEBUG(dbgs() << "SCCP on function '" << F.getName() << "'\n");
1559 const DataLayout *DL = getAnalysisIfAvailable>();
1559 const DataLayoutPass *DLP = getAnalysisIfAvailable>();
1560 const DataLayout *DL = DLP ? &DLP->getDataLayout() : 0;
15601561 const TargetLibraryInfo *TLI = &getAnalysis();
15611562 SCCPSolver Solver(DL, TLI);
15621563
16851686 }
16861687
16871688 bool IPSCCP::runOnModule(Module &M) {
1688 const DataLayout *DL = getAnalysisIfAvailable>();
1689 DataLayoutPass *DLP = getAnalysisIfAvailable>();
1690 const DataLayout *DL = DLP ? &DLP->getDataLayout() : 0;
16891691 const TargetLibraryInfo *TLI = &getAnalysis();
16901692 SCCPSolver Solver(DL, TLI);
16911693
36223622
36233623 DEBUG(dbgs() << "SROA function: " << F.getName() << "\n");
36243624 C = &F.getContext();
3625 DL = getAnalysisIfAvailable();
3626 if (!DL) {
3625 DataLayoutPass *DLP = getAnalysisIfAvailable();
3626 if (!DLP) {
36273627 DEBUG(dbgs() << " Skipping SROA -- no target data!\n");
36283628 return false;
36293629 }
3630 DL = &DLP->getDataLayout();
36303631 DominatorTreeWrapperPass *DTWP =
36313632 getAnalysisIfAvailable();
36323633 DT = DTWP ? &DTWP->getDomTree() : 0;
10221022 if (skipOptnoneFunction(F))
10231023 return false;
10241024
1025 DL = getAnalysisIfAvailable>();
1025 DataLayoutPass *DLP = getAnalysisIfAvailable>();
1026 DL = DLP ? &DLP->getDataLayout() : 0;
10261027
10271028 bool Changed = performPromotion(F);
10281029
239239 }
240240
241241 bool Scalarizer::runOnFunction(Function &F) {
242 DL = getAnalysisIfAvailable>();
242 DataLayoutPass *DLP = getAnalysisIfAvailable>();
243 DL = DLP ? &DLP->getDataLayout() : 0;
243244 for (Function::iterator BBI = F.begin(), BBE = F.end(); BBI != BBE; ++BBI) {
244245 BasicBlock *BB = BBI;
245246 for (BasicBlock::iterator II = BB->begin(), IE = BB->end(); II != IE;) {
171171 return false;
172172
173173 const TargetTransformInfo &TTI = getAnalysis();
174 const DataLayout *DL = getAnalysisIfAvailable>();
174 DataLayoutPass *DLP = getAnalysisIfAvailable>();
175 const DataLayout *DL = DLP ? &DLP->getDataLayout() : 0;
175176 bool EverChanged = removeUnreachableBlocks(F);
176177 EverChanged |= mergeEmptyReturnBlocks(F);
177178 EverChanged |= iterativelySimplifyCFG(F, TTI, DL);
5959 L(Loop),
6060 LI(LPM->getAnalysisIfAvailable()),
6161 SE(SE),
62 DL(LPM->getAnalysisIfAvailable()),
6362 DeadInsts(Dead),
6463 Changed(false) {
64 DataLayoutPass *DLP = LPM->getAnalysisIfAvailable();
65 DL = DLP ? &DLP->getDataLayout() : 0;
6566 assert(LI && "IV simplification requires LoopInfo");
6667 }
6768
4747 const DominatorTreeWrapperPass *DTWP =
4848 getAnalysisIfAvailable();
4949 const DominatorTree *DT = DTWP ? &DTWP->getDomTree() : 0;
50 const DataLayout *DL = getAnalysisIfAvailable>();
50 DataLayoutPass *DLP = getAnalysisIfAvailable>();
51 const DataLayout *DL = DLP ? &DLP->getDataLayout() : 0;
5152 const TargetLibraryInfo *TLI = &getAnalysis();
5253 SmallPtrSet S1, S2, *ToSimplify = &S1, *Next = &S2;
5354 bool Changed = false;
200200 AA = &P->getAnalysis();
201201 DT = &P->getAnalysis().getDomTree();
202202 SE = &P->getAnalysis();
203 DL = P->getAnalysisIfAvailable>();
203 DataLayoutPass *DLP = P->getAnalysisIfAvailable>();
204 DL = DLP ? &DLP->getDataLayout() : 0;
204205 TTI = IgnoreTargetInfo ? 0 : &P->getAnalysis();
205206 }
206207
435436 AA = &getAnalysis();
436437 DT = &getAnalysis().getDomTree();
437438 SE = &getAnalysis();
438 DL = getAnalysisIfAvailable>();
439 DataLayoutPass *DLP = getAnalysisIfAvailable>();
440 DL = DLP ? &DLP->getDataLayout() : 0;
439441 TTI = IgnoreTargetInfo ? 0 : &getAnalysis();
440442
441443 return vectorizeBB(BB);
10211021
10221022 virtual bool runOnFunction(Function &F) {
10231023 SE = &getAnalysis();
1024 DL = getAnalysisIfAvailable>();
1024 DataLayoutPass *DLP = getAnalysisIfAvailable>();
1025 DL = DLP ? &DLP->getDataLayout() : 0;
10251026 LI = &getAnalysis();
10261027 TTI = &getAnalysis();
10271028 DT = &getAnalysis().getDomTree();
17941794 return false;
17951795
17961796 SE = &getAnalysis();
1797 DL = getAnalysisIfAvailable>();
1797 DataLayoutPass *DLP = getAnalysisIfAvailable>();
1798 DL = DLP ? &DLP->getDataLayout() : 0;
17981799 TTI = &getAnalysis();
17991800 AA = &getAnalysis();
18001801 LI = &getAnalysis();
298298
299299 // Add the target data from the target machine, if it exists, or the module.
300300 if (const DataLayout *DL = Target.getDataLayout())
301 PM.add(new DataLayout(*DL));
301 PM.add(new DataLayoutPass(*DL));
302302 else
303 PM.add(new DataLayout(mod));
303 PM.add(new DataLayoutPass(mod));
304304
305305 // Override default to generate verbose assembly.
306306 Target.setAsmVerbosityDefault(true);
253253 // In addition to deleting all other functions, we also want to spiff it
254254 // up a little bit. Do this now.
255255 PassManager Passes;
256 Passes.add(new DataLayout(M.get())); // Use correct DataLayout
256 Passes.add(new DataLayoutPass(M.get())); // Use correct DataLayout
257257
258258 std::vector Gvs(GVs.begin(), GVs.end());
259259
436436 DL = new DataLayout(DefaultDataLayout);
437437
438438 if (DL)
439 Passes.add(DL);
439 Passes.add(new DataLayoutPass(*DL));
440440
441441 Triple ModuleTriple(M->getTargetTriple());
442442 TargetMachine *Machine = 0;
452452 if (OptLevelO1 || OptLevelO2 || OptLevelOs || OptLevelOz || OptLevelO3) {
453453 FPasses.reset(new FunctionPassManager(M.get()));
454454 if (DL)
455 FPasses->add(new DataLayout(*DL));
455 FPasses->add(new DataLayoutPass(*DL));
456456 if (TM.get())
457457 TM->addAnalysisPasses(*FPasses);
458458
9898 initializeModuleNDMPass(*PassRegistry::getPassRegistry());
9999 }
100100 virtual bool runOnModule(Module &M) {
101 EXPECT_TRUE(getAnalysisIfAvailable>());
101 EXPECT_TRUE(getAnalysisIfAvailablePass>());
102102 run++;
103103 return false;
104104 }
175175 initializeCGPassPass(*PassRegistry::getPassRegistry());
176176 }
177177 virtual bool runOnSCC(CallGraphSCC &SCMM) {
178 EXPECT_TRUE(getAnalysisIfAvailable>());
178 EXPECT_TRUE(getAnalysisIfAvailablePass>());
179179 run();
180180 return false;
181181 }
214214 return false;
215215 }
216216 virtual bool runOnLoop(Loop *L, LPPassManager &LPM) {
217 EXPECT_TRUE(getAnalysisIfAvailable>());
217 EXPECT_TRUE(getAnalysisIfAvailablePass>());
218218 run();
219219 return false;
220220 }
251251 return false;
252252 }
253253 virtual bool runOnBasicBlock(BasicBlock &BB) {
254 EXPECT_TRUE(getAnalysisIfAvailable>());
254 EXPECT_TRUE(getAnalysisIfAvailablePass>());
255255 run();
256256 return false;
257257 }
276276 initializeFPassPass(*PassRegistry::getPassRegistry());
277277 }
278278 virtual bool runOnModule(Module &M) {
279 EXPECT_TRUE(getAnalysisIfAvailable>());
279 EXPECT_TRUE(getAnalysisIfAvailablePass>());
280280 for (Module::iterator I=M.begin(),E=M.end(); I != E; ++I) {
281281 Function &F = *I;
282282 {
302302 mNDM->run = mNDNM->run = mDNM->run = mNDM2->run = 0;
303303
304304 PassManager Passes;
305 Passes.add(new DataLayout(&M));
305 Passes.add(new DataLayoutPass(&M));
306306 Passes.add(mNDM2);
307307 Passes.add(mNDM);
308308 Passes.add(mNDNM);
326326 mNDM->run = mNDNM->run = mDNM->run = mNDM2->run = 0;
327327
328328 PassManager Passes;
329 Passes.add(new DataLayout(&M));
329 Passes.add(new DataLayoutPass(&M));
330330 Passes.add(mNDM);
331331 Passes.add(mNDNM);
332332 Passes.add(mNDM2);// invalidates mNDM needed by mDNM
348348 OwningPtr M(makeLLVMModule());
349349 T *P = new T();
350350 PassManager Passes;
351 Passes.add(new DataLayout(M.get()));
351 Passes.add(new DataLayoutPass(M.get()));
352352 Passes.add(P);
353353 Passes.run(*M);
354354 T::finishedOK(run);
359359 Module *M = makeLLVMModule();
360360 T *P = new T();
361361 PassManager Passes;
362 Passes.add(new DataLayout(M));
362 Passes.add(new DataLayoutPass(M));
363363 Passes.add(P);
364364 Passes.run(*M);
365365 T::finishedOK(run, N);
397397 SCOPED_TRACE("Running OnTheFlyTest");
398398 struct OnTheFlyTest *O = new OnTheFlyTest();
399399 PassManager Passes;
400 Passes.add(new DataLayout(M));
400 Passes.add(new DataLayoutPass(M));
401401 Passes.add(O);
402402 Passes.run(*M);
403403