llvm.org GIT mirror llvm / 13bc67e
[Target, Transforms] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292320 91177308-0d34-0410-b5e6-96231b3b80d8 Eugene Zelenko 2 years ago
14 changed file(s) with 342 addition(s) and 244 deletion(s). Raw diff Collapse all Expand all
1313 #ifndef LLVM_TARGET_TARGETCALLINGCONV_H
1414 #define LLVM_TARGET_TARGETCALLINGCONV_H
1515
16 #include "llvm/CodeGen/MachineValueType.h"
1617 #include "llvm/CodeGen/ValueTypes.h"
17 #include "llvm/Support/DataTypes.h"
1818 #include "llvm/Support/MathExtras.h"
19 #include
1920 #include
21 #include
2022
2123 namespace llvm {
22
2324 namespace ISD {
25
2426 struct ArgFlagsTy {
2527 private:
2628 static const uint64_t NoFlagSet = 0ULL;
7072
7173 static const uint64_t One = 1ULL; ///< 1 of this type, for shifts
7274
73 uint64_t Flags;
75 uint64_t Flags = 0;
7476
7577 public:
76 ArgFlagsTy() : Flags(0) { }
78 ArgFlagsTy() = default;
7779
7880 bool isZExt() const { return Flags & ZExt; }
7981 void setZExt() { Flags |= One << ZExtOffs; }
161163 ///
162164 struct InputArg {
163165 ArgFlagsTy Flags;
164 MVT VT;
166 MVT VT = MVT::Other;
165167 EVT ArgVT;
166 bool Used;
168 bool Used = false;
167169
168170 /// Index original Function's argument.
169171 unsigned OrigArgIndex;
175177 /// registers, we got 4 InputArgs with PartOffsets 0, 4, 8 and 12.
176178 unsigned PartOffset;
177179
178 InputArg() : VT(MVT::Other), Used(false) {}
180 InputArg() = default;
179181 InputArg(ArgFlagsTy flags, EVT vt, EVT argvt, bool used,
180182 unsigned origIdx, unsigned partOffs)
181183 : Flags(flags), Used(used), OrigArgIndex(origIdx), PartOffset(partOffs) {
203205 EVT ArgVT;
204206
205207 /// IsFixed - Is this a "fixed" value, ie not passed through a vararg "...".
206 bool IsFixed;
208 bool IsFixed = false;
207209
208210 /// Index original Function's argument.
209211 unsigned OrigArgIndex;
213215 /// registers, we got 4 OutputArgs with PartOffsets 0, 4, 8 and 12.
214216 unsigned PartOffset;
215217
216 OutputArg() : IsFixed(false) {}
218 OutputArg() = default;
217219 OutputArg(ArgFlagsTy flags, EVT vt, EVT argvt, bool isfixed,
218220 unsigned origIdx, unsigned partOffs)
219221 : Flags(flags), IsFixed(isfixed), OrigArgIndex(origIdx),
222224 ArgVT = argvt;
223225 }
224226 };
227
225228 } // end namespace ISD
226
227 } // end llvm namespace
229 } // end namespace llvm
228230
229231 #endif // LLVM_TARGET_TARGETCALLINGCONV_H
1515 #define LLVM_TARGET_TARGETLOWERINGOBJECTFILE_H
1616
1717 #include "llvm/ADT/ArrayRef.h"
18 #include "llvm/ADT/StringRef.h"
1819 #include "llvm/IR/Module.h"
1920 #include "llvm/MC/MCObjectFileInfo.h"
2021 #include "llvm/MC/SectionKind.h"
22 #include
2123
2224 namespace llvm {
23 class MachineModuleInfo;
24 class Mangler;
25 class MCContext;
26 class MCExpr;
27 class MCSection;
28 class MCSymbol;
29 class MCSymbolRefExpr;
30 class MCStreamer;
31 class MCValue;
32 class ConstantExpr;
33 class GlobalValue;
34 class TargetMachine;
25
26 class GlobalValue;
27 class MachineModuleInfo;
28 class Mangler;
29 class MCContext;
30 class MCExpr;
31 class MCSection;
32 class MCSymbol;
33 class MCSymbolRefExpr;
34 class MCStreamer;
35 class MCValue;
36 class TargetMachine;
3537
3638 class TargetLoweringObjectFile : public MCObjectFileInfo {
37 MCContext *Ctx;
39 MCContext *Ctx = nullptr;
3840
3941 /// Name-mangler for global names.
4042 Mangler *Mang = nullptr;
4143
42 TargetLoweringObjectFile(
43 const TargetLoweringObjectFile&) = delete;
44 void operator=(const TargetLoweringObjectFile&) = delete;
45
4644 protected:
47 bool SupportIndirectSymViaGOTPCRel;
48 bool SupportGOTPCRelWithOffset;
45 bool SupportIndirectSymViaGOTPCRel = false;
46 bool SupportGOTPCRelWithOffset = true;
4947
5048 /// This section contains the static constructor pointer list.
5149 MCSection *StaticCtorSection;
5452 MCSection *StaticDtorSection;
5553
5654 public:
55 TargetLoweringObjectFile() = default;
56 TargetLoweringObjectFile(const TargetLoweringObjectFile &) = delete;
57 TargetLoweringObjectFile &
58 operator=(const TargetLoweringObjectFile &) = delete;
59 virtual ~TargetLoweringObjectFile();
60
5761 MCContext &getContext() const { return *Ctx; }
5862 Mangler &getMangler() const { return *Mang; }
59
60 TargetLoweringObjectFile()
61 : MCObjectFileInfo(), Ctx(nullptr), Mang(nullptr),
62 SupportIndirectSymViaGOTPCRel(false), SupportGOTPCRelWithOffset(true) {}
63
64 virtual ~TargetLoweringObjectFile();
6563
6664 /// This method must be called before any actual lowering is done. This
6765 /// specifies the current context for codegen, and gives the lowering
193191
194192 } // end namespace llvm
195193
196 #endif
194 #endif // LLVM_TARGET_TARGETLOWERINGOBJECTFILE_H
1414 #ifndef LLVM_TRANSFORMS_IPO_LOWERTYPETESTS_H
1515 #define LLVM_TRANSFORMS_IPO_LOWERTYPETESTS_H
1616
17 #include "llvm/ADT/DenseMap.h"
1817 #include "llvm/ADT/SmallVector.h"
1918 #include "llvm/IR/Module.h"
2019 #include "llvm/IR/PassManager.h"
21
2220 #include
2321 #include
2422 #include
2725
2826 namespace llvm {
2927
30 class DataLayout;
31 class GlobalObject;
32 class Value;
3328 class raw_ostream;
3429
3530 namespace lowertypetests {
6459
6560 struct BitSetBuilder {
6661 SmallVector Offsets;
67 uint64_t Min, Max;
68
69 BitSetBuilder() : Min(std::numeric_limits::max()), Max(0) {}
62 uint64_t Min = std::numeric_limits::max();
63 uint64_t Max = 0;
64
65 BitSetBuilder() = default;
7066
7167 void addOffset(uint64_t Offset) {
7268 if (Min > Offset)
None //===- Transforms/InstrProfiling.h - Instrumentation passes ---*- C++ -*-===//
0 //===- Transforms/InstrProfiling.h - Instrumentation passes -----*- C++ -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
1313 #ifndef LLVM_TRANSFORMS_INSTRPROFILING_H
1414 #define LLVM_TRANSFORMS_INSTRPROFILING_H
1515
16 #include "llvm/ADT/DenseMap.h"
17 #include "llvm/ADT/StringRef.h"
1618 #include "llvm/IR/IntrinsicInst.h"
1719 #include "llvm/IR/PassManager.h"
1820 #include "llvm/ProfileData/InstrProf.h"
1921 #include "llvm/Transforms/Instrumentation.h"
22 #include
23 #include
24 #include
25 #include
2026
2127 namespace llvm {
2228
2733 /// instrumentation pass.
2834 class InstrProfiling : public PassInfoMixin {
2935 public:
30 InstrProfiling() {}
36 InstrProfiling() = default;
3137 InstrProfiling(const InstrProfOptions &Options) : Options(Options) {}
3238
3339 PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
3945 const TargetLibraryInfo *TLI;
4046 struct PerFunctionProfileData {
4147 uint32_t NumValueSites[IPVK_Last + 1];
42 GlobalVariable *RegionCounters;
43 GlobalVariable *DataVar;
44 PerFunctionProfileData() : RegionCounters(nullptr), DataVar(nullptr) {
48 GlobalVariable *RegionCounters = nullptr;
49 GlobalVariable *DataVar = nullptr;
50
51 PerFunctionProfileData() {
4552 memset(NumValueSites, 0, sizeof(uint32_t) * (IPVK_Last + 1));
4653 }
4754 };
103110 void emitInitialization();
104111 };
105112
106 } // End llvm namespace
107 #endif
113 } // end namespace llvm
114
115 #endif // LLVM_TRANSFORMS_INSTRPROFILING_H
1515
1616 #include "llvm/ADT/StringRef.h"
1717 #include "llvm/IR/BasicBlock.h"
18 #include
19 #include
20 #include
21 #include
1822 #include
1923
2024 #if defined(__GNUC__) && defined(__linux__) && !defined(ANDROID)
3337
3438 namespace llvm {
3539
36 class TargetMachine;
40 class FunctionPass;
41 class ModulePass;
3742
3843 /// Instrumentation passes often insert conditional checks into entry blocks.
3944 /// Call this function before splitting the entry block to move instructions
4247 /// block.
4348 BasicBlock::iterator PrepareToSplitEntryBlock(BasicBlock &BB,
4449 BasicBlock::iterator IP);
45
46 class ModulePass;
47 class FunctionPass;
4850
4951 // Insert GCOV profiling instrumentation
5052 struct GCOVOptions {
7577 // all of the function body's blocks.
7678 bool ExitBlockBeforeBody;
7779 };
80
7881 ModulePass *createGCOVProfilerPass(const GCOVOptions &Options =
7982 GCOVOptions::getDefault());
8083
8689
8790 /// Options for the frontend instrumentation based profiling pass.
8891 struct InstrProfOptions {
89 InstrProfOptions() : NoRedZone(false) {}
90
9192 // Add the 'noredzone' attribute to added runtime library calls.
92 bool NoRedZone;
93 bool NoRedZone = false;
9394
9495 // Name of the profile file to use as output
9596 std::string InstrProfileOutput;
97
98 InstrProfOptions() = default;
9699 };
97100
98101 /// Insert frontend instrumentation based profiling.
120123
121124 // Options for EfficiencySanitizer sub-tools.
122125 struct EfficiencySanitizerOptions {
123 EfficiencySanitizerOptions() : ToolType(ESAN_None) {}
124126 enum Type {
125127 ESAN_None = 0,
126128 ESAN_CacheFrag,
127129 ESAN_WorkingSet,
128 } ToolType;
130 } ToolType = ESAN_None;
131
132 EfficiencySanitizerOptions() = default;
129133 };
130134
131135 // Insert EfficiencySanitizer instrumentation.
134138
135139 // Options for sanitizer coverage instrumentation.
136140 struct SanitizerCoverageOptions {
137 SanitizerCoverageOptions()
138 : CoverageType(SCK_None), IndirectCalls(false), TraceBB(false),
139 TraceCmp(false), TraceDiv(false), TraceGep(false),
140 Use8bitCounters(false), TracePC(false), TracePCGuard(false) {}
141
142141 enum Type {
143142 SCK_None = 0,
144143 SCK_Function,
145144 SCK_BB,
146145 SCK_Edge
147 } CoverageType;
148 bool IndirectCalls;
149 bool TraceBB;
150 bool TraceCmp;
151 bool TraceDiv;
152 bool TraceGep;
153 bool Use8bitCounters;
154 bool TracePC;
155 bool TracePCGuard;
146 } CoverageType = SCK_None;
147 bool IndirectCalls = false;
148 bool TraceBB = false;
149 bool TraceCmp = false;
150 bool TraceDiv = false;
151 bool TraceGep = false;
152 bool Use8bitCounters = false;
153 bool TracePC = false;
154 bool TracePCGuard = false;
155
156 SanitizerCoverageOptions() = default;
156157 };
157158
158159 // Insert SanitizerCoverage instrumentation.
174175 /// \brief Calculate what to divide by to scale counts.
175176 ///
176177 /// Given the maximum count, calculate a divisor that will scale all the
177 /// weights to strictly less than UINT32_MAX.
178 /// weights to strictly less than std::numeric_limits::max().
178179 static inline uint64_t calculateCountScale(uint64_t MaxCount) {
179 return MaxCount < UINT32_MAX ? 1 : MaxCount / UINT32_MAX + 1;
180 return MaxCount < std::numeric_limits::max()
181 ? 1
182 : MaxCount / std::numeric_limits::max() + 1;
180183 }
181184
182185 /// \brief Scale an individual branch count.
185188 ///
186189 static inline uint32_t scaleBranchCount(uint64_t Count, uint64_t Scale) {
187190 uint64_t Scaled = Count / Scale;
188 assert(Scaled <= UINT32_MAX && "overflow 32-bits");
191 assert(Scaled <= std::numeric_limits::max() && "overflow 32-bits");
189192 return Scaled;
190193 }
191194
192 } // End llvm namespace
195 } // end namespace llvm
193196
194 #endif
197 #endif // LLVM_TRANSFORMS_INSTRUMENTATION_H
None //======- GVNExpression.h - GVN Expression classes -------*- C++ -*-==-------=//
0 //======- GVNExpression.h - GVN Expression classes --------------*- C++ -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
1616 #define LLVM_TRANSFORMS_SCALAR_GVNEXPRESSION_H
1717
1818 #include "llvm/ADT/Hashing.h"
19 #include "llvm/ADT/iterator_range.h"
1920 #include "llvm/IR/Constant.h"
2021 #include "llvm/IR/Instructions.h"
2122 #include "llvm/IR/Value.h"
2223 #include "llvm/Support/Allocator.h"
2324 #include "llvm/Support/ArrayRecycler.h"
25 #include "llvm/Support/Casting.h"
2426 #include "llvm/Support/Debug.h"
2527 #include "llvm/Support/raw_ostream.h"
2628 #include "llvm/Transforms/Utils/MemorySSA.h"
2729 #include
30 #include
31 #include
32 #include
2833
2934 namespace llvm {
30 class MemoryAccess;
3135
3236 namespace GVNExpression {
3337
5256 unsigned Opcode;
5357
5458 public:
55 Expression(const Expression &) = delete;
5659 Expression(ExpressionType ET = ET_Base, unsigned O = ~2U)
5760 : EType(ET), Opcode(O) {}
58 void operator=(const Expression &) = delete;
61 Expression(const Expression &) = delete;
62 Expression &operator=(const Expression &) = delete;
5963 virtual ~Expression();
6064
6165 static unsigned getEmptyKey() { return ~0U; }
100104 printInternal(OS, true);
101105 OS << "}";
102106 }
107
103108 void dump() const { print(dbgs()); }
104109 };
105110
118123 Type *ValueType;
119124
120125 public:
121 static bool classof(const Expression *EB) {
122 ExpressionType ET = EB->getExpressionType();
123 return ET > ET_BasicStart && ET < ET_BasicEnd;
124 }
125
126126 BasicExpression(unsigned NumOperands)
127127 : BasicExpression(NumOperands, ET_Basic) {}
128128 BasicExpression(unsigned NumOperands, ExpressionType ET)
129129 : Expression(ET), Operands(nullptr), MaxOperands(NumOperands),
130130 NumOperands(0), ValueType(nullptr) {}
131 virtual ~BasicExpression() override;
132 void operator=(const BasicExpression &) = delete;
131 BasicExpression() = delete;
133132 BasicExpression(const BasicExpression &) = delete;
134 BasicExpression() = delete;
133 BasicExpression &operator=(const BasicExpression &) = delete;
134 ~BasicExpression() override;
135
136 static bool classof(const Expression *EB) {
137 ExpressionType ET = EB->getExpressionType();
138 return ET > ET_BasicStart && ET < ET_BasicEnd;
139 }
135140
136141 /// \brief Swap two operands. Used during GVN to put commutative operands in
137142 /// order.
184189 void setType(Type *T) { ValueType = T; }
185190 Type *getType() const { return ValueType; }
186191
187 virtual bool equals(const Expression &Other) const override {
192 bool equals(const Expression &Other) const override {
188193 if (getOpcode() != Other.getOpcode())
189194 return false;
190195
193198 std::equal(op_begin(), op_end(), OE.op_begin());
194199 }
195200
196 virtual hash_code getHashValue() const override {
201 hash_code getHashValue() const override {
197202 return hash_combine(getExpressionType(), getOpcode(), ValueType,
198203 hash_combine_range(op_begin(), op_end()));
199204 }
201206 //
202207 // Debugging support
203208 //
204 virtual void printInternal(raw_ostream &OS, bool PrintEType) const override {
209 void printInternal(raw_ostream &OS, bool PrintEType) const override {
205210 if (PrintEType)
206211 OS << "ExpressionTypeBasic, ";
207212
215220 OS << "} ";
216221 }
217222 };
223
218224 class op_inserter
219225 : public std::iterator {
220226 private:
240246 MemoryAccess *DefiningAccess;
241247
242248 public:
243 static bool classof(const Expression *EB) {
244 return EB->getExpressionType() == ET_Call;
245 }
246
247249 CallExpression(unsigned NumOperands, CallInst *C, MemoryAccess *DA)
248250 : BasicExpression(NumOperands, ET_Call), Call(C), DefiningAccess(DA) {}
249 void operator=(const CallExpression &) = delete;
251 CallExpression() = delete;
250252 CallExpression(const CallExpression &) = delete;
251 CallExpression() = delete;
252 virtual ~CallExpression() override;
253
254 virtual bool equals(const Expression &Other) const override {
253 CallExpression &operator=(const CallExpression &) = delete;
254 ~CallExpression() override;
255
256 static bool classof(const Expression *EB) {
257 return EB->getExpressionType() == ET_Call;
258 }
259
260 bool equals(const Expression &Other) const override {
255261 if (!this->BasicExpression::equals(Other))
256262 return false;
257263 const auto &OE = cast(Other);
258264 return DefiningAccess == OE.DefiningAccess;
259265 }
260266
261 virtual hash_code getHashValue() const override {
267 hash_code getHashValue() const override {
262268 return hash_combine(this->BasicExpression::getHashValue(), DefiningAccess);
263269 }
264270
265271 //
266272 // Debugging support
267273 //
268 virtual void printInternal(raw_ostream &OS, bool PrintEType) const override {
274 void printInternal(raw_ostream &OS, bool PrintEType) const override {
269275 if (PrintEType)
270276 OS << "ExpressionTypeCall, ";
271277 this->BasicExpression::printInternal(OS, false);
280286 unsigned Alignment;
281287
282288 public:
283 static bool classof(const Expression *EB) {
284 return EB->getExpressionType() == ET_Load;
285 }
286
287289 LoadExpression(unsigned NumOperands, LoadInst *L, MemoryAccess *DA)
288290 : LoadExpression(ET_Load, NumOperands, L, DA) {}
289291 LoadExpression(enum ExpressionType EType, unsigned NumOperands, LoadInst *L,
291293 : BasicExpression(NumOperands, EType), Load(L), DefiningAccess(DA) {
292294 Alignment = L ? L->getAlignment() : 0;
293295 }
294 void operator=(const LoadExpression &) = delete;
296 LoadExpression() = delete;
295297 LoadExpression(const LoadExpression &) = delete;
296 LoadExpression() = delete;
297 virtual ~LoadExpression() override;
298 LoadExpression &operator=(const LoadExpression &) = delete;
299 ~LoadExpression() override;
300
301 static bool classof(const Expression *EB) {
302 return EB->getExpressionType() == ET_Load;
303 }
298304
299305 LoadInst *getLoadInst() const { return Load; }
300306 void setLoadInst(LoadInst *L) { Load = L; }
304310 unsigned getAlignment() const { return Alignment; }
305311 void setAlignment(unsigned Align) { Alignment = Align; }
306312
307 virtual bool equals(const Expression &Other) const override;
308
309 virtual hash_code getHashValue() const override {
313 bool equals(const Expression &Other) const override;
314
315 hash_code getHashValue() const override {
310316 return hash_combine(getOpcode(), getType(), DefiningAccess,
311317 hash_combine_range(op_begin(), op_end()));
312318 }
314320 //
315321 // Debugging support
316322 //
317 virtual void printInternal(raw_ostream &OS, bool PrintEType) const override {
323 void printInternal(raw_ostream &OS, bool PrintEType) const override {
318324 if (PrintEType)
319325 OS << "ExpressionTypeLoad, ";
320326 this->BasicExpression::printInternal(OS, false);
329335 MemoryAccess *DefiningAccess;
330336
331337 public:
332 static bool classof(const Expression *EB) {
333 return EB->getExpressionType() == ET_Store;
334 }
335
336338 StoreExpression(unsigned NumOperands, StoreInst *S, MemoryAccess *DA)
337339 : BasicExpression(NumOperands, ET_Store), Store(S), DefiningAccess(DA) {}
338 void operator=(const StoreExpression &) = delete;
340 StoreExpression() = delete;
339341 StoreExpression(const StoreExpression &) = delete;
340 StoreExpression() = delete;
341 virtual ~StoreExpression() override;
342 StoreExpression &operator=(const StoreExpression &) = delete;
343 ~StoreExpression() override;
344
345 static bool classof(const Expression *EB) {
346 return EB->getExpressionType() == ET_Store;
347 }
342348
343349 StoreInst *getStoreInst() const { return Store; }
344350 MemoryAccess *getDefiningAccess() const { return DefiningAccess; }
345351
346 virtual bool equals(const Expression &Other) const override;
347
348 virtual hash_code getHashValue() const override {
352 bool equals(const Expression &Other) const override;
353
354 hash_code getHashValue() const override {
349355 return hash_combine(getOpcode(), getType(), DefiningAccess,
350356 hash_combine_range(op_begin(), op_end()));
351357 }
353359 //
354360 // Debugging support
355361 //
356 virtual void printInternal(raw_ostream &OS, bool PrintEType) const override {
362 void printInternal(raw_ostream &OS, bool PrintEType) const override {
357363 if (PrintEType)
358364 OS << "ExpressionTypeStore, ";
359365 this->BasicExpression::printInternal(OS, false);
369375 unsigned *IntOperands;
370376
371377 public:
372 static bool classof(const Expression *EB) {
373 return EB->getExpressionType() == ET_AggregateValue;
374 }
375
376378 AggregateValueExpression(unsigned NumOperands, unsigned NumIntOperands)
377379 : BasicExpression(NumOperands, ET_AggregateValue),
378380 MaxIntOperands(NumIntOperands), NumIntOperands(0),
379381 IntOperands(nullptr) {}
380
381 void operator=(const AggregateValueExpression &) = delete;
382 AggregateValueExpression() = delete;
382383 AggregateValueExpression(const AggregateValueExpression &) = delete;
383 AggregateValueExpression() = delete;
384 virtual ~AggregateValueExpression() override;
384 AggregateValueExpression &
385 operator=(const AggregateValueExpression &) = delete;
386 ~AggregateValueExpression() override;
387
388 static bool classof(const Expression *EB) {
389 return EB->getExpressionType() == ET_AggregateValue;
390 }
385391
386392 typedef unsigned *int_arg_iterator;
387393 typedef const unsigned *const_int_arg_iterator;
406412 IntOperands = Allocator.Allocate(MaxIntOperands);
407413 }
408414
409 virtual bool equals(const Expression &Other) const override {
415 bool equals(const Expression &Other) const override {
410416 if (!this->BasicExpression::equals(Other))
411417 return false;
412418 const AggregateValueExpression &OE = cast(Other);
414420 std::equal(int_op_begin(), int_op_end(), OE.int_op_begin());
415421 }
416422
417 virtual hash_code getHashValue() const override {
423 hash_code getHashValue() const override {
418424 return hash_combine(this->BasicExpression::getHashValue(),
419425 hash_combine_range(int_op_begin(), int_op_end()));
420426 }
422428 //
423429 // Debugging support
424430 //
425 virtual void printInternal(raw_ostream &OS, bool PrintEType) const override {
431 void printInternal(raw_ostream &OS, bool PrintEType) const override {
426432 if (PrintEType)
427433 OS << "ExpressionTypeAggregateValue, ";
428434 this->BasicExpression::printInternal(OS, false);
433439 OS << "}";
434440 }
435441 };
442
436443 class int_op_inserter
437444 : public std::iterator {
438445 private:
442449 public:
443450 explicit int_op_inserter(AggregateValueExpression &E) : AVE(&E) {}
444451 explicit int_op_inserter(AggregateValueExpression *E) : AVE(E) {}
452
445453 int_op_inserter &operator=(unsigned int val) {
446454 AVE->int_op_push_back(val);
447455 return *this;
456464 BasicBlock *BB;
457465
458466 public:
459 static bool classof(const Expression *EB) {
460 return EB->getExpressionType() == ET_Phi;
461 }
462
463467 PHIExpression(unsigned NumOperands, BasicBlock *B)
464468 : BasicExpression(NumOperands, ET_Phi), BB(B) {}
465 void operator=(const PHIExpression &) = delete;
469 PHIExpression() = delete;
466470 PHIExpression(const PHIExpression &) = delete;
467 PHIExpression() = delete;
468 virtual ~PHIExpression() override;
469
470 virtual bool equals(const Expression &Other) const override {
471 PHIExpression &operator=(const PHIExpression &) = delete;
472 ~PHIExpression() override;
473
474 static bool classof(const Expression *EB) {
475 return EB->getExpressionType() == ET_Phi;
476 }
477
478 bool equals(const Expression &Other) const override {
471479 if (!this->BasicExpression::equals(Other))
472480 return false;
473481 const PHIExpression &OE = cast(Other);
474482 return BB == OE.BB;
475483 }
476484
477 virtual hash_code getHashValue() const override {
485 hash_code getHashValue() const override {
478486 return hash_combine(this->BasicExpression::getHashValue(), BB);
479487 }
480488
481489 //
482490 // Debugging support
483491 //
484 virtual void printInternal(raw_ostream &OS, bool PrintEType) const override {
492 void printInternal(raw_ostream &OS, bool PrintEType) const override {
485493 if (PrintEType)
486494 OS << "ExpressionTypePhi, ";
487495 this->BasicExpression::printInternal(OS, false);
494502 Value *VariableValue;
495503
496504 public:
505 VariableExpression(Value *V) : Expression(ET_Variable), VariableValue(V) {}
506 VariableExpression() = delete;
507 VariableExpression(const VariableExpression &) = delete;
508 VariableExpression &operator=(const VariableExpression &) = delete;
509
497510 static bool classof(const Expression *EB) {
498511 return EB->getExpressionType() == ET_Variable;
499512 }
500
501 VariableExpression(Value *V) : Expression(ET_Variable), VariableValue(V) {}
502 void operator=(const VariableExpression &) = delete;
503 VariableExpression(const VariableExpression &) = delete;
504 VariableExpression() = delete;
505513
506514 Value *getVariableValue() const { return VariableValue; }
507515 void setVariableValue(Value *V) { VariableValue = V; }
508 virtual bool equals(const Expression &Other) const override {
516
517 bool equals(const Expression &Other) const override {
509518 const VariableExpression &OC = cast(Other);
510519 return VariableValue == OC.VariableValue;
511520 }
512521
513 virtual hash_code getHashValue() const override {
522 hash_code getHashValue() const override {
514523 return hash_combine(getExpressionType(), VariableValue->getType(),
515524 VariableValue);
516525 }
518527 //
519528 // Debugging support
520529 //
521 virtual void printInternal(raw_ostream &OS, bool PrintEType) const override {
530 void printInternal(raw_ostream &OS, bool PrintEType) const override {
522531 if (PrintEType)
523532 OS << "ExpressionTypeVariable, ";
524533 this->Expression::printInternal(OS, false);
528537
529538 class ConstantExpression final : public Expression {
530539 private:
531 Constant *ConstantValue;
532
533 public:
534 static bool classof(const Expression *EB) {
535 return EB->getExpressionType() == ET_Constant;
536 }
537
538 ConstantExpression() : Expression(ET_Constant), ConstantValue(NULL) {}
540 Constant *ConstantValue = nullptr;
541
542 public:
543 ConstantExpression() : Expression(ET_Constant) {}
539544 ConstantExpression(Constant *constantValue)
540545 : Expression(ET_Constant), ConstantValue(constantValue) {}
541 void operator=(const ConstantExpression &) = delete;
542546 ConstantExpression(const ConstantExpression &) = delete;
547 ConstantExpression &operator=(const ConstantExpression &) = delete;
548
549 static bool classof(const Expression *EB) {
550 return EB->getExpressionType() == ET_Constant;
551 }
543552
544553 Constant *getConstantValue() const { return ConstantValue; }
545554 void setConstantValue(Constant *V) { ConstantValue = V; }
546555
547 virtual bool equals(const Expression &Other) const override {
556 bool equals(const Expression &Other) const override {
548557 const ConstantExpression &OC = cast(Other);
549558 return ConstantValue == OC.ConstantValue;
550559 }
551560
552 virtual hash_code getHashValue() const override {
561 hash_code getHashValue() const override {
553562 return hash_combine(getExpressionType(), ConstantValue->getType(),
554563 ConstantValue);
555564 }
557566 //
558567 // Debugging support
559568 //
560 virtual void printInternal(raw_ostream &OS, bool PrintEType) const override {
569 void printInternal(raw_ostream &OS, bool PrintEType) const override {
561570 if (PrintEType)
562571 OS << "ExpressionTypeConstant, ";
563572 this->Expression::printInternal(OS, false);
570579 Instruction *Inst;
571580
572581 public:
582 UnknownExpression(Instruction *I) : Expression(ET_Unknown), Inst(I) {}
583 UnknownExpression() = delete;
584 UnknownExpression(const UnknownExpression &) = delete;
585 UnknownExpression &operator=(const UnknownExpression &) = delete;
586
573587 static bool classof(const Expression *EB) {
574588 return EB->getExpressionType() == ET_Unknown;
575589 }
576
577 UnknownExpression(Instruction *I) : Expression(ET_Unknown), Inst(I) {}
578 void operator=(const UnknownExpression &) = delete;
579 UnknownExpression(const UnknownExpression &) = delete;
580 UnknownExpression() = delete;
581590
582591 Instruction *getInstruction() const { return Inst; }
583592 void setInstruction(Instruction *I) { Inst = I; }
584 virtual bool equals(const Expression &Other) const override {
593
594 bool equals(const Expression &Other) const override {
585595 const auto &OU = cast(Other);
586596 return Inst == OU.Inst;
587597 }
588 virtual hash_code getHashValue() const override {
598
599 hash_code getHashValue() const override {
589600 return hash_combine(getExpressionType(), Inst);
590601 }
591 //
592 // Debugging support
593 //
594 virtual void printInternal(raw_ostream &OS, bool PrintEType) const override {
602
603 //
604 // Debugging support
605 //
606 void printInternal(raw_ostream &OS, bool PrintEType) const override {
595607 if (PrintEType)
596608 OS << "ExpressionTypeUnknown, ";
597609 this->Expression::printInternal(OS, false);
598610 OS << " inst = " << *Inst;
599611 }
600612 };
601 }
602 }
603
604 #endif
613
614 } // end namespace GVNExpression
615
616 } // end namespace llvm
617
618 #endif // LLVM_TRANSFORMS_SCALAR_GVNEXPRESSION_H
2121 /// An optimization pass inserting data prefetches in loops.
2222 class LoopDataPrefetchPass : public PassInfoMixin {
2323 public:
24 LoopDataPrefetchPass() {}
24 LoopDataPrefetchPass() = default;
25
2526 /// \brief Run the pass over the function.
2627 PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
2728 };
28 }
2929
30 #endif
30 } // end namespace llvm
31
32 #endif // LLVM_TRANSFORMS_SCALAR_LOOPDATAPREFETCH_H
None //===- LoopDeletion.h - Loop Deletion -------------------------------------===//
0 //===- LoopDeletion.h - Loop Deletion ---------------------------*- C++ -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
1313 #ifndef LLVM_TRANSFORMS_SCALAR_LOOPDELETION_H
1414 #define LLVM_TRANSFORMS_SCALAR_LOOPDELETION_H
1515
16 #include "llvm/Analysis/LoopAnalysisManager.h"
1617 #include "llvm/Analysis/LoopInfo.h"
1718 #include "llvm/Analysis/ScalarEvolution.h"
1819 #include "llvm/IR/PassManager.h"
2223
2324 class LoopDeletionPass : public PassInfoMixin {
2425 public:
25 LoopDeletionPass() {}
26 LoopDeletionPass() = default;
27
2628 PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM,
2729 LoopStandardAnalysisResults &AR, LPMUpdater &U);
2830 };
29 }
31
32 } // end namespace llvm
3033
3134 #endif // LLVM_TRANSFORMS_SCALAR_LOOPDELETION_H
1414 #ifndef LLVM_TRANSFORMS_SCALAR_MEMCPYOPTIMIZER_H
1515 #define LLVM_TRANSFORMS_SCALAR_MEMCPYOPTIMIZER_H
1616
17 #include "llvm/ADT/STLExtras.h"
1817 #include "llvm/Analysis/AliasAnalysis.h"
1918 #include "llvm/Analysis/AssumptionCache.h"
20 #include "llvm/Analysis/GlobalsModRef.h"
2119 #include "llvm/Analysis/MemoryDependenceAnalysis.h"
2220 #include "llvm/Analysis/TargetLibraryInfo.h"
21 #include "llvm/IR/BasicBlock.h"
2322 #include "llvm/IR/Dominators.h"
2423 #include "llvm/IR/Function.h"
2524 #include "llvm/IR/Instructions.h"
2625 #include "llvm/IR/IntrinsicInst.h"
2726 #include "llvm/IR/PassManager.h"
27 #include
28 #include
2829
2930 namespace llvm {
3031
3637 std::function LookupDomTree;
3738
3839 public:
39 MemCpyOptPass() {}
40 MemCpyOptPass() = default;
41
4042 PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
4143 // Glue for the old PM.
4244 bool runImpl(Function &F, MemoryDependenceResults *MD_,
6264
6365 bool iterateOnFunction(Function &F);
6466 };
65 }
67
68 } // end namespace llvm
6669
6770 #endif // LLVM_TRANSFORMS_SCALAR_MEMCPYOPTIMIZER_H
2020 #include "llvm/IR/Dominators.h"
2121 #include "llvm/IR/Function.h"
2222 #include "llvm/IR/PassManager.h"
23 #include "llvm/Support/Compiler.h"
24 #include
2325
2426 namespace llvm {
2527
2628 /// A private "module" namespace for types and utilities used by SROA. These
2729 /// are implementation details and should not be used by clients.
2830 namespace sroa LLVM_LIBRARY_VISIBILITY {
31
2932 class AllocaSliceRewriter;
3033 class AllocaSlices;
3134 class Partition;
3235 class SROALegacyPass;
33 }
36
37 } // end namespace sroa
3438
3539 /// \brief An optimization pass providing Scalar Replacement of Aggregates.
3640 ///
5155 /// this form. By doing so, it will enable promotion of vector aggregates to
5256 /// SSA vector values.
5357 class SROA : public PassInfoMixin {
54 LLVMContext *C;
55 DominatorTree *DT;
56 AssumptionCache *AC;
58 LLVMContext *C = nullptr;
59 DominatorTree *DT = nullptr;
60 AssumptionCache *AC = nullptr;
5761
5862 /// \brief Worklist of alloca instructions to simplify.
5963 ///
98102 SetVector> SpeculatableSelects;
99103
100104 public:
101 SROA() : C(nullptr), DT(nullptr), AC(nullptr) {}
105 SROA() = default;
102106
103107 /// \brief Run the pass over the function.
104108 PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
121125 bool promoteAllocas(Function &F);
122126 };
123127
124 }
128 } // end namespace llvm
125129
126 #endif
130 #endif // LLVM_TRANSFORMS_SCALAR_SROA_H
4242 /// This keeps track of which value to use on a per-block basis. When we
4343 /// insert PHI nodes, we keep track of them here.
4444 //typedef DenseMap AvailableValsTy;
45 void *AV;
45 void *AV = nullptr;
4646
4747 /// ProtoType holds the type of the values being rewritten.
48 Type *ProtoType;
48 Type *ProtoType = nullptr;
4949
5050 /// PHI nodes are given a name based on ProtoName.
5151 std::string ProtoName;
1313 //===----------------------------------------------------------------------===//
1414
1515 #include "llvm/Transforms/InstrProfiling.h"
16 #include "llvm/ADT/ArrayRef.h"
17 #include "llvm/ADT/SmallVector.h"
18 #include "llvm/ADT/StringRef.h"
1619 #include "llvm/ADT/Triple.h"
20 #include "llvm/ADT/Twine.h"
1721 #include "llvm/Analysis/TargetLibraryInfo.h"
22 #include "llvm/IR/Attributes.h"
23 #include "llvm/IR/BasicBlock.h"
24 #include "llvm/IR/Constant.h"
25 #include "llvm/IR/Constants.h"
26 #include "llvm/IR/DerivedTypes.h"
27 #include "llvm/IR/Function.h"
28 #include "llvm/IR/GlobalValue.h"
29 #include "llvm/IR/GlobalVariable.h"
30 #include "llvm/IR/Instruction.h"
31 #include "llvm/IR/Instructions.h"
32 #include "llvm/IR/IntrinsicInst.h"
1833 #include "llvm/IR/IRBuilder.h"
19 #include "llvm/IR/IntrinsicInst.h"
2034 #include "llvm/IR/Module.h"
35 #include "llvm/IR/Type.h"
36 #include "llvm/Pass.h"
2137 #include "llvm/ProfileData/InstrProf.h"
38 #include "llvm/Support/Casting.h"
39 #include "llvm/Support/CommandLine.h"
40 #include "llvm/Support/Error.h"
41 #include "llvm/Support/ErrorHandling.h"
2242 #include "llvm/Transforms/Utils/ModuleUtils.h"
43 #include
44 #include
45 #include
46 #include
47 #include
2348
2449 using namespace llvm;
2550
4065 "vp-static-alloc",
4166 cl::desc("Do static counter allocation for value profiler"),
4267 cl::init(true));
68
4369 cl::opt NumCountersPerValueSite(
4470 "vp-counters-per-site",
4571 cl::desc("The average number of profile counters allocated "
5581
5682 public:
5783 static char ID;
58 InstrProfilingLegacyPass() : ModulePass(ID), InstrProf() {}
84
85 InstrProfilingLegacyPass() : ModulePass(ID) {}
5986 InstrProfilingLegacyPass(const InstrProfOptions &Options)
6087 : ModulePass(ID), InstrProf(Options) {}
88
6189 StringRef getPassName() const override {
6290 return "Frontend instrumentation-based coverage lowering";
6391 }
72100 }
73101 };
74102
75 } // anonymous namespace
103 } // end anonymous namespace
76104
77105 PreservedAnalyses InstrProfiling::run(Module &M, ModuleAnalysisManager &AM) {
78106 auto &TLI = AM.getResult(M);
207235 }
208236
209237 void InstrProfiling::computeNumValueSiteCounts(InstrProfValueProfileInst *Ind) {
210
211238 GlobalVariable *Name = Ind->getName();
212239 uint64_t ValueKind = Ind->getValueKind()->getZExtValue();
213240 uint64_t Index = Ind->getIndex()->getZExtValue();
221248 }
222249
223250 void InstrProfiling::lowerValueProfileInst(InstrProfValueProfileInst *Ind) {
224
225251 GlobalVariable *Name = Ind->getName();
226252 auto It = ProfileDataMap.find(Name);
227253 assert(It != ProfileDataMap.end() && It->second.DataVar &&
258284 }
259285
260286 void InstrProfiling::lowerCoverageData(GlobalVariable *CoverageNamesVar) {
261
262287 ConstantArray *Names =
263288 cast(CoverageNamesVar->getInitializer());
264289 for (unsigned I = 0, E = Names->getNumOperands(); I < E; ++I) {
375400 // the current function.
376401 Constant *ValuesPtrExpr = ConstantPointerNull::get(Int8PtrTy);
377402 if (ValueProfileStaticAlloc && !needsRuntimeRegistrationOfSectionRange(*M)) {
378
379403 uint64_t NS = 0;
380404 for (uint32_t Kind = IPVK_First; Kind <= IPVK_Last; ++Kind)
381405 NS += PD.NumValueSites[Kind];
391415 ValuesVar->setAlignment(8);
392416 ValuesVar->setComdat(ProfileVarsComdat);
393417 ValuesPtrExpr =
394 ConstantExpr::getBitCast(ValuesVar, llvm::Type::getInt8PtrTy(Ctx));
418 ConstantExpr::getBitCast(ValuesVar, Type::getInt8PtrTy(Ctx));
395419 }
396420 }
397421
480504
481505 ArrayType *VNodesTy = ArrayType::get(VNodeTy, NumCounters);
482506 auto *VNodesVar = new GlobalVariable(
483 *M, VNodesTy, false, llvm::GlobalValue::PrivateLinkage,
507 *M, VNodesTy, false, GlobalValue::PrivateLinkage,
484508 Constant::getNullValue(VNodesTy), getInstrProfVNodesVarName());
485509 VNodesVar->setSection(getInstrProfVNodesSectionName(isMachO()));
486510 UsedVars.push_back(VNodesVar);
495519 std::string CompressedNameStr;
496520 if (Error E = collectPGOFuncNameStrings(ReferencedNames, CompressedNameStr,
497521 DoNameCompression)) {
498 llvm::report_fatal_error(toString(std::move(E)), false);
522 report_fatal_error(toString(std::move(E)), false);
499523 }
500524
501525 auto &Ctx = M->getContext();
502 auto *NamesVal = llvm::ConstantDataArray::getString(
526 auto *NamesVal = ConstantDataArray::getString(
503527 Ctx, StringRef(CompressedNameStr), false);
504 NamesVar = new llvm::GlobalVariable(*M, NamesVal->getType(), true,
505 llvm::GlobalValue::PrivateLinkage,
506 NamesVal, getInstrProfNamesVarName());
528 NamesVar = new GlobalVariable(*M, NamesVal->getType(), true,
529 GlobalValue::PrivateLinkage, NamesVal,
530 getInstrProfNamesVarName());
507531 NamesSize = CompressedNameStr.size();
508532 NamesVar->setSection(getNameSection());
509533 UsedVars.push_back(NamesVar);
549573 }
550574
551575 void InstrProfiling::emitRuntimeHook() {
552
553576 // We expect the linker to be invoked with -u flag for linux,
554577 // for which case there is no need to emit the user function.
555578 if (Triple(M->getTargetTriple()).isOSLinux())
1111 //
1212 //===----------------------------------------------------------------------===//
1313
14 #include "llvm/Transforms/Scalar/MemCpyOptimizer.h"
15 #include "llvm/Transforms/Scalar.h"
1614 #include "llvm/ADT/DenseSet.h"
15 #include "llvm/ADT/iterator_range.h"
1716 #include "llvm/ADT/SmallVector.h"
1817 #include "llvm/ADT/Statistic.h"
18 #include "llvm/ADT/STLExtras.h"
19 #include "llvm/Analysis/AssumptionCache.h"
20 #include "llvm/Analysis/GlobalsModRef.h"
21 #include "llvm/Analysis/MemoryDependenceAnalysis.h"
22 #include "llvm/Analysis/MemoryLocation.h"
23 #include "llvm/Analysis/TargetLibraryInfo.h"
1924 #include "llvm/Analysis/ValueTracking.h"
25 #include "llvm/IR/Argument.h"
26 #include "llvm/IR/Constants.h"
2027 #include "llvm/IR/DataLayout.h"
28 #include "llvm/IR/DerivedTypes.h"
29 #include "llvm/IR/Dominators.h"
30 #include "llvm/IR/Function.h"
2131 #include "llvm/IR/GetElementPtrTypeIterator.h"
2232 #include "llvm/IR/GlobalVariable.h"
33 #include "llvm/IR/InstrTypes.h"
34 #include "llvm/IR/Instruction.h"
35 #include "llvm/IR/Instructions.h"
36 #include "llvm/IR/IntrinsicInst.h"
37 #include "llvm/IR/Intrinsics.h"
2338 #include "llvm/IR/IRBuilder.h"
39 #include "llvm/IR/LLVMContext.h"
40 #include "llvm/IR/Module.h"
41 #include "llvm/IR/Operator.h"
42 #include "llvm/IR/Type.h"
43 #include "llvm/IR/User.h"
44 #include "llvm/IR/Value.h"
45 #include "llvm/Pass.h"
46 #include "llvm/Support/Casting.h"
2447 #include "llvm/Support/Debug.h"
48 #include "llvm/Support/MathExtras.h"
2549 #include "llvm/Support/raw_ostream.h"
50 #include "llvm/Transforms/Scalar.h"
51 #include "llvm/Transforms/Scalar/MemCpyOptimizer.h"
2652 #include "llvm/Transforms/Utils/Local.h"
2753 #include
54 #include
55 #include
56
2857 using namespace llvm;
2958
3059 #define DEBUG_TYPE "memcpyopt"
118147 return true;
119148 }
120149
150 namespace {
121151
122152 /// Represents a range of memset'd bytes with the ByteVal value.
123153 /// This allows us to analyze stores like:
129159 /// the first store, we make a range [1, 2). The second store extends the range
130160 /// to [0, 2). The third makes a new range [2, 3). The fourth store joins the
131161 /// two ranges into [0, 3) which is memset'able.
132 namespace {
133162 struct MemsetRange {
134163 // Start/End - A semi range that describes the span that this range covers.
135164 // The range is closed at the start and open at the end: [Start, End).
147176
148177 bool isProfitableToUseMemset(const DataLayout &DL) const;
149178 };
150 } // end anon namespace
179
180 } // end anonymous namespace
151181
152182 bool MemsetRange::isProfitableToUseMemset(const DataLayout &DL) const {
153183 // If we found more than 4 stores to merge or 16 bytes, use memset.
191221 return TheStores.size() > NumPointerStores+NumByteStores;
192222 }
193223
194
195224 namespace {
225
196226 class MemsetRanges {
197227 /// A sorted list of the memset ranges.
198228 SmallVector Ranges;
199229 typedef SmallVectorImpl::iterator range_iterator;
200230 const DataLayout &DL;
231
201232 public:
202233 MemsetRanges(const DataLayout &DL) : DL(DL) {}
203234
230261
231262 };
232263
233 } // end anon namespace
234
264 } // end anonymous namespace
235265
236266 /// Add a new store to the MemsetRanges data structure. This adds a
237267 /// new range for the specified store at the specified offset, merging into
298328 //===----------------------------------------------------------------------===//
299329
300330 namespace {
331
301332 class MemCpyOptLegacyPass : public FunctionPass {
302333 MemCpyOptPass Impl;
334
303335 public:
304336 static char ID; // Pass identification, replacement for typeid
337
305338 MemCpyOptLegacyPass() : FunctionPass(ID) {
306339 initializeMemCpyOptLegacyPassPass(*PassRegistry::getPassRegistry());
307340 }
339372 };
340373
341374 char MemCpyOptLegacyPass::ID = 0;
342 }
375
376 } // end anonymous namespace
343377
344378 /// The public interface to this file...
345379 FunctionPass *llvm::createMemCpyOptPass() { return new MemCpyOptLegacyPass(); }
522556 if (Args.erase(C))
523557 NeedLift = true;
524558 else if (MayAlias) {
525 NeedLift = any_of(MemLocs, [C, &AA](const MemoryLocation &ML) {
559 NeedLift = llvm::any_of(MemLocs, [C, &AA](const MemoryLocation &ML) {
526560 return AA.getModRefInfo(C, ML);
527561 });
528562
529563 if (!NeedLift)
530 NeedLift = any_of(CallSites, [C, &AA](const ImmutableCallSite &CS) {
531 return AA.getModRefInfo(C, CS);
532 });
564 NeedLift =
565 llvm::any_of(CallSites, [C, &AA](const ImmutableCallSite &CS) {
566 return AA.getModRefInfo(C, CS);
567 });
533568 }
534569
535570 if (!NeedLift)
566601 }
567602
568603 // We made it, we need to lift
569 for (auto *I : reverse(ToLift)) {
604 for (auto *I : llvm::reverse(ToLift)) {
570605 DEBUG(dbgs() << "Lifting " << *I << " before " << *P << "\n");
571606 I->moveBefore(P);
572607 }
760795 return false;
761796 }
762797
763
764798 /// Takes a memcpy and a call that it depends on,
765799 /// and checks for the possibility of a call slot optimization by having
766800 /// the call write its result directly into the destination of the memcpy.
13741408 }
13751409
13761410 PreservedAnalyses MemCpyOptPass::run(Function &F, FunctionAnalysisManager &AM) {
1377
13781411 auto &MD = AM.getResult(F);
13791412 auto &TLI = AM.getResult(F);
13801413
14181451 if (!TLI->has(LibFunc::memset) || !TLI->has(LibFunc::memcpy))
14191452 return false;
14201453
1421 while (1) {
1454 while (true) {
14221455 if (!iterateOnFunction(F))
14231456 break;
14241457 MadeChange = true;
1010 //
1111 //===----------------------------------------------------------------------===//
1212
13 #include "llvm/Transforms/Utils/SSAUpdater.h"
1413 #include "llvm/ADT/DenseMap.h"
14 #include "llvm/ADT/SmallVector.h"
15 #include "llvm/ADT/STLExtras.h"
16 #include "llvm/ADT/StringRef.h"
1517 #include "llvm/ADT/TinyPtrVector.h"
1618 #include "llvm/Analysis/InstructionSimplify.h"
19 #include "llvm/IR/BasicBlock.h"
1720 #include "llvm/IR/CFG.h"
1821 #include "llvm/IR/Constants.h"
22 #include "llvm/IR/DebugLoc.h"
23 #include "llvm/IR/Instruction.h"
1924 #include "llvm/IR/Instructions.h"
20 #include "llvm/IR/IntrinsicInst.h"
2125 #include "llvm/IR/Module.h"
26 #include "llvm/IR/Use.h"
27 #include "llvm/IR/Value.h"
28 #include "llvm/IR/ValueHandle.h"
29 #include "llvm/Support/Casting.h"
2230 #include "llvm/Support/Debug.h"
2331 #include "llvm/Support/raw_ostream.h"
24 #include "llvm/Transforms/Utils/BasicBlockUtils.h"
25 #include "llvm/Transforms/Utils/Local.h"
32 #include "llvm/Transforms/Utils/SSAUpdater.h"
2633 #include "llvm/Transforms/Utils/SSAUpdaterImpl.h"
34 #include
35 #include
2736
2837 using namespace llvm;
2938
3544 }
3645
3746 SSAUpdater::SSAUpdater(SmallVectorImpl *NewPHI)
38 : AV(nullptr), ProtoType(nullptr), ProtoName(), InsertedPHIs(NewPHI) {}
47 : InsertedPHIs(NewPHI) {}
3948
4049 SSAUpdater::~SSAUpdater() {
4150 delete static_cast(AV);
204213 }
205214
206215 namespace llvm {
216
207217 template<>
208218 class SSAUpdaterTraits {
209219 public:
229239 PHI_iterator &operator++() { ++idx; return *this; }
230240 bool operator==(const PHI_iterator& x) const { return idx == x.idx; }
231241 bool operator!=(const PHI_iterator& x) const { return !operator==(x); }
242
232243 Value *getIncomingValue() { return PHI->getIncomingValue(idx); }
233244 BasicBlock *getIncomingBlock() { return PHI->getIncomingBlock(idx); }
234245 };
302313 }
303314 };
304315
305 } // End llvm namespace
316 } // end namespace llvm
306317
307318 /// Check to see if AvailableVals has an entry for the specified BB and if so,
308319 /// return it. If not, construct SSA form by first calculating the required
336347 SSA.Initialize(SomeVal->getType(), BaseName);
337348 }
338349
339
340350 void LoadAndStorePromoter::
341351 run(const SmallVectorImpl &Insts) const {
342
343352 // First step: bucket up uses of the alloca by the block they occur in.
344353 // This is important because we have to handle multiple defs/uses in a block
345354 // ourselves: SSAUpdater is purely for cross-block references.
346 DenseMap > UsesByBlock;
355 DenseMap> UsesByBlock;
347356
348357 for (Instruction *User : Insts)
349358 UsesByBlock[User->getParent()].push_back(User);