[CGCall] Check store type in findDominatingStoreToReturnValue()

We need to make sure that the stored type matches the return type.
This commit is contained in:
Nikita Popov 2022-04-11 12:06:39 +02:00
parent b24b56165a
commit b72fd1a84d
2 changed files with 3 additions and 2 deletions

View File

@ -3228,7 +3228,8 @@ static llvm::StoreInst *findDominatingStoreToReturnValue(CodeGenFunction &CGF) {
// ReturnValue to some other location.
auto GetStoreIfValid = [&CGF](llvm::User *U) -> llvm::StoreInst * {
auto *SI = dyn_cast<llvm::StoreInst>(U);
if (!SI || SI->getPointerOperand() != CGF.ReturnValue.getPointer())
if (!SI || SI->getPointerOperand() != CGF.ReturnValue.getPointer() ||
SI->getValueOperand()->getType() != CGF.ReturnValue.getElementType())
return nullptr;
// These aren't actually possible for non-coerced returns, and we
// only care about non-coerced returns on this code path.

View File

@ -1,4 +1,4 @@
// RUN: %clang_cc1 -no-opaque-pointers -triple thumbv7--windows-itanium -fdeclspec -fobjc-runtime=ios -emit-llvm -o - %s -Wno-objc-root-class | FileCheck %s
// RUN: %clang_cc1 -triple thumbv7--windows-itanium -fdeclspec -fobjc-runtime=ios -emit-llvm -o - %s -Wno-objc-root-class | FileCheck %s
@protocol Protocol
- (void) protocol_method;