diff options
author | Matthijs Kooijman <matthijs@stdin.nl> | 2008-06-20 15:16:45 +0000 |
---|---|---|
committer | Matthijs Kooijman <matthijs@stdin.nl> | 2008-06-20 15:16:45 +0000 |
commit | 03d18569cb39b0e4bd50f5eff2d4fe61bb234678 (patch) | |
tree | 3957d9e70cdca5c151df6dd0bf617a09aa44a0ed /lib/Transforms/IPO | |
parent | 9cb6ec26b3041ff4879579fd9ecee48b616154d8 (diff) | |
download | llvm-03d18569cb39b0e4bd50f5eff2d4fe61bb234678.tar.gz llvm-03d18569cb39b0e4bd50f5eff2d4fe61bb234678.tar.bz2 llvm-03d18569cb39b0e4bd50f5eff2d4fe61bb234678.tar.xz |
Don't let DeadArgElimination change the return type ({} into void and {T}
into T) when no return values are actually dead.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52537 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/IPO')
-rw-r--r-- | lib/Transforms/IPO/DeadArgumentElimination.cpp | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/lib/Transforms/IPO/DeadArgumentElimination.cpp b/lib/Transforms/IPO/DeadArgumentElimination.cpp index 6f00c89bf5..3253c54a68 100644 --- a/lib/Transforms/IPO/DeadArgumentElimination.cpp +++ b/lib/Transforms/IPO/DeadArgumentElimination.cpp @@ -598,15 +598,21 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) { ++NumRetValsEliminated; Changed = true; } - if (RetTypes.size() == 0) - // No return types? Make it void - NRetTy = Type::VoidTy; + if (RetTypes.size() > 1 || (STy && STy->getNumElements() == RetTypes.size())) + // More than one return type? Return a struct with them. Also, if we used + // to return a struct and didn't change the number of return values, + // return a struct again. This prevents chaning {something} into something + // and {} into void. + // Make the new struct packed if we used to return a packed struct + // already. + NRetTy = StructType::get(RetTypes, STy->isPacked()); else if (RetTypes.size() == 1) - // One return type? Just a simple value then + // One return type? Just a simple value then, but only if we didn't use to + // return a struct with that simple value before. NRetTy = RetTypes.front(); - else - // More return types? Return a struct with them - NRetTy = StructType::get(RetTypes); + else if (RetTypes.size() == 0) + // No return types? Make it void, but only if we didn't use to return {} + NRetTy = Type::VoidTy; } else { NRetTy = Type::VoidTy; } |