@@ -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