@@ -1229,7 +1229,7 @@ amd_comgr_status_t AMDGPUCompiler::unbundle() {
1229
1229
// Collect bitcode memory buffers from bitcodes, bundles, and archives
1230
1230
for (auto *Input : InSet->DataObjects ) {
1231
1231
1232
- std::string FileExtension;
1232
+ const char * FileExtension;
1233
1233
amd_comgr_data_kind_t UnbundledDataKind;
1234
1234
switch (Input->DataKind ) {
1235
1235
case AMD_COMGR_DATA_KIND_BC_BUNDLE:
@@ -1260,36 +1260,33 @@ amd_comgr_status_t AMDGPUCompiler::unbundle() {
1260
1260
const size_t BufSize = sizeof (char ) * 30 ;
1261
1261
char *Buf = (char *)malloc (BufSize);
1262
1262
snprintf (Buf, BufSize, " comgr-bundle-%d.%s" , std::rand () % 10000 ,
1263
- FileExtension. c_str () );
1263
+ FileExtension);
1264
1264
Input->Name = Buf;
1265
1265
}
1266
1266
1267
1267
// Write input file system so that OffloadBundler API can process
1268
1268
// TODO: Switch write to VFS
1269
- std::string InputFilePath = getFilePath (Input, InputDir). str (). str ( );
1269
+ SmallString< 128 > InputFilePath = getFilePath (Input, InputDir);
1270
1270
if (auto Status = outputToFile (Input, InputFilePath)) {
1271
1271
return Status;
1272
1272
}
1273
1273
1274
1274
// Bundler input name
1275
- BundlerConfig.InputFileNames .push_back (InputFilePath);
1275
+ BundlerConfig.InputFileNames .emplace_back (InputFilePath);
1276
1276
1277
1277
// Generate prefix for output files
1278
- std::string OutputPrefix = std::string ( Input->Name ) ;
1278
+ StringRef OutputPrefix = Input->Name ;
1279
1279
size_t Index = OutputPrefix.find_last_of (" ." );
1280
1280
OutputPrefix = OutputPrefix.substr (0 , Index);
1281
1281
1282
1282
// Bundler target and output names
1283
- for (auto Entry : ActionInfo->BundleEntryIDs ) {
1284
- BundlerConfig.TargetNames .push_back (Entry);
1283
+ for (StringRef Entry : ActionInfo->BundleEntryIDs ) {
1284
+ BundlerConfig.TargetNames .emplace_back (Entry);
1285
1285
1286
- // Add an output file for each target
1287
- std::string OutputFileName =
1288
- OutputPrefix + ' -' + Entry + " ." + FileExtension;
1289
-
1290
- // TODO: Switch this to LLVM path APIs
1291
- std::string OutputFilePath = OutputDir.str ().str () + " /" + OutputFileName;
1292
- BundlerConfig.OutputFileNames .push_back (OutputFilePath);
1286
+ SmallString<128 > OutputFilePath = OutputDir;
1287
+ sys::path::append (OutputFilePath,
1288
+ OutputPrefix + " -" + Entry + " ." + FileExtension);
1289
+ BundlerConfig.OutputFileNames .emplace_back (OutputFilePath);
1293
1290
}
1294
1291
1295
1292
OffloadBundler Bundler (BundlerConfig);
@@ -1300,8 +1297,10 @@ amd_comgr_status_t AMDGPUCompiler::unbundle() {
1300
1297
<< " \t Unbundled Files Extension: ." << FileExtension << " \n "
1301
1298
<< " \t Bundle Entry ID: " << BundlerConfig.TargetNames [0 ] << " \n "
1302
1299
<< " \t Input Filename: " << BundlerConfig.InputFileNames [0 ] << " \n "
1303
- << " \t Output Filename: " << BundlerConfig.OutputFileNames [0 ]
1304
- << " \n " ;
1300
+ << " \t Output Filenames: " ;
1301
+ for (StringRef OutputFileName : BundlerConfig.OutputFileNames )
1302
+ LogS << OutputFileName << " " ;
1303
+ LogS << " \n " ;
1305
1304
LogS.flush ();
1306
1305
}
1307
1306
@@ -1329,7 +1328,7 @@ amd_comgr_status_t AMDGPUCompiler::unbundle() {
1329
1328
}
1330
1329
1331
1330
// Add new bitcodes to OutSetT
1332
- for (auto OutputFilePath : BundlerConfig.OutputFileNames ) {
1331
+ for (StringRef OutputFilePath : BundlerConfig.OutputFileNames ) {
1333
1332
1334
1333
amd_comgr_data_t ResultT;
1335
1334
@@ -1340,11 +1339,10 @@ amd_comgr_status_t AMDGPUCompiler::unbundle() {
1340
1339
ScopedDataObjectReleaser SDOR (ResultT);
1341
1340
1342
1341
DataObject *Result = DataObject::convert (ResultT);
1343
- if (auto Status = inputFromFile (Result, StringRef ( OutputFilePath) ))
1342
+ if (auto Status = inputFromFile (Result, OutputFilePath))
1344
1343
return Status;
1345
1344
1346
- StringRef OutputFileName =
1347
- llvm::sys::path::filename (StringRef (OutputFilePath));
1345
+ StringRef OutputFileName = sys::path::filename (OutputFilePath);
1348
1346
Result->setName (OutputFileName);
1349
1347
1350
1348
if (auto Status = amd_comgr_data_set_add (OutSetT, ResultT)) {
0 commit comments