[llvm] eeabd90 - [NFC] Cleanup off by one indexes in CallBase::dataOperandHasImpliedAttr()
Arthur Eubanks via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 7 14:52:23 PDT 2021
Author: Arthur Eubanks
Date: 2021-09-07T14:52:12-07:00
New Revision: eeabd90efd2697d186adf4ef9200fb01a5c67de2
URL: https://github.com/llvm/llvm-project/commit/eeabd90efd2697d186adf4ef9200fb01a5c67de2
DIFF: https://github.com/llvm/llvm-project/commit/eeabd90efd2697d186adf4ef9200fb01a5c67de2.diff
LOG: [NFC] Cleanup off by one indexes in CallBase::dataOperandHasImpliedAttr()
Verified that previously nothing was calling dataOperandHasImpliedAttr()
with AttributeList::ReturnIndex even though we had a code path for it.
Reviewed By: rnk
Differential Revision: https://reviews.llvm.org/D109390
Added:
Modified:
llvm/include/llvm/IR/InstrTypes.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/IR/InstrTypes.h b/llvm/include/llvm/IR/InstrTypes.h
index bb9084cadd3f..f5b0845d2632 100644
--- a/llvm/include/llvm/IR/InstrTypes.h
+++ b/llvm/include/llvm/IR/InstrTypes.h
@@ -1631,42 +1631,35 @@ class CallBase : public Instruction {
/// A.
///
/// Data operands include call arguments and values used in operand bundles,
- /// but does not include the callee operand. This routine dispatches to the
- /// underlying AttributeList or the OperandBundleUser as appropriate.
+ /// but does not include the callee operand.
///
/// The index \p i is interpreted as
///
- /// \p i == Attribute::ReturnIndex -> the return value
- /// \p i in [1, arg_size + 1) -> argument number (\p i - 1)
- /// \p i in [arg_size + 1, data_operand_size + 1) -> bundle operand at index
- /// (\p i - 1) in the operand list.
+ /// \p i in [0, arg_size) -> argument number (\p i)
+ /// \p i in [arg_size, data_operand_size) -> bundle operand at index
+ /// (\p i) in the operand list.
bool dataOperandHasImpliedAttr(unsigned i, Attribute::AttrKind Kind) const {
// Note that we have to add one because `i` isn't zero-indexed.
- assert(i < (getNumArgOperands() + getNumTotalBundleOperands() + 1) &&
+ assert(i < getNumArgOperands() + getNumTotalBundleOperands() &&
"Data operand index out of bounds!");
// The attribute A can either be directly specified, if the operand in
// question is a call argument; or be indirectly implied by the kind of its
// containing operand bundle, if the operand is a bundle operand.
- if (i == AttributeList::ReturnIndex)
- return hasRetAttr(Kind);
+ if (i < getNumArgOperands())
+ return paramHasAttr(i, Kind);
- // FIXME: Avoid these i - 1 calculations and update the API to use
- // zero-based indices.
- if (i < (getNumArgOperands() + 1))
- return paramHasAttr(i - 1, Kind);
-
- assert(hasOperandBundles() && i >= (getBundleOperandsStartIndex() + 1) &&
+ assert(hasOperandBundles() && i >= getBundleOperandsStartIndex() &&
"Must be either a call argument or an operand bundle!");
- return bundleOperandHasAttr(i - 1, Kind);
+ return bundleOperandHasAttr(i, Kind);
}
/// Determine whether this data operand is not captured.
// FIXME: Once this API is no longer duplicated in `CallSite`, rename this to
// better indicate that this may return a conservative answer.
bool doesNotCapture(unsigned OpNo) const {
- return dataOperandHasImpliedAttr(OpNo + 1, Attribute::NoCapture);
+ return dataOperandHasImpliedAttr(OpNo, Attribute::NoCapture);
}
/// Determine whether this argument is passed by value.
@@ -1707,21 +1700,21 @@ class CallBase : public Instruction {
// FIXME: Once this API is no longer duplicated in `CallSite`, rename this to
// better indicate that this may return a conservative answer.
bool doesNotAccessMemory(unsigned OpNo) const {
- return dataOperandHasImpliedAttr(OpNo + 1, Attribute::ReadNone);
+ return dataOperandHasImpliedAttr(OpNo, Attribute::ReadNone);
}
// FIXME: Once this API is no longer duplicated in `CallSite`, rename this to
// better indicate that this may return a conservative answer.
bool onlyReadsMemory(unsigned OpNo) const {
- return dataOperandHasImpliedAttr(OpNo + 1, Attribute::ReadOnly) ||
- dataOperandHasImpliedAttr(OpNo + 1, Attribute::ReadNone);
+ return dataOperandHasImpliedAttr(OpNo, Attribute::ReadOnly) ||
+ dataOperandHasImpliedAttr(OpNo, Attribute::ReadNone);
}
// FIXME: Once this API is no longer duplicated in `CallSite`, rename this to
// better indicate that this may return a conservative answer.
bool doesNotReadMemory(unsigned OpNo) const {
- return dataOperandHasImpliedAttr(OpNo + 1, Attribute::WriteOnly) ||
- dataOperandHasImpliedAttr(OpNo + 1, Attribute::ReadNone);
+ return dataOperandHasImpliedAttr(OpNo, Attribute::WriteOnly) ||
+ dataOperandHasImpliedAttr(OpNo, Attribute::ReadNone);
}
/// Extract the alignment of the return value.
More information about the llvm-commits
mailing list