]> granicus.if.org Git - llvm/commitdiff
Include invoke'd functions for recursive extract
authorDavid Callahan <dcallahan@fb.com>
Thu, 4 Apr 2019 23:30:47 +0000 (23:30 +0000)
committerDavid Callahan <dcallahan@fb.com>
Thu, 4 Apr 2019 23:30:47 +0000 (23:30 +0000)
Summary: When recursively extracting a function from a bit code file, include functions mentioned in InvokeInst as well as CallInst

Reviewers: loladiro, espindola, volkan

Reviewed By: loladiro

Subscribers: llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D60231

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@357735 91177308-0d34-0410-b5e6-96231b3b80d8

test/tools/llvm-extract/recursive.ll
tools/llvm-extract/llvm-extract.cpp

index 54813dba796883c6035400e74278f959c6b5314e..7fa9eceba91eb4bd12b78b5ef3bc58a79e23f885 100644 (file)
@@ -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 @@ define void @d() {
   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
index 30c89a874398428855eb61001d04bd963fc37bc3..64674729bf4b14012418351e4d226037e1bcf918 100644 (file)
@@ -270,10 +270,10 @@ int main(int argc, char **argv) {
       ExitOnErr(F->materialize());
       for (auto &BB : *F) {
         for (auto &I : BB) {
-          auto *CI = dyn_cast<CallInst>(&I);
-          if (!CI)
+          CallBase *CB = dyn_cast<CallBase>(&I);
+          if (!CB)
             continue;
-          Function *CF = CI->getCalledFunction();
+          Function *CF = CB->getCalledFunction();
           if (!CF)
             continue;
           if (CF->isDeclaration() || GVs.count(CF))