|
17 | 17 | #include "llvm/IR/Module.h"
|
18 | 18 |
|
19 | 19 | using namespace llvm;
|
20 |
| -using swift::SwiftAAResult; |
21 |
| -using swift::SwiftAAWrapperPass; |
| 20 | +using namespace swift; |
22 | 21 |
|
23 | 22 | //===----------------------------------------------------------------------===//
|
24 | 23 | // Alias Analysis Result
|
25 | 24 | //===----------------------------------------------------------------------===//
|
26 | 25 |
|
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" |
54 | 30 | }
|
| 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; |
55 | 40 |
|
| 41 | + // Otherwise, delegate to the rest of the AA ModRefInfo machinery. |
56 | 42 | return AAResultBase::getModRefInfo(CS, Loc);
|
57 | 43 | }
|
58 | 44 |
|
|
0 commit comments