Skip to content

Commit 8ac67aa

Browse files
authored
[NFC][CFI][CodeGen] Move GeneralizeFunctionType out of CreateMetadataIdentifierGeneralized (#158190)
For #158193
1 parent bac9e46 commit 8ac67aa

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

clang/lib/CodeGen/CodeGenModule.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3041,9 +3041,12 @@ void CodeGenModule::createFunctionTypeMetadataForIcall(const FunctionDecl *FD,
30413041
if (isa<CXXMethodDecl>(FD) && !cast<CXXMethodDecl>(FD)->isStatic())
30423042
return;
30433043

3044-
llvm::Metadata *MD = CreateMetadataIdentifierForType(FD->getType());
3044+
QualType FnType = FD->getType();
3045+
llvm::Metadata *MD = CreateMetadataIdentifierForType(FnType);
30453046
F->addTypeMetadata(0, MD);
3046-
F->addTypeMetadata(0, CreateMetadataIdentifierGeneralized(FD->getType()));
3047+
3048+
QualType GenPtrFnType = GeneralizeFunctionType(getContext(), FD->getType());
3049+
F->addTypeMetadata(0, CreateMetadataIdentifierGeneralized(GenPtrFnType));
30473050

30483051
// Emit a hash-based bit set entry for cross-DSO calls.
30493052
if (CodeGenOpts.SanitizeCfiCrossDso)
@@ -7936,8 +7939,10 @@ CodeGenModule::CreateMetadataIdentifierImpl(QualType T, MetadataTypeMap &Map,
79367939

79377940
llvm::Metadata *CodeGenModule::CreateMetadataIdentifierForFnType(QualType T) {
79387941
assert(isa<FunctionType>(T));
7939-
if (getCodeGenOpts().SanitizeCfiICallGeneralizePointers)
7942+
if (getCodeGenOpts().SanitizeCfiICallGeneralizePointers) {
7943+
T = GeneralizeFunctionType(getContext(), T);
79407944
return CreateMetadataIdentifierGeneralized(T);
7945+
}
79417946
return CreateMetadataIdentifierForType(T);
79427947
}
79437948

@@ -7951,8 +7956,8 @@ CodeGenModule::CreateMetadataIdentifierForVirtualMemPtrType(QualType T) {
79517956
}
79527957

79537958
llvm::Metadata *CodeGenModule::CreateMetadataIdentifierGeneralized(QualType T) {
7954-
return CreateMetadataIdentifierImpl(GeneralizeFunctionType(getContext(), T),
7955-
GeneralizedMetadataIdMap, ".generalized");
7959+
return CreateMetadataIdentifierImpl(T, GeneralizedMetadataIdMap,
7960+
".generalized");
79567961
}
79577962

79587963
/// Returns whether this module needs the "all-vtables" type identifier.

0 commit comments

Comments
 (0)