Debian Codegraph @

external/llvm/releases/14.0.0/patches_external/Backport-When-creating-a-stack-space-for-inlined-byv.patch

raw
1 From 52fc8d7dc229c68b87f7dba8be84ade0f0eb430a Mon Sep 17 00:00:00 2001
2 From: Victor Mustya <[email protected]>
3 Date: Mon, 31 Oct 2022 13:27:02 -0700
4 Subject: =?UTF-8?q?[Backport]=20When=20creating=20a=20stack=20space=20for?=
5 =?UTF-8?q?=20inlined=20byval=20args,=0A=20use=20the=20same=20addrspace=20?=
6 =?UTF-8?q?as=20the=20original=20argument.?=
7
8 From: Chang-Sun Lin Jr <[email protected]>
9 ---
10 llvm/lib/Transforms/Utils/InlineFunction.cpp | 6 ++++++
11 1 file changed, 6 insertions(+)
12
13 diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp
14 index 923bcc781e47..1d6dca24a4ad 100644
15 --- a/llvm/lib/Transforms/Utils/InlineFunction.cpp
16 +++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp
17 @@ -1429,6 +1429,12 @@ static Value *HandleByValArgument(Type *ByValType, Value *Arg,
18 Arg->getName(), &*Caller->begin()->begin());
19 IFI.StaticAllocas.push_back(cast<AllocaInst>(NewAlloca));
20
21 + // If the byval was in a different address space, add a cast.
22 + if (DL.getAllocaAddrSpace() != Arg->getType()->getPointerAddressSpace()) {
23 + NewAlloca = new AddrSpaceCastInst(
24 + NewAlloca, Arg->getType(), "",
25 + cast<Instruction>(NewAlloca)->getNextNonDebugInstruction());
26 + }
27 // Uses of the argument in the function should use our new alloca
28 // instead.
29 return NewAlloca;
30 --
31 2.34.1
32