[llvm] a08cbab - [MC] Optimize relaxInstruction: remove SmallVector copy. NFC
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Thu May 4 23:34:40 PDT 2023
Author: Fangrui Song
Date: 2023-05-04T23:34:35-07:00
New Revision: a08cbabb28e5e5f27ce802e1b26ba273a071a0f3
URL: https://github.com/llvm/llvm-project/commit/a08cbabb28e5e5f27ce802e1b26ba273a071a0f3
DIFF: https://github.com/llvm/llvm-project/commit/a08cbabb28e5e5f27ce802e1b26ba273a071a0f3.diff
LOG: [MC] Optimize relaxInstruction: remove SmallVector copy. NFC
Added:
Modified:
llvm/lib/MC/MCAssembler.cpp
Removed:
################################################################################
diff --git a/llvm/lib/MC/MCAssembler.cpp b/llvm/lib/MC/MCAssembler.cpp
index 159b6a8ffc984..8d87bcb5dc202 100644
--- a/llvm/lib/MC/MCAssembler.cpp
+++ b/llvm/lib/MC/MCAssembler.cpp
@@ -990,18 +990,11 @@ bool MCAssembler::relaxInstruction(MCAsmLayout &Layout,
getBackend().relaxInstruction(Relaxed, *F.getSubtargetInfo());
// Encode the new instruction.
- //
- // FIXME-PERF: If it matters, we could let the target do this. It can
- // probably do so more efficiently in many cases.
- SmallVector<MCFixup, 4> Fixups;
- SmallString<256> Code;
- getEmitter().encodeInstruction(Relaxed, Code, Fixups, *F.getSubtargetInfo());
-
- // Update the fragment.
F.setInst(Relaxed);
- F.getContents() = Code;
- F.getFixups() = Fixups;
-
+ F.getFixups().clear();
+ F.getContents().clear();
+ getEmitter().encodeInstruction(Relaxed, F.getContents(), F.getFixups(),
+ *F.getSubtargetInfo());
return true;
}
More information about the llvm-commits
mailing list