LLVM: include/llvm/Analysis/MemorySSA.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85#ifndef LLVM_ANALYSIS_MEMORYSSA_H

86#define LLVM_ANALYSIS_MEMORYSSA_H

87

102#include

103#include

104#include

105#include

106#include

107#include

108

109namespace llvm {

110

111template struct GraphTraits;

119

126

127enum : unsigned {

128

129

131};

132

133template class memoryaccess_def_iterator_base;

137

138

139

142 public ilist_node<MemoryAccess, ilist_tagMSSAHelpers::AllAccessTag>,

143 public ilist_node<MemoryAccess, ilist_tagMSSAHelpers::DefsOnlyTag> {

144public:

149

152

153 void *operator new(size_t) = delete;

154

155

156

158 unsigned ID = V->getValueID();

159 return ID == MemoryUseVal || ID == MemoryPhiVal || ID == MemoryDefVal;

160 }

161

163

166

167

170

171

172

173

178

179

180

205

206protected:

212

213

214

216

217

218

219 inline unsigned getID() const;

220

225

226

228

229private:

231};

232

233template <>

237

242

243

244

245

246

247

248

249

251public:

252 void *operator new(size_t) = delete;

253

255

256

258

259

261

265

266

268

270

272

273

274

275

277

278protected:

281

286 MemoryInstruction(MI) {

288 }

289

290

292

294 if (!Optimized) {

296 return;

297 }

299 }

300

301private:

303};

304

305

306

307

308

309

312

313public:

315

318

319

320 void *operator new(size_t S) { return User::operator new(S, AllocMarker); }

321 void operator delete(void *Ptr) { User::operator delete(Ptr); }

322

324 return MA->getValueID() == MemoryUseVal;

325 }

326

328

330 OptimizedID = DMA->getID();

332 }

333

334

335

336

340

344

348

349protected:

351

352private:

354

356};

357

358template <>

361

362

363

364

365

366

367

368

369

370

373

374public:

376

378

380 unsigned Ver)

381 : MemoryUseOrDef(C, DMA, MemoryDefVal, deleteMe, MI, BB, AllocMarker),

382 ID(Ver) {}

383

384

385 void *operator new(size_t S) { return User::operator new(S, AllocMarker); }

386 void operator delete(void *Ptr) { User::operator delete(Ptr); }

387

389 return MA->getValueID() == MemoryDefVal;

390 }

391

394 OptimizedID = MA->getID();

395 }

396

400

404

409

411

412 unsigned getID() const { return ID; }

413

414private:

416

417 const unsigned ID;

419};

420

421template <>

424

425template <>

446

447

448

449

450

451

452

453

454

455

456

457

458

459

460

461

462

463

464

465

466

467

468

469

470

471

472

473

474

475

476

477

478

481

482

483 void *operator new(size_t S) { return User::operator new(S, AllocMarker); }

484

485public:

486 void operator delete(void *Ptr) { User::operator delete(Ptr); }

487

488

490

492 : MemoryAccess(C, MemoryPhiVal, deleteMe, BB, AllocMarker), ID(Ver),

493 ReservedSpace(NumPreds) {

495 }

496

497

498

501

505

509

511

515

519

523

525

527

528

530

531

534 assert(V && "PHI node got a null value!");

536 }

537

540

541

543

544

545

547 assert(this == U.getUser() && "Iterator doesn't point to PHI's Uses?");

549 }

550

551

552

556

558 assert(BB && "PHI node got a null basic block!");

560 }

561

562

565 growOperands();

566

570 }

571

572

573

577 return I;

578 return -1;

579 }

580

583 assert(Idx >= 0 && "Invalid basic block argument!");

585 }

586

587

590 assert(I < E && "Cannot remove out of bounds Phi entry.");

591

592

593 assert(E >= 2 && "Cannot only remove incoming values in MemoryPhis with "

594 "at least 2 values.");

600 }

601

602

603

609 --I;

610 }

612 "Cannot remove all incoming blocks in a MemoryPhi.");

613 }

614

615

620

621

622

627

629 return V->getValueID() == MemoryPhiVal;

630 }

631

633

634 unsigned getID() const { return ID; }

635

636protected:

638

639

640

641

645

646private:

647

648 const unsigned ID;

649 unsigned ReservedSpace;

650

651

652

653 void growOperands() {

654 unsigned E = getNumOperands();

655

656 ReservedSpace = std::max(E + E / 2, 2u);

657 growHungoffUses(ReservedSpace, true);

658 }

659

660 static void deleteMe(DerivedUser *Self);

661};

662

665 "only memory defs and phis have ids");

667 return MD->getID();

669}

670

673 return MD->isOptimized();

675}

676

679 return MD->getOptimized();

681}

682

685 MD->setOptimized(MA);

686 else

688}

689

692 MD->resetOptimized();

