From 5a374e2969699cbbe83da62c8f4af666dbdd6eed Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Wed, 19 Nov 2008 01:15:05 +0000 Subject: [PATCH] Match an element of the return type if it returns a structure. llvm-svn: 59576 --- lib/VMCore/Verifier.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp index 86413ed6202..43ecf65f7e4 100644 --- a/lib/VMCore/Verifier.cpp +++ b/lib/VMCore/Verifier.cpp @@ -1395,8 +1395,18 @@ bool Verifier::PerformTypeCheck(Intrinsic::ID ID, Function *F, const Type *Ty, if (VT < 0) { int Match = ~VT; - if (Match == 0) { - if (Ty != FTy->getReturnType()) { + const Type *RetTy = FTy->getReturnType(); + const StructType *ST = cast(RetTy); + unsigned NumRets = 1; + + if (ST) + NumRets = ST->getNumElements(); + + if (Match <= static_cast(NumRets - 1)) { + if (ST) + RetTy = ST->getElementType(Match); + + if (Ty != RetTy) { CheckFailed("Intrinsic parameter #" + utostr(ArgNo - 1) + " does not " "match return type.", F); return false;