Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions amd/comgr/src/comgr-compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -810,16 +810,11 @@ amd_comgr_status_t AMDGPUCompiler::createTmpDirs() {
return AMD_COMGR_STATUS_SUCCESS;
}

amd_comgr_status_t AMDGPUCompiler::removeTmpDirs() {
if (TmpDir.empty()) {
return AMD_COMGR_STATUS_SUCCESS;
}
ProfilePoint Point("RemoveDir");

#ifdef _WIN32
// On windows fs::remove_directories takes huge time so use fs::remove.
#ifdef _WIN32
amd_comgr_status_t removeDirectory(const StringRef DirName) {
std::error_code EC;
for (fs::directory_iterator Dir(TmpDir, EC), DirEnd; Dir != DirEnd && !EC;
for (fs::directory_iterator Dir(DirName, EC), DirEnd; Dir != DirEnd && !EC;
Dir.increment(EC)) {
const StringRef Path = Dir->path();

Expand Down Expand Up @@ -849,16 +844,26 @@ amd_comgr_status_t AMDGPUCompiler::removeTmpDirs() {
}
}

if (fs::remove(TmpDir)) {
if (fs::remove(DirName)) {
return AMD_COMGR_STATUS_ERROR;
}

return AMD_COMGR_STATUS_SUCCESS;
#else
}
#endif

amd_comgr_status_t AMDGPUCompiler::removeTmpDirs() {
if (TmpDir.empty()) {
return AMD_COMGR_STATUS_SUCCESS;
}
ProfilePoint Point("RemoveDir");
#ifndef _WIN32
if (fs::remove_directories(TmpDir)) {
return AMD_COMGR_STATUS_ERROR;
}
return AMD_COMGR_STATUS_SUCCESS;
#else
return removeDirectory(TmpDir);
#endif
}

Expand Down