[PATCH] D60231: Include invoke'd functions for recursive extract
David Callahan via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 3 13:19:15 PDT 2019
david2050 created this revision.
david2050 added reviewers: loladiro, espindola, volkan.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
When recursively extracting a function from a bit code file, include functions mentioned in InvokeInst as well as CallInst
Repository:
rL LLVM
https://reviews.llvm.org/D60231
Files:
test/tools/llvm-extract/recursive.ll
tools/llvm-extract/llvm-extract.cpp
Index: tools/llvm-extract/llvm-extract.cpp
===================================================================
--- tools/llvm-extract/llvm-extract.cpp
+++ tools/llvm-extract/llvm-extract.cpp
@@ -270,10 +270,11 @@
ExitOnErr(F->materialize());
for (auto &BB : *F) {
for (auto &I : BB) {
- auto *CI = dyn_cast<CallInst>(&I);
- if (!CI)
- continue;
- Function *CF = CI->getCalledFunction();
+ Function *CF = nullptr;
+ if(auto *CI = dyn_cast<CallInst>(&I))
+ CF = CI->getCalledFunction();
+ else if(auto *II = dyn_cast<InvokeInst>(&I))
+ CF = II->getCalledFunction();
if (!CF)
continue;
if (CF->isDeclaration() || GVs.count(CF))
Index: test/tools/llvm-extract/recursive.ll
===================================================================
--- test/tools/llvm-extract/recursive.ll
+++ test/tools/llvm-extract/recursive.ll
@@ -1,6 +1,7 @@
; RUN: llvm-extract -func=a --recursive %s -S | FileCheck --check-prefix=CHECK-AB %s
; RUN: llvm-extract -func=a --recursive --delete %s -S | FileCheck --check-prefix=CHECK-CD %s
; RUN: llvm-extract -func=d --recursive %s -S | FileCheck --check-prefix=CHECK-CD %s
+; RUN: llvm-extract -func=e --recursive %s -S | FileCheck --check-prefix=CHECK-CD %s
; CHECK-AB: define void @a
; CHECK-AB: define void @b
@@ -30,3 +31,10 @@
call void @c()
ret void
}
+
+define void @e() {
+ invoke void @c()
+ to label %L unwind label %L
+L:
+ ret void
+}
\ No newline at end of file
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60231.193579.patch
Type: text/x-patch
Size: 1563 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190403/2fb4de0a/attachment.bin>
More information about the llvm-commits
mailing list