Skip to content
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

[mlir][dlti] Fix query keys preallocation #127786

Merged
merged 1 commit into from
Feb 19, 2025

Conversation

adam-smnk
Copy link
Contributor

Fixes upfront space allocation after #126716

Fixes upfront space allocation after llvm#126716
@llvmbot
Copy link
Member

llvmbot commented Feb 19, 2025

@llvm/pr-subscribers-mlir

@llvm/pr-subscribers-mlir-dlti

Author: Adam Siemieniuk (adam-smnk)

Changes

Fixes upfront space allocation after #126716


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

1 Files Affected:

  • (modified) mlir/lib/Dialect/DLTI/DLTI.cpp (+2-1)
diff --git a/mlir/lib/Dialect/DLTI/DLTI.cpp b/mlir/lib/Dialect/DLTI/DLTI.cpp
index b057554c40d8c..70e05cb4cb383 100644
--- a/mlir/lib/Dialect/DLTI/DLTI.cpp
+++ b/mlir/lib/Dialect/DLTI/DLTI.cpp
@@ -571,7 +571,8 @@ FailureOr<Attribute> dlti::query(Operation *op, ArrayRef<StringRef> keys,
     return failure();
 
   MLIRContext *ctx = op->getContext();
-  SmallVector<DataLayoutEntryKey> entryKeys(keys.size());
+  SmallVector<DataLayoutEntryKey> entryKeys;
+  entryKeys.reserve(keys.size());
   for (StringRef key : keys)
     entryKeys.push_back(StringAttr::get(ctx, key));
 

Copy link
Contributor

@rolfmorel rolfmorel left a comment

Choose a reason for hiding this comment

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

Ah, yeah. Should have looked more carefully at that myself.

LGTM now though!

@adam-smnk adam-smnk merged commit c6a907a into llvm:main Feb 19, 2025
11 checks passed
Prakhar-Dixit pushed a commit to Prakhar-Dixit/llvm-project that referenced this pull request Feb 19, 2025
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