Skip to content

Commit 8828d8e

Browse files
committed
tests: clean-up MemBehavior tests
Add more relevant instructions to dump in MemBehaviorDumper. Therefore the -enable-mem-behavior-dump-all option can be removed. Also mem-behavior-all.sil into mem-behavior.sil, because the sil-opt command lines don't differ anymore.
1 parent 8978dc8 commit 8828d8e

File tree

4 files changed

+314
-327
lines changed

4 files changed

+314
-327
lines changed

lib/SILOptimizer/UtilityPasses/MemBehaviorDumper.cpp

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@
2424

2525
using namespace swift;
2626

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-
3127
//===----------------------------------------------------------------------===//
3228
// Value Gatherer
3329
//===----------------------------------------------------------------------===//
@@ -58,14 +54,25 @@ class MemBehaviorDumper : public SILModuleTransform {
5854
// To reduce the amount of output, we only dump the memory behavior of
5955
// selected types of instructions.
6056
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:
6672
return true;
67-
68-
return false;
73+
default:
74+
return false;
75+
}
6976
}
7077

7178
void run() override {
@@ -88,6 +95,9 @@ class MemBehaviorDumper : public SILModuleTransform {
8895
for (auto &V : Values) {
8996
if (V->getDefiningInstruction() == &I)
9097
continue;
98+
99+
if (!V->getType().isAddress() && !isa<AddressToPointerInst>(V))
100+
continue;
91101

92102
bool Read = AA->mayReadFromMemory(&I, V);
93103
bool Write = AA->mayWriteToMemory(&I, V);

test/SILOptimizer/mem-behavior-all.sil

Lines changed: 0 additions & 288 deletions
This file was deleted.

0 commit comments

Comments
 (0)