Files
intel-graphics-compiler/external/llvm/releases/17.0.0/patches_external/Backport-When-creating-a-stack-space-for-inlined-byv.patch
Mielczarek, Aleksander 9d5bec3237 Additional LLVM patching
Add necessary LLVM patches.
2025-10-14 14:05:15 +02:00

33 lines
1.3 KiB
Diff

From 84d340ed615c3601a2f46178acce2040d9d114f9 Mon Sep 17 00:00:00 2001
From: Victor Mustya <victor.mustya@intel.com>
Date: Mon, 31 Oct 2022 13:27:02 -0700
Subject: =?UTF-8?q?[Backport]=20When=20creating=20a=20stack=20space=20for?=
=?UTF-8?q?=20inlined=20byval=20args,=0A=20use=20the=20same=20addrspace=20?=
=?UTF-8?q?as=20the=20original=20argument.?=
From: Chang-Sun Lin Jr <chang-sun.lin.jr@intel.com>
---
llvm/lib/Transforms/Utils/InlineFunction.cpp | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp
index 399c9a43793f..bfb027568227 100644
--- a/llvm/lib/Transforms/Utils/InlineFunction.cpp
+++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp
@@ -1599,6 +1599,12 @@ static Value *HandleByValArgument(Type *ByValType, Value *Arg,
Arg->getName(), &*Caller->begin()->begin());
IFI.StaticAllocas.push_back(cast<AllocaInst>(NewAlloca));
+ // If the byval was in a different address space, add a cast.
+ if (DL.getAllocaAddrSpace() != Arg->getType()->getPointerAddressSpace()) {
+ NewAlloca = new AddrSpaceCastInst(
+ NewAlloca, Arg->getType(), "",
+ cast<Instruction>(NewAlloca)->getNextNonDebugInstruction());
+ }
// Uses of the argument in the function should use our new alloca
// instead.
return NewAlloca;
--
2.43.0