[llvm] 566fbb4 - [RISCV] Defer creating RISCVInsertVSETVLI to avoid leak with -stop-after (#92303)
via llvm-commits
llvm-commits at lists.llvm.org
Wed May 15 21:58:13 PDT 2024
Author: Luke Lau
Date: 2024-05-16T12:57:28+08:00
New Revision: 566fbb450092bf8c9f966a6ab1b0381626e3e535
URL: https://github.com/llvm/llvm-project/commit/566fbb450092bf8c9f966a6ab1b0381626e3e535
DIFF: https://github.com/llvm/llvm-project/commit/566fbb450092bf8c9f966a6ab1b0381626e3e535.diff
LOG: [RISCV] Defer creating RISCVInsertVSETVLI to avoid leak with -stop-after (#92303)
As noted in
https://github.com/llvm/llvm-project/pull/91440#discussion_r1601976425,
if the pass pipeline stops early because of -stop-after any allocated
passes added with insertPass will not be freed if they haven't already
been added.
This was showing up as a failure on the address sanitizer buildbots. We
can fix it by instead passing the pass ID instead so that allocation is
deferred.
Added:
Modified:
llvm/lib/Target/RISCV/RISCV.h
llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
llvm/lib/Target/RISCV/RISCVTargetMachine.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/RISCV/RISCV.h b/llvm/lib/Target/RISCV/RISCV.h
index d405395dcf9ec..2b8688c5de61f 100644
--- a/llvm/lib/Target/RISCV/RISCV.h
+++ b/llvm/lib/Target/RISCV/RISCV.h
@@ -60,6 +60,7 @@ void initializeRISCVExpandAtomicPseudoPass(PassRegistry &);
FunctionPass *createRISCVInsertVSETVLIPass();
void initializeRISCVInsertVSETVLIPass(PassRegistry &);
+extern char &RISCVInsertVSETVLIID;
FunctionPass *createRISCVCoalesceVSETVLIPass();
void initializeRISCVCoalesceVSETVLIPass(PassRegistry &);
diff --git a/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp b/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
index 363007d7b68b1..324ce5cb5ed7d 100644
--- a/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
+++ b/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
@@ -868,6 +868,7 @@ class RISCVCoalesceVSETVLI : public MachineFunctionPass {
} // end anonymous namespace
char RISCVInsertVSETVLI::ID = 0;
+char &llvm::RISCVInsertVSETVLIID = RISCVInsertVSETVLI::ID;
INITIALIZE_PASS(RISCVInsertVSETVLI, DEBUG_TYPE, RISCV_INSERT_VSETVLI_NAME,
false, false)
diff --git a/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp b/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp
index 5d598a275a008..5aab138dae408 100644
--- a/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp
+++ b/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp
@@ -548,9 +548,9 @@ void RISCVPassConfig::addPreRegAlloc() {
// Run RISCVInsertVSETVLI after PHI elimination. On O1 and above do it after
// register coalescing so needVSETVLIPHI doesn't need to look through COPYs.
if (TM->getOptLevel() == CodeGenOptLevel::None)
- insertPass(&PHIEliminationID, createRISCVInsertVSETVLIPass());
+ insertPass(&PHIEliminationID, &RISCVInsertVSETVLIID);
else
- insertPass(&RegisterCoalescerID, createRISCVInsertVSETVLIPass());
+ insertPass(&RegisterCoalescerID, &RISCVInsertVSETVLIID);
}
void RISCVPassConfig::addFastRegAlloc() {
More information about the llvm-commits
mailing list