aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/ModuleUtils.cpp
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2025-06-05 10:52:01 -0700
committerGitHub <noreply@github.com>2025-06-05 10:52:01 -0700
commitd1b0b4bb4405c144e23be3d5c0459b03f95bd5ac (patch)
treee420f9df26dcfeafbb9c00b9bc72e04caf19d6e7 /llvm/lib/Transforms/Utils/ModuleUtils.cpp
parentdef37f7e3a66601e044ce49c034293e7e32d2a3b (diff)
downloadllvm-d1b0b4bb4405c144e23be3d5c0459b03f95bd5ac.zip
llvm-d1b0b4bb4405c144e23be3d5c0459b03f95bd5ac.tar.gz
llvm-d1b0b4bb4405c144e23be3d5c0459b03f95bd5ac.tar.bz2
Add -funique-source-file-identifier option.
This option complements -funique-source-file-names and allows the user to use a different unique identifier than the source file path. Reviewers: teresajohnson Reviewed By: teresajohnson Pull Request: https://github.com/llvm/llvm-project/pull/142901
Diffstat (limited to 'llvm/lib/Transforms/Utils/ModuleUtils.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/ModuleUtils.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Utils/ModuleUtils.cpp b/llvm/lib/Transforms/Utils/ModuleUtils.cpp
index 10efdd6..596849e 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/Casting.h"
#include "llvm/Support/MD5.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/xxhash.h"
@@ -346,10 +347,11 @@ void llvm::filterDeadComdatFunctions(
std::string llvm::getUniqueModuleId(Module *M) {
MD5 Md5;
- auto *UniqueSourceFileNames = mdconst::extract_or_null<ConstantInt>(
- M->getModuleFlag("Unique Source File Names"));
- if (UniqueSourceFileNames && UniqueSourceFileNames->getZExtValue()) {
- Md5.update(M->getSourceFileName());
+ auto *UniqueSourceFileIdentifier = dyn_cast_or_null<MDNode>(
+ M->getModuleFlag("Unique Source File Identifier"));
+ if (UniqueSourceFileIdentifier) {
+ Md5.update(
+ cast<MDString>(UniqueSourceFileIdentifier->getOperand(0))->getString());
} else {
bool ExportsSymbols = false;
for (auto &GV : M->global_values()) {