Skip to content

Commit

Permalink
[clang] Remove getPointerElementType() in EmitVTableTypeCheckedLoad()
Browse files Browse the repository at this point in the history
  • Loading branch information
aeubanks committed Feb 23, 2022
1 parent 87753ce commit 6eec483
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
5 changes: 3 additions & 2 deletions clang/lib/CodeGen/CGClass.cpp
Expand Up @@ -2829,7 +2829,8 @@ bool CodeGenFunction::ShouldEmitVTableTypeCheckedLoad(const CXXRecordDecl *RD) {
}

llvm::Value *CodeGenFunction::EmitVTableTypeCheckedLoad(
const CXXRecordDecl *RD, llvm::Value *VTable, uint64_t VTableByteOffset) {
const CXXRecordDecl *RD, llvm::Value *VTable, llvm::Type *VTableTy,
uint64_t VTableByteOffset) {
SanitizerScope SanScope(this);

EmitSanitizerStatReport(llvm::SanStat_CFI_VCall);
Expand All @@ -2854,7 +2855,7 @@ llvm::Value *CodeGenFunction::EmitVTableTypeCheckedLoad(
}

return Builder.CreateBitCast(Builder.CreateExtractValue(CheckedLoad, 0),
VTable->getType()->getPointerElementType());
VTableTy);
}

void CodeGenFunction::EmitForwardingCallToLambda(
Expand Down
4 changes: 3 additions & 1 deletion clang/lib/CodeGen/CodeGenFunction.h
Expand Up @@ -2322,7 +2322,9 @@ class CodeGenFunction : public CodeGenTypeCache {
bool ShouldEmitVTableTypeCheckedLoad(const CXXRecordDecl *RD);

/// Emit a type checked load from the given vtable.
llvm::Value *EmitVTableTypeCheckedLoad(const CXXRecordDecl *RD, llvm::Value *VTable,
llvm::Value *EmitVTableTypeCheckedLoad(const CXXRecordDecl *RD,
llvm::Value *VTable,
llvm::Type *VTableTy,
uint64_t VTableByteOffset);

/// EnterDtorCleanups - Enter the cleanups necessary to complete the
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/CodeGen/ItaniumCXXABI.cpp
Expand Up @@ -1925,7 +1925,7 @@ CGCallee ItaniumCXXABI::getVirtualFunctionPointer(CodeGenFunction &CGF,
llvm::Value *VFunc;
if (CGF.ShouldEmitVTableTypeCheckedLoad(MethodDecl->getParent())) {
VFunc = CGF.EmitVTableTypeCheckedLoad(
MethodDecl->getParent(), VTable,
MethodDecl->getParent(), VTable, TyPtr,
VTableIndex * CGM.getContext().getTargetInfo().getPointerWidth(0) / 8);
} else {
CGF.EmitTypeMetadataCodeForVCall(MethodDecl->getParent(), VTable, Loc);
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/CodeGen/MicrosoftCXXABI.cpp
Expand Up @@ -1947,7 +1947,7 @@ CGCallee MicrosoftCXXABI::getVirtualFunctionPointer(CodeGenFunction &CGF,
llvm::Value *VFunc;
if (CGF.ShouldEmitVTableTypeCheckedLoad(MethodDecl->getParent())) {
VFunc = CGF.EmitVTableTypeCheckedLoad(
getObjectWithVPtr(), VTable,
getObjectWithVPtr(), VTable, Ty,
ML.Index * CGM.getContext().getTargetInfo().getPointerWidth(0) / 8);
} else {
if (CGM.getCodeGenOpts().PrepareForLTO)
Expand Down

0 comments on commit 6eec483

Please sign in to comment.