diff --git a/llvm/include/llvm/Transforms/IPO/Attributor.h b/llvm/include/llvm/Transforms/IPO/Attributor.h index d2666d4b86827d..bed180e6717a2e 100644 --- a/llvm/include/llvm/Transforms/IPO/Attributor.h +++ b/llvm/include/llvm/Transforms/IPO/Attributor.h @@ -2047,6 +2047,9 @@ struct AbstractAttribute : public IRPosition { /// This function should return the name of the AbstractAttribute virtual const std::string getName() const = 0; + + /// This function should return the address of the ID of the AbstractAttribute + virtual const char *getIdAddr() const = 0; ///} /// Allow the Attributor access to the protected methods. @@ -2164,6 +2167,15 @@ struct AAReturnedValues /// See AbstractAttribute::getName() const std::string getName() const override { return "AAReturnedValues"; } + /// See AbstractAttribute::getIdAddr() + const char *getIdAddr() const override { return &ID; } + + /// This function should return true if the type of the \p AA is + /// AAReturnedValues + static bool classof(const AbstractAttribute *AA) { + return (AA->getIdAddr() == &ID); + } + /// Unique ID (due to the unique address) static const char ID; }; @@ -2185,6 +2197,14 @@ struct AANoUnwind /// See AbstractAttribute::getName() const std::string getName() const override { return "AANoUnwind"; } + /// See AbstractAttribute::getIdAddr() + const char *getIdAddr() const override { return &ID; } + + /// This function should return true if the type of the \p AA is AANoUnwind + static bool classof(const AbstractAttribute *AA) { + return (AA->getIdAddr() == &ID); + } + /// Unique ID (due to the unique address) static const char ID; }; @@ -2206,6 +2226,14 @@ struct AANoSync /// See AbstractAttribute::getName() const std::string getName() const override { return "AANoSync"; } + /// See AbstractAttribute::getIdAddr() + const char *getIdAddr() const override { return &ID; } + + /// This function should return true if the type of the \p AA is AANoSync + static bool classof(const AbstractAttribute *AA) { + return (AA->getIdAddr() == &ID); + } + /// Unique ID (due to the unique address) static const char ID; }; @@ -2228,6 +2256,14 @@ struct AANonNull /// See AbstractAttribute::getName() const std::string getName() const override { return "AANonNull"; } + /// See AbstractAttribute::getIdAddr() + const char *getIdAddr() const override { return &ID; } + + /// This function should return true if the type of the \p AA is AANonNull + static bool classof(const AbstractAttribute *AA) { + return (AA->getIdAddr() == &ID); + } + /// Unique ID (due to the unique address) static const char ID; }; @@ -2250,6 +2286,14 @@ struct AANoRecurse /// See AbstractAttribute::getName() const std::string getName() const override { return "AANoRecurse"; } + /// See AbstractAttribute::getIdAddr() + const char *getIdAddr() const override { return &ID; } + + /// This function should return true if the type of the \p AA is AANoRecurse + static bool classof(const AbstractAttribute *AA) { + return (AA->getIdAddr() == &ID); + } + /// Unique ID (due to the unique address) static const char ID; }; @@ -2272,6 +2316,14 @@ struct AAWillReturn /// See AbstractAttribute::getName() const std::string getName() const override { return "AAWillReturn"; } + /// See AbstractAttribute::getIdAddr() + const char *getIdAddr() const override { return &ID; } + + /// This function should return true if the type of the \p AA is AAWillReturn + static bool classof(const AbstractAttribute *AA) { + return (AA->getIdAddr() == &ID); + } + /// Unique ID (due to the unique address) static const char ID; }; @@ -2301,6 +2353,15 @@ struct AAUndefinedBehavior /// See AbstractAttribute::getName() const std::string getName() const override { return "AAUndefinedBehavior"; } + /// See AbstractAttribute::getIdAddr() + const char *getIdAddr() const override { return &ID; } + + /// This function should return true if the type of the \p AA is + /// AAUndefineBehavior + static bool classof(const AbstractAttribute *AA) { + return (AA->getIdAddr() == &ID); + } + /// Unique ID (due to the unique address) static const char ID; }; @@ -2332,6 +2393,15 @@ struct AAReachability : public StateWrapper { /// See AbstractAttribute::getName() const std::string getName() const override { return "AAReachability"; } + /// See AbstractAttribute::getIdAddr() + const char *getIdAddr() const override { return &ID; } + + /// This function should return true if the type of the \p AA is + /// AAReachability + static bool classof(const AbstractAttribute *AA) { + return (AA->getIdAddr() == &ID); + } + /// Unique ID (due to the unique address) static const char ID; }; @@ -2354,6 +2424,14 @@ struct AANoAlias /// See AbstractAttribute::getName() const std::string getName() const override { return "AANoAlias"; } + /// See AbstractAttribute::getIdAddr() + const char *getIdAddr() const override { return &ID; } + + /// This function should return true if the type of the \p AA is AANoAlias + static bool classof(const AbstractAttribute *AA) { + return (AA->getIdAddr() == &ID); + } + /// Unique ID (due to the unique address) static const char ID; }; @@ -2376,6 +2454,14 @@ struct AANoFree /// See AbstractAttribute::getName() const std::string getName() const override { return "AANoFree"; } + /// See AbstractAttribute::getIdAddr() + const char *getIdAddr() const override { return &ID; } + + /// This function should return true if the type of the \p AA is AANoFree + static bool classof(const AbstractAttribute *AA) { + return (AA->getIdAddr() == &ID); + } + /// Unique ID (due to the unique address) static const char ID; }; @@ -2398,6 +2484,14 @@ struct AANoReturn /// See AbstractAttribute::getName() const std::string getName() const override { return "AANoReturn"; } + /// See AbstractAttribute::getIdAddr() + const char *getIdAddr() const override { return &ID; } + + /// This function should return true if the type of the \p AA is AANoReturn + static bool classof(const AbstractAttribute *AA) { + return (AA->getIdAddr() == &ID); + } + /// Unique ID (due to the unique address) static const char ID; }; @@ -2455,6 +2549,14 @@ struct AAIsDead : public StateWrapper { /// See AbstractAttribute::getName() const std::string getName() const override { return "AAIsDead"; } + /// See AbstractAttribute::getIdAddr() + const char *getIdAddr() const override { return &ID; } + + /// This function should return true if the type of the \p AA is AAIsDead + static bool classof(const AbstractAttribute *AA) { + return (AA->getIdAddr() == &ID); + } + /// Unique ID (due to the unique address) static const char ID; @@ -2648,6 +2750,15 @@ struct AADereferenceable /// See AbstractAttribute::getName() const std::string getName() const override { return "AADereferenceable"; } + /// See AbstractAttribute::getIdAddr() + const char *getIdAddr() const override { return &ID; } + + /// This function should return true if the type of the \p AA is + /// AADereferenceable + static bool classof(const AbstractAttribute *AA) { + return (AA->getIdAddr() == &ID); + } + /// Unique ID (due to the unique address) static const char ID; }; @@ -2669,6 +2780,14 @@ struct AAAlign : public IRAttribute< /// See AbstractAttribute::getName() const std::string getName() const override { return "AAAlign"; } + /// See AbstractAttribute::getIdAddr() + const char *getIdAddr() const override { return &ID; } + + /// This function should return true if the type of the \p AA is AAAlign + static bool classof(const AbstractAttribute *AA) { + return (AA->getIdAddr() == &ID); + } + /// Create an abstract attribute view for the position \p IRP. static AAAlign &createForPosition(const IRPosition &IRP, Attributor &A); @@ -2726,6 +2845,14 @@ struct AANoCapture /// See AbstractAttribute::getName() const std::string getName() const override { return "AANoCapture"; } + /// See AbstractAttribute::getIdAddr() + const char *getIdAddr() const override { return &ID; } + + /// This function should return true if the type of the \p AA is AANoCapture + static bool classof(const AbstractAttribute *AA) { + return (AA->getIdAddr() == &ID); + } + /// Unique ID (due to the unique address) static const char ID; }; @@ -2747,6 +2874,15 @@ struct AAValueSimplify : public StateWrapper { /// See AbstractAttribute::getName() const std::string getName() const override { return "AAValueSimplify"; } + /// See AbstractAttribute::getIdAddr() + const char *getIdAddr() const override { return &ID; } + + /// This function should return true if the type of the \p AA is + /// AAValueSimplify + static bool classof(const AbstractAttribute *AA) { + return (AA->getIdAddr() == &ID); + } + /// Unique ID (due to the unique address) static const char ID; }; @@ -2767,6 +2903,14 @@ struct AAHeapToStack : public StateWrapper { /// See AbstractAttribute::getName() const std::string getName() const override { return "AAHeapToStack"; } + /// See AbstractAttribute::getIdAddr() + const char *getIdAddr() const override { return &ID; } + + /// This function should return true if the type of the \p AA is AAHeapToStack + static bool classof(const AbstractAttribute *AA) { + return (AA->getIdAddr() == &ID); + } + /// Unique ID (due to the unique address) static const char ID; }; @@ -2803,6 +2947,15 @@ struct AAPrivatizablePtr /// See AbstractAttribute::getName() const std::string getName() const override { return "AAPrivatizablePtr"; } + /// See AbstractAttribute::getIdAddr() + const char *getIdAddr() const override { return &ID; } + + /// This function should return true if the type of the \p AA is + /// AAPricatizablePtr + static bool classof(const AbstractAttribute *AA) { + return (AA->getIdAddr() == &ID); + } + /// Unique ID (due to the unique address) static const char ID; }; @@ -2857,6 +3010,15 @@ struct AAMemoryBehavior /// See AbstractAttribute::getName() const std::string getName() const override { return "AAMemoryBehavior"; } + /// See AbstractAttribute::getIdAddr() + const char *getIdAddr() const override { return &ID; } + + /// This function should return true if the type of the \p AA is + /// AAMemoryBehavior + static bool classof(const AbstractAttribute *AA) { + return (AA->getIdAddr() == &ID); + } + /// Unique ID (due to the unique address) static const char ID; }; @@ -3018,6 +3180,15 @@ struct AAMemoryLocation /// See AbstractAttribute::getName() const std::string getName() const override { return "AAMemoryLocation"; } + /// See AbstractAttribute::getIdAddr() + const char *getIdAddr() const override { return &ID; } + + /// This function should return true if the type of the \p AA is + /// AAMemoryLocation + static bool classof(const AbstractAttribute *AA) { + return (AA->getIdAddr() == &ID); + } + /// Unique ID (due to the unique address) static const char ID; }; @@ -3066,6 +3237,15 @@ struct AAValueConstantRange /// See AbstractAttribute::getName() const std::string getName() const override { return "AAValueConstantRange"; } + /// See AbstractAttribute::getIdAddr() + const char *getIdAddr() const override { return &ID; } + + /// This function should return true if the type of the \p AA is + /// AAValueConstantRange + static bool classof(const AbstractAttribute *AA) { + return (AA->getIdAddr() == &ID); + } + /// Unique ID (due to the unique address) static const char ID; }; diff --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp index 6e5625d26c38b3..f96dac5f3515c9 100644 --- a/llvm/lib/Transforms/IPO/Attributor.cpp +++ b/llvm/lib/Transforms/IPO/Attributor.cpp @@ -23,6 +23,7 @@ #include "llvm/IR/NoFolder.h" #include "llvm/IR/Verifier.h" #include "llvm/InitializePasses.h" +#include "llvm/Support/Casting.h" #include "llvm/Support/CommandLine.h" #include "llvm/Transforms/Utils/BasicBlockUtils.h" #include "llvm/Transforms/Utils/Local.h" diff --git a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp index 2a3b2abf617629..1da47e97e3bd8c 100644 --- a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp +++ b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp @@ -1113,6 +1113,14 @@ struct AAICVTracker : public StateWrapper { /// See AbstractAttribute::getName() const std::string getName() const override { return "AAICVTracker"; } + /// See AbstractAttribute::getIdAddr() + const char *getIdAddr() const override { return &ID; } + + /// This function should return true if the type of the \p AA is AAICVTracker + static bool classof(const AbstractAttribute *AA) { + return (AA->getIdAddr() == &ID); + } + static const char ID; };