[llvm] [BOLT] Move instrumentation option check (NFC) (PR #71581)

Vladislav Khmelevsky via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 7 11:50:48 PST 2023


https://github.com/yota9 created https://github.com/llvm/llvm-project/pull/71581

Move options check from emitBinary to more proper
adjustCommandLineOptions.


>From 23302db0b85e95f61fcaea8af8458403d6a70066 Mon Sep 17 00:00:00 2001
From: Vladislav Khmelevsky <och95 at yandex.ru>
Date: Tue, 7 Nov 2023 23:49:17 +0400
Subject: [PATCH] [BOLT] Move instrumentation option check (NFC)

Move options check from emitBinary to more proper
adjustCommandLineOptions.
---
 .../RuntimeLibs/InstrumentationRuntimeLibrary.cpp | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/bolt/lib/RuntimeLibs/InstrumentationRuntimeLibrary.cpp b/bolt/lib/RuntimeLibs/InstrumentationRuntimeLibrary.cpp
index cc36406543f3995..ec0e2e21c66d9ae 100644
--- a/bolt/lib/RuntimeLibs/InstrumentationRuntimeLibrary.cpp
+++ b/bolt/lib/RuntimeLibs/InstrumentationRuntimeLibrary.cpp
@@ -57,6 +57,14 @@ void InstrumentationRuntimeLibrary::adjustCommandLineOptions(
               "the input binary\n";
     exit(1);
   }
+
+  if (BC.IsStaticExecutable && !opts::InstrumentationSleepTime) {
+    errs() << "BOLT-ERROR: instrumentation of static binary currently does not "
+      "support profile output on binary finalization, so it "
+      "requires -instrumentation-sleep-time=N (N>0) usage\n";
+    exit(1);
+  }
+
   if (!BC.FiniFunctionAddress && !BC.IsStaticExecutable) {
     errs() << "BOLT-ERROR: input binary lacks DT_FINI entry in the dynamic "
               "section but instrumentation currently relies on patching "
@@ -89,13 +97,6 @@ void InstrumentationRuntimeLibrary::emitBinary(BinaryContext &BC,
                                  "__BOLT", "__counters", MachO::S_REGULAR,
                                  SectionKind::getData()));
 
-  if (BC.IsStaticExecutable && !opts::InstrumentationSleepTime) {
-    errs() << "BOLT-ERROR: instrumentation of static binary currently does not "
-              "support profile output on binary finalization, so it "
-              "requires -instrumentation-sleep-time=N (N>0) usage\n";
-    exit(1);
-  }
-
   Section->setAlignment(llvm::Align(BC.RegularPageSize));
   Streamer.switchSection(Section);
 



More information about the llvm-commits mailing list