@@ -1118,6 +1118,59 @@ static CGProfileSortKind getCGProfileSortKind(Ctx &ctx,
11181118 return CGProfileSortKind::None;
11191119}
11201120
1121+ static void parseBPOrdererOptions (Ctx &ctx, opt::InputArgList &args) {
1122+ if (auto *arg = args.getLastArg (OPT_bp_startup_sort)) {
1123+ StringRef startupSortStr = arg->getValue ();
1124+ if (startupSortStr == " function" ) {
1125+ ctx.arg .bpStartupFunctionSort = true ;
1126+ } else if (startupSortStr != " none" ) {
1127+ ErrAlways (ctx) << " unknown value '" + startupSortStr + " ' for " +
1128+ arg->getSpelling ();
1129+ }
1130+ if (startupSortStr != " none" )
1131+ if (args.hasArg (OPT_call_graph_ordering_file))
1132+ ErrAlways (ctx) << " --bp-startup-sort=function is incompatible with "
1133+ " --call-graph-ordering-file" ;
1134+ }
1135+ ctx.arg .bpCompressionSortStartupFunctions =
1136+ args.hasFlag (OPT_bp_compression_sort_startup_functions,
1137+ OPT_no_bp_compression_sort_startup_functions, false );
1138+
1139+ ctx.arg .irpgoProfilePath = args.getLastArgValue (OPT_irpgo_profile);
1140+ if (ctx.arg .irpgoProfilePath .empty ()) {
1141+ if (ctx.arg .bpStartupFunctionSort )
1142+ ErrAlways (ctx) << " --bp-startup-sort=function must be used with "
1143+ " --irpgo-profile" ;
1144+ if (ctx.arg .bpCompressionSortStartupFunctions )
1145+ ErrAlways (ctx)
1146+ << " --bp-compression-sort-startup-functions must be used with "
1147+ " --irpgo-profile" ;
1148+ }
1149+
1150+ if (auto *arg = args.getLastArg (OPT_bp_compression_sort)) {
1151+ StringRef s = arg->getValue ();
1152+ if (s == " function" ) {
1153+ ctx.arg .bpFunctionOrderForCompression = true ;
1154+ } else if (s == " data" ) {
1155+ ctx.arg .bpDataOrderForCompression = true ;
1156+ } else if (s == " both" ) {
1157+ ctx.arg .bpFunctionOrderForCompression = true ;
1158+ ctx.arg .bpDataOrderForCompression = true ;
1159+ } else if (s != " none" ) {
1160+ ErrAlways (ctx) << " unknown value '" + s + " ' for " +
1161+ arg->getSpelling ();
1162+ }
1163+ if (ctx.arg .bpDataOrderForCompression ||
1164+ ctx.arg .bpFunctionOrderForCompression ) {
1165+ if (args.getLastArg (OPT_call_graph_ordering_file) != nullptr ) {
1166+ ErrAlways (ctx) << " --bp-compression-sort is incompatible with "
1167+ " --call-graph-ordering-file" ;
1168+ }
1169+ }
1170+ }
1171+ ctx.arg .bpVerboseSectionOrderer = args.hasArg (OPT_verbose_bp_section_orderer);
1172+ }
1173+
11211174static DebugCompressionType getCompressionType (Ctx &ctx, StringRef s,
11221175 StringRef option) {
11231176 DebugCompressionType type = StringSwitch<DebugCompressionType>(s)
@@ -1259,55 +1312,7 @@ static void readConfigs(Ctx &ctx, opt::InputArgList &args) {
12591312 ctx.arg .bsymbolic = BsymbolicKind::All;
12601313 }
12611314 ctx.arg .callGraphProfileSort = getCGProfileSortKind (ctx, args);
1262- ctx.arg .irpgoProfilePath = args.getLastArgValue (OPT_irpgo_profile);
1263- ctx.arg .bpCompressionSortStartupFunctions =
1264- args.hasFlag (OPT_bp_compression_sort_startup_functions,
1265- OPT_no_bp_compression_sort_startup_functions, false );
1266- if (auto *arg = args.getLastArg (OPT_bp_startup_sort)) {
1267- StringRef startupSortStr = arg->getValue ();
1268- if (startupSortStr == " function" ) {
1269- ctx.arg .bpStartupFunctionSort = true ;
1270- } else if (startupSortStr != " none" ) {
1271- ErrAlways (ctx) << " unknown value '" + startupSortStr + " ' for " +
1272- arg->getSpelling ();
1273- }
1274- if (startupSortStr != " none" )
1275- if (args.hasArg (OPT_call_graph_ordering_file))
1276- ErrAlways (ctx) << " --bp-startup-sort=function is incompatible with "
1277- " --call-graph-ordering-file" ;
1278- }
1279- if (ctx.arg .irpgoProfilePath .empty ()) {
1280- if (ctx.arg .bpStartupFunctionSort )
1281- ErrAlways (ctx) << " --bp-startup-sort=function must be used with "
1282- " --irpgo-profile" ;
1283- if (ctx.arg .bpCompressionSortStartupFunctions )
1284- ErrAlways (ctx)
1285- << " --bp-compression-sort-startup-functions must be used with "
1286- " --irpgo-profile" ;
1287- }
1288-
1289- if (auto *arg = args.getLastArg (OPT_bp_compression_sort)) {
1290- StringRef compressionSortStr = arg->getValue ();
1291- if (compressionSortStr == " function" ) {
1292- ctx.arg .bpFunctionOrderForCompression = true ;
1293- } else if (compressionSortStr == " data" ) {
1294- ctx.arg .bpDataOrderForCompression = true ;
1295- } else if (compressionSortStr == " both" ) {
1296- ctx.arg .bpFunctionOrderForCompression = true ;
1297- ctx.arg .bpDataOrderForCompression = true ;
1298- } else if (compressionSortStr != " none" ) {
1299- ErrAlways (ctx) << " unknown value '" + compressionSortStr + " ' for " +
1300- arg->getSpelling ();
1301- }
1302- if (ctx.arg .bpDataOrderForCompression ||
1303- ctx.arg .bpFunctionOrderForCompression ) {
1304- if (args.getLastArg (OPT_call_graph_ordering_file) != nullptr ) {
1305- ErrAlways (ctx) << " --bp-compression-sort is incompatible with "
1306- " --call-graph-ordering-file" ;
1307- }
1308- }
1309- }
1310- ctx.arg .bpVerboseSectionOrderer = args.hasArg (OPT_verbose_bp_section_orderer);
1315+ parseBPOrdererOptions (ctx, args);
13111316 ctx.arg .checkSections =
13121317 args.hasFlag (OPT_check_sections, OPT_no_check_sections, true );
13131318 ctx.arg .chroot = args.getLastArgValue (OPT_chroot);
0 commit comments