693 else

695}

696

699

700

701

703public:

706

707

708

710

712

715

716

717

718

719

723

727

729

732

733

734

735

736

737

738

739

741 return MA == LiveOnEntryDef.get();

742 }

743

745 return LiveOnEntryDef.get();

746 }

747

748

749

750

751

752

756

757

758

759

763

764

765

766

767

771

772

773

776

777

778

780

781

782

784

786

787

789 verifyMemorySSA(VerificationLevel = VerificationLevel::Fast) const;

790

791

792

794

795

796

797

798

799

800 LLVM_ABI void ensureOptimizedUses();

801

803

804protected:

805

807

808 template

813

814

816 auto It = PerBlockAccesses.find(BB);

817 return It == PerBlockAccesses.end() ? nullptr : It->second.get();

818 }

819

820

822 auto It = PerBlockDefs.find(BB);

823 return It == PerBlockDefs.end() ? nullptr : It->second.get();

824 }

825

826

827

828

829

831 AccessList::iterator Where);

833 InsertionPlace Point);

834

835

838 renamePass(DT->getNode(BB), IncomingVal, Visited, true, true);

839 }

840

844 InsertionPlace);

846 AccessList::iterator);

850 bool CreationMustSucceed = true);

851

852private:

853 class ClobberWalkerBase;

854 class CachingWalker;

855 class SkipSelfWalker;

856 class OptimizeUses;

857

858 CachingWalker *getWalkerImpl();

859 template

860 void buildMemorySSA(BatchAAResults &BAA, IterT Blocks);

861

864

867

868 void markUnreachableAsLiveOnEntry(BasicBlock *BB);

870 template

878 bool SkipVisited = false,

879 bool RenameAllUses = false);

880 AccessList *getOrCreateAccessList(const BasicBlock *);

881 DefsList *getOrCreateDefsList(const BasicBlock *);

882 void renumberBlock(const BasicBlock *) const;

886 Loop *L = nullptr;

887

888

890

891

892

893

894

895

896

897 AccessMap PerBlockAccesses;

898 DefsMap PerBlockDefs;

899 std::unique_ptr<MemoryAccess, ValueDeleter> LiveOnEntryDef;

900

901

902

903

906

907

908 std::unique_ptr WalkerBase;

909 std::unique_ptr Walker;

910 std::unique_ptr SkipWalker;

911 unsigned NextID = 0;

912 bool IsOptimized = false;

913};

914

915

916

917

918

919

921

922

924protected:

927

928

932};

933

934

935

938

940

941public:

942

943

944

947

949

950 std::unique_ptr MSSA;

951

953 FunctionAnalysisManager::Invalidator &Inv);

954 };

955

957};

958

959

962 bool EnsureOptimizedUses;

963

964public:

966 : OS(OS), EnsureOptimizedUses(EnsureOptimizedUses) {}

967

969

971};

972

973

975 : public PassInfoMixin {

977

978public:

980

982

984};

985

986

991

992

994public:

996

998

1003

1004 void getAnalysisUsage(AnalysisUsage &AU) const override;

1005

1006 void verifyAnalysis() const override;

1008

1009private:

1010 std::unique_ptr MSSA;

1011};

1012

1013

1014

1015

1016

1017

1018

1019

1020

1021

1022

1023

1025public:

1028

1030

1031

1032

1033

1034

1035

1036

1037

1038

1039

1040

1041

1042

1043

1044

1045

1046

1047

1048

1049

1050

1051

1052

1056 assert(MA && "Handed an instruction that MemorySSA doesn't recognize?");

1058 }

1059

1060

1061

1064

1065

1066

1067

1068

1069

1070

1071

1072

1073

1074

1075

1079

1084

1089

1095

1096

1097

1098

1099

1100

1102

1103protected:

1104 friend class MemorySSA;

1105

1107};

1108

1109

1110

1112public:

1113

1114

1116

1122};

1123

1126

1127

1128

1129template

1132 std::forward_iterator_tag, T, ptrdiff_t, T *,

1133 T *> {

1134 using BaseT = typename memoryaccess_def_iterator_base::iterator_facade_base;

1135

1136public:

1139

1141 return Access == Other.Access && (!Access || ArgNo == Other.ArgNo);

1142 }

1143

1144

1145

1146

1147

1148

1149

1152 assert(MP && "Tried to get phi arg block when not iterating over a PHI");

1154 }

1155

1156 typename std::iterator_traits::pointer operator*() const {

1157 assert(Access && "Tried to access past the end of our iterator");

1158

1159

1161 return MP->getIncomingValue(ArgNo);

1163 }

1164

1165 using BaseT::operator++;

1167 assert(Access && "Hit end of iterator");

1169 if (++ArgNo >= MP->getNumIncomingValues()) {

1170 ArgNo = 0;

1171 Access = nullptr;

1172 }

