1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 11:02:59 +02:00

[InferAddressSpaces] Add AS parameter to the pass factory

This enables the pass to be used in the absence of
TargetTransformInfo. When the argument isn't passed, the factory
defaults to UninitializedAddressSpace and the flat address space is
obtained from the TargetTransformInfo as before this change. Existing
users won't have to change.

Patch by Kevin Petit.

Differential Revision: https://reviews.llvm.org/D60602

llvm-svn: 359290
This commit is contained in:
Sven van Haastregt 2019-04-26 09:21:25 +00:00
parent 83fd9bda79
commit 49ee27caa1
2 changed files with 14 additions and 8 deletions

View File

@ -383,9 +383,10 @@ Pass *createCorrelatedValuePropagationPass();
//
// InferAddressSpaces - Modify users of addrspacecast instructions with values
// in the source address space if using the destination address space is slower
// on the target.
// on the target. If AddressSpace is left to its default value, it will be
// obtained from the TargetTransformInfo.
//
FunctionPass *createInferAddressSpacesPass();
FunctionPass *createInferAddressSpacesPass(unsigned AddressSpace = ~0u);
extern char &InferAddressSpacesID;
//===----------------------------------------------------------------------===//

View File

@ -148,7 +148,9 @@ class InferAddressSpaces : public FunctionPass {
public:
static char ID;
InferAddressSpaces() : FunctionPass(ID) {}
InferAddressSpaces() :
FunctionPass(ID), FlatAddrSpace(UninitializedAddressSpace) {}
InferAddressSpaces(unsigned AS) : FunctionPass(ID), FlatAddrSpace(AS) {}
void getAnalysisUsage(AnalysisUsage &AU) const override {
AU.setPreservesCFG();
@ -624,9 +626,12 @@ bool InferAddressSpaces::runOnFunction(Function &F) {
const TargetTransformInfo &TTI =
getAnalysis<TargetTransformInfoWrapperPass>().getTTI(F);
FlatAddrSpace = TTI.getFlatAddressSpace();
if (FlatAddrSpace == UninitializedAddressSpace)
return false;
if (FlatAddrSpace == UninitializedAddressSpace) {
FlatAddrSpace = TTI.getFlatAddressSpace();
if (FlatAddrSpace == UninitializedAddressSpace)
return false;
}
// Collects all flat address expressions in postorder.
std::vector<WeakTrackingVH> Postorder = collectFlatAddressExpressions(F);
@ -1018,6 +1023,6 @@ bool InferAddressSpaces::rewriteWithNewAddressSpaces(
return true;
}
FunctionPass *llvm::createInferAddressSpacesPass() {
return new InferAddressSpaces();
FunctionPass *llvm::createInferAddressSpacesPass(unsigned AddressSpace) {
return new InferAddressSpaces(AddressSpace);
}