From e5f2b035dd8ff5cce3e12d5ab7e478f7e66b9117 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Tue, 22 Jun 2021 22:10:51 +0200 Subject: [PATCH] [OpaquePtr] Support invoke instruction With call support in place, this is only a matter of relaxing a bitcode reader assertion. --- llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 2 +- llvm/test/Assembler/opaque-ptr.ll | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index 7d69bd4..7deb193 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(Callee->getType())->getElementType()); if (!FTy) return error("Callee is not of pointer to function type"); - } else if (cast(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 d4ce6a9..62d2d50 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 +} -- 2.7.4