1173 } else {

1174 Access = nullptr;

1175 }

1176 return *this;

1177 }

1178

1179private:

1181 unsigned ArgNo = 0;

1182};

1183

1187

1191

1195

1199

1200

1201

1210

1219

1220

1221

1222

1223

1224

1225

1226

1227

1230 std::forward_iterator_tag,

1231 const MemoryAccessPair> {

1232 using BaseT = upward_defs_iterator::iterator_facade_base;

1233

1234public:

1236 : DefIterator(Info.first), Location(Info.second),

1237 OriginalAccess(Info.first), DT(DT) {

1238 CurrentPair.first = nullptr;

1239

1241 fillInCurrentPair();

1242 }

1243

1245

1247 return DefIterator == Other.DefIterator;

1248 }

1249

1250 std::iterator_traits::reference operator*() const {

1251 assert(DefIterator != OriginalAccess->defs_end() &&

1252 "Tried to access past the end of our iterator");

1253 return CurrentPair;

1254 }

1255

1256 using BaseT::operator++;

1258 assert(DefIterator != OriginalAccess->defs_end() &&

1259 "Tried to access past the end of the iterator");

1260 ++DefIterator;

1261 if (DefIterator != OriginalAccess->defs_end())

1262 fillInCurrentPair();

1263 return *this;

1264 }

1265

1267

1268private:

1269

1270

1271

1272 LLVM_ABI bool IsGuaranteedLoopInvariant(const Value *Ptr) const;

1273

1274 void fillInCurrentPair() {

1275 CurrentPair.first = *DefIterator;

1276 CurrentPair.second = Location;

1277 if (WalkingPhi && Location.Ptr) {

1279 const_cast<Value *>(Location.Ptr),

1281

1282 if (Value *Addr =

1283 Translator.translateValue(OriginalAccess->getBlock(),

1285 if (Addr != CurrentPair.second.Ptr)

1286 CurrentPair.second = CurrentPair.second.getWithNewPtr(Addr);

1287

1288

1289

1290

1291

1292

1293 if (!IsGuaranteedLoopInvariant(CurrentPair.second.Ptr))

1294 CurrentPair.second = CurrentPair.second.getWithNewSize(

1296 }

1297 }

1298

1301 MemoryLocation Location;

1302 MemoryAccess *OriginalAccess = nullptr;

1303 DominatorTree *DT = nullptr;

1304 bool WalkingPhi = false;

1305};

1306

1311

1313

1318

1319

1320

1321

1322

1323

1324

1325

1326

1327

1328

1329

1330

1331

1332template <class T, bool UseOptimizedChain = false>

1335 std::forward_iterator_tag, MemoryAccess *> {

1338

1340

1342

1344 if (UseOptimizedChain && MUD->isOptimized())

1345 MA = MUD->getOptimized();

1346 else

1347 MA = MUD->getDefiningAccess();

1348 } else {

1349 MA = nullptr;

1350 }

1351

1352 return *this;

1353 }

1354

1356

1357private:

1358 T MA;

1359};

1360

1361template

1364#ifdef EXPENSIVE_CHECKS

1366 "UpTo isn't in the def chain!");

1367#endif

1369}

1370

1371template

1376

1377}

1378

1379#endif

assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")

static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)

static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")

static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")

static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")

Analysis containing CSE Info

This file defines the DenseMap class.

early cse Early CSE w MemorySSA

static bool runOnFunction(Function &F, bool PostInlining)

static MemoryAccess * getClobberingMemoryAccess(MemorySSA &MSSA, BatchAAResults &BAA, SinkAndHoistLICMFlags &Flags, MemoryUseOrDef *MA)

This file provides utility analysis objects describing memory locations.

#define DEFINE_TRANSPARENT_OPERAND_ACCESSORS(CLASS, VALUECLASS)

Macro for generating out-of-class operand accessor definitions.

static bool dominates(InstrPosIndexes &PosIndexes, const MachineInstr &A, const MachineInstr &B)

This file defines the SmallPtrSet class.

This file defines the SmallVector class.

Represent the analysis usage information of a pass.

LLVM Basic Block Representation.

LLVM_ABI const DataLayout & getDataLayout() const

Get the data layout of the module this basic block belongs to.

This class is a wrapper over an AAResults, and it is intended to be used only when there are no IR ch...

Extension point for the Value hierarchy.

void(*)(DerivedUser *) DeleteValueTy

DerivedUser(Type *Ty, unsigned VK, AllocInfo AllocInfo, DeleteValueTy DeleteValue)

A MemorySSAWalker that does no alias queries, or anything else.

Definition MemorySSA.h:1111

Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.

This is an important class for using LLVM in a threaded context.

static constexpr LocationSize beforeOrAfterPointer()

Any location before or after the base pointer (but still within the underlying object).

