[llvm] [MC] Avoid useless triple copy (PR #103026)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 13 02:11:37 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mc
Author: Alexis Engelke (aengelke)
<details>
<summary>Changes</summary>
Copying a triple is cheap, but not free, so let's not do that if there's no reason to do so.
Trivial cleanup.
---
Full diff: https://github.com/llvm/llvm-project/pull/103026.diff
2 Files Affected:
- (modified) llvm/include/llvm/CodeGen/BasicTTIImpl.h (+1-1)
- (modified) llvm/lib/MC/MCObjectFileInfo.cpp (+1-1)
``````````diff
diff --git a/llvm/include/llvm/CodeGen/BasicTTIImpl.h b/llvm/include/llvm/CodeGen/BasicTTIImpl.h
index c2bc1353ee8838..279cfb5aa47d6f 100644
--- a/llvm/include/llvm/CodeGen/BasicTTIImpl.h
+++ b/llvm/include/llvm/CodeGen/BasicTTIImpl.h
@@ -525,7 +525,7 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
TM.getCodeModel() == CodeModel::Large)
return false;
- Triple TargetTriple = TM.getTargetTriple();
+ const Triple &TargetTriple = TM.getTargetTriple();
if (!TargetTriple.isArch64Bit())
return false;
diff --git a/llvm/lib/MC/MCObjectFileInfo.cpp b/llvm/lib/MC/MCObjectFileInfo.cpp
index 6dadd9752646f2..f37e138edc36b1 100644
--- a/llvm/lib/MC/MCObjectFileInfo.cpp
+++ b/llvm/lib/MC/MCObjectFileInfo.cpp
@@ -1024,7 +1024,7 @@ void MCObjectFileInfo::initMCObjectFileInfo(MCContext &MCCtx, bool PIC,
DwarfAccelNamespaceSection = nullptr; // Used only by selected targets.
DwarfAccelTypesSection = nullptr; // Used only by selected targets.
- Triple TheTriple = Ctx->getTargetTriple();
+ const Triple &TheTriple = Ctx->getTargetTriple();
switch (Ctx->getObjectFileType()) {
case MCContext::IsMachO:
initMachOMCObjectFileInfo(TheTriple);
``````````
</details>
https://github.com/llvm/llvm-project/pull/103026
More information about the llvm-commits
mailing list