Skip to content

Commit 8ad279c

Browse files
fda0igcbot
authored andcommitted
Open files using append mode for IGC_ShaderDumpEnable
IGC_ShaderDumpEnable now will open files using append mode always. This prevents dumps from being silently overwritten in rare cases where a process compiles the same kernel multiple times.
1 parent 961a7ce commit 8ad279c

File tree

2 files changed

+3
-13
lines changed

2 files changed

+3
-13
lines changed

IGC/common/debug/Dump.cpp

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -497,9 +497,8 @@ class PrefixStream : public llvm::raw_ostream {
497497
// (In the case where Dump is on the heap and DumpName is on the stack, the reference would go bad
498498
// when the calling function returns)
499499
Dump::Dump(DumpName const &dumpName, DumpType type)
500-
: m_name(dumpName), m_pStream(std::make_unique<llvm::raw_string_ostream>(m_string)) // buffered stream!
501-
,
502-
m_pStringStream(nullptr), m_type(type), m_ClearFile(true) {
500+
: m_name(dumpName), m_pStream(std::make_unique<llvm::raw_string_ostream>(m_string)), // buffered stream!
501+
m_pStringStream(nullptr), m_type(type) {
503502
m_pStringStream = m_pStream.get();
504503
if (isConsolePrintable(m_type)) {
505504
if (IGC_IS_FLAG_ENABLED(PrintToConsole)) {
@@ -520,15 +519,7 @@ Dump::Dump(DumpName const &dumpName, DumpType type)
520519

521520
void Dump::flush() {
522521
m_pStringStream->flush();
523-
if (m_string.empty() && !m_ClearFile) {
524-
return;
525-
}
526-
std::ios_base::openmode mode = std::ios_base::out;
527-
if (m_ClearFile) {
528-
m_ClearFile = false;
529-
} else {
530-
mode |= std::ios_base::app;
531-
}
522+
std::ios_base::openmode mode = std::ios_base::out | std::ios_base::app;
532523
if (!isText(m_type))
533524
mode |= std::ios_base::binary;
534525
if (m_name.allow()) {

IGC/common/debug/Dump.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ class Dump {
128128
std::unique_ptr<llvm::raw_ostream> m_pStream;
129129
llvm::raw_ostream *m_pStringStream;
130130
const DumpType m_type;
131-
bool m_ClearFile;
132131
};
133132

134133
// Common implementation of the flush pass

0 commit comments

Comments
 (0)