aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-mca/llvm-mca.cpp
diff options
context:
space:
mode:
authorserge-sans-paille <sguelton@redhat.com>2020-03-04 00:47:43 +0100
committerserge-sans-paille <sguelton@redhat.com>2020-03-17 14:01:30 +0100
commitac1d23ed7de01fb3a18b340536842a419b504d86 (patch)
tree3f8f04b6b545d6660443d2681518b202ee08bdbd /llvm/tools/llvm-mca/llvm-mca.cpp
parent4ece6f051bd088fb8d4862bedf590f4f9d86cd17 (diff)
downloadllvm-ac1d23ed7de01fb3a18b340536842a419b504d86.zip
llvm-ac1d23ed7de01fb3a18b340536842a419b504d86.tar.gz
llvm-ac1d23ed7de01fb3a18b340536842a419b504d86.tar.bz2
Replace MCTargetOptionsCommandFlags.inc and CommandFlags.inc by runtime registration
MCTargetOptionsCommandFlags.inc and CommandFlags.inc are headers which contain cl::opt with static storage. These headers are meant to be incuded by tools to make it easier to parametrize codegen/mc. However, these headers are also included in at least two libraries: lldCommon and handle-llvm. As a result, when creating DYLIB, clang-cpp holds a reference to the options, and lldCommon holds another reference. Linking the two in a single executable, as zig does[0], results in a double registration. This patch explores an other approach: the .inc files are moved to regular files, and the registration happens on-demand through static declaration of options in the constructor of a static object. [0] https://bugzilla.redhat.com/show_bug.cgi?id=1756977#c5 Differential Revision: https://reviews.llvm.org/D75579
Diffstat (limited to 'llvm/tools/llvm-mca/llvm-mca.cpp')
-rw-r--r--llvm/tools/llvm-mca/llvm-mca.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/llvm/tools/llvm-mca/llvm-mca.cpp b/llvm/tools/llvm-mca/llvm-mca.cpp
index 06c1ce9..9f3bf41 100644
--- a/llvm/tools/llvm-mca/llvm-mca.cpp
+++ b/llvm/tools/llvm-mca/llvm-mca.cpp
@@ -39,7 +39,7 @@
#include "llvm/MC/MCObjectFileInfo.h"
#include "llvm/MC/MCRegisterInfo.h"
#include "llvm/MC/MCSubtargetInfo.h"
-#include "llvm/MC/MCTargetOptionsCommandFlags.inc"
+#include "llvm/MC/MCTargetOptionsCommandFlags.h"
#include "llvm/MCA/CodeEmitter.h"
#include "llvm/MCA/Context.h"
#include "llvm/MCA/InstrBuilder.h"
@@ -62,6 +62,8 @@
using namespace llvm;
+static mc::RegisterMCTargetOptionsFlags MOF;
+
static cl::OptionCategory ToolOptions("Tool Options");
static cl::OptionCategory ViewOptions("View Options");
@@ -353,7 +355,7 @@ int main(int argc, char **argv) {
std::unique_ptr<MCRegisterInfo> MRI(TheTarget->createMCRegInfo(TripleName));
assert(MRI && "Unable to create target register info!");
- MCTargetOptions MCOptions = InitMCTargetOptionsFromFlags();
+ MCTargetOptions MCOptions = mc::InitMCTargetOptionsFromFlags();
std::unique_ptr<MCAsmInfo> MAI(
TheTarget->createMCAsmInfo(*MRI, TripleName, MCOptions));
assert(MAI && "Unable to create target asm info!");
@@ -443,7 +445,7 @@ int main(int argc, char **argv) {
TheTarget->createMCCodeEmitter(*MCII, *MRI, Ctx));
std::unique_ptr<MCAsmBackend> MAB(TheTarget->createMCAsmBackend(
- *STI, *MRI, InitMCTargetOptionsFromFlags()));
+ *STI, *MRI, mc::InitMCTargetOptionsFromFlags()));
for (const std::unique_ptr<mca::CodeRegion> &Region : Regions) {
// Skip empty code regions.