mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 12:41:49 +01:00
BlockExtractor: Don’t delete functions directly
Blocks may have function calls, so don’t erase functions directly to avoid erasing a function that has a user. llvm-svn: 327340
This commit is contained in:
parent
db7886716e
commit
e71a34b01d
@ -161,8 +161,9 @@ bool BlockExtractor::runOnModule(Module &M) {
|
||||
// Erase the functions.
|
||||
if (EraseFunctions || BlockExtractorEraseFuncs) {
|
||||
for (Function *F : Functions) {
|
||||
DEBUG(dbgs() << "BlockExtractor: Deleting " << F->getName() << "\n");
|
||||
F->eraseFromParent();
|
||||
DEBUG(dbgs() << "BlockExtractor: Trying to delete " << F->getName()
|
||||
<< "\n");
|
||||
F->deleteBody();
|
||||
}
|
||||
// Set linkage as ExternalLinkage to avoid erasing unreachable functions.
|
||||
for (Function &F : M)
|
||||
|
@ -6,7 +6,7 @@
|
||||
; CHECK-NO-ERASE: @foo(
|
||||
; CHECK-NO-ERASE: @foo_bb9(
|
||||
; CHECK-NO-ERASE: @foo_bb20(
|
||||
; CHECK-ERASE-NOT: @foo(
|
||||
; CHECK-ERASE: declare i32 @foo(
|
||||
; CHECK-ERASE: @foo_bb9(
|
||||
; CHECK-ERASE: @foo_bb20(
|
||||
define i32 @foo(i32 %arg, i32 %arg1) {
|
||||
|
@ -1,6 +1,19 @@
|
||||
; RUN: llvm-extract -S -bb foo:bb4 %s | FileCheck %s
|
||||
|
||||
; CHECK: declare void @bar()
|
||||
define void @bar() {
|
||||
bb:
|
||||
ret void
|
||||
}
|
||||
|
||||
; CHECK-NOT: @unused()
|
||||
define void @unused() {
|
||||
bb:
|
||||
ret void
|
||||
}
|
||||
|
||||
; CHECK: @foo_bb4
|
||||
; CHECK: call void @bar()
|
||||
; CHECK: %tmp5
|
||||
define i32 @foo(i32 %arg) {
|
||||
bb:
|
||||
@ -12,6 +25,7 @@ bb:
|
||||
br i1 %tmp3, label %bb4, label %bb7
|
||||
|
||||
bb4: ; preds = %bb
|
||||
call void @bar()
|
||||
%tmp5 = load i32, i32* %tmp1, align 4
|
||||
%tmp6 = add nsw i32 %tmp5, 1
|
||||
store i32 %tmp6, i32* %tmp1, align 4
|
||||
|
Loading…
x
Reference in New Issue
Block a user