Skip to content
This repository was archived by the owner on Apr 23, 2020. It is now read-only.

Commit 6d2bd95

Browse files
committed
Don't refuse to transform constexpr(call(arg, ...)) to call(constexpr(arg), ...)) just because the function has multiple return values even if their return types are the same. Patch by Eduard Burtescu!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199564 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent c975958 commit 6d2bd95

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

Diff for: lib/Transforms/InstCombine/InstCombineCalls.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -994,11 +994,12 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
994994
Type *OldRetTy = Caller->getType();
995995
Type *NewRetTy = FT->getReturnType();
996996

997-
if (NewRetTy->isStructTy())
998-
return false; // TODO: Handle multiple return values.
999-
1000997
// Check to see if we are changing the return type...
1001998
if (OldRetTy != NewRetTy) {
999+
1000+
if (NewRetTy->isStructTy())
1001+
return false; // TODO: Handle multiple return values.
1002+
10021003
if (!CastInst::isBitCastable(NewRetTy, OldRetTy)) {
10031004
if (Callee->isDeclaration())
10041005
return false; // Cannot transform this return value.

Diff for: test/Transforms/InstCombine/call-cast-target.ll

+12
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,15 @@ entry:
1313

1414
declare i8* @ctime(i32*)
1515

16+
define internal { i8 } @foo(i32*) {
17+
entry:
18+
ret { i8 } { i8 0 }
19+
}
20+
21+
define void @test_struct_ret() {
22+
; CHECK-LABEL: @test_struct_ret
23+
; CHECK-NOT: bitcast
24+
entry:
25+
%0 = call { i8 } bitcast ({ i8 } (i32*)* @foo to { i8 } (i16*)*)(i16* null)
26+
ret void
27+
}

0 commit comments

Comments
 (0)