From d1b0b4bb4405c144e23be3d5c0459b03f95bd5ac Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Thu, 5 Jun 2025 10:52:01 -0700 Subject: 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 --- llvm/lib/Transforms/Utils/ModuleUtils.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'llvm/lib/Transforms/Utils/ModuleUtils.cpp') 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( - M->getModuleFlag("Unique Source File Names")); - if (UniqueSourceFileNames && UniqueSourceFileNames->getZExtValue()) { - Md5.update(M->getSourceFileName()); + auto *UniqueSourceFileIdentifier = dyn_cast_or_null( + M->getModuleFlag("Unique Source File Identifier")); + if (UniqueSourceFileIdentifier) { + Md5.update( + cast(UniqueSourceFileIdentifier->getOperand(0))->getString()); } else { bool ExportsSymbols = false; for (auto &GV : M->global_values()) { -- cgit v1.1