llvm.org GIT mirror llvm / f7b7304
The address of an indirect call must be in R12 on Darwin. Make it so. (This patch is in LowerCall_Darwin, which seems to be used by SVR4 code as well; since that doesn't belong here, I haven't worried about this case.) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98077 91177308-0d34-0410-b5e6-96231b3b80d8 Dale Johannesen 10 years ago
2 changed file(s) with 29 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
32573257 false, false, 0);
32583258 }
32593259
3260 // On Darwin, R12 must contain the address of an indirect callee. This does
3261 // not mean the MTCTR instruction must use R12; it's easier to model this as
3262 // an extra parameter, so do that.
3263 if (!isTailCall &&
3264 !dyn_cast(Callee) &&
3265 !dyn_cast(Callee) &&
3266 !isBLACompatibleAddress(Callee, DAG))
3267 RegsToPass.push_back(std::make_pair((unsigned)(isPPC64 ? PPC::X12 :
3268 PPC::R12), Callee));
3269
32603270 // Build a sequence of copy-to-reg nodes chained together with token chain
32613271 // and flag operands which copy the outgoing args into the appropriate regs.
32623272 SDValue InFlag;
0 ; RUN: llc < %s -march=ppc32 -mcpu=g5 -mtriple=powerpc-apple-darwin10.0 | FileCheck %s
1 ; ModuleID = 'nn.c'
2 target datalayout = "E-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f128:64:128"
3 target triple = "powerpc-apple-darwin11.0"
4 ; Indirect calls must use R12 on Darwin (i.e., R12 must contain the address of
5 ; the function being called; the mtctr is not required to use it).
6
7 @p = external global void (...)* ; [#uses=1]
8
9 define void @foo() nounwind ssp {
10 entry:
11 ; CHECK: mtctr r12
12 %0 = load void (...)** @p, align 4 ; [#uses=1]
13 call void (...)* %0() nounwind
14 br label %return
15
16 return: ; preds = %entry
17 ret void
18 }