Skip to content

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