Minor fixes when accesing CallInst operands
Summary: Fix minor issues found while adding support for emitting textual function names when calling non-callables. Reviewed By: tmikov, avp Differential Revision: D40617534 fbshipit-source-id: 02b8782159d4f30f10fc875f47a947fd822e9f57
This commit is contained in:
Родитель
bb0aa44866
Коммит
f6bb69c6a0
|
@ -699,6 +699,10 @@ class CallInst : public Instruction {
|
|||
CallInst(const CallInst &) = delete;
|
||||
void operator=(const CallInst &) = delete;
|
||||
|
||||
// Forces the code to use the appropriate getters instead of relying on
|
||||
// hard-coded offsets when accessing the arguments.
|
||||
using Instruction::getOperand;
|
||||
|
||||
public:
|
||||
enum { CalleeIdx, ThisIdx };
|
||||
|
||||
|
@ -721,7 +725,7 @@ class CallInst : public Instruction {
|
|||
}
|
||||
|
||||
unsigned getNumArguments() const {
|
||||
return getNumOperands() - 1;
|
||||
return getNumOperands() - ThisIdx;
|
||||
}
|
||||
|
||||
explicit CallInst(
|
||||
|
|
|
@ -811,7 +811,7 @@ bool SpillRegisters::requiresShortOperand(Instruction *I, int op) {
|
|||
case ValueKind::CallBuiltinInstKind:
|
||||
case ValueKind::HBCConstructInstKind:
|
||||
case ValueKind::HBCCallDirectInstKind:
|
||||
return op == 0;
|
||||
return op == CallInst::CalleeIdx;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -149,11 +149,11 @@ static bool performFSO(Function *F, std::vector<Function *> &worklist) {
|
|||
|
||||
// Replace all unused arguments with undef.
|
||||
for (auto &arg : unusedParams) {
|
||||
auto *prevArg = arg.first->getOperand(arg.second + 1);
|
||||
auto *prevArg = arg.first->getArgument(arg.second);
|
||||
if (!llvh::isa<Literal>(prevArg))
|
||||
toRedo.insert(arg.first->getParent()->getParent());
|
||||
|
||||
arg.first->setOperand(undef, arg.second + 1);
|
||||
arg.first->setArgument(undef, arg.second);
|
||||
NumArgsOpt++;
|
||||
}
|
||||
|
||||
|
|
|
@ -99,7 +99,7 @@ void IRPrinter::printTypeLabel(Type T) {
|
|||
|
||||
void IRPrinter::printValueLabel(Instruction *I, Value *V, unsigned opIndex) {
|
||||
auto &ctx = I->getContext();
|
||||
if (isa<CallBuiltinInst>(I) && opIndex == 0) {
|
||||
if (isa<CallBuiltinInst>(I) && opIndex == CallInst::CalleeIdx) {
|
||||
os << "["
|
||||
<< getBuiltinMethodName(cast<CallBuiltinInst>(I)->getBuiltinIndex())
|
||||
<< "]";
|
||||
|
|
Загрузка…
Ссылка в новой задаче