Skip to content

[RISCV][llvm-exegesis] Simplify copying a SmallVector to a std::vector. NFC #122988

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
Jan 15, 2025

Conversation

topperc
Copy link
Collaborator

@topperc topperc commented Jan 14, 2025

No description provided.

@topperc topperc changed the title [RISCV][llvm-exegesis] Simplfy copying a SmallVector to a std::vector. NFC [RISCV][llvm-exegesis] Simplify copying a SmallVector to a std::vector. NFC Jan 14, 2025
@llvmbot
Copy link
Member

llvmbot commented Jan 14, 2025

@llvm/pr-subscribers-tools-llvm-exegesis

Author: Craig Topper (topperc)

Changes

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

1 Files Affected:

  • (modified) llvm/tools/llvm-exegesis/lib/RISCV/Target.cpp (+1-3)
diff --git a/llvm/tools/llvm-exegesis/lib/RISCV/Target.cpp b/llvm/tools/llvm-exegesis/lib/RISCV/Target.cpp
index 5636782bdf7f6f..d55db9af8a9bd8 100644
--- a/llvm/tools/llvm-exegesis/lib/RISCV/Target.cpp
+++ b/llvm/tools/llvm-exegesis/lib/RISCV/Target.cpp
@@ -32,13 +32,11 @@ namespace {
 static std::vector<MCInst> loadIntReg(const MCSubtargetInfo &STI, unsigned Reg,
                                       const APInt &Value) {
   SmallVector<MCInst, 8> MCInstSeq;
-  std::vector<MCInst> MatIntInstrs;
   MCRegister DestReg = Reg;
 
   RISCVMatInt::generateMCInstSeq(Value.getSExtValue(), STI, DestReg, MCInstSeq);
-  MatIntInstrs.resize(MCInstSeq.size());
-  std::copy(MCInstSeq.begin(), MCInstSeq.end(), MatIntInstrs.begin());
 
+  std::vector<MCInst> MatIntInstrs(MCInstSeq.begin(), MCInstSeq.end());
   return MatIntInstrs;
 }
 

Copy link
Contributor

@boomanaiden154 boomanaiden154 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 for the cleanup.

@topperc topperc merged commit da4ac13 into llvm:main Jan 15, 2025
10 checks passed
@topperc topperc deleted the pr/exegesis-simplify-copy branch January 15, 2025 04:04
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