Debian Codegraph @

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

raw
1 From 880c024c9d1c183b70bd0fe87076b015e04b31c9 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: [PATCH] [Backport] When creating a stack space for inlined byval
5 args, use the same addrspace as the original argument.
6
7 From: Chang-Sun Lin Jr <[email protected]>
8 ---
9 llvm/lib/Transforms/Utils/InlineFunction.cpp | 6 ++++++
10 1 file changed, 6 insertions(+)
11
12 diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp
13 index a7f0f7ac5d61..ea4a545582b8 100644
14 --- a/llvm/lib/Transforms/Utils/InlineFunction.cpp
15 +++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp
16 @@ -1305,6 +1305,12 @@ static Value *HandleByValArgument(Value *Arg, Instruction *TheCall,
17 &*Caller->begin()->begin());
18 IFI.StaticAllocas.push_back(cast<AllocaInst>(NewAlloca));
19
20 + // If the byval was in a different address space, add a cast.
21 + if (DL.getAllocaAddrSpace() != ArgTy->getAddressSpace()) {
22 + NewAlloca = new AddrSpaceCastInst(
23 + NewAlloca, ArgTy, "",
24 + cast<Instruction>(NewAlloca)->getNextNonDebugInstruction());
25 + }
26 // Uses of the argument in the function should use our new alloca
27 // instead.
28 return NewAlloca;
29 --
30 2.34.1
31