summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/Function.cpp
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2014-05-20 01:23:40 +0000
committerNick Lewycky <nicholas@mxc.ca>2014-05-20 01:23:40 +0000
commitd52b1528c0dd7a5f00e18d9ba974c8ef0e549f0b (patch)
treec00b5abebd9a613232f62650ef6c5cfd5a857e96 /llvm/lib/IR/Function.cpp
parent57cccec4467282be31fb1c8b47bd1a71629ff732 (diff)
downloadbcm5719-llvm-d52b1528c0dd7a5f00e18d9ba974c8ef0e549f0b.tar.gz
bcm5719-llvm-d52b1528c0dd7a5f00e18d9ba974c8ef0e549f0b.zip
Add 'nonnull', a new parameter and return attribute which indicates that the pointer is not null. Instcombine will elide comparisons between these and null. Patch by Luqman Aden!
llvm-svn: 209185
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 de8e66f1bca..fe32c4613e7 100644
--- a/llvm/lib/IR/Function.cpp
+++ b/llvm/lib/IR/Function.cpp
@@ -76,6 +76,14 @@ unsigned Argument::getArgNo() const {
return ArgIdx;
}
+/// hasNonNullAttr - Return true if this argument has the nonnull attribute on
+/// it in its containing function.
+bool Argument::hasNonNullAttr() const {
+ if (!getType()->isPointerTy()) return false;
+ return getParent()->getAttributes().
+ hasAttribute(getArgNo()+1, Attribute::NonNull);
+}
+
/// hasByValAttr - Return true if this argument has the byval attribute on it
/// in its containing function.
bool Argument::hasByValAttr() const {
OpenPOWER on IntegriCloud