Represents a single loop in the control flow graph.

Definition MemorySSA.h:143

LLVM_ABI void dump() const

AllAccessType::reverse_self_iterator getReverseIterator()

Definition MemorySSA.h:187

friend class MemorySSA

Definition MemorySSA.h:209

AllAccessType::const_self_iterator getIterator() const

Definition MemorySSA.h:184

MemoryAccess(const MemoryAccess &)=delete

static bool classof(const Value *V)

Definition MemorySSA.h:157

friend class MemoryUse

Definition MemorySSA.h:210

friend class MemoryUseOrDef

Definition MemorySSA.h:211

DefsOnlyType::const_self_iterator getDefsIterator() const

Definition MemorySSA.h:196

friend class MemoryPhi

Definition MemorySSA.h:208

DefsOnlyType::self_iterator getDefsIterator()

Definition MemorySSA.h:193

DefsOnlyType::reverse_self_iterator getReverseDefsIterator()

Definition MemorySSA.h:199

ilist_node< MemoryAccess, ilist_tag< MSSAHelpers::AllAccessTag > > AllAccessType

Definition MemorySSA.h:145

DefsOnlyType::const_reverse_self_iterator getReverseDefsIterator() const

Definition MemorySSA.h:202

memoryaccess_def_iterator defs_end()

Definition MemorySSA.h:1192

MemoryAccess(LLVMContext &C, unsigned Vty, DeleteValueTy DeleteValue, BasicBlock *BB, AllocInfo AllocInfo)

Definition MemorySSA.h:221

ilist_node< MemoryAccess, ilist_tag< MSSAHelpers::DefsOnlyTag > > DefsOnlyType

Definition MemorySSA.h:147

friend class MemoryDef

Definition MemorySSA.h:207

BasicBlock * getBlock() const

Definition MemorySSA.h:162

user_iterator iterator

The user iterators for a memory access.

Definition MemorySSA.h:168

AllAccessType::const_reverse_self_iterator getReverseIterator() const

Definition MemorySSA.h:190

LLVM_ABI void print(raw_ostream &OS) const

unsigned getID() const

Used for debugging and tracking things about MemoryAccesses.

Definition MemorySSA.h:663

MemoryAccess & operator=(const MemoryAccess &)=delete

void setBlock(BasicBlock *BB)

Used by MemorySSA to change the block of a MemoryAccess when it is moved.

Definition MemorySSA.h:215

const_user_iterator const_iterator

Definition MemorySSA.h:169

memoryaccess_def_iterator defs_begin()

This iterator walks over all of the defs in a given MemoryAccess.

Definition MemorySSA.h:1184

AllAccessType::self_iterator getIterator()

Get the iterators for the all access list and the defs only list We default to the all access list.

Definition MemorySSA.h:181

Represents a read-write access to memory, whether it is a must-alias, or a may-alias.

Definition MemorySSA.h:371

friend class MemorySSA

Definition MemorySSA.h:375

static bool classof(const Value *MA)

Definition MemorySSA.h:388

void resetOptimized()

Definition MemorySSA.h:405

MemoryAccess * getOptimized() const

Definition MemorySSA.h:397

unsigned getID() const

Definition MemorySSA.h:412

DECLARE_TRANSPARENT_OPERAND_ACCESSORS(MemoryAccess)

bool isOptimized() const

Definition MemorySSA.h:401

MemoryDef(LLVMContext &C, MemoryAccess *DMA, Instruction *MI, BasicBlock *BB, unsigned Ver)

Definition MemorySSA.h:379

void setOptimized(MemoryAccess *MA)

Definition MemorySSA.h:392

Representation for a specific memory location.

Represents phi nodes for memory accesses.

Definition MemorySSA.h:479

void setIncomingBlock(unsigned I, BasicBlock *BB)

Definition MemorySSA.h:557

void allocHungoffUses(unsigned N)

this is more complicated than the generic User::allocHungoffUses, because we have to allocate Uses fo...

Definition MemorySSA.h:642

friend class MemorySSA

Definition MemorySSA.h:637

void setIncomingValue(unsigned I, MemoryAccess *V)

Definition MemorySSA.h:533

static bool classof(const Value *V)

Definition MemorySSA.h:628

void unorderedDeleteIncomingValue(const MemoryAccess *MA)

Definition MemorySSA.h:623

const_block_iterator block_end() const

Definition MemorySSA.h:512

BasicBlock * getIncomingBlock(const Use &U) const

Return incoming basic block corresponding to an operand of the PHI.

Definition MemorySSA.h:546

DECLARE_TRANSPARENT_OPERAND_ACCESSORS(MemoryAccess)

Provide fast operand accessors.

unsigned getNumIncomingValues() const

Return the number of incoming edges.

Definition MemorySSA.h:529

MemoryAccess * getIncomingValueForBlock(const BasicBlock *BB) const

