From b72fd1a84d33e19f9f7fa6b7fdcaea57dc51aee4 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Mon, 11 Apr 2022 12:06:39 +0200 Subject: [PATCH] [CGCall] Check store type in findDominatingStoreToReturnValue() We need to make sure that the stored type matches the return type. --- clang/lib/CodeGen/CGCall.cpp | 3 ++- clang/test/CodeGenObjC/section-name.m | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp index c4d342e3d2aa..e6a5fd1f4f98 100644 --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/lib/CodeGen/CGCall.cpp @@ -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(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. diff --git a/clang/test/CodeGenObjC/section-name.m b/clang/test/CodeGenObjC/section-name.m index b6b9fa4a59f1..63fad82af4e6 100644 --- a/clang/test/CodeGenObjC/section-name.m +++ b/clang/test/CodeGenObjC/section-name.m @@ -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;