Merging r143357:
------------------------------------------------------------------------
r143357 | baldrick | 2011-10-31 13:07:09 -0700 (Mon, 31 Oct 2011) | 5 lines
Fix a compile failure on 483.xalancbmk, caused by a minor GCC bug:
what should be the same type in the caller and callee are two
different (but equivalent) types (and not just variants of each
other).
------------------------------------------------------------------------
llvm-svn: 143434
diff --git a/dragonegg/src/Convert.cpp b/dragonegg/src/Convert.cpp
index 00cab6b..0582bae 100644
--- a/dragonegg/src/Convert.cpp
+++ b/dragonegg/src/Convert.cpp
@@ -2802,6 +2802,20 @@
Client.clear();
}
+ // If the caller and callee disagree about a parameter type but the difference
+ // is trivial, correct the type used by the caller.
+ for (unsigned i = 0, e = std::min((unsigned)CallOperands.size(),
+ FTy->getNumParams());
+ i != e; ++i) {
+ Type *ExpectedTy = FTy->getParamType(i);
+ Type *ActualTy = CallOperands[i]->getType();
+ if (ActualTy == ExpectedTy)
+ continue;
+ assert(isa<PointerType>(ActualTy) && isa<PointerType>(ExpectedTy) &&
+ "Type difference is not trivial!");
+ CallOperands[i] = Builder.CreateBitCast(CallOperands[i], ExpectedTy);
+ }
+
// Unlike LLVM, GCC does not require that call statements provide a value for
// every function argument (it passes rubbish for arguments with no value).
// To get the same effect we pass 'undef' for any unspecified arguments.