@@ -1118,6 +1118,53 @@ 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_compression_sort)) {
1123+ StringRef s = arg->getValue ();
1124+ if (s == " function" ) {
1125+ ctx.arg .bpFunctionOrderForCompression = true ;
1126+ } else if (s == " data" ) {
1127+ ctx.arg .bpDataOrderForCompression = true ;
1128+ } else if (s == " both" ) {
1129+ ctx.arg .bpFunctionOrderForCompression = true ;
1130+ ctx.arg .bpDataOrderForCompression = true ;
1131+ } else if (s != " none" ) {
1132+ ErrAlways (ctx) << arg->getSpelling ()
1133+ << " : expected [none|function|data|both]" ;
1134+ }
1135+ if (s != " none" && args.hasArg (OPT_call_graph_ordering_file))
1136+ ErrAlways (ctx) << " --bp-compression-sort is incompatible with "
1137+ " --call-graph-ordering-file" ;
1138+ }
1139+ if (auto *arg = args.getLastArg (OPT_bp_startup_sort)) {
1140+ StringRef s = arg->getValue ();
1141+ if (s == " function" ) {
1142+ ctx.arg .bpStartupFunctionSort = true ;
1143+ } else if (s != " none" ) {
1144+ ErrAlways (ctx) << arg->getSpelling () << " : expected [none|function]" ;
1145+ }
1146+ if (s != " none" && args.hasArg (OPT_call_graph_ordering_file))
1147+ ErrAlways (ctx) << " --bp-startup-sort=function is incompatible with "
1148+ " --call-graph-ordering-file" ;
1149+ }
1150+
1151+ ctx.arg .bpCompressionSortStartupFunctions =
1152+ args.hasFlag (OPT_bp_compression_sort_startup_functions,
1153+ OPT_no_bp_compression_sort_startup_functions, false );
1154+ ctx.arg .bpVerboseSectionOrderer = args.hasArg (OPT_verbose_bp_section_orderer);
1155+
1156+ ctx.arg .irpgoProfilePath = args.getLastArgValue (OPT_irpgo_profile);
1157+ if (ctx.arg .irpgoProfilePath .empty ()) {
1158+ if (ctx.arg .bpStartupFunctionSort )
1159+ ErrAlways (ctx) << " --bp-startup-sort=function must be used with "
1160+ " --irpgo-profile" ;
1161+ if (ctx.arg .bpCompressionSortStartupFunctions )
1162+ ErrAlways (ctx)
1163+ << " --bp-compression-sort-startup-functions must be used with "
1164+ " --irpgo-profile" ;
1165+ }
1166+ }
1167+
11211168static DebugCompressionType getCompressionType (Ctx &ctx, StringRef s,
11221169 StringRef option) {
11231170 DebugCompressionType type = StringSwitch<DebugCompressionType>(s)
@@ -1259,55 +1306,7 @@ static void readConfigs(Ctx &ctx, opt::InputArgList &args) {
12591306 ctx.arg .bsymbolic = BsymbolicKind::All;
12601307 }
12611308 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);
1309+ parseBPOrdererOptions (ctx, args);
13111310 ctx.arg .checkSections =
13121311 args.hasFlag (OPT_check_sections, OPT_no_check_sections, true );
13131312 ctx.arg .chroot = args.getLastArgValue (OPT_chroot);
0 commit comments