Skip to content

Commit 46bbe8b

Browse files
committed
[LLVM 21] GC2Stack: remove removed removeCallEdgeFor
1 parent 705a60e commit 46bbe8b

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

gen/passes/GarbageCollect2Stack.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
#include "llvm/ADT/Statistic.h"
2525
#include "llvm/ADT/StringMap.h"
2626
#include "llvm/ADT/StringSwitch.h"
27+
#if LDC_LLVM_VER >= 2100
28+
#include "llvm/IR/AbstractCallSite.h"
29+
#endif
2730
#include "llvm/IR/Constants.h"
2831
#include "llvm/IR/DataLayout.h"
2932
#include "llvm/IR/Dominators.h"
@@ -350,7 +353,23 @@ static void RemoveCall(CallBase *CB, const G2StackAnalysis &A) {
350353

351354
// Remove the runtime call.
352355
if (A.CGNode) {
356+
#if LDC_LLVM_VER >= 2100
357+
//FIXME: Look into using `LazyCallGraph` and the new pass manager
358+
for (auto I = A.CGNode->begin(); ; I++) {
359+
assert(I != A.CGNode->end() && "Cannot find callsite to remove!");
360+
if (I->first && *I->first == CB) {
361+
A.CGNode->removeCallEdge(I);
362+
363+
// Remove all references to callback functions if there are any.
364+
forEachCallbackFunction(*CB, [=](Function *_CB) {
365+
A.CGNode->removeOneAbstractEdgeTo(A.CG->getOrInsertFunction(_CB));
366+
});
367+
break;
368+
}
369+
}
370+
#else
353371
A.CGNode->removeCallEdgeFor(*CB);
372+
#endif
354373
}
355374
static_cast<Instruction *>(CB)->eraseFromParent();
356375
}

0 commit comments

Comments
 (0)