brintos

brintos / llvm-project-archived public Read only

0
0
Text · 6.7 KiB · f95153b Raw
177 lines · plain
1; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu | FileCheck %s -check-prefix=X642; RUN: llc < %s -mtriple=i686-unknown-linux-gnu | FileCheck %s -check-prefix=X323 4; CHECK-LABEL: foo5 6; Check the functionality of the local stack symbol table ordering7; heuristics.8; The test has a bunch of locals of various sizes that are referenced a9; different number of times.10;11; a   : 120B, 9 uses,   density = 0.07512; aa  : 4000B, 1 use,   density = 0.0002513; b   : 4B, 1 use,      density = 0.2514; cc  : 4000B, 2 uses   density = 0.000515; d   : 4B, 2 uses      density = 0.516; e   : 4B, 3 uses      density = 0.7517; f   : 4B, 4 uses      density = 118;19; Given the size, number of uses and calculated density (uses / size), we're20; going to hope that f gets allocated closest to the stack pointer,21; followed by e, d, b, then a (to check for just a few).22; We use gnu-inline asm between calls to prevent registerization of addresses23; so that we get exact counts.24;25; The test is taken from something like this:26; void foo()27; {28;   int f; // 4 uses.          4 / 4 = 129;   int a[30]; // 9 uses.      8 / 120 = 0.0630;   int aa[1000]; // 1 use.    1 / 4000 =31;   int e; // 3 uses.          3 / 4 = 0.7532;   int cc[1000]; // 2 uses.   2 / 4000 = 33;   int b; // 1 use.           1 / 4 = 0.2534;   int d; // 2 uses.          2 / 4 = 0.535;   int aaa[1000]; // 2 uses.  2 / 400036;37; 38;   check_a(&a);39;   bar1(&aaa);40;   asm ("":::"esi","edi","ebp","ebx","rbx","r12","r13","r14","r15","rbp");41;   bar1(&a);42;   check_f(&f);43;   asm ("":::"esi","edi","ebp","ebx","rbx","r12","r13","r14","r15","rbp");44;   bar1(&a);45;   bar3(&aa, &aaa, &cc);46;   asm ("":::"esi","edi","ebp","ebx","rbx","r12","r13","r14","r15","rbp");47;   bar2(&a,&cc);48;   check_b(&b);49;   asm ("":::"esi","edi","ebp","ebx","rbx","r12","r13","r14","r15","rbp");50;   bar1(&a);51;   asm ("":::"esi","edi","ebp","ebx","rbx","r12","r13","r14","r15","rbp");52;   bar2(&a, &f);53;   check_e(&e);54;   asm ("":::"esi","edi","ebp","ebx","rbx","r12","r13","r14","r15","rbp");55;   bar1(&a);56;   asm ("":::"esi","edi","ebp","ebx","rbx","r12","r13","r14","r15","rbp");57;   bar2(&e, &f);58;   check_d(&d);59;   bar1(&a);60;   asm ("":::"esi","edi","ebp","ebx","rbx","r12","r13","r14","r15","rbp");61;   bar3(&d, &e, &f);62;   asm ("":::"esi","edi","ebp","ebx","rbx","r12","r13","r14","r15","rbp");63;   bar1(&a);64; }65;66; X64: leaq 16(%rsp), %rdi67; X64: callq check_a68; X64: callq bar169; X64: callq bar170; X64: movq %rsp, %rdi71; X64: callq check_f72; X64: callq bar173; X64: callq bar374; X64: callq bar275; X64: leaq 12(%rsp), %rdi76; X64: callq check_b77; X64: callq bar178; X64: callq bar279; X64: leaq 4(%rsp), %rdi80; X64: callq check_e81; X64: callq bar182; X64: callq bar283; X64: leaq 8(%rsp), %rdi84; X64: callq check_d85 86; X32: leal 32(%esp)87; X32: calll check_a88; X32: calll bar189; X32: calll bar190; X32: leal 16(%esp)91; X32: calll check_f92; X32: calll bar193; X32: calll bar394; X32: calll bar295; X32: leal 28(%esp)96; X32: calll check_b97; X32: calll bar198; X32: calll bar299; X32: leal 20(%esp)100; X32: calll check_e101; X32: calll bar1102; X32: calll bar2103; X32: leal 24(%esp)104; X32: calll check_d105 106 107define void @foo() nounwind uwtable {108entry:109  %f = alloca i32, align 4110  %a = alloca [30 x i32], align 16111  %aa = alloca [1000 x i32], align 16112  %e = alloca i32, align 4113  %cc = alloca [1000 x i32], align 16114  %b = alloca i32, align 4115  %d = alloca i32, align 4116  %aaa = alloca [1000 x i32], align 16117  call void @llvm.lifetime.start.p0(i64 4, ptr %f) #1118  call void @llvm.lifetime.start.p0(i64 120, ptr %a) #1119  call void @llvm.lifetime.start.p0(i64 4000, ptr %aa) #1120  call void @llvm.lifetime.start.p0(i64 4, ptr %e) #1121  call void @llvm.lifetime.start.p0(i64 4000, ptr %cc) #1122  call void @llvm.lifetime.start.p0(i64 4, ptr %b) #1123  call void @llvm.lifetime.start.p0(i64 4, ptr %d) #1124  call void @llvm.lifetime.start.p0(i64 4000, ptr %aaa) #1125  %call = call i32 (ptr, ...) @check_a(ptr %a)126  %call1 = call i32 (ptr, ...) @bar1(ptr %aaa)127  call void asm sideeffect "", "~{esi},~{edi},~{ebp},~{ebx},~{rbx},~{r12},~{r13},~{r14},~{r15},~{rbp},~{dirflag},~{fpsr},~{flags}"() #1128  %call2 = call i32 (ptr, ...) @bar1(ptr %a)129  %call3 = call i32 (ptr, ...) @check_f(ptr %f)130  call void asm sideeffect "", "~{esi},~{edi},~{ebp},~{ebx},~{rbx},~{r12},~{r13},~{r14},~{r15},~{rbp},~{dirflag},~{fpsr},~{flags}"() #1131  %call4 = call i32 (ptr, ...) @bar1(ptr %a)132  %call5 = call i32 (ptr, ptr, ptr, ...) @bar3(ptr %aa, ptr %aaa, ptr %cc)133  call void asm sideeffect "", "~{esi},~{edi},~{ebp},~{ebx},~{rbx},~{r12},~{r13},~{r14},~{r15},~{rbp},~{dirflag},~{fpsr},~{flags}"() #1134  %call6 = call i32 (ptr, ptr, ...) @bar2(ptr %a, ptr %cc)135  %call7 = call i32 (ptr, ...) @check_b(ptr %b)136  call void asm sideeffect "", "~{esi},~{edi},~{ebp},~{ebx},~{rbx},~{r12},~{r13},~{r14},~{r15},~{rbp},~{dirflag},~{fpsr},~{flags}"() #1137  %call8 = call i32 (ptr, ...) @bar1(ptr %a)138  call void asm sideeffect "", "~{esi},~{edi},~{ebp},~{ebx},~{rbx},~{r12},~{r13},~{r14},~{r15},~{rbp},~{dirflag},~{fpsr},~{flags}"() #1139  %call9 = call i32 (ptr, ptr, ...) @bar2(ptr %a, ptr %f)140  %call10 = call i32 (ptr, ...) @check_e(ptr %e)141  call void asm sideeffect "", "~{esi},~{edi},~{ebp},~{ebx},~{rbx},~{r12},~{r13},~{r14},~{r15},~{rbp},~{dirflag},~{fpsr},~{flags}"() #1142  %call11 = call i32 (ptr, ...) @bar1(ptr %a)143  call void asm sideeffect "", "~{esi},~{edi},~{ebp},~{ebx},~{rbx},~{r12},~{r13},~{r14},~{r15},~{rbp},~{dirflag},~{fpsr},~{flags}"() #1144  %call12 = call i32 (ptr, ptr, ...) @bar2(ptr %e, ptr %f)145  %call13 = call i32 (ptr, ...) @check_d(ptr %d)146  %call14 = call i32 (ptr, ...) @bar1(ptr %a)147  call void asm sideeffect "", "~{esi},~{edi},~{ebp},~{ebx},~{rbx},~{r12},~{r13},~{r14},~{r15},~{rbp},~{dirflag},~{fpsr},~{flags}"() #1148  %call15 = call i32 (ptr, ptr, ptr, ...) @bar3(ptr %d, ptr %e, ptr %f)149  call void asm sideeffect "", "~{esi},~{edi},~{ebp},~{ebx},~{rbx},~{r12},~{r13},~{r14},~{r15},~{rbp},~{dirflag},~{fpsr},~{flags}"() #1150  %call16 = call i32 (ptr, ...) @bar1(ptr %a)151  call void @llvm.lifetime.end.p0(i64 4000, ptr %aaa) #1152  call void @llvm.lifetime.end.p0(i64 4, ptr %d) #1153  call void @llvm.lifetime.end.p0(i64 4, ptr %b) #1154  call void @llvm.lifetime.end.p0(i64 4000, ptr %cc) #1155  call void @llvm.lifetime.end.p0(i64 4, ptr %e) #1156  call void @llvm.lifetime.end.p0(i64 4000, ptr %aa) #1157  call void @llvm.lifetime.end.p0(i64 120, ptr %a) #1158  call void @llvm.lifetime.end.p0(i64 4, ptr %f) #1159  ret void160}161 162; Function Attrs: nounwind163declare void @llvm.lifetime.start.p0(i64, ptr nocapture) #1164 165declare i32 @check_a(...) #2166declare i32 @bar1(...) #2167declare i32 @check_f(...) #2168declare i32 @bar3(...) #2169declare i32 @bar2(...) #2170declare i32 @check_b(...) #2171declare i32 @check_e(...) #2172declare i32 @check_d(...) #2173 174; Function Attrs: nounwind175declare void @llvm.lifetime.end.p0(i64, ptr nocapture) #1176 177