aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/Function.cpp
diff options
context:
space:
mode:
authorAndreas Jonson <andjo403@hotmail.com>2024-03-20 12:43:00 +0100
committerGitHub <noreply@github.com>2024-03-20 12:43:00 +0100
commite66cfebb04ff4fcf313905f49dbd863e7113432c (patch)
tree11f5ba3cd889f64b63387240d663a7ada1c80ee2 /llvm/lib/IR/Function.cpp
parentf24d68a1078c4330a764a837eff58e9934637c1a (diff)
downloadllvm-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.cpp8
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);