aboutsummaryrefslogtreecommitdiff
path: root/backend/lib
diff options
context:
space:
mode:
authorRichard-Qin-X <richard.qin.001@gmail.com>2026-08-11 19:05:56 +0800
committerRichard-Qin-X <richard.qin.001@gmail.com>2026-08-11 19:05:56 +0800
commit3eb34f8b7d06851cb2cb2b5ca04b411a3eecda20 (patch)
tree4331a611ef29e860d202275ac81b45efd27245bb /backend/lib
parenta8b2946e939ee87d1a627b49ca86db41728cc22a (diff)
downloadrcc-project-3eb34f8b7d06851cb2cb2b5ca04b411a3eecda20.tar.gz
rcc-project-3eb34f8b7d06851cb2cb2b5ca04b411a3eecda20.tar.xz
[CodeGen] Revisit instructions invalidated by legalization
Diffstat (limited to 'backend/lib')
-rw-r--r--backend/lib/CodeGen/MachinePipelinePasses.cpp23
1 files changed, 11 insertions, 12 deletions
diff --git a/backend/lib/CodeGen/MachinePipelinePasses.cpp b/backend/lib/CodeGen/MachinePipelinePasses.cpp
index 9c42bdb..9bde291 100644
--- a/backend/lib/CodeGen/MachinePipelinePasses.cpp
+++ b/backend/lib/CodeGen/MachinePipelinePasses.cpp
@@ -352,11 +352,13 @@ Expected<MachinePassResult> LegalizerPass::runImplementation(MachineFunction &Fu
std::unordered_set<OpcodeState, OpcodeStateHash> SeenStates;
std::vector<MachineInstr *> Worklist = layoutInstructions(Function);
- std::unordered_set<MachineInstrStableID> DiscoveredInstructions;
+ std::unordered_set<MachineInstrStableID> PendingInstructions;
for (const MachineInstr *Instruction : Worklist)
- DiscoveredInstructions.insert(Instruction->stableID());
+ PendingInstructions.insert(Instruction->stableID());
for (std::size_t Index = 0; Index < Worklist.size(); ++Index) {
MachineInstr *Instruction = Worklist[Index];
+ if (Instruction != nullptr)
+ PendingInstructions.erase(Instruction->stableID());
if (Instruction == nullptr || Instruction->parent() == nullptr)
continue;
@@ -418,19 +420,16 @@ Expected<MachinePassResult> LegalizerPass::runImplementation(MachineFunction &Fu
Result.Changed = true;
Result.Changes.add(MachinePassChange::Instructions);
- if (!InstructionWasErased) {
- const InstructionDescriptor *LoweredDescriptor =
- Target.instructionDescriptor(Instruction->opcode());
- if (LoweredDescriptor == nullptr)
- return std::unexpected(
- passFailure("legalizer produced an unknown instruction descriptor"));
- if (LoweredDescriptor->Flags.has(InstructionFlag::Generic))
- Worklist.push_back(Instruction);
- }
const std::vector<MachineInstr *> Current = layoutInstructions(Function);
for (MachineInstr *Candidate : Current) {
- if (DiscoveredInstructions.insert(Candidate->stableID()).second)
+ const InstructionDescriptor *CandidateDescriptor =
+ Target.instructionDescriptor(Candidate->opcode());
+ if (CandidateDescriptor == nullptr)
+ return std::unexpected(passFailure("legalizer produced an unknown instruction descriptor"));
+ if (CandidateDescriptor->Flags.has(InstructionFlag::Generic) &&
+ PendingInstructions.insert(Candidate->stableID()).second) {
Worklist.push_back(Candidate);
+ }
}
}