Index: llvm/include/llvm/Bitcode/LLVMBitCodes.h =================================================================== --- llvm/include/llvm/Bitcode/LLVMBitCodes.h +++ llvm/include/llvm/Bitcode/LLVMBitCodes.h @@ -633,6 +633,7 @@ ATTR_KIND_NOFREE = 62, ATTR_KIND_NOSYNC = 63, ATTR_KIND_SANITIZE_MEMTAG = 64, + ATTR_KIND_REACHABILITY = 65, }; enum ComdatSelectionKindCodes { Index: llvm/include/llvm/IR/Attributes.td =================================================================== --- llvm/include/llvm/IR/Attributes.td +++ llvm/include/llvm/IR/Attributes.td @@ -127,6 +127,9 @@ /// Function must not be optimized. def OptimizeNone : EnumAttr<"optnone">; +/// Reachability from point A to B. +def Reachability: EnumAttr<"reachable">; + /// Function does not access memory. def ReadNone : EnumAttr<"readnone">; Index: llvm/include/llvm/Transforms/IPO/Attributor.h =================================================================== --- llvm/include/llvm/Transforms/IPO/Attributor.h +++ llvm/include/llvm/Transforms/IPO/Attributor.h @@ -1682,6 +1682,29 @@ static const char ID; }; +/// An abstract interface to determine reachability of point A to B. +struct AAReachability + : public StateWrapper, + public IRPosition { + AAReachability(const IRPosition &IRP) : IRPosition(IRP) {} + + /// Returns true if instruction is assumed reachable. + bool getAssumedReachability() const { return getAssumed(); } + + /// Returns true if instruction is known reachable. + bool isKnownReachability() const { return getKnown(); } + + /// Return an IR position, see struct IRPosition. + const IRPosition &getIRPosition() const override { return *this; } + + /// Create an abstract attribute view for the position \p IRP. + static AAReachability &createForPosition(const IRPosition &IRP, + Attributor &A); + + /// Unique ID (due to the unique address) + static const char ID; +}; + /// An abstract interface for all noalias attributes. struct AANoAlias : public IRAttribute