[llvm-branch-commits] [llvm-branch] r85211 - in /llvm/branches/Apple/Leela: lib/Transforms/Utils/InlineFunction.cpp test/Transforms/Inline/basictest.ll

Bill Wendling isanbard at gmail.com
Tue Oct 27 01:32:01 PDT 2009


Author: void
Date: Tue Oct 27 03:31:59 2009
New Revision: 85211

URL: http://llvm.org/viewvc/llvm-project?rev=85211&view=rev
Log:
$ svn merge -c 85206 https://llvm.org/svn/llvm-project/llvm/trunk
--- Merging r85206 into '.':
U    test/Transforms/Inline/basictest.ll
U    lib/Transforms/Utils/InlineFunction.cpp


Modified:
    llvm/branches/Apple/Leela/lib/Transforms/Utils/InlineFunction.cpp
    llvm/branches/Apple/Leela/test/Transforms/Inline/basictest.ll

Modified: llvm/branches/Apple/Leela/lib/Transforms/Utils/InlineFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Leela/lib/Transforms/Utils/InlineFunction.cpp?rev=85211&r1=85210&r2=85211&view=diff

==============================================================================
--- llvm/branches/Apple/Leela/lib/Transforms/Utils/InlineFunction.cpp (original)
+++ llvm/branches/Apple/Leela/lib/Transforms/Utils/InlineFunction.cpp Tue Oct 27 03:31:59 2009
@@ -621,8 +621,17 @@
                "Ret value not consistent in function!");
         PHI->addIncoming(RI->getReturnValue(), RI->getParent());
       }
+    
+      // Now that we inserted the PHI, check to see if it has a single value
+      // (e.g. all the entries are the same or undef).  If so, remove the PHI so
+      // it doesn't block other optimizations.
+      if (Value *V = PHI->hasConstantValue()) {
+        PHI->replaceAllUsesWith(V);
+        PHI->eraseFromParent();
+      }
     }
 
+
     // Add a branch to the merge points and remove return instructions.
     for (unsigned i = 0, e = Returns.size(); i != e; ++i) {
       ReturnInst *RI = Returns[i];

Modified: llvm/branches/Apple/Leela/test/Transforms/Inline/basictest.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Leela/test/Transforms/Inline/basictest.ll?rev=85211&r1=85210&r2=85211&view=diff

==============================================================================
--- llvm/branches/Apple/Leela/test/Transforms/Inline/basictest.ll (original)
+++ llvm/branches/Apple/Leela/test/Transforms/Inline/basictest.ll Tue Oct 27 03:31:59 2009
@@ -1,4 +1,4 @@
-; RUN: opt < %s -inline -disable-output -print-function 2> /dev/null
+; RUN: opt < %s -inline -scalarrepl -S | FileCheck %s
 
 define i32 @func(i32 %i) {
         ret i32 %i
@@ -10,3 +10,34 @@
         ret i32 %Y
 }
 
+
+
+; rdar://7339069
+
+%T = type { i32, i32 }
+
+; CHECK-NOT: @test2f
+define internal %T* @test2f(i1 %cond, %T* %P) {
+  br i1 %cond, label %T, label %F
+  
+T:
+  %A = getelementptr %T* %P, i32 0, i32 0
+  store i32 42, i32* %A
+  ret %T* %P
+  
+F:
+  ret %T* %P
+}
+
+define i32 @test2(i1 %cond) {
+  %A = alloca %T
+  
+  %B = call %T* @test2f(i1 %cond, %T* %A)
+  %C = getelementptr %T* %B, i32 0, i32 0
+  %D = load i32* %C
+  ret i32 %D
+  
+; CHECK: @test2(
+; CHECK-NOT: = alloca
+; CHECK: ret i32 42
+}





More information about the llvm-branch-commits mailing list