@@ -1247,7 +1247,7 @@ amd_comgr_status_t AMDGPUCompiler::unbundle() {
1247
1247
// Collect bitcode memory buffers from bitcodes, bundles, and archives
1248
1248
for (auto *Input : InSet->DataObjects ) {
1249
1249
1250
- std::string FileExtension;
1250
+ const char * FileExtension;
1251
1251
amd_comgr_data_kind_t UnbundledDataKind;
1252
1252
switch (Input->DataKind ) {
1253
1253
case AMD_COMGR_DATA_KIND_BC_BUNDLE:
@@ -1278,36 +1278,33 @@ amd_comgr_status_t AMDGPUCompiler::unbundle() {
1278
1278
const size_t BufSize = sizeof (char ) * 30 ;
1279
1279
char *Buf = (char *)malloc (BufSize);
1280
1280
snprintf (Buf, BufSize, " comgr-bundle-%d.%s" , std::rand () % 10000 ,
1281
- FileExtension. c_str () );
1281
+ FileExtension);
1282
1282
Input->Name = Buf;
1283
1283
}
1284
1284
1285
1285
// Write input file system so that OffloadBundler API can process
1286
1286
// TODO: Switch write to VFS
1287
- std::string InputFilePath = getFilePath (Input, InputDir). str (). str ( );
1287
+ SmallString< 128 > InputFilePath = getFilePath (Input, InputDir);
1288
1288
if (auto Status = outputToFile (Input, InputFilePath)) {
1289
1289
return Status;
1290
1290
}
1291
1291
1292
1292
// Bundler input name
1293
- BundlerConfig.InputFileNames .push_back (InputFilePath);
1293
+ BundlerConfig.InputFileNames .emplace_back (InputFilePath);
1294
1294
1295
1295
// Generate prefix for output files
1296
- std::string OutputPrefix = std::string ( Input->Name ) ;
1296
+ StringRef OutputPrefix = Input->Name ;
1297
1297
size_t Index = OutputPrefix.find_last_of (" ." );
1298
1298
OutputPrefix = OutputPrefix.substr (0 , Index);
1299
1299
1300
1300
// Bundler target and output names
1301
- for (auto Entry : ActionInfo->BundleEntryIDs ) {
1302
- BundlerConfig.TargetNames .push_back (Entry);
1301
+ for (StringRef Entry : ActionInfo->BundleEntryIDs ) {
1302
+ BundlerConfig.TargetNames .emplace_back (Entry);
1303
1303
1304
- // Add an output file for each target
1305
- std::string OutputFileName =
1306
- OutputPrefix + ' -' + Entry + " ." + FileExtension;
1307
-
1308
- // TODO: Switch this to LLVM path APIs
1309
- std::string OutputFilePath = OutputDir.str ().str () + " /" + OutputFileName;
1310
- BundlerConfig.OutputFileNames .push_back (OutputFilePath);
1304
+ SmallString<128 > OutputFilePath = OutputDir;
1305
+ sys::path::append (OutputFilePath,
1306
+ OutputPrefix + " -" + Entry + " ." + FileExtension);
1307
+ BundlerConfig.OutputFileNames .emplace_back (OutputFilePath);
1311
1308
}
1312
1309
1313
1310
OffloadBundler Bundler (BundlerConfig);
@@ -1318,8 +1315,10 @@ amd_comgr_status_t AMDGPUCompiler::unbundle() {
1318
1315
<< " \t Unbundled Files Extension: ." << FileExtension << " \n "
1319
1316
<< " \t Bundle Entry ID: " << BundlerConfig.TargetNames [0 ] << " \n "
1320
1317
<< " \t Input Filename: " << BundlerConfig.InputFileNames [0 ] << " \n "
1321
- << " \t Output Filename: " << BundlerConfig.OutputFileNames [0 ]
1322
- << " \n " ;
1318
+ << " \t Output Filenames: " ;
1319
+ for (StringRef OutputFileName : BundlerConfig.OutputFileNames )
1320
+ LogS << OutputFileName << " " ;
1321
+ LogS << " \n " ;
1323
1322
LogS.flush ();
1324
1323
}
1325
1324
@@ -1347,7 +1346,7 @@ amd_comgr_status_t AMDGPUCompiler::unbundle() {
1347
1346
}
1348
1347
1349
1348
// Add new bitcodes to OutSetT
1350
- for (auto OutputFilePath : BundlerConfig.OutputFileNames ) {
1349
+ for (StringRef OutputFilePath : BundlerConfig.OutputFileNames ) {
1351
1350
1352
1351
amd_comgr_data_t ResultT;
1353
1352
@@ -1358,11 +1357,10 @@ amd_comgr_status_t AMDGPUCompiler::unbundle() {
1358
1357
ScopedDataObjectReleaser SDOR (ResultT);
1359
1358
1360
1359
DataObject *Result = DataObject::convert (ResultT);
1361
- if (auto Status = inputFromFile (Result, StringRef ( OutputFilePath) ))
1360
+ if (auto Status = inputFromFile (Result, OutputFilePath))
1362
1361
return Status;
1363
1362
1364
- StringRef OutputFileName =
1365
- llvm::sys::path::filename (StringRef (OutputFilePath));
1363
+ StringRef OutputFileName = sys::path::filename (OutputFilePath);
1366
1364
Result->setName (OutputFileName);
1367
1365
1368
1366
if (auto Status = amd_comgr_data_set_add (OutSetT, ResultT)) {
0 commit comments