| 1 |
From a3fac27e2181df52592003021bb4a6e4c50b89eb 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 792aa8208f27..6a19c53e19f8 100644 |
| 15 |
--- a/llvm/lib/Transforms/Utils/InlineFunction.cpp |
| 16 |
+++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp |
| 17 |
@@ -1439,6 +1439,12 @@ static Value *HandleByValArgument(Value *Arg, Instruction *TheCall, |
| 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() != ArgTy->getAddressSpace()) { |
| 23 |
+ NewAlloca = new AddrSpaceCastInst( |
| 24 |
+ NewAlloca, ArgTy, "", |
| 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 |
|