aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorVitaly Buka <vitalybuka@google.com>2025-09-12 16:38:21 -0700
committerGitHub <noreply@github.com>2025-09-12 23:38:21 +0000
commit8ac67aa8a9ef0012a619e1395a23a04cbea3abe9 (patch)
tree5c79e3339443232a6fa1734586ec104aab2ee8e3 /clang/lib/CodeGen/CodeGenModule.cpp
parentbac9e463b1f77b7354fe68c87d58be67e3294806 (diff)
downloadllvm-8ac67aa8a9ef0012a619e1395a23a04cbea3abe9.zip
llvm-8ac67aa8a9ef0012a619e1395a23a04cbea3abe9.tar.gz
llvm-8ac67aa8a9ef0012a619e1395a23a04cbea3abe9.tar.bz2
[NFC][CFI][CodeGen] Move GeneralizeFunctionType out of CreateMetadataIdentifierGeneralized (#158190)
For #158193
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index d45fb82..a650f27 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -3041,9 +3041,12 @@ void CodeGenModule::createFunctionTypeMetadataForIcall(const FunctionDecl *FD,
if (isa<CXXMethodDecl>(FD) && !cast<CXXMethodDecl>(FD)->isStatic())
return;
- llvm::Metadata *MD = CreateMetadataIdentifierForType(FD->getType());
+ QualType FnType = FD->getType();
+ llvm::Metadata *MD = CreateMetadataIdentifierForType(FnType);
F->addTypeMetadata(0, MD);
- F->addTypeMetadata(0, CreateMetadataIdentifierGeneralized(FD->getType()));
+
+ QualType GenPtrFnType = GeneralizeFunctionType(getContext(), FD->getType());
+ F->addTypeMetadata(0, CreateMetadataIdentifierGeneralized(GenPtrFnType));
// Emit a hash-based bit set entry for cross-DSO calls.
if (CodeGenOpts.SanitizeCfiCrossDso)
@@ -7936,8 +7939,10 @@ CodeGenModule::CreateMetadataIdentifierImpl(QualType T, MetadataTypeMap &Map,
llvm::Metadata *CodeGenModule::CreateMetadataIdentifierForFnType(QualType T) {
assert(isa<FunctionType>(T));
- if (getCodeGenOpts().SanitizeCfiICallGeneralizePointers)
+ if (getCodeGenOpts().SanitizeCfiICallGeneralizePointers) {
+ T = GeneralizeFunctionType(getContext(), T);
return CreateMetadataIdentifierGeneralized(T);
+ }
return CreateMetadataIdentifierForType(T);
}
@@ -7951,8 +7956,8 @@ CodeGenModule::CreateMetadataIdentifierForVirtualMemPtrType(QualType T) {
}
llvm::Metadata *CodeGenModule::CreateMetadataIdentifierGeneralized(QualType T) {
- return CreateMetadataIdentifierImpl(GeneralizeFunctionType(getContext(), T),
- GeneralizedMetadataIdMap, ".generalized");
+ return CreateMetadataIdentifierImpl(T, GeneralizedMetadataIdMap,
+ ".generalized");
}
/// Returns whether this module needs the "all-vtables" type identifier.