================
@@ -46,47 +46,52 @@ static std::string getThinLTOOutputFile(Ctx &ctx, StringRef
modulePath) {
static lto::Config createConfig(Ctx &ctx) {
lto::Config c;
- // LLD supports the new relocations and address-significance tables.
- c.Options = initTargetOptionsFromCodeGenFlags();
- c.Options.EmitAddrsig = true;
- for (StringRef C : ctx.arg.mllvmOpts)
- c.MllvmArgs.emplace_back(C.str());
-
- // Always emit a section per function/datum with LTO.
- c.Options.FunctionSections = true;
- c.Options.DataSections = true;
-
- // Check if basic block sections must be used.
- // Allowed values for --lto-basic-block-sections are "all",
- // "<file name specifying basic block ids>", or none. This is the equivalent
- // of -fbasic-block-sections= flag in clang.
- if (!ctx.arg.ltoBasicBlockSections.empty()) {
- if (ctx.arg.ltoBasicBlockSections == "all") {
- c.Options.BBSections = BasicBlockSection::All;
- } else if (ctx.arg.ltoBasicBlockSections == "labels") {
- c.Options.BBAddrMap = true;
- Warn(ctx)
- << "'--lto-basic-block-sections=labels' is deprecated; Please use "
- "'--lto-basic-block-address-map' instead";
- } else if (ctx.arg.ltoBasicBlockSections == "none") {
- c.Options.BBSections = BasicBlockSection::None;
- } else {
- ErrorOr<std::unique_ptr<MemoryBuffer>> MBOrErr =
- MemoryBuffer::getFile(ctx.arg.ltoBasicBlockSections.str());
- if (!MBOrErr) {
- ErrAlways(ctx) << "cannot open " << ctx.arg.ltoBasicBlockSections <<
":"
- << MBOrErr.getError().message();
+ // Set up the callback to modify TargetOptions.
+ c.ModifyTargetOptions = [&](TargetOptions &Options) -> void {
+ // LLD supports the new relocations and address-significance tables.
+ Options.EmitAddrsig = true;
+ // Always emit a section per function/datum with LTO.
+ Options.FunctionSections = true;
+ Options.DataSections = true;
+
+ // Check if basic block sections must be used.
+ // Allowed values for --lto-basic-block-sections are "all",
+ // "<file name specifying basic block ids>", or none. This is the
+ // equivalent of -fbasic-block-sections= flag in clang.
+ if (!ctx.arg.ltoBasicBlockSections.empty()) {
+ if (ctx.arg.ltoBasicBlockSections == "all") {
+ Options.BBSections = BasicBlockSection::All;
+ } else if (ctx.arg.ltoBasicBlockSections == "labels") {
+ Options.BBAddrMap = true;
+ Warn(ctx)
+ << "'--lto-basic-block-sections=labels' is deprecated; Please use "
+ "'--lto-basic-block-address-map' instead";
+ } else if (ctx.arg.ltoBasicBlockSections == "none") {
+ Options.BBSections = BasicBlockSection::None;
} else {
- c.Options.BBSectionsFuncListBuf = std::move(*MBOrErr);
+ ErrorOr<std::unique_ptr<MemoryBuffer>> MBOrErr =
+ MemoryBuffer::getFile(ctx.arg.ltoBasicBlockSections.str());
----------------
nikic wrote:
This looks like something that should be happening outside the lambda, so we
only create the buffer once.
https://github.com/llvm/llvm-project/pull/179509
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits