[llvm] [MC] Avoid useless triple copy (PR #103026)
Alexis Engelke via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 13 02:11:06 PDT 2024
https://github.com/aengelke created https://github.com/llvm/llvm-project/pull/103026
Copying a triple is cheap, but not free, so let's not do that if there's no reason to do so.
Trivial cleanup.
>From 0978e5964f7057d2e7d9f2ac4df7c6728668a63f Mon Sep 17 00:00:00 2001
From: Alexis Engelke <engelke at in.tum.de>
Date: Tue, 13 Aug 2024 08:44:30 +0000
Subject: [PATCH] [MC] Avoid useless triply copy
Copying a triple is cheap, but not free, so let's not do that if there's
no reason to do so.
---
llvm/include/llvm/CodeGen/BasicTTIImpl.h | 2 +-
llvm/lib/MC/MCObjectFileInfo.cpp | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
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);
More information about the llvm-commits
mailing list