[OpaquePtr] Support invoke instruction
authorNikita Popov <nikita.ppv@gmail.com>
Tue, 22 Jun 2021 20:10:51 +0000 (22:10 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Wed, 23 Jun 2021 18:24:33 +0000 (20:24 +0200)
With call support in place, this is only a matter of relaxing a
bitcode reader assertion.

llvm/lib/Bitcode/Reader/BitcodeReader.cpp
llvm/test/Assembler/opaque-ptr.ll

index 7d69bd4..7deb193 100644 (file)
@@ -4638,7 +4638,7 @@ Error BitcodeReader::parseFunctionBody(Function *F) {
             cast<PointerType>(Callee->getType())->getElementType());
         if (!FTy)
           return error("Callee is not of pointer to function type");
-      } else if (cast<PointerType>(Callee->getType())->getElementType() != FTy)
+      } else if (!CalleeTy->isOpaqueOrPointeeTypeMatches(FTy))
         return error("Explicit invoke type does not match pointee type of "
                      "callee operand");
       if (Record.size() < FTy->getNumParams() + OpNum)
index d4ce6a9..62d2d50 100644 (file)
@@ -114,3 +114,20 @@ define void @call_arg(ptr %p, i32 %a) {
   call void %p(i32 %a)
   ret void
 }
+
+; CHECK: define void @invoke(ptr %p) personality void ()* @personality {
+; CHECK:   invoke void %p()
+; CHECK:     to label %continue unwind label %cleanup
+declare void @personality()
+define void @invoke(ptr %p) personality void ()* @personality {
+  invoke void %p()
+    to label %continue unwind label %cleanup
+
+continue:
+  ret void
+
+cleanup:
+  landingpad {}
+    cleanup
+  ret void
+}