Don't refuse to transform constexpr(call(arg, ...)) to call(constexpr(arg), ...)...
authorNick Lewycky <nicholas@mxc.ca>
Sat, 18 Jan 2014 22:47:12 +0000 (22:47 +0000)
committerNick Lewycky <nicholas@mxc.ca>
Sat, 18 Jan 2014 22:47:12 +0000 (22:47 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199564 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/InstCombine/InstCombineCalls.cpp
test/Transforms/InstCombine/call-cast-target.ll

index 0cd7b149d42a975471019e8bc0e2d40ebf780aeb..c949720b1f53fe04d3937134f658293406a94712 100644 (file)
@@ -994,11 +994,12 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
   Type *OldRetTy = Caller->getType();
   Type *NewRetTy = FT->getReturnType();
 
-  if (NewRetTy->isStructTy())
-    return false; // TODO: Handle multiple return values.
-
   // Check to see if we are changing the return type...
   if (OldRetTy != NewRetTy) {
+
+    if (NewRetTy->isStructTy())
+      return false; // TODO: Handle multiple return values.
+
     if (!CastInst::isBitCastable(NewRetTy, OldRetTy)) {
       if (Callee->isDeclaration())
         return false;   // Cannot transform this return value.
index 315c51683fd2c4ce0e25b6083baffa673ba409c0..1af3317a398b1af3b2aea564d326404e471d8fdf 100644 (file)
@@ -13,3 +13,15 @@ entry:
 
 declare i8* @ctime(i32*)
 
+define internal { i8 } @foo(i32*) {
+entry:
+  ret { i8 } { i8 0 }
+}
+
+define void @test_struct_ret() {
+; CHECK-LABEL: @test_struct_ret
+; CHECK-NOT: bitcast
+entry:
+  %0 = call { i8 } bitcast ({ i8 } (i32*)* @foo to { i8 } (i16*)*)(i16* null)
+  ret void
+}