Skip to content

Commit c7e8239

Browse files
chinmayddlamb-j
andauthored
Revert "[Comgr][NFC] Refactor remove dir for windows" (llvm#3141)
Reverts AMD-Lightning-Internal/llvm-project#2816 --------- Co-authored-by: Lambert, Jacob <[email protected]>
1 parent 096fe69 commit c7e8239

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

amd/comgr/src/comgr-compiler.cpp

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -810,16 +810,11 @@ amd_comgr_status_t AMDGPUCompiler::createTmpDirs() {
810810
return AMD_COMGR_STATUS_SUCCESS;
811811
}
812812

813-
amd_comgr_status_t AMDGPUCompiler::removeTmpDirs() {
814-
if (TmpDir.empty()) {
815-
return AMD_COMGR_STATUS_SUCCESS;
816-
}
817-
ProfilePoint Point("RemoveDir");
818-
819-
#ifdef _WIN32
820813
// On windows fs::remove_directories takes huge time so use fs::remove.
814+
#ifdef _WIN32
815+
amd_comgr_status_t removeDirectory(const StringRef DirName) {
821816
std::error_code EC;
822-
for (fs::directory_iterator Dir(TmpDir, EC), DirEnd; Dir != DirEnd && !EC;
817+
for (fs::directory_iterator Dir(DirName, EC), DirEnd; Dir != DirEnd && !EC;
823818
Dir.increment(EC)) {
824819
const StringRef Path = Dir->path();
825820

@@ -849,16 +844,26 @@ amd_comgr_status_t AMDGPUCompiler::removeTmpDirs() {
849844
}
850845
}
851846

852-
if (fs::remove(TmpDir)) {
847+
if (fs::remove(DirName)) {
853848
return AMD_COMGR_STATUS_ERROR;
854849
}
855850

856851
return AMD_COMGR_STATUS_SUCCESS;
857-
#else
852+
}
853+
#endif
854+
855+
amd_comgr_status_t AMDGPUCompiler::removeTmpDirs() {
856+
if (TmpDir.empty()) {
857+
return AMD_COMGR_STATUS_SUCCESS;
858+
}
859+
ProfilePoint Point("RemoveDir");
860+
#ifndef _WIN32
858861
if (fs::remove_directories(TmpDir)) {
859862
return AMD_COMGR_STATUS_ERROR;
860863
}
861864
return AMD_COMGR_STATUS_SUCCESS;
865+
#else
866+
return removeDirectory(TmpDir);
862867
#endif
863868
}
864869

0 commit comments

Comments
 (0)