aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/ValueMapper.cpp
diff options
context:
space:
mode:
authorPrabhu Rajasekaran <prabhukr@google.com>2025-07-18 14:40:54 -0700
committerGitHub <noreply@github.com>2025-07-18 14:40:54 -0700
commit921c6dbecaf49e3ed24b94802f094cd7f61f1873 (patch)
treed25e45eb05da07ef36276a4fbc4d524285762253 /llvm/lib/Transforms/Utils/ValueMapper.cpp
parent6d8e53d4afe46608f47bcb014387c053829cdcf1 (diff)
downloadllvm-921c6dbecaf49e3ed24b94802f094cd7f61f1873.zip
llvm-921c6dbecaf49e3ed24b94802f094cd7f61f1873.tar.gz
llvm-921c6dbecaf49e3ed24b94802f094cd7f61f1873.tar.bz2
[llvm] Introduce callee_type metadata
Introduce `callee_type` metadata which will be attached to the indirect call instructions. The `callee_type` metadata will be used to generate `.callgraph` section described in this RFC: https://lists.llvm.org/pipermail/llvm-dev/2021-July/151739.html Reviewers: morehouse, petrhosek, nikic, ilovepi Reviewed By: nikic, ilovepi Pull Request: https://github.com/llvm/llvm-project/pull/87573
Diffstat (limited to 'llvm/lib/Transforms/Utils/ValueMapper.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/ValueMapper.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/ValueMapper.cpp b/llvm/lib/Transforms/Utils/ValueMapper.cpp
index 7ba95e2..8d8a60b 100644
--- a/llvm/lib/Transforms/Utils/ValueMapper.cpp
+++ b/llvm/lib/Transforms/Utils/ValueMapper.cpp
@@ -987,6 +987,13 @@ void Mapper::remapInstruction(Instruction *I) {
"Referenced value not in value map!");
}
+ // Drop callee_type metadata from calls that were remapped
+ // into a direct call from an indirect one.
+ if (auto *CB = dyn_cast<CallBase>(I)) {
+ if (CB->getMetadata(LLVMContext::MD_callee_type) && !CB->isIndirectCall())
+ CB->setMetadata(LLVMContext::MD_callee_type, nullptr);
+ }
+
// Remap phi nodes' incoming blocks.
if (PHINode *PN = dyn_cast<PHINode>(I)) {
for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) {