[llvm-commits] [llvm] r53890 - /llvm/trunk/lib/VMCore/AutoUpgrade.cpp
Dan Gohman
gohman at apple.com
Mon Jul 21 17:36:51 PDT 2008
Author: djg
Date: Mon Jul 21 19:36:48 2008
New Revision: 53890
URL: http://llvm.org/viewvc/llvm-project?rev=53890&view=rev
Log:
Fix multiple-return-value-to-first-class-aggregates autoupgrade to
correctly handle the case where multiple-return-value constructs
were used to return one or zero values.
Modified:
llvm/trunk/lib/VMCore/AutoUpgrade.cpp
Modified: llvm/trunk/lib/VMCore/AutoUpgrade.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/AutoUpgrade.cpp?rev=53890&r1=53889&r2=53890&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/AutoUpgrade.cpp (original)
+++ llvm/trunk/lib/VMCore/AutoUpgrade.cpp Mon Jul 21 19:36:48 2008
@@ -420,12 +420,15 @@
/// function to use aggregate return values built with insertvalue
/// instructions.
void llvm::UpgradeMultipleReturnValues(Function *CurrentFunction) {
+ const Type *ReturnType = CurrentFunction->getReturnType();
for (Function::iterator I = CurrentFunction->begin(),
E = CurrentFunction->end(); I != E; ++I) {
BasicBlock *BB = I;
if (ReturnInst *RI = dyn_cast<ReturnInst>(BB->getTerminator())) {
unsigned NumVals = RI->getNumOperands();
- if (NumVals > 1) {
+ if (NumVals > 1 ||
+ (isa<StructType>(ReturnType) &&
+ (NumVals == 0 || RI->getOperand(0)->getType() != ReturnType))) {
std::vector<const Type *> Types(NumVals);
for (unsigned i = 0; i != NumVals; ++i)
Types[i] = RI->getOperand(i)->getType();
More information about the llvm-commits
mailing list