aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CGExprAgg.cpp
diff options
context:
space:
mode:
authorAlex Voicu <alexandru.voicu@amd.com>2025-02-27 02:03:17 +0000
committerGitHub <noreply@github.com>2025-02-27 09:03:17 +0700
commitc8f70d7286db0eb54b001a6621a863b96c006e45 (patch)
tree6959c9224c00a2032d7eba7441d64d6b5be70ab4 /clang/lib/CodeGen/CGExprAgg.cpp
parenta3165398db0736588daedb07650195502592e567 (diff)
downloadllvm-c8f70d7286db0eb54b001a6621a863b96c006e45.zip
llvm-c8f70d7286db0eb54b001a6621a863b96c006e45.tar.gz
llvm-c8f70d7286db0eb54b001a6621a863b96c006e45.tar.bz2
[clang][CodeGen] Additional fixes for #114062 (#128166)
This addresses two issues introduced by moving indirect args into an explicit AS (please see <https://github.com/llvm/llvm-project/pull/114062#issuecomment-2659829790> and <https://github.com/llvm/llvm-project/pull/114062#issuecomment-2661158477>): 1. Unconditionally stripping casts from a pre-allocated return slot was incorrect / insufficient (this is illustrated by the `amdgcn_sret_ctor.cpp` test); 2. Putting compiler manufactured sret args in a non default AS can lead to a C-cast (surprisingly) requiring an AS cast (this is illustrated by the `sret_cast_with_nonzero_alloca_as.cpp test). The way we handle (2), by subverting CK_BitCast emission iff a sret arg is involved, is quite naff, but I couldn't think of any other way to use a non default indirect AS and make this case work (hopefully this is a failure of imagination on my part).
Diffstat (limited to 'clang/lib/CodeGen/CGExprAgg.cpp')
-rw-r--r--clang/lib/CodeGen/CGExprAgg.cpp11
1 files changed, 2 insertions, 9 deletions
diff --git a/clang/lib/CodeGen/CGExprAgg.cpp b/clang/lib/CodeGen/CGExprAgg.cpp
index 625ca36..200fb7f 100644
--- a/clang/lib/CodeGen/CGExprAgg.cpp
+++ b/clang/lib/CodeGen/CGExprAgg.cpp
@@ -302,15 +302,8 @@ void AggExprEmitter::withReturnValueSlot(
llvm::Value *LifetimeSizePtr = nullptr;
llvm::IntrinsicInst *LifetimeStartInst = nullptr;
if (!UseTemp) {
- // It is possible for the existing slot we are using directly to have been
- // allocated in the correct AS for an indirect return, and then cast to
- // the default AS (this is the behaviour of CreateMemTemp), however we know
- // that the return address is expected to point to the uncasted AS, hence we
- // strip possible pointer casts here.
- if (Dest.getAddress().isValid())
- RetAddr = Dest.getAddress().withPointer(
- Dest.getAddress().getBasePointer()->stripPointerCasts(),
- Dest.getAddress().isKnownNonNull());
+ RetAddr = Dest.getAddress();
+ RawAddress RetAllocaAddr = RawAddress::invalid();
} else {
RetAddr = CGF.CreateMemTempWithoutCast(RetTy, "tmp");
llvm::TypeSize Size =