@@ -1257,7 +1257,7 @@ amd_comgr_status_t AMDGPUCompiler::unbundle() {
1257
1257
// Collect bitcode memory buffers from bitcodes, bundles, and archives
1258
1258
for (auto *Input : InSet->DataObjects ) {
1259
1259
1260
- std::string FileExtension;
1260
+ const char * FileExtension;
1261
1261
amd_comgr_data_kind_t UnbundledDataKind;
1262
1262
switch (Input->DataKind ) {
1263
1263
case AMD_COMGR_DATA_KIND_BC_BUNDLE:
@@ -1288,22 +1288,22 @@ amd_comgr_status_t AMDGPUCompiler::unbundle() {
1288
1288
const size_t BufSize = sizeof (char ) * 30 ;
1289
1289
char *Buf = (char *)malloc (BufSize);
1290
1290
snprintf (Buf, BufSize, " comgr-bundle-%d.%s" , std::rand () % 10000 ,
1291
- FileExtension. c_str () );
1291
+ FileExtension);
1292
1292
Input->Name = Buf;
1293
1293
}
1294
1294
1295
1295
// Write input file system so that OffloadBundler API can process
1296
1296
// TODO: Switch write to VFS
1297
- std::string InputFilePath = getFilePath (Input, InputDir). str (). str ( );
1297
+ SmallString< 128 > InputFilePath = getFilePath (Input, InputDir);
1298
1298
if (auto Status = outputToFile (Input, InputFilePath)) {
1299
1299
return Status;
1300
1300
}
1301
1301
1302
1302
// Bundler input name
1303
- BundlerConfig.InputFileNames .push_back (InputFilePath);
1303
+ BundlerConfig.InputFileNames .emplace_back (InputFilePath);
1304
1304
1305
1305
// Generate prefix for output files
1306
- std::string OutputPrefix = std::string ( Input->Name ) ;
1306
+ StringRef OutputPrefix = Input->Name ;
1307
1307
size_t Index = OutputPrefix.find_last_of (" ." );
1308
1308
OutputPrefix = OutputPrefix.substr (0 , Index);
1309
1309
@@ -1314,22 +1314,18 @@ amd_comgr_status_t AMDGPUCompiler::unbundle() {
1314
1314
<< " Unbundled Files Extension: ." << FileExtension << " \n " ;
1315
1315
}
1316
1316
1317
- for (size_t I = 0 ; I < ActionInfo->BundleEntryIDs .size (); I++) {
1318
- auto Entry = ActionInfo->BundleEntryIDs [I];
1319
- BundlerConfig.TargetNames .push_back (Entry);
1320
-
1317
+ for (StringRef Entry : ActionInfo->BundleEntryIDs ) {
1321
1318
// Add an output file for each target
1322
- std::string OutputFileName =
1323
- OutputPrefix + ' -' + Entry + " ." + FileExtension;
1319
+ SmallString<128 > OutputFilePath = OutputDir;
1320
+ sys::path::append (OutputFilePath,
1321
+ OutputPrefix + " -" + Entry + " ." + FileExtension);
1324
1322
1325
- // TODO: Switch this to LLVM path APIs
1326
- std::string OutputFilePath = OutputDir.str ().str () + " /" + OutputFileName;
1327
- BundlerConfig.OutputFileNames .push_back (OutputFilePath);
1323
+ BundlerConfig.TargetNames .emplace_back (Entry);
1324
+ BundlerConfig.OutputFileNames .emplace_back (OutputFilePath);
1328
1325
1329
1326
if (env::shouldEmitVerboseLogs ()) {
1330
- LogS << " \t Bundle Entry ID: " << BundlerConfig.TargetNames [I] << " \n "
1331
- << " \t Output Filename: " << BundlerConfig.OutputFileNames [I]
1332
- << " \n " ;
1327
+ LogS << " \t Bundle Entry ID: " << Entry << " \n "
1328
+ << " \t Output Filename: " << OutputFilePath << " \n " ;
1333
1329
LogS.flush ();
1334
1330
}
1335
1331
}
@@ -1360,7 +1356,7 @@ amd_comgr_status_t AMDGPUCompiler::unbundle() {
1360
1356
}
1361
1357
1362
1358
// Add new bitcodes to OutSetT
1363
- for (auto OutputFilePath : BundlerConfig.OutputFileNames ) {
1359
+ for (StringRef OutputFilePath : BundlerConfig.OutputFileNames ) {
1364
1360
1365
1361
amd_comgr_data_t ResultT;
1366
1362
@@ -1371,11 +1367,10 @@ amd_comgr_status_t AMDGPUCompiler::unbundle() {
1371
1367
ScopedDataObjectReleaser SDOR (ResultT);
1372
1368
1373
1369
DataObject *Result = DataObject::convert (ResultT);
1374
- if (auto Status = inputFromFile (Result, StringRef ( OutputFilePath) ))
1370
+ if (auto Status = inputFromFile (Result, OutputFilePath))
1375
1371
return Status;
1376
1372
1377
- StringRef OutputFileName =
1378
- llvm::sys::path::filename (StringRef (OutputFilePath));
1373
+ StringRef OutputFileName = sys::path::filename (OutputFilePath);
1379
1374
Result->setName (OutputFileName);
1380
1375
1381
1376
if (auto Status = amd_comgr_data_set_add (OutSetT, ResultT)) {
0 commit comments