Definition MemorySSA.h:581

block_iterator block_end()

Definition MemorySSA.h:510

const_block_iterator block_begin() const

Definition MemorySSA.h:506

iterator_range< block_iterator > blocks()

Definition MemorySSA.h:516

void unorderedDeleteIncomingIf(Fn &&Pred)

Definition MemorySSA.h:604

void unorderedDeleteIncoming(unsigned I)

Definition MemorySSA.h:588

BasicBlock * getIncomingBlock(unsigned I) const

Return incoming basic block number i.

Definition MemorySSA.h:542

const_op_range incoming_values() const

Definition MemorySSA.h:526

BasicBlock ** block_iterator

Definition MemorySSA.h:499

BasicBlock * getIncomingBlock(MemoryAccess::const_user_iterator I) const

Return incoming basic block corresponding to value use iterator.

Definition MemorySSA.h:553

static unsigned getIncomingValueNumForOperand(unsigned I)

Definition MemorySSA.h:539

void addIncoming(MemoryAccess *V, BasicBlock *BB)

Add an incoming value to the end of the PHI list.

Definition MemorySSA.h:563

op_range incoming_values()

Definition MemorySSA.h:524

void unorderedDeleteIncomingBlock(const BasicBlock *BB)

Definition MemorySSA.h:616

MemoryPhi(LLVMContext &C, BasicBlock *BB, unsigned Ver, unsigned NumPreds=0)

Definition MemorySSA.h:491

MemoryAccess * getIncomingValue(unsigned I) const

Return incoming value number x.

Definition MemorySSA.h:532

static unsigned getOperandNumForIncomingValue(unsigned I)

Definition MemorySSA.h:538

int getBasicBlockIndex(const BasicBlock *BB) const

Return the first index of the specified basic block in the value list for this PHI.

Definition MemorySSA.h:574

iterator_range< const_block_iterator > blocks() const

Definition MemorySSA.h:520

unsigned getID() const

Definition MemorySSA.h:634

BasicBlock *const * const_block_iterator

Definition MemorySSA.h:500

block_iterator block_begin()

Definition MemorySSA.h:502

An analysis that produces MemorySSA for a function.

Definition MemorySSA.h:936

LLVM_ABI Result run(Function &F, FunctionAnalysisManager &AM)

static bool isRequired()

Definition MemorySSA.h:970

LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)

MemorySSAPrinterPass(raw_ostream &OS, bool EnsureOptimizedUses)

Definition MemorySSA.h:965

Definition MemorySSA.h:923

static LLVM_ABI bool defClobbersUseOrDef(MemoryDef *MD, const MemoryUseOrDef *MU, AliasAnalysis &AA)

friend class MemorySSAWalker

Definition MemorySSA.h:926

friend class GVNHoist

Definition MemorySSA.h:925

static bool isRequired()

Definition MemorySSA.h:983

MemorySSAWalkerPrinterPass(raw_ostream &OS)

Definition MemorySSA.h:979

LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)

This is the generic walker interface for walkers of MemorySSA.

Definition MemorySSA.h:1024

SmallVector< MemoryAccess *, 8 > MemoryAccessSet

Definition MemorySSA.h:1029

friend class MemorySSA

Definition MemorySSA.h:1104

MemorySSA * MSSA

Definition MemorySSA.h:1106

MemoryAccess * getClobberingMemoryAccess(const Instruction *I, BatchAAResults &AA)

Given a memory Mod/Ref/ModRef'ing instruction, calling this will give you the nearest dominating Memo...

Definition MemorySSA.h:1053

LLVM_ABI MemorySSAWalker(MemorySSA *)

virtual ~MemorySSAWalker()=default

MemoryAccess * getClobberingMemoryAccess(MemoryAccess *MA, const MemoryLocation &Loc)

Definition MemorySSA.h:1090

virtual void invalidateInfo(MemoryAccess *)

Given a memory access, invalidate anything this walker knows about that access.

Definition MemorySSA.h:1101

virtual MemoryAccess * getClobberingMemoryAccess(MemoryAccess *, const MemoryLocation &, BatchAAResults &AA)=0

Given a potentially clobbering memory access and a new location, calling this will give you the neare...

virtual MemoryAccess * getClobberingMemoryAccess(MemoryAccess *, BatchAAResults &AA)=0

Does the same thing as getClobberingMemoryAccess(const Instruction *I), but takes a MemoryAccess inst...

MemoryAccess * getClobberingMemoryAccess(const Instruction *I)

Definition MemorySSA.h:1080

MemoryAccess * getClobberingMemoryAccess(MemoryAccess *MA)

Definition MemorySSA.h:1085

void releaseMemory() override

releaseMemory() - This member can be implemented by a pass if it wants to be able to release its memo...

MemorySSA & getMSSA()

Definition MemorySSA.h:1001

