From 71fbbb69d63c461f391cbabf1e32cd9977c4ce68 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Wed, 15 May 2024 10:13:42 +0900 Subject: [PATCH] [IR] Move GlobalValue::getGUID() out of line (NFC) Avoid including MD5.h in a core IR header. --- llvm/include/llvm/IR/GlobalValue.h | 3 +-- llvm/lib/IR/Globals.cpp | 5 +++++ llvm/lib/Target/NVPTX/NVPTXCtorDtorLowering.cpp | 1 + llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp | 1 + llvm/lib/Transforms/Utils/ModuleUtils.cpp | 1 + 5 files changed, 9 insertions(+), 2 deletions(-) diff --git a/llvm/include/llvm/IR/GlobalValue.h b/llvm/include/llvm/IR/GlobalValue.h index c61d502aa332..b1262b27f022 100644 --- a/llvm/include/llvm/IR/GlobalValue.h +++ b/llvm/include/llvm/IR/GlobalValue.h @@ -24,7 +24,6 @@ #include "llvm/IR/Value.h" #include "llvm/Support/Casting.h" #include "llvm/Support/ErrorHandling.h" -#include "llvm/Support/MD5.h" #include #include #include @@ -588,7 +587,7 @@ public: /// Return a 64-bit global unique ID constructed from global value name /// (i.e. returned by getGlobalIdentifier()). - static GUID getGUID(StringRef GlobalName) { return MD5Hash(GlobalName); } + static GUID getGUID(StringRef GlobalName); /// Return a 64-bit global unique ID constructed from global value name /// (i.e. returned by getGlobalIdentifier()). diff --git a/llvm/lib/IR/Globals.cpp b/llvm/lib/IR/Globals.cpp index 40f854a2c906..6f071847bb58 100644 --- a/llvm/lib/IR/Globals.cpp +++ b/llvm/lib/IR/Globals.cpp @@ -21,6 +21,7 @@ #include "llvm/IR/Module.h" #include "llvm/Support/Error.h" #include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/MD5.h" #include "llvm/TargetParser/Triple.h" using namespace llvm; @@ -71,6 +72,10 @@ void GlobalValue::copyAttributesFrom(const GlobalValue *Src) { removeSanitizerMetadata(); } +GlobalValue::GUID GlobalValue::getGUID(StringRef GlobalName) { + return MD5Hash(GlobalName); +} + void GlobalValue::removeFromParent() { switch (getValueID()) { #define HANDLE_GLOBAL_VALUE(NAME) \ diff --git a/llvm/lib/Target/NVPTX/NVPTXCtorDtorLowering.cpp b/llvm/lib/Target/NVPTX/NVPTXCtorDtorLowering.cpp index f77a1f0272c8..f940dc05948b 100644 --- a/llvm/lib/Target/NVPTX/NVPTXCtorDtorLowering.cpp +++ b/llvm/lib/Target/NVPTX/NVPTXCtorDtorLowering.cpp @@ -22,6 +22,7 @@ #include "llvm/IR/Value.h" #include "llvm/Pass.h" #include "llvm/Support/CommandLine.h" +#include "llvm/Support/MD5.h" #include "llvm/Transforms/Utils/ModuleUtils.h" using namespace llvm; diff --git a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp index fca1824165e7..8d39217992c7 100644 --- a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp @@ -53,6 +53,7 @@ #include "llvm/Support/Casting.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" +#include "llvm/Support/MD5.h" #include "llvm/Support/RandomNumberGenerator.h" #include "llvm/Support/raw_ostream.h" #include "llvm/TargetParser/Triple.h" diff --git a/llvm/lib/Transforms/Utils/ModuleUtils.cpp b/llvm/lib/Transforms/Utils/ModuleUtils.cpp index 209a6a34a3c9..122279160cc7 100644 --- a/llvm/lib/Transforms/Utils/ModuleUtils.cpp +++ b/llvm/lib/Transforms/Utils/ModuleUtils.cpp @@ -18,6 +18,7 @@ #include "llvm/IR/IRBuilder.h" #include "llvm/IR/MDBuilder.h" #include "llvm/IR/Module.h" +#include "llvm/Support/MD5.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Support/xxhash.h"