[lld] r277644 - Do not instantiate Triple twice.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 3 13:25:29 PDT 2016
Author: ruiu
Date: Wed Aug 3 15:25:29 2016
New Revision: 277644
URL: http://llvm.org/viewvc/llvm-project?rev=277644&view=rev
Log:
Do not instantiate Triple twice.
Also removes redundant variables. NFC.
Modified:
lld/trunk/ELF/InputFiles.cpp
Modified: lld/trunk/ELF/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputFiles.cpp?rev=277644&r1=277643&r2=277644&view=diff
==============================================================================
--- lld/trunk/ELF/InputFiles.cpp (original)
+++ lld/trunk/ELF/InputFiles.cpp Wed Aug 3 15:25:29 2016
@@ -554,17 +554,15 @@ template <class ELFT> void SharedFile<EL
}
static ELFKind getELFKind(MemoryBufferRef MB) {
- std::string TripleStr = getBitcodeTargetTriple(MB, Driver->Context);
- Triple TheTriple(TripleStr);
- bool Is64Bits = TheTriple.isArch64Bit();
- if (TheTriple.isLittleEndian())
- return Is64Bits ? ELF64LEKind : ELF32LEKind;
- return Is64Bits ? ELF64BEKind : ELF32BEKind;
+ Triple T(getBitcodeTargetTriple(MB, Driver->Context));
+ if (T.isLittleEndian())
+ return T.isArch64Bit() ? ELF64LEKind : ELF32LEKind;
+ return T.isArch64Bit() ? ELF64BEKind : ELF32BEKind;
}
static uint8_t getMachineKind(MemoryBufferRef MB) {
- std::string TripleStr = getBitcodeTargetTriple(MB, Driver->Context);
- switch (Triple(TripleStr).getArch()) {
+ Triple T(getBitcodeTargetTriple(MB, Driver->Context));
+ switch (T.getArch()) {
case Triple::aarch64:
return EM_AARCH64;
case Triple::arm:
@@ -579,13 +577,12 @@ static uint8_t getMachineKind(MemoryBuff
case Triple::ppc64:
return EM_PPC64;
case Triple::x86:
- return Triple(TripleStr).isOSIAMCU() ? EM_IAMCU : EM_386;
+ return T.isOSIAMCU() ? EM_IAMCU : EM_386;
case Triple::x86_64:
return EM_X86_64;
default:
fatal(MB.getBufferIdentifier() +
- ": could not infer e_machine from bitcode target triple " +
- TripleStr);
+ ": could not infer e_machine from bitcode target triple " + T.str());
}
}
More information about the llvm-commits
mailing list