const MemorySSA & getMSSA() const

Definition MemorySSA.h:1002

static char ID

Definition MemorySSA.h:997

Encapsulates MemorySSA, including all data associated with memory accesses.

Definition MemorySSA.h:702

simple_ilist< MemoryAccess, ilist_tag< MSSAHelpers::DefsOnlyTag > > DefsList

Definition MemorySSA.h:754

AliasAnalysis & getAA()

Definition MemorySSA.h:802

const AccessList * getBlockAccesses(const BasicBlock *BB) const

Return the list of MemoryAccess's for a given basic block.

Definition MemorySSA.h:760

void renamePass(BasicBlock *BB, MemoryAccess *IncomingVal, SmallPtrSetImpl< BasicBlock * > &Visited)

Definition MemorySSA.h:836

LLVM_ABI MemorySSAWalker * getSkipSelfWalker()

LLVM_ABI MemorySSA(Function &, AliasAnalysis *, DominatorTree *)

iplist< MemoryAccess, ilist_tag< MSSAHelpers::AllAccessTag > > AccessList

Definition MemorySSA.h:753

void verifyOrderingDominationAndDefUses(IterT Blocks, VerificationLevel=VerificationLevel::Fast) const

Verify ordering: the order and existence of MemoryAccesses matches the order and existence of memory ...

AccessList * getWritableBlockAccesses(const BasicBlock *BB) const

Definition MemorySSA.h:815

VerificationLevel

Definition MemorySSA.h:785

@ Full

Definition MemorySSA.h:785

@ Fast

Definition MemorySSA.h:785

LLVM_ABI MemorySSAWalker * getWalker()

InsertionPlace

Used in various insertion functions to specify whether we are talking about the beginning or end of a...

Definition MemorySSA.h:793

@ End

Definition MemorySSA.h:793

@ BeforeTerminator

Definition MemorySSA.h:793

@ Beginning

Definition MemorySSA.h:793

DefsList * getWritableBlockDefs(const BasicBlock *BB) const

Definition MemorySSA.h:821

MemorySSA(MemorySSA &&)=delete

DominatorTree & getDomTree() const

Definition MemorySSA.h:728

MemoryUseOrDef * getMemoryAccess(const Instruction *I) const

Given a memory Mod/Ref'ing instruction, get the MemorySSA access associated with it.

Definition MemorySSA.h:720

friend class MemorySSAUpdater

Definition MemorySSA.h:806

MemoryPhi * getMemoryAccess(const BasicBlock *BB) const

Definition MemorySSA.h:724

MemoryAccess * getLiveOnEntryDef() const

Definition MemorySSA.h:744

void verifyDominationNumbers(IterT Blocks) const

Verify that all of the blocks we believe to have valid domination numbers actually have valid dominat...

void verifyPrevDefInPhis(IterT Blocks) const

const DefsList * getBlockDefs(const BasicBlock *BB) const

Return the list of MemoryDef's and MemoryPhi's for a given basic block.

Definition MemorySSA.h:768

bool isLiveOnEntryDef(const MemoryAccess *MA) const

Return true if MA represents the live on entry value.

Definition MemorySSA.h:740

Class that has the common methods + fields of memory uses/defs.

Definition MemorySSA.h:250

friend class MemorySSA

Definition MemorySSA.h:279

MemoryUseOrDef(LLVMContext &C, MemoryAccess *DMA, unsigned Vty, DeleteValueTy DeleteValue, Instruction *MI, BasicBlock *BB, AllocInfo AllocInfo)

Definition MemorySSA.h:282

~MemoryUseOrDef()=default

MemoryAccess * getDefiningAccess() const

Get the access that produces the memory state used by this Use.

Definition MemorySSA.h:260

void resetOptimized()

Reset the ID of what this MemoryUse was optimized to, causing it to be rewalked by the walker if nece...

Definition MemorySSA.h:690

MemoryAccess * getOptimized() const

Return the MemoryAccess associated with the optimized use, or nullptr.

Definition MemorySSA.h:677

void setDefiningAccess(MemoryAccess *DMA, bool Optimized=false)

Definition MemorySSA.h:293

void setOptimized(MemoryAccess *)

Sets the optimized use for a MemoryDef.

Definition MemorySSA.h:683

DECLARE_TRANSPARENT_OPERAND_ACCESSORS(MemoryAccess)

Instruction * getMemoryInst() const

Get the instruction that this MemoryUse represents.

Definition MemorySSA.h:257

friend class MemorySSAUpdater

Definition MemorySSA.h:280

static bool classof(const Value *MA)

Definition MemorySSA.h:262

bool isOptimized() const

Do we have an optimized use?

Definition MemorySSA.h:671

Represents read-only accesses to memory.

Definition MemorySSA.h:310

friend class MemorySSA

Definition MemorySSA.h:350

