Skip to content

[CodeGen] Avoid repeated hash lookups (NFC) #131722

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

Conversation

kazutakahirata
Copy link
Contributor

No description provided.

@kazutakahirata kazutakahirata requested a review from nikic March 18, 2025 03:58
@llvmbot llvmbot added the llvm:SelectionDAG SelectionDAGISel as well label Mar 18, 2025
@llvmbot
Copy link
Member

llvmbot commented Mar 18, 2025

@llvm/pr-subscribers-llvm-selectiondag

Author: Kazu Hirata (kazutakahirata)

Changes

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

1 Files Affected:

  • (modified) llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp (+9-7)
diff --git a/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp
index 735dcef8c28bf..f01f066367509 100644
--- a/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp
@@ -916,13 +916,15 @@ SDValue SelectionDAGBuilder::LowerAsSTATEPOINT(
     bool IsLocal = (Relocate->getParent() == StatepointInstr->getParent());
 
     RecordType Record;
-    if (IsLocal && LowerAsVReg.count(SDV)) {
-      // Result is already stored in StatepointLowering
-      Record.type = RecordType::SDValueNode;
-    } else if (LowerAsVReg.count(SDV)) {
-      Record.type = RecordType::VReg;
-      assert(VirtRegs.count(SDV));
-      Record.payload.Reg = VirtRegs[SDV];
+    if (LowerAsVReg.count(SDV)) {
+      if (IsLocal) {
+        // Result is already stored in StatepointLowering
+        Record.type = RecordType::SDValueNode;
+      } else {
+        Record.type = RecordType::VReg;
+        assert(VirtRegs.count(SDV));
+        Record.payload.Reg = VirtRegs[SDV];
+      }
     } else if (Loc.getNode()) {
       Record.type = RecordType::Spill;
       Record.payload.FI = cast<FrameIndexSDNode>(Loc)->getIndex();

@kazutakahirata kazutakahirata merged commit 6220448 into llvm:main Mar 18, 2025
11 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_001_repeated_hash_lookups_llvm_SelectionDAG branch March 18, 2025 07:27
Comment on lines +925 to +927
auto It = VirtRegs.find(SDV);
assert(It != VirtRegs.end());
Record.payload.Reg = It->second;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
auto It = VirtRegs.find(SDV);
assert(It != VirtRegs.end());
Record.payload.Reg = It->second;
Record.payload.Reg = VirtRegs.at(SDV);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
llvm:SelectionDAG SelectionDAGISel as well
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants