Skip to content

Commit 431838a

Browse files
committed
Add Global AA pass
1 parent a5825ae commit 431838a

File tree

4 files changed

+17
-0
lines changed

4 files changed

+17
-0
lines changed

Sources/LLVM/PassManager.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,12 @@ public enum Pass {
141141
case scopedNoAliasAA
142142
/// LLVM's primary stateless and local alias analysis.
143143
case basicAliasAnalysis
144+
/// Performs alias and mod/ref analysis for internal global values that
145+
/// do not have their address taken.
146+
///
147+
/// Internal global variables that are only loaded from may be marked as
148+
/// constants.
149+
case globalsAliasAnalysis
144150
/// This pass is used to ensure that functions have at most one return
145151
/// instruction in them. Additionally, it keeps track of which node is
146152
/// the new exit node of the CFG.

Sources/LLVM/PassPipeliner.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,8 @@ extension PassPipeliner {
321321
LLVMAddScopedNoAliasAAPass(passManager)
322322
case .basicAliasAnalysis:
323323
LLVMAddBasicAliasAnalysisPass(passManager)
324+
case .globalsAliasAnalysis:
325+
LLVMAddGlobalsAAWrapperPass(passManager)
324326
case .unifyFunctionExitNodes:
325327
LLVMAddUnifyFunctionExitNodesPass(passManager)
326328
case .alwaysInliner:

Sources/llvmshims/include/shim.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ void LLVMAppendExistingBasicBlock(LLVMValueRef Fn,
9898

9999
void LLVMAddAddDiscriminatorsPass(LLVMPassManagerRef PM);
100100

101+
void LLVMAddGlobalsAAWrapperPass(LLVMPassManagerRef PM);
102+
101103
void LLVMAddInternalizePassWithMustPreservePredicate(
102104
LLVMPassManagerRef PM, void *Context,
103105
LLVMBool (*MustPreserve)(LLVMValueRef, void *));

Sources/llvmshims/src/shim.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ extern "C" {
127127
// https://reviews.llvm.org/D58624
128128
void LLVMAddAddDiscriminatorsPass(LLVMPassManagerRef PM);
129129

130+
// https://reviews.llvm.org/D66237
131+
void LLVMAddGlobalsAAWrapperPass(LLVMPassManagerRef PM);
132+
130133
// https://reviews.llvm.org/D62456
131134
void LLVMAddInternalizePassWithMustPreservePredicate(
132135
LLVMPassManagerRef PM, void *Context,
@@ -377,3 +380,7 @@ void LLVMAddInternalizePassWithMustPreservePredicate(
377380
return Pred(wrap(&GV), Context) == 0 ? false : true;
378381
}));
379382
}
383+
384+
void LLVMAddGlobalsAAWrapperPass(LLVMPassManagerRef PM) {
385+
unwrap(PM)->add(createGlobalsAAWrapperPass());
386+
}

0 commit comments

Comments
 (0)