}
ErrorOr<std::unique_ptr<MachOObjectFile>>
- getObjectForArch(Triple::ArchType Arch) const;
+ getObjectForArch(StringRef ArchName) const;
};
} // namespace object
/// \brief Load the coverage mapping from the given files.
static ErrorOr<std::unique_ptr<CoverageMapping>>
load(StringRef ObjectFilename, StringRef ProfileFilename,
- Triple::ArchType Arch = Triple::ArchType::UnknownArch);
+ StringRef Arch = StringRef());
/// \brief The number of functions that couldn't have their profiles mapped.
///
public:
static ErrorOr<std::unique_ptr<BinaryCoverageReader>>
create(std::unique_ptr<MemoryBuffer> &ObjectBuffer,
- Triple::ArchType Arch = Triple::ArchType::UnknownArch);
+ StringRef Arch);
std::error_code readNextRecord(CoverageMappingRecord &Record) override;
};
ec = std::error_code();
}
-static bool getCTMForArch(Triple::ArchType Arch, MachO::CPUType &CTM) {
- switch (Arch) {
- case Triple::x86: CTM = MachO::CPU_TYPE_I386; return true;
- case Triple::x86_64: CTM = MachO::CPU_TYPE_X86_64; return true;
- case Triple::arm: CTM = MachO::CPU_TYPE_ARM; return true;
- case Triple::sparc: CTM = MachO::CPU_TYPE_SPARC; return true;
- case Triple::ppc: CTM = MachO::CPU_TYPE_POWERPC; return true;
- case Triple::ppc64: CTM = MachO::CPU_TYPE_POWERPC64; return true;
- default: return false;
- }
-}
-
ErrorOr<std::unique_ptr<MachOObjectFile>>
-MachOUniversalBinary::getObjectForArch(Triple::ArchType Arch) const {
- MachO::CPUType CTM;
- if (!getCTMForArch(Arch, CTM))
+MachOUniversalBinary::getObjectForArch(StringRef ArchName) const {
+ if (Triple(ArchName).getArch() == Triple::ArchType::UnknownArch)
return object_error::arch_not_found;
+
for (object_iterator I = begin_objects(), E = end_objects(); I != E; ++I) {
- if (I->getCPUType() == static_cast<uint32_t>(CTM))
+ if (I->getArchTypeName() == ArchName)
return I->getAsObjectFile();
}
return object_error::arch_not_found;
ErrorOr<std::unique_ptr<CoverageMapping>>
CoverageMapping::load(StringRef ObjectFilename, StringRef ProfileFilename,
- Triple::ArchType Arch) {
+ StringRef Arch) {
auto CounterMappingBuff = MemoryBuffer::getFileOrSTDIN(ObjectFilename);
if (std::error_code EC = CounterMappingBuff.getError())
return EC;
StringRef &CoverageMapping,
uint8_t &BytesInAddress,
support::endianness &Endian,
- Triple::ArchType Arch) {
+ StringRef Arch) {
auto BinOrErr = object::createBinary(ObjectBuffer);
if (std::error_code EC = BinOrErr.getError())
return EC;
// For any other object file, upcast and take ownership.
OF.reset(cast<object::ObjectFile>(Bin.release()));
// If we've asked for a particular arch, make sure they match.
- if (Arch != Triple::ArchType::UnknownArch && OF->getArch() != Arch)
+ if (!Arch.empty() && OF->getArch() != Triple(Arch).getArch())
return object_error::arch_not_found;
} else
// We can only handle object files.
ErrorOr<std::unique_ptr<BinaryCoverageReader>>
BinaryCoverageReader::create(std::unique_ptr<MemoryBuffer> &ObjectBuffer,
- Triple::ArchType Arch) {
+ StringRef Arch) {
std::unique_ptr<BinaryCoverageReader> Reader(new BinaryCoverageReader());
SectionData Profile;
--- /dev/null
+/* Compile with:
+ clang -arch armv7 -arch armv7m -arch armv7em -arch x86_64 -arch x86_64h -c
+*/
+
+#ifdef __x86_64h__
+void x86_64h_function() {}
+#elif defined(__x86_64__)
+void x86_64_function() {}
+#elif defined(__ARM_ARCH_7EM__)
+void armv7em_function() {}
+#elif defined(__ARM_ARCH_7M__)
+void armv7m_function() {}
+#elif defined(__ARM_ARCH_7A__)
+void armv7_function() {}
+#endif
--- /dev/null
+RUN: echo 0 | llvm-symbolizer -obj=%p/Inputs/fat.o -default-arch=x86_64 | FileCheck --check-prefix=X86_64 %s
+RUN: echo 0 | llvm-symbolizer -obj=%p/Inputs/fat.o -default-arch=x86_64h | FileCheck --check-prefix=X86_64H %s
+RUN: echo 0 | llvm-symbolizer -obj=%p/Inputs/fat.o -default-arch=armv7 | FileCheck --check-prefix=ARMV7 %s
+RUN: echo 0 | llvm-symbolizer -obj=%p/Inputs/fat.o -default-arch=armv7em | FileCheck --check-prefix=ARMV7EM %s
+RUN: echo 0 | llvm-symbolizer -obj=%p/Inputs/fat.o -default-arch=armv7m | FileCheck --check-prefix=ARMV7M %s
+
+X86_64: x86_64_function
+X86_64H: x86_64h_function
+ARMV7: armv7_function
+ARMV7EM: armv7em_function
+ARMV7M: armv7m_function
LoadedSourceFiles;
bool CompareFilenamesOnly;
StringMap<std::string> RemappedFilenames;
- llvm::Triple::ArchType CoverageArch;
+ std::string CoverageArch;
};
}
Filters.push_back(std::unique_ptr<CoverageFilter>(StatFilterer));
}
- if (Arch.empty())
- CoverageArch = llvm::Triple::ArchType::UnknownArch;
- else {
- CoverageArch = Triple(Arch).getArch();
- if (CoverageArch == llvm::Triple::ArchType::UnknownArch) {
- errs() << "error: Unknown architecture: " << Arch << "\n";
- return 1;
- }
+ if (!Arch.empty() &&
+ Triple(Arch).getArch() == llvm::Triple::ArchType::UnknownArch) {
+ errs() << "error: Unknown architecture: " << Arch << "\n";
+ return 1;
}
+ CoverageArch = Arch;
for (const auto &File : InputSourceFiles) {
SmallString<128> Path(File);
if (I != ObjectFileForArch.end())
return I->second;
ErrorOr<std::unique_ptr<ObjectFile>> ParsedObj =
- UB->getObjectForArch(Triple(ArchName).getArch());
+ UB->getObjectForArch(ArchName);
if (ParsedObj) {
Res = ParsedObj.get().get();
ParsedBinariesAndObjects.push_back(std::move(ParsedObj.get()));