aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Support/RISCVAttributes.cpp
diff options
context:
space:
mode:
authorMehdi Amini <joker.eph@gmail.com>2021-07-15 23:52:44 +0000
committerMehdi Amini <joker.eph@gmail.com>2021-07-16 06:54:26 +0000
commitaf9321739b20becf170e6bb5060b8d780e1dc8dd (patch)
treeb6102c00e02d67904fab6a4638b0f0e3d1afca9b /llvm/lib/Support/RISCVAttributes.cpp
parent20113d66c7bfe935cf2b300fc6cc3ef996bb847d (diff)
downloadllvm-af9321739b20becf170e6bb5060b8d780e1dc8dd.zip
llvm-af9321739b20becf170e6bb5060b8d780e1dc8dd.tar.gz
llvm-af9321739b20becf170e6bb5060b8d780e1dc8dd.tar.bz2
Use ManagedStatic and lazy initialization of cl::opt in libSupport to make it free of global initializer
We can build it with -Werror=global-constructors now. This helps in situation where libSupport is embedded as a shared library, potential with dlopen/dlclose scenario, and when command-line parsing or other facilities may not be involved. Avoiding the implicit construction of these cl::opt can avoid double-registration issues and other kind of behavior. Reviewed By: lattner, jpienaar Differential Revision: https://reviews.llvm.org/D105959
Diffstat (limited to 'llvm/lib/Support/RISCVAttributes.cpp')
-rw-r--r--llvm/lib/Support/RISCVAttributes.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/llvm/lib/Support/RISCVAttributes.cpp b/llvm/lib/Support/RISCVAttributes.cpp
index 201048e..9e62976 100644
--- a/llvm/lib/Support/RISCVAttributes.cpp
+++ b/llvm/lib/Support/RISCVAttributes.cpp
@@ -11,7 +11,7 @@
using namespace llvm;
using namespace llvm::RISCVAttrs;
-static const TagNameItem tagData[] = {
+static constexpr TagNameItem tagData[] = {
{STACK_ALIGN, "Tag_stack_align"},
{ARCH, "Tag_arch"},
{UNALIGNED_ACCESS, "Tag_unaligned_access"},
@@ -20,6 +20,7 @@ static const TagNameItem tagData[] = {
{PRIV_SPEC_REVISION, "Tag_priv_spec_revision"},
};
-const TagNameMap llvm::RISCVAttrs::RISCVAttributeTags(tagData,
- sizeof(tagData) /
- sizeof(TagNameItem));
+constexpr TagNameMap RISCVAttributeTags{tagData};
+const TagNameMap &llvm::RISCVAttrs::getRISCVAttributeTags() {
+ return RISCVAttributeTags;
+}