diff options
author | Andreas Jonson <andjo403@hotmail.com> | 2024-03-20 12:43:00 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-20 12:43:00 +0100 |
commit | e66cfebb04ff4fcf313905f49dbd863e7113432c (patch) | |
tree | 11f5ba3cd889f64b63387240d663a7ada1c80ee2 /llvm/lib/IR/Function.cpp | |
parent | f24d68a1078c4330a764a837eff58e9934637c1a (diff) | |
download | llvm-e66cfebb04ff4fcf313905f49dbd863e7113432c.zip llvm-e66cfebb04ff4fcf313905f49dbd863e7113432c.tar.gz llvm-e66cfebb04ff4fcf313905f49dbd863e7113432c.tar.bz2 |
[ValueTracking] Handle range attributes (#85143)
Handle the range attribute in ValueTracking.
Diffstat (limited to 'llvm/lib/IR/Function.cpp')
-rw-r--r-- | llvm/lib/IR/Function.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/lib/IR/Function.cpp b/llvm/lib/IR/Function.cpp index d22e1c1..eb126f1 100644 --- a/llvm/lib/IR/Function.cpp +++ b/llvm/lib/IR/Function.cpp @@ -24,6 +24,7 @@ #include "llvm/IR/Attributes.h" #include "llvm/IR/BasicBlock.h" #include "llvm/IR/Constant.h" +#include "llvm/IR/ConstantRange.h" #include "llvm/IR/Constants.h" #include "llvm/IR/DerivedTypes.h" #include "llvm/IR/GlobalValue.h" @@ -256,6 +257,13 @@ FPClassTest Argument::getNoFPClass() const { return getParent()->getParamNoFPClass(getArgNo()); } +std::optional<ConstantRange> Argument::getRange() const { + const Attribute RangeAttr = getAttribute(llvm::Attribute::Range); + if (RangeAttr.isValid()) + return RangeAttr.getRange(); + return std::nullopt; +} + bool Argument::hasNestAttr() const { if (!getType()->isPointerTy()) return false; return hasAttribute(Attribute::Nest); |