[llvm] r359290 - [InferAddressSpaces] Add AS parameter to the pass factory
Sven van Haastregt via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 26 02:21:25 PDT 2019
Author: svenvh
Date: Fri Apr 26 02:21:25 2019
New Revision: 359290
URL: http://llvm.org/viewvc/llvm-project?rev=359290&view=rev
Log:
[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
Modified:
llvm/trunk/include/llvm/Transforms/Scalar.h
llvm/trunk/lib/Transforms/Scalar/InferAddressSpaces.cpp
Modified: llvm/trunk/include/llvm/Transforms/Scalar.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Scalar.h?rev=359290&r1=359289&r2=359290&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Transforms/Scalar.h (original)
+++ llvm/trunk/include/llvm/Transforms/Scalar.h Fri Apr 26 02:21:25 2019
@@ -383,9 +383,10 @@ Pass *createCorrelatedValuePropagationPa
//
// 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;
//===----------------------------------------------------------------------===//
Modified: llvm/trunk/lib/Transforms/Scalar/InferAddressSpaces.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InferAddressSpaces.cpp?rev=359290&r1=359289&r2=359290&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/InferAddressSpaces.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/InferAddressSpaces.cpp Fri Apr 26 02:21:25 2019
@@ -148,7 +148,9 @@ class InferAddressSpaces : public Functi
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(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::rewriteWithNewA
return true;
}
-FunctionPass *llvm::createInferAddressSpacesPass() {
- return new InferAddressSpaces();
+FunctionPass *llvm::createInferAddressSpacesPass(unsigned AddressSpace) {
+ return new InferAddressSpaces(AddressSpace);
}
More information about the llvm-commits
mailing list