diff options
author | Arnold Schwaighofer <aschwaighofer@apple.com> | 2016-09-10 18:14:54 +0000 |
---|---|---|
committer | Arnold Schwaighofer <aschwaighofer@apple.com> | 2016-09-10 18:14:54 +0000 |
commit | ad83002243b385b991123554ec1254ab255865e3 (patch) | |
tree | 407d8cac2c47ada61138f01d72e68b08d3bca1f6 /llvm | |
parent | 34c4d2abfd7a33f9190d50243811fe219977e981 (diff) | |
download | bcm5719-llvm-ad83002243b385b991123554ec1254ab255865e3.tar.gz bcm5719-llvm-ad83002243b385b991123554ec1254ab255865e3.zip |
Add an isSwiftError predicate to Value
llvm-svn: 281143
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/include/llvm/IR/Value.h | 6 | ||||
-rw-r--r-- | llvm/lib/IR/Value.cpp | 10 |
2 files changed, 16 insertions, 0 deletions
diff --git a/llvm/include/llvm/IR/Value.h b/llvm/include/llvm/IR/Value.h index b3d318cf47f..bb673521c47 100644 --- a/llvm/include/llvm/IR/Value.h +++ b/llvm/include/llvm/IR/Value.h @@ -448,6 +448,12 @@ public: /// \brief Return true if there is metadata referencing this value. bool isUsedByMetadata() const { return IsUsedByMD; } + /// \brief Return true if this value is a swifterror value. + /// + /// swifterror values can be either a function argument or an alloca with a + /// swifterror attribute. + bool isSwiftError() const; + /// \brief Strip off pointer casts, all-zero GEPs, and aliases. /// /// Returns the original uncasted value. If this is called on a non-pointer diff --git a/llvm/lib/IR/Value.cpp b/llvm/lib/IR/Value.cpp index be704a778a8..a1dfb37bf90 100644 --- a/llvm/lib/IR/Value.cpp +++ b/llvm/lib/IR/Value.cpp @@ -664,6 +664,16 @@ void Value::reverseUseList() { Head->setPrev(&UseList); } +bool Value::isSwiftError() const { + auto *Arg = dyn_cast<Argument>(this); + if (Arg) + return Arg->hasSwiftErrorAttr(); + auto *Alloca = dyn_cast<AllocaInst>(this); + if (!Alloca) + return false; + return Alloca->isSwiftError(); +} + //===----------------------------------------------------------------------===// // ValueHandleBase Class //===----------------------------------------------------------------------===// |