diff options
author | Nick Lewycky <nicholas@mxc.ca> | 2011-11-20 19:09:04 +0000 |
---|---|---|
committer | Nick Lewycky <nicholas@mxc.ca> | 2011-11-20 19:09:04 +0000 |
commit | 173862e5468fbcf4b022b9088d2c81b25c2d60c5 (patch) | |
tree | 7e5397de7252f267c99878bc8176abc1bfb0fdd2 /include | |
parent | 742e5cf61298e9d7a0672d0cd79708c4939da489 (diff) | |
download | external_llvm-173862e5468fbcf4b022b9088d2c81b25c2d60c5.zip external_llvm-173862e5468fbcf4b022b9088d2c81b25c2d60c5.tar.gz external_llvm-173862e5468fbcf4b022b9088d2c81b25c2d60c5.tar.bz2 |
Refactor code to use new attribute getters on CallSite for NoCapture and ByVal.
Suggested in code review by Eli.
That code in InstCombine looks kinda suspicious.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@145013 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/Analysis/CaptureTracking.h | 2 | ||||
-rw-r--r-- | include/llvm/Support/CallSite.h | 10 |
2 files changed, 11 insertions, 1 deletions
diff --git a/include/llvm/Analysis/CaptureTracking.h b/include/llvm/Analysis/CaptureTracking.h index 4461564..b033f14 100644 --- a/include/llvm/Analysis/CaptureTracking.h +++ b/include/llvm/Analysis/CaptureTracking.h @@ -104,7 +104,7 @@ void llvm::PointerMayBeCaptured(const llvm::Value *V, CaptureTracker &Tracker) { // (think of self-referential objects). CallSite::arg_iterator B = CS.arg_begin(), E = CS.arg_end(); for (CallSite::arg_iterator A = B; A != E; ++A) - if (A->get() == V && !CS.paramHasAttr(A - B + 1, Attribute::NoCapture)) + if (A->get() == V && !CS.doesNotCapture(A - B)) // The parameter is not marked 'nocapture' - captured. if (Tracker.captured(I)) return; diff --git a/include/llvm/Support/CallSite.h b/include/llvm/Support/CallSite.h index 04b8c4e..20634ed 100644 --- a/include/llvm/Support/CallSite.h +++ b/include/llvm/Support/CallSite.h @@ -237,6 +237,16 @@ public: #undef CALLSITE_DELEGATE_GETTER #undef CALLSITE_DELEGATE_SETTER + /// @brief Determine whether this argument is not captured. + bool doesNotCapture(unsigned ArgNo) const { + return paramHasAttr(ArgNo + 1, Attribute::NoCapture); + } + + /// @brief Determine whether this argument is passed by value. + bool isByValArgument(unsigned ArgNo) const { + return paramHasAttr(ArgNo + 1, Attribute::ByVal); + } + /// hasArgument - Returns true if this CallSite passes the given Value* as an /// argument to the called function. bool hasArgument(const Value *Arg) const { |