@@ -1250,7 +1250,7 @@ amd_comgr_status_t AMDGPUCompiler::unbundle() {
1250
1250
// Collect bitcode memory buffers from bitcodes, bundles, and archives
1251
1251
for (auto *Input : InSet->DataObjects ) {
1252
1252
1253
- std::string FileExtension;
1253
+ const char * FileExtension;
1254
1254
amd_comgr_data_kind_t UnbundledDataKind;
1255
1255
switch (Input->DataKind ) {
1256
1256
case AMD_COMGR_DATA_KIND_BC_BUNDLE:
@@ -1281,36 +1281,33 @@ amd_comgr_status_t AMDGPUCompiler::unbundle() {
1281
1281
const size_t BufSize = sizeof (char ) * 30 ;
1282
1282
char *Buf = (char *)malloc (BufSize);
1283
1283
snprintf (Buf, BufSize, " comgr-bundle-%d.%s" , std::rand () % 10000 ,
1284
- FileExtension. c_str () );
1284
+ FileExtension);
1285
1285
Input->Name = Buf;
1286
1286
}
1287
1287
1288
1288
// Write input file system so that OffloadBundler API can process
1289
1289
// TODO: Switch write to VFS
1290
- std::string InputFilePath = getFilePath (Input, InputDir). str (). str ( );
1290
+ SmallString< 128 > InputFilePath = getFilePath (Input, InputDir);
1291
1291
if (auto Status = outputToFile (Input, InputFilePath)) {
1292
1292
return Status;
1293
1293
}
1294
1294
1295
1295
// Bundler input name
1296
- BundlerConfig.InputFileNames .push_back (InputFilePath);
1296
+ BundlerConfig.InputFileNames .emplace_back (InputFilePath);
1297
1297
1298
1298
// Generate prefix for output files
1299
- std::string OutputPrefix = std::string ( Input->Name ) ;
1299
+ StringRef OutputPrefix = Input->Name ;
1300
1300
size_t Index = OutputPrefix.find_last_of (" ." );
1301
1301
OutputPrefix = OutputPrefix.substr (0 , Index);
1302
1302
1303
1303
// 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);
1306
1306
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);
1314
1311
}
1315
1312
1316
1313
OffloadBundler Bundler (BundlerConfig);
@@ -1321,8 +1318,10 @@ amd_comgr_status_t AMDGPUCompiler::unbundle() {
1321
1318
<< " \t Unbundled Files Extension: ." << FileExtension << " \n "
1322
1319
<< " \t Bundle Entry ID: " << BundlerConfig.TargetNames [0 ] << " \n "
1323
1320
<< " \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 " ;
1326
1325
LogS.flush ();
1327
1326
}
1328
1327
@@ -1350,7 +1349,7 @@ amd_comgr_status_t AMDGPUCompiler::unbundle() {
1350
1349
}
1351
1350
1352
1351
// Add new bitcodes to OutSetT
1353
- for (auto OutputFilePath : BundlerConfig.OutputFileNames ) {
1352
+ for (StringRef OutputFilePath : BundlerConfig.OutputFileNames ) {
1354
1353
1355
1354
amd_comgr_data_t ResultT;
1356
1355
@@ -1361,11 +1360,10 @@ amd_comgr_status_t AMDGPUCompiler::unbundle() {
1361
1360
ScopedDataObjectReleaser SDOR (ResultT);
1362
1361
1363
1362
DataObject *Result = DataObject::convert (ResultT);
1364
- if (auto Status = inputFromFile (Result, StringRef ( OutputFilePath) ))
1363
+ if (auto Status = inputFromFile (Result, OutputFilePath))
1365
1364
return Status;
1366
1365
1367
- StringRef OutputFileName =
1368
- llvm::sys::path::filename (StringRef (OutputFilePath));
1366
+ StringRef OutputFileName = sys::path::filename (OutputFilePath);
1369
1367
Result->setName (OutputFileName);
1370
1368
1371
1369
if (auto Status = amd_comgr_data_set_add (OutSetT, ResultT)) {
0 commit comments