Match an element of the return type if it returns a structure.
authorBill Wendling <isanbard@gmail.com>
Wed, 19 Nov 2008 01:15:05 +0000 (01:15 +0000)
committerBill Wendling <isanbard@gmail.com>
Wed, 19 Nov 2008 01:15:05 +0000 (01:15 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@59576 91177308-0d34-0410-b5e6-96231b3b80d8

lib/VMCore/Verifier.cpp

index 86413ed6202caeb3695c461aaa396dd7f8334331..43ecf65f7e43b639ab5f817e65fd4fb48912167f 100644 (file)
@@ -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<StructType>(RetTy);
+    unsigned NumRets = 1;
+
+    if (ST)
+      NumRets = ST->getNumElements();
+
+    if (Match <= static_cast<int>(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;