Skip to content

Commit 1ed04f8

Browse files
committed
[semantic-arc] Use BaseModRef effects from LLVMSwift.def in LLVMSwiftAA instead of a switch.
1 parent 7f45e39 commit 1ed04f8

File tree

1 file changed

+15
-29
lines changed

1 file changed

+15
-29
lines changed

lib/LLVMPasses/LLVMSwiftAA.cpp

Lines changed: 15 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -17,42 +17,28 @@
1717
#include "llvm/IR/Module.h"
1818

1919
using namespace llvm;
20-
using swift::SwiftAAResult;
21-
using swift::SwiftAAWrapperPass;
20+
using namespace swift;
2221

2322
//===----------------------------------------------------------------------===//
2423
// Alias Analysis Result
2524
//===----------------------------------------------------------------------===//
2625

27-
llvm::ModRefInfo SwiftAAResult::getModRefInfo(llvm::ImmutableCallSite CS,
28-
const llvm::MemoryLocation &Loc) {
29-
// We know the mod-ref behavior of various runtime functions.
30-
switch (classifyInstruction(*CS.getInstruction())) {
31-
case RT_AllocObject:
32-
case RT_NoMemoryAccessed:
33-
case RT_Retain:
34-
case RT_RetainUnowned:
35-
case RT_CheckUnowned:
36-
case RT_ObjCRetain:
37-
case RT_BridgeRetain:
38-
case RT_UnknownRetain:
39-
case RT_RetainN:
40-
case RT_UnknownRetainN:
41-
case RT_BridgeRetainN:
42-
case RT_FixLifetime:
43-
// These entrypoints don't modify any compiler-visible state.
44-
return MRI_NoModRef;
45-
case RT_ReleaseN:
46-
case RT_UnknownReleaseN:
47-
case RT_BridgeReleaseN:
48-
case RT_Release:
49-
case RT_ObjCRelease:
50-
case RT_BridgeRelease:
51-
case RT_UnknownRelease:
52-
case RT_Unknown:
53-
break;
26+
static ModRefInfo getConservativeModRefForKind(const llvm::Instruction &I) {
27+
switch (classifyInstruction(I)) {
28+
#define KIND(Name, MemBehavior) case RT_ ## Name: return MRI_ ## MemBehavior;
29+
#include "LLVMSwift.def"
5430
}
31+
}
32+
33+
ModRefInfo SwiftAAResult::getModRefInfo(llvm::ImmutableCallSite CS,
34+
const llvm::MemoryLocation &Loc) {
35+
// We know at compile time that certain entry points do not modify any
36+
// compiler-visible state ever. Quickly check if we have one of those
37+
// instructions and return if so.
38+
if (MRI_NoModRef == getConservativeModRefForKind(*CS.getInstruction()))
39+
return MRI_NoModRef;
5540

41+
// Otherwise, delegate to the rest of the AA ModRefInfo machinery.
5642
return AAResultBase::getModRefInfo(CS, Loc);
5743
}
5844

0 commit comments

Comments
 (0)