Skip to content

Commit 268a86e

Browse files
DianaChensys_zuul
authored andcommitted
VLA: Ignore llvm.stacksave/stackrestore if no SP
If stack is not initialized (no SP), which means there's no VLA, we can safely remove llvm.stacksave and stackrestore Change-Id: I252ff3ce5383ba23bcd3514591e8b9fc159d61f1
1 parent f38d775 commit 268a86e

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

IGC/Compiler/CISACodeGen/EmitVISAPass.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8326,11 +8326,17 @@ void EmitPass::EmitIntrinsicMessage(llvm::IntrinsicInst* inst)
83268326
// do nothing
83278327
break;
83288328
case Intrinsic::stacksave:
8329-
emitLLVMStackSave(inst);
8329+
// If stack is not initialized (no SP), we can assume there's no VLA.
8330+
// We can ignore llvm.stacksave and llvm.stackrestore intrinsics
8331+
if (m_currShader->hasSP())
8332+
emitLLVMStackSave(inst);
83308333
break;
83318334

83328335
case Intrinsic::stackrestore:
8333-
emitLLVMStackRestore(inst);
8336+
// If stack is not initialized (no SP), we can assume there's no VLA.
8337+
// We can ignore llvm.stacksave and llvm.stackrestore intrinsics
8338+
if (m_currShader->hasSP())
8339+
emitLLVMStackRestore(inst);
83348340
break;
83358341

83368342
case Intrinsic::bswap:

IGC/Compiler/CISACodeGen/ShaderCodeGen.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,10 @@ class CShader
193193
CVariable* GetARGV();
194194
CVariable* GetRETV();
195195
CVariable* GetPrivateBase();
196+
197+
bool hasSP() const { return m_SP != nullptr; }
198+
bool hasFP() const { return m_FP != nullptr; }
199+
196200
void InitializeStackVariables();
197201
void SaveStackState();
198202
void RestoreStackState();

0 commit comments

Comments
 (0)