Improve disable inlining pass

Remove always inline attribute from call instructions to prevent
LLVM inliner from inlining them.
This commit is contained in:
Stefan Ilic
2025-10-27 14:48:38 +00:00
committed by igcbot
parent e3fc880273
commit 6057876654
4 changed files with 20 additions and 12 deletions

View File

@ -12,6 +12,8 @@ SPDX-License-Identifier: MIT
#include "common/LLVMWarningsPush.hpp"
#include <llvm/IR/Function.h>
#include <llvm/IR/InstIterator.h>
#include <llvm/IR/Instructions.h>
#include "common/LLVMWarningsPop.hpp"
using namespace llvm;
@ -38,5 +40,14 @@ bool DisableInlining::runOnFunction(llvm::Function &F) {
F.removeFnAttr(llvm::Attribute::AlwaysInline);
}
F.addFnAttr(llvm::Attribute::NoInline);
for (auto &I : llvm::instructions(F)) {
if (auto *CI = dyn_cast<CallInst>(&I)) {
if (CI->hasFnAttr(llvm::Attribute::AlwaysInline)) {
CI->removeFnAttr(llvm::Attribute::AlwaysInline);
}
}
}
return true;
}
}

View File

@ -1330,19 +1330,17 @@ DECLARE_IGC_REGKEY(DWORD, ForceGroupSizeX, 8, "force group size along X", false)
DECLARE_IGC_REGKEY(DWORD, ForceGroupSizeY, 8, "force group size along Y", false)
DECLARE_IGC_REGKEY(bool, EnableThreadCombiningWithNoSLM, false, "Enable thread combining opt for shader without SLM",
false)
DECLARE_IGC_REGKEY(bool, DisableInlining, false, "Disable inlining of all functions", true)
DECLARE_IGC_REGKEY(bool, EnableDropTargetFunctions, false, "Enables pass for dropping targeted functions", true)
DECLARE_IGC_REGKEY(bool, DisableInlining, false, "Disable inlining of all functions", false)
DECLARE_IGC_REGKEY(bool, EnableDropTargetFunctions, false, "Enables pass for dropping targeted functions", false)
DECLARE_IGC_REGKEY(bool, VerboseDropTargetFunctions, false, "Enables verbose logging for dropping targeted functions",
true)
false)
DECLARE_IGC_REGKEY(bool, CrashOnDroppedFnAccess, false, "Enables crash on access to dropped functions",
true)
DECLARE_IGC_REGKEY(debugString, DropTargetFnListPath, 0, "Path to folder with lists of functions to drop", true)
DECLARE_IGC_REGKEY(bool, EnableDropTargetBBs, false, "Enables pass for dropping targeted BBs", true)
DECLARE_IGC_REGKEY(debugString, DropTargetFnListPath, 0, "Path to folder with lists of functions to drop", false)
DECLARE_IGC_REGKEY(bool, EnableDropTargetBBs, false, "Enables pass for dropping targeted BBs", false)
DECLARE_IGC_REGKEY(bool, VerboseDropTargetBBs, false, "Enables verbose logging for dropping targeted BBs",
true)
DECLARE_IGC_REGKEY(bool, CrashOnDroppedBBAccess, false, "Enables crash on access to dropped BBs",
true)
DECLARE_IGC_REGKEY(debugString, DropTargetBBListPath, 0, "Path to folder with lists of BBs to drop", true)
false)
DECLARE_IGC_REGKEY(debugString, DropTargetBBListPath, 0, "Path to folder with lists of BBs to drop", false)
DECLARE_IGC_REGKEY(DWORD, PrintFunctionSizeAnalysis, 0, "Print analysis data of function sizes", true)
DECLARE_IGC_REGKEY(DWORD, SubroutineThreshold, 110000, "Minimal kernel size to enable subroutines", false)
DECLARE_IGC_REGKEY(DWORD, SubroutineInlinerThreshold, 3000, "Subroutine inliner threshold", false)

View File

@ -35,7 +35,7 @@ define linkonce_odr spir_func void @testInlineFn2(i32 %d) {
}
define spir_kernel void @testKernel(i32 %a, i32 %b, i32 %c) {
call spir_func void @testInlineFn1(i32 %b)
call spir_func void @testInlineFn1(i32 %b) #0
call spir_func void @testInlineFn2(i32 %c)
ret void
}

View File

@ -702,7 +702,6 @@ $ export IGC_ShaderDumpEnable=1
| `ControlInlineTinySizeForSPGT` | Tiny function size for controlling kernel total size | Available |
| `ControlKernelTotalSize` | Control kernel total size | Available |
| `ControlUnitSize` | Control compilation unit size by unit trimming | Available |
| `CrashOnDroppedBBAccess` | Enables crash on access to dropped BBs | Available |
| `CrashOnDroppedFnAccess` | Enables crash on access to dropped functions | Available |
| `DelayEmuInt64AddLimit` | Delay emulating Int64 Add operations in vISA | - |
| `DetectCastToGAS` | Check if the module contains local/private to GAS (Gerneric Address Space) cast, it also check internal flags | Available |