Skip to content

Commit 5554eda

Browse files
committed
[CloneFunction] Don't remove unrelated nodes from the CGSSC
CGSCC use a WeakVH to track call sites. RAUW a call within a function can result in that WeakVH getting confused about whether or not the call site is still around. llvm-svn: 279268
1 parent 9335bf0 commit 5554eda

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

llvm/lib/Transforms/Utils/CloneFunction.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,12 @@ void llvm::CloneAndPruneIntoFromInst(Function *NewFunc, const Function *OldFunc,
566566
if (!I)
567567
continue;
568568

569+
// Skip over non-intrinsic callsites, we don't want to remove any nodes from
570+
// the CGSCC.
571+
CallSite CS = CallSite(I);
572+
if (CS && CS.getCalledFunction() && !CS.getCalledFunction()->isIntrinsic())
573+
continue;
574+
569575
// See if this instruction simplifies.
570576
Value *SimpleV = SimplifyInstruction(I, DL);
571577
if (!SimpleV)

llvm/test/Transforms/Inline/inline_constprop.ll

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,8 @@ entry:
299299
}
300300

301301
; CHECK-LABEL: define i32 @PR28802(
302-
; CHECK: call i32 @PR28802.external(i32 0)
303-
; CHECK: ret i32 0
302+
; CHECK: %[[call:.*]] = call i32 @PR28802.external(i32 0)
303+
; CHECK: ret i32 %[[call]]
304304

305305
define internal i32 @PR28848.callee(i32 %p2, i1 %c) {
306306
entry:
@@ -322,3 +322,25 @@ entry:
322322
}
323323
; CHECK-LABEL: define i32 @PR28848(
324324
; CHECK: ret i32 0
325+
326+
define internal void @callee7(i16 %param1, i16 %param2) {
327+
entry:
328+
br label %bb
329+
330+
bb:
331+
%phi = phi i16 [ %param2, %entry ]
332+
%add = add i16 %phi, %param1
333+
ret void
334+
}
335+
336+
declare i16 @caller7.external(i16 returned)
337+
338+
define void @caller7() {
339+
bb1:
340+
%call = call i16 @caller7.external(i16 1)
341+
call void @callee7(i16 0, i16 %call)
342+
ret void
343+
}
344+
; CHECK-LABEL: define void @caller7(
345+
; CHECK: %call = call i16 @caller7.external(i16 1)
346+
; CHECK-NEXT: ret void

0 commit comments

Comments
 (0)