1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 11:02:59 +02:00

move PR9408 here.

llvm-svn: 131841
This commit is contained in:
Chris Lattner 2011-05-22 05:45:06 +00:00
parent 82ddea6aaa
commit 9359dea740

View File

@ -2305,4 +2305,44 @@ The two or/and's should be merged into one each.
//===---------------------------------------------------------------------===//
Machine level code hoisting can be useful in some cases. For example, PR9408
is about:
typedef union {
void (*f1)(int);
void (*f2)(long);
} funcs;
void foo(funcs f, int which) {
int a = 5;
if (which) {
f.f1(a);
} else {
f.f2(a);
}
}
which we compile to:
foo: # @foo
# BB#0: # %entry
pushq %rbp
movq %rsp, %rbp
testl %esi, %esi
movq %rdi, %rax
je .LBB0_2
# BB#1: # %if.then
movl $5, %edi
callq *%rax
popq %rbp
ret
.LBB0_2: # %if.else
movl $5, %edi
callq *%rax
popq %rbp
ret
Note that bb1 and bb2 are the same. This doesn't happen at the IR level
because one call is passing an i32 and the other is passing an i64.
//===---------------------------------------------------------------------===//