[PATCH] D23441: [ppc64] Don't apply sibling call optimization if callee has any byval arg
Chuang-Yu Cheng via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 12 02:37:10 PDT 2016
cycheng added a comment.
Note that gcc is able to do SCO when caller uses more stack space than callee. Please look at this example:
#define noinline __attribute__((noinline))
struct test {
long int a;
char ary[56];
};
struct test gTest;
noinline int callee(struct test v, struct test *b) {
b->a = v.a;
return 0;
}
void caller1(struct test a, struct test c, struct test *b) { callee(gTest, b); }
void caller2(struct test *b) { callee(gTest, b); }
Generated by gcc:
caller1: caller2:
0: addis 2,12,.TOC.-0b at ha 0: addis 2,12,.TOC.-0b at ha
addi 2,2,.TOC.-0b at l addi 2,2,.TOC.-0b at l
.localentry caller1,.-caller1 .localentry caller2,.-caller2
std 3,32(1) mflr 0
ld 3,160(1) addis 10,2,.LC1 at toc@ha # gpr load fusion, type long
addis 11,2,.LC0 at toc@ha ld 10,.LC1 at toc@l(10)
ld 11,.LC0 at toc@l(11) std 0,16(1)
std 31,-8(1) stdu 1,-112(1)
std 4,40(1) std 3,96(1)
std 5,48(1) ld 4,8(10)
std 6,56(1) ld 3,0(10)
std 3,96(1) ld 5,16(10)
std 7,64(1) ld 6,24(10)
std 8,72(1) ld 7,32(10)
std 9,80(1) ld 8,40(10)
std 10,88(1) ld 9,48(10)
ld 31,-8(1) ld 10,56(10)
ld 3,0(11) bl callee
ld 4,8(11) addi 1,1,112
ld 5,16(11) ld 0,16(1)
ld 6,24(11) mtlr 0
ld 7,32(11) blr
ld 8,40(11)
ld 9,48(11)
ld 10,56(11)
b callee
We can see that caller1 can sibcall to callee, but caller2 can't do that.
https://reviews.llvm.org/D23441
More information about the llvm-commits
mailing list