MemoryAccess * getOptimized() const

Definition MemorySSA.h:341

DECLARE_TRANSPARENT_OPERAND_ACCESSORS(MemoryAccess)

MemoryUse(LLVMContext &C, MemoryAccess *DMA, Instruction *MI, BasicBlock *BB)

Definition MemorySSA.h:316

LLVM_ABI void print(raw_ostream &OS) const

void resetOptimized()

Definition MemorySSA.h:345

bool isOptimized() const

Whether the MemoryUse is optimized.

Definition MemorySSA.h:337

static bool classof(const Value *MA)

Definition MemorySSA.h:323

void setOptimized(MemoryAccess *DMA)

Definition MemorySSA.h:329

A Module instance is used to store all the information related to an LLVM module.

PHITransAddr - An address value which tracks and handles phi translation.

A set of analyses that are preserved following a run of a transformation pass.

A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...

SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.

This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.

The instances of the Type class are immutable: once they are created, they are never changed.

A Use represents the edge between a Value definition and its users.

iterator_range< const_op_iterator > const_op_range

void setOperand(unsigned i, Value *Val)

void setNumHungOffUseOperands(unsigned NumOps)

Subclasses with hung off uses need to manage the operand count themselves.

iterator_range< op_iterator > op_range

LLVM_ABI void allocHungoffUses(unsigned N, bool IsPhi=false)

Allocate the array of Uses, followed by a pointer (with bottom bit set) to the User.

Value * getOperand(unsigned i) const

unsigned getNumOperands() const

LLVM Value Representation.

user_iterator_impl< const User > const_user_iterator

unsigned getValueID() const

Return an ID for the concrete type of this object.

LLVM_ABI void deleteValue()

Delete a pointer to a generic Value.

user_iterator_impl< User > user_iterator

ilist_select_iterator_type< OptionsT, false, true > const_self_iterator

ilist_select_iterator_type< OptionsT, true, false > reverse_self_iterator

reverse_self_iterator getReverseIterator()

ilist_select_iterator_type< OptionsT, true, true > const_reverse_self_iterator

self_iterator getIterator()

ilist_select_iterator_type< OptionsT, false, false > self_iterator

An intrusive list with ownership and callbacks specified/controlled by ilist_traits,...

CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of ...

A range adaptor for a pair of iterators.

Iterator base class used to implement const and non-const iterators over the defining accesses of a M...

Definition MemorySSA.h:1133

memoryaccess_def_iterator_base()=default

BasicBlock * getPhiArgBlock() const

Definition MemorySSA.h:1150

std::iterator_traits< BaseT >::pointer operator*() const

Definition MemorySSA.h:1156

bool operator==(const memoryaccess_def_iterator_base &Other) const

Definition MemorySSA.h:1140

memoryaccess_def_iterator_base(T *Start)

Definition MemorySSA.h:1137

memoryaccess_def_iterator_base & operator++()

Definition MemorySSA.h:1166

This class implements an extremely fast bulk output stream that can only output to a stream.

A simple intrusive list implementation.

Provide an iterator that walks defs, giving both the memory access, and the current pointer location,...

Definition MemorySSA.h:1231

upward_defs_iterator(const MemoryAccessPair &Info, DominatorTree *DT)

Definition MemorySSA.h:1235

upward_defs_iterator()

Definition MemorySSA.h:1244

std::iterator_traits< BaseT >::reference operator*() const

Definition MemorySSA.h:1250

BasicBlock * getPhiArgBlock() const

Definition MemorySSA.h:1266

upward_defs_iterator & operator++()

Definition MemorySSA.h:1257

bool operator==(const upward_defs_iterator &Other) const

Definition MemorySSA.h:1246

This file defines the ilist_node class template, which is a convenient base class for creating classe...

This provides a very simple, boring adaptor for a begin and end iterator into a range type.

Abstract Attribute helper functions.

unsigned ID

LLVM IR allows to use arbitrary numbers as calling convention identifiers.

@ C

The default llvm calling convention, compatible with C.

Definition MemorySSA.h:120

This is an optimization pass for GlobalISel generic memory operations.

void dump(const SparseBitVector< ElementSize > &LHS, raw_ostream &out)

auto find(R &&Range, const T &Val)

Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly.

@ INVALID_MEMORYACCESS_ID

Definition MemorySSA.h:130

Printable print(const GCNRegPressure &RP, const GCNSubtarget *ST=nullptr, unsigned DynamicVGPRBlockSize=0)

decltype(auto) dyn_cast(const From &Val)

dyn_cast - Return the argument parameter cast to the specified type.

iterator_range< T > make_range(T x, T y)

Convenience function for iterating over sub-ranges.

auto cast_or_null(const Y &Val)

upward_defs_iterator upward_defs_begin(const MemoryAccessPair &Pair, DominatorTree &DT)

