[llvm] r281143 - Add an isSwiftError predicate to Value
Arnold Schwaighofer via llvm-commits
llvm-commits at lists.llvm.org
Sat Sep 10 11:14:55 PDT 2016
Author: arnolds
Date: Sat Sep 10 13:14:54 2016
New Revision: 281143
URL: http://llvm.org/viewvc/llvm-project?rev=281143&view=rev
Log:
Add an isSwiftError predicate to Value
Modified:
llvm/trunk/include/llvm/IR/Value.h
llvm/trunk/lib/IR/Value.cpp
Modified: llvm/trunk/include/llvm/IR/Value.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Value.h?rev=281143&r1=281142&r2=281143&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/Value.h (original)
+++ llvm/trunk/include/llvm/IR/Value.h Sat Sep 10 13:14:54 2016
@@ -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
Modified: llvm/trunk/lib/IR/Value.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Value.cpp?rev=281143&r1=281142&r2=281143&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Value.cpp (original)
+++ llvm/trunk/lib/IR/Value.cpp Sat Sep 10 13:14:54 2016
@@ -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
//===----------------------------------------------------------------------===//
More information about the llvm-commits
mailing list