}
void CWriter::writeOperand(Value *Operand) {
- if (isa<GlobalVariable>(Operand) || isDirectAlloca(Operand))
+ if (isa<GlobalVariable>(Operand) || isDirectAlloca(Operand) || ByValParams.count(Operand))
Out << "(&"; // Global variables are referenced as their addresses by llvm
writeOperandInternal(Operand);
- if (isa<GlobalVariable>(Operand) || isDirectAlloca(Operand))
+ if (isa<GlobalVariable>(Operand) || isDirectAlloca(Operand) || ByValParams.count(Operand))
Out << ')';
}
// Check if the argument is expected to be passed by value.
bool isOutByVal = PAL && PAL->paramHasAttr(ArgNo+1, ParamAttr::ByVal);
// Check if this argument itself is passed in by reference.
- bool isInByVal = ByValParams.count(*AI);
- if (isOutByVal && !isInByVal)
+ //bool isInByVal = ByValParams.count(*AI);
+ if (isOutByVal)
Out << "*(";
- else if (!isOutByVal && isInByVal)
- Out << "&(";
writeOperand(*AI);
- if (isOutByVal ^ isInByVal)
+ if (isOutByVal)
Out << ")";
PrintedArg = true;
}