Skip to content

[ARM] Use DenseSet instead of DenseMap. NFC #131978

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 19, 2025
Merged

Conversation

topperc
Copy link
Collaborator

@topperc topperc commented Mar 19, 2025

The value in the map is set to "true" when something is added to the map.

Techncally this:

if (!DefRegs.contains(Reg))

will set the value in the map to false if it didn't already exist, and this is used to indicate the value wasn't in the map. This only occurs after all the "true" values have already been added to the map.

The value in the map is set to "true" when something is added to
the map.

Techncally this:

  if (!DefRegs.contains(Reg))

will set the value in the map to false if it didn't alrady exist,
and this is used to indicate the value wasn't in the map. This only
occurs after all the "true" values have already been added to the map.
@llvmbot
Copy link
Member

llvmbot commented Mar 19, 2025

@llvm/pr-subscribers-backend-arm

Author: Craig Topper (topperc)

Changes

The value in the map is set to "true" when something is added to the map.

Techncally this:

if (!DefRegs.contains(Reg))

will set the value in the map to false if it didn't alrady exist, and this is used to indicate the value wasn't in the map. This only occurs after all the "true" values have already been added to the map.


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

1 Files Affected:

  • (modified) llvm/lib/Target/ARM/ARMISelLowering.cpp (+3-3)
diff --git a/llvm/lib/Target/ARM/ARMISelLowering.cpp b/llvm/lib/Target/ARM/ARMISelLowering.cpp
index 1fb68fa85f7b6..234abefe75ee7 100644
--- a/llvm/lib/Target/ARM/ARMISelLowering.cpp
+++ b/llvm/lib/Target/ARM/ARMISelLowering.cpp
@@ -11366,12 +11366,12 @@ void ARMTargetLowering::EmitSjLjDispatchBlock(MachineInstr &MI,
            II = BB->rbegin(), IE = BB->rend(); II != IE; ++II) {
       if (!II->isCall()) continue;
 
-      DenseMap<unsigned, bool> DefRegs;
+      DenseSet<unsigned> DefRegs;
       for (MachineInstr::mop_iterator
              OI = II->operands_begin(), OE = II->operands_end();
            OI != OE; ++OI) {
         if (!OI->isReg()) continue;
-        DefRegs[OI->getReg()] = true;
+        DefRegs.insert(OI->getReg());
       }
 
       MachineInstrBuilder MIB(*MF, &*II);
@@ -11386,7 +11386,7 @@ void ARMTargetLowering::EmitSjLjDispatchBlock(MachineInstr &MI,
           continue;
         if (!Subtarget->isThumb() && !ARM::GPRRegClass.contains(Reg))
           continue;
-        if (!DefRegs[Reg])
+        if (!DefRegs.contains(Reg))
           MIB.addReg(Reg, RegState::ImplicitDefine | RegState::Dead);
       }
 

Copy link
Contributor

@kazutakahirata kazutakahirata left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks!

@topperc topperc merged commit d7879e5 into llvm:main Mar 19, 2025
11 of 13 checks passed
@topperc topperc deleted the pr/arm-denseset branch March 19, 2025 15:32
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