[llvm] [; SystemZ][z/OS] Fix llvm-ctxprof to open input files in text mode (PR #109691)

Zibi Sarbinowski via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 23 10:24:45 PDT 2024


https://github.com/zibi2 created https://github.com/llvm/llvm-project/pull/109691

Reading text files on z/OS relies on auto conversion to handle ASCII/EBCDIC correctly. For this to work files need to be opened in text mode is that is the type of the file. This PR fixes `llvm-ctxprof` utility in this regards which in turn fixes the following LIT failure on z/OS:

`FAIL: LLVM :: Analysis/CtxProfAnalysis/flatten-zero-path.ll` 

>From 8fef41e79c8692b9cbcec57bb73139eeb783667f Mon Sep 17 00:00:00 2001
From: Zbigniew Sarbinowski <zibi at ca.ibm.com>
Date: Mon, 23 Sep 2024 17:22:27 +0000
Subject: [PATCH] Fix llvm-ctxprof to open input files in text mode

---
 llvm/tools/llvm-ctxprof-util/llvm-ctxprof-util.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/llvm/tools/llvm-ctxprof-util/llvm-ctxprof-util.cpp b/llvm/tools/llvm-ctxprof-util/llvm-ctxprof-util.cpp
index 0fad4ee4360ddf..485f6c7d33d902 100644
--- a/llvm/tools/llvm-ctxprof-util/llvm-ctxprof-util.cpp
+++ b/llvm/tools/llvm-ctxprof-util/llvm-ctxprof-util.cpp
@@ -48,7 +48,8 @@ static cl::opt<std::string> OutputFilename("output", cl::value_desc("output"),
 
 // Save the bitstream profile from the JSON representation.
 Error convertFromJSON() {
-  auto BufOrError = MemoryBuffer::getFileOrSTDIN(InputFilename);
+  auto BufOrError =
+      MemoryBuffer::getFileOrSTDIN(InputFilename, /*IsText=*/true);
   if (!BufOrError)
     return createFileError(InputFilename, BufOrError.getError());
 



More information about the llvm-commits mailing list