llvm.org GIT mirror llvm / 688b5df
[OperandBundles] Have DeadArgElim play nice with operand bundles A call site's use of a Value might not correspond to an argument operand but to a bundle operand. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256326 91177308-0d34-0410-b5e6-96231b3b80d8 David Majnemer 3 years ago
3 changed file(s) with 52 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
117117 /// Determine whether this Use is the callee operand's Use.
118118 bool isCallee(const Use *U) const { return getCallee() == U; }
119119
120 /// \brief Determine whether the passed iterator points to an argument
121 /// operand.
122 bool isArgOperand(Value::const_user_iterator UI) const {
123 return isArgOperand(&UI.getUse());
124 }
125
126 /// \brief Determine whether the passed use points to an argument operand.
127 bool isArgOperand(const Use *U) const {
128 return arg_begin() <= U && U < arg_end();
129 }
130
131 /// \brief Determine whether the passed iterator points to a bundle operand.
132 bool isBundleOperand(Value::const_user_iterator UI) const {
133 return isBundleOperand(&UI.getUse());
134 }
135
136 /// \brief Determine whether the passed use points to a bundle operand.
137 bool isBundleOperand(const Use *U) const {
138 if (!hasOperandBundles())
139 return false;
140 unsigned OperandNo = U->getOperandNo();
141 return getBundleOperandsStartIndex() <= OperandNo &&
142 OperandNo < getBundleOperandsEndIndex();
143 }
144
120145 ValTy *getArgument(unsigned ArgNo) const {
121146 assert(arg_begin() + ArgNo < arg_end() && "Argument # out of range!");
122147 return *(arg_begin() + ArgNo);
138163 /// it.
139164 unsigned getArgumentNo(const Use *U) const {
140165 assert(getInstruction() && "Not a call or invoke instruction!");
141 assert(arg_begin() <= U && U < arg_end()
142 && "Argument # out of range!");
166 assert(isArgOperand(U) && "Argument # out of range!");
143167 return U - arg_begin();
144168 }
145169
353377 CALLSITE_DELEGATE_SETTER(setDoesNotThrow());
354378 }
355379
356 int getNumOperandBundles() const {
380 unsigned getNumOperandBundles() const {
357381 CALLSITE_DELEGATE_GETTER(getNumOperandBundles());
358382 }
359383
361385 CALLSITE_DELEGATE_GETTER(hasOperandBundles());
362386 }
363387
364 int getNumTotalBundleOperands() const {
388 unsigned getBundleOperandsStartIndex() const {
389 CALLSITE_DELEGATE_GETTER(getBundleOperandsStartIndex());
390 }
391
392 unsigned getBundleOperandsEndIndex() const {
393 CALLSITE_DELEGATE_GETTER(getBundleOperandsEndIndex());
394 }
395
396 unsigned getNumTotalBundleOperands() const {
365397 CALLSITE_DELEGATE_GETTER(getNumTotalBundleOperands());
366398 }
367399
479479 if (F) {
480480 // Used in a direct call.
481481
482 // The function argument is live if it is used as a bundle operand.
483 if (CS.isBundleOperand(U))
484 return Live;
485
482486 // Find the argument number. We know for sure that this use is an
483487 // argument, since if it was the function argument this would be an
484488 // indirect call and the we know can't be looking at a value of the
0 ; RUN: opt < %s -deadargelim -S | FileCheck %s
1
2 define internal void @f(i32 %arg) {
3 entry:
4 call void @g() [ "foo"(i32 %arg) ]
5 ret void
6 }
7
8 ; CHECK-LABEL: define internal void @f(
9 ; CHECK: call void @g() [ "foo"(i32 %arg) ]
10
11 declare void @g()