@@ -1250,7 +1250,7 @@ amd_comgr_status_t AMDGPUCompiler::unbundle() {
12501250 // Collect bitcode memory buffers from bitcodes, bundles, and archives
12511251 for (auto *Input : InSet->DataObjects ) {
12521252
1253- std::string FileExtension;
1253+ const char * FileExtension;
12541254 amd_comgr_data_kind_t UnbundledDataKind;
12551255 switch (Input->DataKind ) {
12561256 case AMD_COMGR_DATA_KIND_BC_BUNDLE:
@@ -1281,36 +1281,33 @@ amd_comgr_status_t AMDGPUCompiler::unbundle() {
12811281 const size_t BufSize = sizeof (char ) * 30 ;
12821282 char *Buf = (char *)malloc (BufSize);
12831283 snprintf (Buf, BufSize, " comgr-bundle-%d.%s" , std::rand () % 10000 ,
1284- FileExtension. c_str () );
1284+ FileExtension);
12851285 Input->Name = Buf;
12861286 }
12871287
12881288 // Write input file system so that OffloadBundler API can process
12891289 // TODO: Switch write to VFS
1290- std::string InputFilePath = getFilePath (Input, InputDir). str (). str ( );
1290+ SmallString< 128 > InputFilePath = getFilePath (Input, InputDir);
12911291 if (auto Status = outputToFile (Input, InputFilePath)) {
12921292 return Status;
12931293 }
12941294
12951295 // Bundler input name
1296- BundlerConfig.InputFileNames .push_back (InputFilePath);
1296+ BundlerConfig.InputFileNames .emplace_back (InputFilePath);
12971297
12981298 // Generate prefix for output files
1299- std::string OutputPrefix = std::string ( Input->Name ) ;
1299+ StringRef OutputPrefix = Input->Name ;
13001300 size_t Index = OutputPrefix.find_last_of (" ." );
13011301 OutputPrefix = OutputPrefix.substr (0 , Index);
13021302
13031303 // Bundler target and output names
1304- for (auto Entry : ActionInfo->BundleEntryIDs ) {
1305- BundlerConfig.TargetNames .push_back (Entry);
1304+ for (StringRef Entry : ActionInfo->BundleEntryIDs ) {
1305+ BundlerConfig.TargetNames .emplace_back (Entry);
13061306
1307- // Add an output file for each target
1308- std::string OutputFileName =
1309- OutputPrefix + ' -' + Entry + " ." + FileExtension;
1310-
1311- // TODO: Switch this to LLVM path APIs
1312- std::string OutputFilePath = OutputDir.str ().str () + " /" + OutputFileName;
1313- BundlerConfig.OutputFileNames .push_back (OutputFilePath);
1307+ SmallString<128 > OutputFilePath = OutputDir;
1308+ sys::path::append (OutputFilePath,
1309+ OutputPrefix + " -" + Entry + " ." + FileExtension);
1310+ BundlerConfig.OutputFileNames .emplace_back (OutputFilePath);
13141311 }
13151312
13161313 OffloadBundler Bundler (BundlerConfig);
@@ -1321,8 +1318,10 @@ amd_comgr_status_t AMDGPUCompiler::unbundle() {
13211318 << " \t Unbundled Files Extension: ." << FileExtension << " \n "
13221319 << " \t Bundle Entry ID: " << BundlerConfig.TargetNames [0 ] << " \n "
13231320 << " \t Input Filename: " << BundlerConfig.InputFileNames [0 ] << " \n "
1324- << " \t Output Filename: " << BundlerConfig.OutputFileNames [0 ]
1325- << " \n " ;
1321+ << " \t Output Filenames: " ;
1322+ for (StringRef OutputFileName : BundlerConfig.OutputFileNames )
1323+ LogS << OutputFileName << " " ;
1324+ LogS << " \n " ;
13261325 LogS.flush ();
13271326 }
13281327
@@ -1350,7 +1349,7 @@ amd_comgr_status_t AMDGPUCompiler::unbundle() {
13501349 }
13511350
13521351 // Add new bitcodes to OutSetT
1353- for (auto OutputFilePath : BundlerConfig.OutputFileNames ) {
1352+ for (StringRef OutputFilePath : BundlerConfig.OutputFileNames ) {
13541353
13551354 amd_comgr_data_t ResultT;
13561355
@@ -1361,11 +1360,10 @@ amd_comgr_status_t AMDGPUCompiler::unbundle() {
13611360 ScopedDataObjectReleaser SDOR (ResultT);
13621361
13631362 DataObject *Result = DataObject::convert (ResultT);
1364- if (auto Status = inputFromFile (Result, StringRef ( OutputFilePath) ))
1363+ if (auto Status = inputFromFile (Result, OutputFilePath))
13651364 return Status;
13661365
1367- StringRef OutputFileName =
1368- llvm::sys::path::filename (StringRef (OutputFilePath));
1366+ StringRef OutputFileName = sys::path::filename (OutputFilePath);
13691367 Result->setName (OutputFileName);
13701368
13711369 if (auto Status = amd_comgr_data_set_add (OutSetT, ResultT)) {
0 commit comments