[PATCH] D66844: getArgOperandNo helper function
Stefan Stipanovic via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Nov 10 13:05:50 PST 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc250ebf7bcaa: getArgOperandNo helper function. (authored by sstefan1).
Changed prior to commit:
https://reviews.llvm.org/D66844?vs=221204&id=228620#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D66844/new/
https://reviews.llvm.org/D66844
Files:
llvm/include/llvm/IR/InstrTypes.h
llvm/lib/Transforms/IPO/Attributor.cpp
Index: llvm/lib/Transforms/IPO/Attributor.cpp
===================================================================
--- llvm/lib/Transforms/IPO/Attributor.cpp
+++ llvm/lib/Transforms/IPO/Attributor.cpp
@@ -1572,7 +1572,7 @@
if (!CB->isArgOperand(U))
continue;
- unsigned ArgNo = U - CB->arg_begin();
+ unsigned ArgNo = CB->getArgOperandNo(U);
const auto &NoFreeArg = A.getAAFor<AANoFree>(
*this, IRPosition::callsite_argument(*CB, ArgNo));
@@ -4144,7 +4144,7 @@
const auto &NoFreeAA =
A.getAAFor<AANoFree>(*this, IRPosition::callsite_function(*CB));
- unsigned ArgNo = U - CB->arg_begin();
+ unsigned ArgNo = CB->getArgOperandNo(U);
const auto &NoCaptureAA = A.getAAFor<AANoCapture>(
*this, IRPosition::callsite_argument(*CB, ArgNo));
Index: llvm/include/llvm/IR/InstrTypes.h
===================================================================
--- llvm/include/llvm/IR/InstrTypes.h
+++ llvm/include/llvm/IR/InstrTypes.h
@@ -1272,6 +1272,19 @@
return isArgOperand(&UI.getUse());
}
+ /// Given a use for a arg operand, get the arg operand number that
+ /// corresponds to it.
+ unsigned getArgOperandNo(const Use *U) const {
+ assert(isArgOperand(U) && "Arg operand # out of range!");
+ return U - arg_begin();
+ }
+
+ /// Given a value use iterator, return the arg operand number corresponding to
+ /// it. Iterator must actually correspond to a data operand.
+ unsigned getArgOperandNo(Value::const_user_iterator UI) const {
+ return getArgOperandNo(&UI.getUse());
+ }
+
/// Returns true if this CallSite passes the given Value* as an argument to
/// the called function.
bool hasArgument(const Value *V) const {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D66844.228620.patch
Type: text/x-patch
Size: 1769 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191110/1073ec96/attachment-0001.bin>
More information about the llvm-commits
mailing list