================
@@ -43,50 +43,72 @@ static std::string getThinLTOOutputFile(Ctx &ctx, StringRef 
modulePath) {
                                    ctx.arg.thinLTOPrefixReplaceNew);
 }
 
+static std::shared_ptr<MemoryBuffer> getBBSectionsMemoryBuffer(Ctx &ctx) {
+  if (ctx.arg.ltoBasicBlockSections.empty() ||
+      ctx.arg.ltoBasicBlockSections == "all" ||
+      ctx.arg.ltoBasicBlockSections == "none")
+    return nullptr;
+
+  if (ctx.arg.ltoBasicBlockSections == "labels") {
+    Warn(ctx)
+        << "'--lto-basic-block-sections=labels' is deprecated; Please use "
+           "'--lto-basic-block-address-map' instead";
+    return nullptr;
+  }
+
+  ErrorOr<std::unique_ptr<MemoryBuffer>> mbOrErr =
+      MemoryBuffer::getFile(ctx.arg.ltoBasicBlockSections.str());
+  if (!mbOrErr) {
+    ErrAlways(ctx) << "cannot open " << ctx.arg.ltoBasicBlockSections << ":"
+                   << mbOrErr.getError().message();
+  }
+  return std::move(*mbOrErr);
+}
+
 static lto::Config createConfig(Ctx &ctx) {
   lto::Config c;
 
----------------
MaskRay wrote:

delete the blank line between c and mbPtr

In lld/ELF, a blank line is added mainly when:

There's a logical break between the declaration block and subsequent code.
Multiple declarations form a cohesive group that sets up state before a 
distinct block of logic begins.

Most cases don't apply.

https://github.com/llvm/llvm-project/pull/179509
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to