[llvm] r357735 - Include invoke'd functions for recursive extract

David Callahan via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 4 16:30:47 PDT 2019


Author: david2050
Date: Thu Apr  4 16:30:47 2019
New Revision: 357735

URL: http://llvm.org/viewvc/llvm-project?rev=357735&view=rev
Log:
Include invoke'd functions for recursive extract

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

Modified:
    llvm/trunk/test/tools/llvm-extract/recursive.ll
    llvm/trunk/tools/llvm-extract/llvm-extract.cpp

Modified: llvm/trunk/test/tools/llvm-extract/recursive.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-extract/recursive.ll?rev=357735&r1=357734&r2=357735&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-extract/recursive.ll (original)
+++ llvm/trunk/test/tools/llvm-extract/recursive.ll Thu Apr  4 16:30:47 2019
@@ -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

Modified: llvm/trunk/tools/llvm-extract/llvm-extract.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-extract/llvm-extract.cpp?rev=357735&r1=357734&r2=357735&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-extract/llvm-extract.cpp (original)
+++ llvm/trunk/tools/llvm-extract/llvm-extract.cpp Thu Apr  4 16:30:47 2019
@@ -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))




More information about the llvm-commits mailing list