[llvm] r203488 - For functions with ARM target specific calling convention, when simplify-libcall
Tim Northover
t.p.northover at gmail.com
Tue Mar 11 02:00:20 PDT 2014
Hi Evan,
> + if (Function *F = dyn_cast<Function>(StrLen->stripPointerCasts())) {
> + CallingConv::ID CC = F->getCallingConv();
> + CallingConv::ID CallerCC = CallerF->getCallingConv();
> + if (CC == CallingConv::C && CallingConv::isARMTargetCC(CallerCC)) {
> + // If caller is using ARM target specific CC such as AAPCS-VFP,
> + // make sure the call uses it or it would introduce a calling
> + // convention mismatch.
> + CI->setCallingConv(CallerCC);
> + F->setCallingConv(CallerCC);
> + } else
> + CI->setCallingConv(CC);
> + }
I don't think this approach works because the calling-convention is a
property of the callee and has nothing to do with the caller.
Chandler's suggestion is probably the only viable one: TargetLowering
should provide the calling convention for anything that we introduce
(and we should follow what's there if the function already exists).
For example, compiling this C on gnueabihf platforms (remember -fno-math-errno):
extern double pow(double, double);
double __attribute__((pcs("aapcs"))) soft(double x) {
return pow(x, 0.5);
}
gives:
define arm_aapcscc double @soft(double %x) #0 {
entry:
%sqrt = tail call arm_aapcscc double @sqrt(double %x) #1
%fabs = tail call arm_aapcscc double @fabs(double %sqrt) #1
%0 = fcmp oeq double %x, 0xFFF0000000000000
%1 = select i1 %0, double 0x7FF0000000000000, double %fabs
ret double %1
}
ARM has vsqrt and vabs instructions so it doesn't actually cause a
problem, but I think that IR is even more wrong than what was
generated before.
Cheers.
Tim.
More information about the llvm-commits
mailing list