24
24
25
25
using namespace swift ;
26
26
27
- static llvm::cl::opt<bool > EnableDumpAll (
28
- " enable-mem-behavior-dump-all" , llvm::cl::init(false ),
29
- llvm::cl::desc(" With -mem-behavior-dump, dump all memory access pairs." ));
30
-
31
27
// ===----------------------------------------------------------------------===//
32
28
// Value Gatherer
33
29
// ===----------------------------------------------------------------------===//
@@ -58,14 +54,25 @@ class MemBehaviorDumper : public SILModuleTransform {
58
54
// To reduce the amount of output, we only dump the memory behavior of
59
55
// selected types of instructions.
60
56
static bool shouldTestInstruction (SILInstruction *I) {
61
- // Only consider function calls.
62
- if ((EnableDumpAll && I->mayReadOrWriteMemory ()) ||
63
- FullApplySite::isa (I) ||
64
- isa<EndApplyInst>(I) ||
65
- isa<AbortApplyInst>(I))
57
+ switch (I->getKind ()) {
58
+ case SILInstructionKind::ApplyInst:
59
+ case SILInstructionKind::TryApplyInst:
60
+ case SILInstructionKind::EndApplyInst:
61
+ case SILInstructionKind::BeginApplyInst:
62
+ case SILInstructionKind::AbortApplyInst:
63
+ case SILInstructionKind::BeginAccessInst:
64
+ case SILInstructionKind::EndAccessInst:
65
+ case SILInstructionKind::EndCOWMutationInst:
66
+ case SILInstructionKind::CopyValueInst:
67
+ case SILInstructionKind::DestroyValueInst:
68
+ case SILInstructionKind::EndBorrowInst:
69
+ case SILInstructionKind::LoadInst:
70
+ case SILInstructionKind::StoreInst:
71
+ case SILInstructionKind::CopyAddrInst:
66
72
return true ;
67
-
68
- return false ;
73
+ default :
74
+ return false ;
75
+ }
69
76
}
70
77
71
78
void run () override {
@@ -88,6 +95,9 @@ class MemBehaviorDumper : public SILModuleTransform {
88
95
for (auto &V : Values) {
89
96
if (V->getDefiningInstruction () == &I)
90
97
continue ;
98
+
99
+ if (!V->getType ().isAddress () && !isa<AddressToPointerInst>(V))
100
+ continue ;
91
101
92
102
bool Read = AA->mayReadFromMemory (&I, V);
93
103
bool Write = AA->mayWriteToMemory (&I, V);
0 commit comments