Skip to content

Conversation

@kazutakahirata
Copy link
Contributor

This patch uses DenseSet instead of DenseMap. Note that the set of
Registers that map to true without this patch is the same as the set
of Registers that are present in the set with this patch. This patch
is inspired by:

commit d7879e5
Author: Craig Topper [email protected]
Date: Wed Mar 19 08:32:09 2025 -0700

This patch uses DenseSet instead of DenseMap.  Note that the set of
Registers that map to true without this patch is the same as the set
of Registers that are present in the set with this patch.  This patch
is inspired by:

  commit d7879e5
  Author: Craig Topper <[email protected]>
  Date:   Wed Mar 19 08:32:09 2025 -0700
@llvmbot
Copy link
Member

llvmbot commented Mar 23, 2025

@llvm/pr-subscribers-backend-x86

Author: Kazu Hirata (kazutakahirata)

Changes

This patch uses DenseSet instead of DenseMap. Note that the set of
Registers that map to true without this patch is the same as the set
of Registers that are present in the set with this patch. This patch
is inspired by:

commit d7879e5
Author: Craig Topper <[email protected]>
Date: Wed Mar 19 08:32:09 2025 -0700


Full diff: https://github.com/llvm/llvm-project/pull/132619.diff

2 Files Affected:

  • (modified) llvm/lib/Target/VE/VEISelLowering.cpp (+3-3)
  • (modified) llvm/lib/Target/X86/X86ISelLowering.cpp (+3-3)
diff --git a/llvm/lib/Target/VE/VEISelLowering.cpp b/llvm/lib/Target/VE/VEISelLowering.cpp
index b7fa089921c2d..313c894cafa85 100644
--- a/llvm/lib/Target/VE/VEISelLowering.cpp
+++ b/llvm/lib/Target/VE/VEISelLowering.cpp
@@ -2645,15 +2645,15 @@ VETargetLowering::emitSjLjDispatchBlock(MachineInstr &MI,
       if (!II.isCall())
         continue;
 
-      DenseMap<Register, bool> DefRegs;
+      DenseSet<Register> DefRegs;
       for (auto &MOp : II.operands())
         if (MOp.isReg())
-          DefRegs[MOp.getReg()] = true;
+          DefRegs.insert(MOp.getReg());
 
       MachineInstrBuilder MIB(*MF, &II);
       for (unsigned RI = 0; SavedRegs[RI]; ++RI) {
         Register Reg = SavedRegs[RI];
-        if (!DefRegs[Reg])
+        if (!DefRegs.contains(Reg))
           MIB.addReg(Reg, RegState::ImplicitDefine | RegState::Dead);
       }
 
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index a7db154bfaa3b..0f737b1f8d854 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -37430,15 +37430,15 @@ X86TargetLowering::EmitSjLjDispatchBlock(MachineInstr &MI,
       if (!II.isCall())
         continue;
 
-      DenseMap<Register, bool> DefRegs;
+      DenseSet<Register> DefRegs;
       for (auto &MOp : II.operands())
         if (MOp.isReg())
-          DefRegs[MOp.getReg()] = true;
+          DefRegs.insert(MOp.getReg());
 
       MachineInstrBuilder MIB(*MF, &II);
       for (unsigned RegIdx = 0; SavedRegs[RegIdx]; ++RegIdx) {
         Register Reg = SavedRegs[RegIdx];
-        if (!DefRegs[Reg])
+        if (!DefRegs.contains(Reg))
           MIB.addReg(Reg, RegState::ImplicitDefine | RegState::Dead);
       }
 

Copy link
Collaborator

@topperc topperc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kazutakahirata kazutakahirata merged commit a578a75 into llvm:main Mar 23, 2025
13 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_001_use_DenseSet branch March 23, 2025 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants