From 738bd4dca61ab1dda877d9181866cba55043b444 Mon Sep 17 00:00:00 2001 From: Jonathan Crowther Date: Fri, 16 Apr 2021 10:02:48 -0400 Subject: [PATCH] [SystemZ][z/OS] Add IsText Argument to GetFile and GetFileOrSTDIN Add the `IsText` argument to `GetFile` and `GetFileOrSTDIN` which will help z/OS distinguish between text and binary correctly. This is an extension to [this patch](https://reviews.llvm.org/D97785) Reviewed By: abhina.sreeskantharajan, amccarth Differential Revision: https://reviews.llvm.org/D100488 --- lib/AsmParser/Parser.cpp | 2 +- lib/CodeGen/MIRParser/MIRParser.cpp | 2 +- lib/ProfileData/InstrProfReader.cpp | 2 +- lib/ProfileData/SampleProfReader.cpp | 2 +- lib/Testing/Support/SupportHelpers.cpp | 2 +- tools/llvm-exegesis/lib/BenchmarkResult.cpp | 4 ++-- tools/llvm-ifs/llvm-ifs.cpp | 2 +- tools/llvm-mc/llvm-mc.cpp | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/AsmParser/Parser.cpp b/lib/AsmParser/Parser.cpp index 8147620181f..b4be041d621 100644 --- a/lib/AsmParser/Parser.cpp +++ b/lib/AsmParser/Parser.cpp @@ -104,7 +104,7 @@ parseAssemblyFileWithIndex(StringRef Filename, SMDiagnostic &Err, bool UpgradeDebugInfo, DataLayoutCallbackTy DataLayoutCallback) { ErrorOr> FileOrErr = - MemoryBuffer::getFileOrSTDIN(Filename); + MemoryBuffer::getFileOrSTDIN(Filename, /*IsText=*/true); if (std::error_code EC = FileOrErr.getError()) { Err = SMDiagnostic(Filename, SourceMgr::DK_Error, "Could not open input file: " + EC.message()); diff --git a/lib/CodeGen/MIRParser/MIRParser.cpp b/lib/CodeGen/MIRParser/MIRParser.cpp index e4e00b2057c..88dc4571b2d 100644 --- a/lib/CodeGen/MIRParser/MIRParser.cpp +++ b/lib/CodeGen/MIRParser/MIRParser.cpp @@ -984,7 +984,7 @@ bool MIRParser::parseMachineFunctions(Module &M, MachineModuleInfo &MMI) { std::unique_ptr llvm::createMIRParserFromFile( StringRef Filename, SMDiagnostic &Error, LLVMContext &Context, std::function ProcessIRFunction) { - auto FileOrErr = MemoryBuffer::getFileOrSTDIN(Filename); + auto FileOrErr = MemoryBuffer::getFileOrSTDIN(Filename, /*IsText=*/true); if (std::error_code EC = FileOrErr.getError()) { Error = SMDiagnostic(Filename, SourceMgr::DK_Error, "Could not open input file: " + EC.message()); diff --git a/lib/ProfileData/InstrProfReader.cpp b/lib/ProfileData/InstrProfReader.cpp index 9581e5b486a..b83295a16f0 100644 --- a/lib/ProfileData/InstrProfReader.cpp +++ b/lib/ProfileData/InstrProfReader.cpp @@ -41,7 +41,7 @@ using namespace llvm; static Expected> setupMemoryBuffer(const Twine &Path) { ErrorOr> BufferOrErr = - MemoryBuffer::getFileOrSTDIN(Path); + MemoryBuffer::getFileOrSTDIN(Path, /*IsText=*/true); if (std::error_code EC = BufferOrErr.getError()) return errorCodeToError(EC); return std::move(BufferOrErr.get()); diff --git a/lib/ProfileData/SampleProfReader.cpp b/lib/ProfileData/SampleProfReader.cpp index 200a0afb01c..656638d7dc6 100644 --- a/lib/ProfileData/SampleProfReader.cpp +++ b/lib/ProfileData/SampleProfReader.cpp @@ -1575,7 +1575,7 @@ SampleProfileReaderItaniumRemapper::lookUpNameInProfile(StringRef Fname) { /// \returns an error code indicating the status of the buffer. static ErrorOr> setupMemoryBuffer(const Twine &Filename) { - auto BufferOrErr = MemoryBuffer::getFileOrSTDIN(Filename); + auto BufferOrErr = MemoryBuffer::getFileOrSTDIN(Filename, /*IsText=*/true); if (std::error_code EC = BufferOrErr.getError()) return EC; auto Buffer = std::move(BufferOrErr.get()); diff --git a/lib/Testing/Support/SupportHelpers.cpp b/lib/Testing/Support/SupportHelpers.cpp index 5f53b2330b2..3c12edfa9d9 100644 --- a/lib/Testing/Support/SupportHelpers.cpp +++ b/lib/Testing/Support/SupportHelpers.cpp @@ -40,7 +40,7 @@ SmallString<128> llvm::unittest::getInputFileDirectory(const char *Argv0) { EXPECT_TRUE(Found) << "Unit test source directory file does not exist."; - auto File = MemoryBuffer::getFile(InputFilePath); + auto File = MemoryBuffer::getFile(InputFilePath, /*IsText=*/true); EXPECT_TRUE(static_cast(File)) << "Could not open unit test source directory file."; diff --git a/tools/llvm-exegesis/lib/BenchmarkResult.cpp b/tools/llvm-exegesis/lib/BenchmarkResult.cpp index d86ab475cb9..7ceef254e60 100644 --- a/tools/llvm-exegesis/lib/BenchmarkResult.cpp +++ b/tools/llvm-exegesis/lib/BenchmarkResult.cpp @@ -334,7 +334,7 @@ namespace exegesis { Expected InstructionBenchmark::readYaml(const LLVMState &State, StringRef Filename) { if (auto ExpectedMemoryBuffer = - errorOrToExpected(MemoryBuffer::getFile(Filename))) { + errorOrToExpected(MemoryBuffer::getFile(Filename, /*IsText=*/true))) { yaml::Input Yin(*ExpectedMemoryBuffer.get()); YamlContext Context(State); InstructionBenchmark Benchmark; @@ -351,7 +351,7 @@ InstructionBenchmark::readYaml(const LLVMState &State, StringRef Filename) { Expected> InstructionBenchmark::readYamls(const LLVMState &State, StringRef Filename) { if (auto ExpectedMemoryBuffer = - errorOrToExpected(MemoryBuffer::getFile(Filename))) { + errorOrToExpected(MemoryBuffer::getFile(Filename, /*IsText=*/true))) { yaml::Input Yin(*ExpectedMemoryBuffer.get()); YamlContext Context(State); std::vector Benchmarks; diff --git a/tools/llvm-ifs/llvm-ifs.cpp b/tools/llvm-ifs/llvm-ifs.cpp index 129dc89d358..b6a1b4a9512 100644 --- a/tools/llvm-ifs/llvm-ifs.cpp +++ b/tools/llvm-ifs/llvm-ifs.cpp @@ -182,7 +182,7 @@ template <> struct MappingTraits { static Expected> readInputFile(StringRef FilePath) { // Read in file. ErrorOr> BufOrError = - MemoryBuffer::getFileOrSTDIN(FilePath); + MemoryBuffer::getFileOrSTDIN(FilePath, /*IsText=*/true); if (!BufOrError) return createStringError(BufOrError.getError(), "Could not open `%s`", FilePath.data()); diff --git a/tools/llvm-mc/llvm-mc.cpp b/tools/llvm-mc/llvm-mc.cpp index 017d6a4e89a..daecbc2c979 100644 --- a/tools/llvm-mc/llvm-mc.cpp +++ b/tools/llvm-mc/llvm-mc.cpp @@ -343,7 +343,7 @@ int main(int argc, char **argv) { Triple TheTriple(TripleName); ErrorOr> BufferPtr = - MemoryBuffer::getFileOrSTDIN(InputFilename); + MemoryBuffer::getFileOrSTDIN(InputFilename, /*IsText=*/true); if (std::error_code EC = BufferPtr.getError()) { WithColor::error(errs(), ProgName) << InputFilename << ": " << EC.message() << '\n';