Definition MemorySSA.h:1308

DomTreeNodeBase< BasicBlock > DomTreeNode

std::pair< MemoryAccess *, MemoryLocation > MemoryAccessPair

Definition MemorySSA.h:1124

iterator_range< def_chain_iterator< T > > def_chain(T MA, MemoryAccess *UpTo=nullptr)

Definition MemorySSA.h:1363

bool isa(const From &Val)

isa - Return true if the parameter to the template is an instance of one of the template type argu...

iterator_range(Container &&) -> iterator_range< llvm::detail::IterOfRange< Container > >

LLVM_ABI bool VerifyMemorySSA

Enables verification of MemorySSA.

upward_defs_iterator upward_defs_end()

Definition MemorySSA.h:1312

raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)

OutputIt move(R &&Range, OutputIt Out)

Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.

std::pair< const MemoryAccess *, MemoryLocation > ConstMemoryAccessPair

Definition MemorySSA.h:1125

decltype(auto) cast(const From &Val)

cast - Return the argument parameter cast to the specified type.

memoryaccess_def_iterator_base< const MemoryAccess > const_memoryaccess_def_iterator

Definition MemorySSA.h:135

AnalysisManager< Function > FunctionAnalysisManager

Convenience typedef for the Function analysis manager.

AAResults AliasAnalysis

Temporary typedef for legacy code that uses a generic AliasAnalysis pointer or reference.

iterator_range< upward_defs_iterator > upward_defs(const MemoryAccessPair &Pair, DominatorTree &DT)

Definition MemorySSA.h:1315

memoryaccess_def_iterator_base< MemoryAccess > memoryaccess_def_iterator

Definition MemorySSA.h:134

iterator_range< def_chain_iterator< T, true > > optimized_def_chain(T MA)

Definition MemorySSA.h:1372

Implement std::hash so that hash_code can be used in STL containers.

A CRTP mix-in that provides informational APIs needed for analysis passes.

A special type used by analysis passes to provide an address that identifies that particular analysis...

FixedNumOperandTraits - determine the allocation regime of the Use array when it is a prefix to the U...

static ChildIteratorType child_begin(NodeRef N)

Definition MemorySSA.h:1216

MemoryAccess::iterator ChildIteratorType

Definition MemorySSA.h:1213

static ChildIteratorType child_end(NodeRef N)

Definition MemorySSA.h:1217

static NodeRef getEntryNode(NodeRef N)

Definition MemorySSA.h:1215

MemoryAccess * NodeRef

Definition MemorySSA.h:1212

static ChildIteratorType child_begin(NodeRef N)

Definition MemorySSA.h:1207

MemoryAccess * NodeRef

Definition MemorySSA.h:1203

static ChildIteratorType child_end(NodeRef N)

Definition MemorySSA.h:1208

static NodeRef getEntryNode(NodeRef N)

Definition MemorySSA.h:1206

memoryaccess_def_iterator ChildIteratorType

Definition MemorySSA.h:1204

HungoffOperandTraits - determine the allocation regime of the Use array when it is not a prefix to th...

Definition MemorySSA.h:122

Definition MemorySSA.h:123

Definition MemorySSA.h:945

Result(std::unique_ptr< MemorySSA > &&MSSA)

Definition MemorySSA.h:946

MemorySSA & getMSSA()

Definition MemorySSA.h:948

LLVM_ABI bool invalidate(Function &F, const PreservedAnalyses &PA, FunctionAnalysisManager::Invalidator &Inv)

std::unique_ptr< MemorySSA > MSSA

Definition MemorySSA.h:950

Verifier pass for MemorySSA.

Definition MemorySSA.h:987

LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)

static bool isRequired()

Definition MemorySSA.h:989

static unsigned operands(const MemoryUseOrDef *MUD)

Definition MemorySSA.h:439

static Use * op_end(MemoryUseOrDef *MUD)

Definition MemorySSA.h:433

static Use * op_begin(MemoryUseOrDef *MUD)

Definition MemorySSA.h:427

Compile-time customization of User operands.

A CRTP mix-in to automatically provide informational APIs needed for passes.

Information about how a User object was allocated, to be passed into the User constructor.

Indicates this User has operands "hung off" in another allocation.

Indicates this User has operands co-allocated.

Walks the defining accesses of MemoryDefs.

Definition MemorySSA.h:1335

bool operator==(const def_chain_iterator &O) const

Definition MemorySSA.h:1355

def_chain_iterator & operator++()

Definition MemorySSA.h:1341

T operator*() const

Definition MemorySSA.h:1339

def_chain_iterator()

Definition MemorySSA.h:1336

def_chain_iterator(T MA)

Definition MemorySSA.h:1337

static void deleteNode(MemoryAccess *MA)

Definition MemorySSA.h:235

Use delete by default for iplist and ilist.