Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion libclc/utils/libclc-remangler/LibclcRemangler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -968,6 +968,7 @@ class LibCLCRemangler : public ASTConsumer {
void postProcessRemoveTmpSuffix(llvm::Module *M) {
if (TestRun)
return;
std::vector<Function *> ToErase;
for (auto &F : make_early_inc_range(*M)) {
StringRef Name = F.getName();
if (!Name.consume_back(TmpSuffix))
Expand All @@ -976,7 +977,8 @@ class LibCLCRemangler : public ASTConsumer {
if (RenamedFunctions.count(Name.str())) {
// Drop unuseful clone of the original or remangled function.
Func->replaceAllUsesWith(ConstantPointerNull::get(Func->getType()));
Func->eraseFromParent();
Func->setName("");
ToErase.push_back(Func);
} else {
// Name doesn't exist in the original module. Drop unuseful clone of
// remangled function.
Expand All @@ -987,6 +989,8 @@ class LibCLCRemangler : public ASTConsumer {
// Complete the mangling process, e.g. from _Z1fPU3AS4i to _Z1fPi.
F.setName(Name);
}
for (auto *F : ToErase)
F->eraseFromParent();
}

void handleModule(llvm::Module *M) {
Expand Down