[llvm] e5f2b03 - [OpaquePtr] Support invoke instruction

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 23 11:24:58 PDT 2021


Author: Nikita Popov
Date: 2021-06-23T20:24:33+02:00
New Revision: e5f2b035dd8ff5cce3e12d5ab7e478f7e66b9117

URL: https://github.com/llvm/llvm-project/commit/e5f2b035dd8ff5cce3e12d5ab7e478f7e66b9117
DIFF: https://github.com/llvm/llvm-project/commit/e5f2b035dd8ff5cce3e12d5ab7e478f7e66b9117.diff

LOG: [OpaquePtr] Support invoke instruction

With call support in place, this is only a matter of relaxing a
bitcode reader assertion.

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index 7d69bd42757d1..7deb19366ec46 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -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)

diff  --git a/llvm/test/Assembler/opaque-ptr.ll b/llvm/test/Assembler/opaque-ptr.ll
index d4ce6a98af2a3..62d2d50786db4 100644
--- a/llvm/test/Assembler/opaque-ptr.ll
+++ b/llvm/test/Assembler/opaque-ptr.ll
@@ -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
+}


        


More information about the llvm-commits mailing list