[llvm-commits] [llvm] r131841 - /llvm/trunk/lib/Target/README.txt
Chris Lattner
sabre at nondot.org
Sat May 21 22:45:06 PDT 2011
Author: lattner
Date: Sun May 22 00:45:06 2011
New Revision: 131841
URL: http://llvm.org/viewvc/llvm-project?rev=131841&view=rev
Log:
move PR9408 here.
Modified:
llvm/trunk/lib/Target/README.txt
Modified: llvm/trunk/lib/Target/README.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/README.txt?rev=131841&r1=131840&r2=131841&view=diff
==============================================================================
--- llvm/trunk/lib/Target/README.txt (original)
+++ llvm/trunk/lib/Target/README.txt Sun May 22 00:45:06 2011
@@ -2305,4 +2305,44 @@
//===---------------------------------------------------------------------===//
+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.
+
+//===---------------------------------------------------------------------===//
More information about the llvm-commits
mailing list