Skip to content

Commit dd3236e

Browse files
scottp101igcbot
authored andcommitted
Optionally allow for compilation without payload header.
1 parent a53e0ef commit dd3236e

File tree

4 files changed

+24
-6
lines changed

4 files changed

+24
-6
lines changed

IGC/Compiler/CISACodeGen/DriverInfo.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,9 @@ namespace IGC
294294
// Limits simple push constants based on pushed inputs
295295
virtual bool EnableSimplePushRestriction() const { return false; }
296296

297+
// Determines whether the PAYLOAD_HEADER implicit arg must be present
298+
virtual bool RequirePayloadHeader() const { return true; }
299+
297300

298301
};
299302

IGC/Compiler/CISACodeGen/FoldKnownWorkGroupSizes.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ namespace IGC
4141
{
4242
private:
4343
static char ID;
44+
CodeGenContext* ctx = nullptr;
45+
bool RequirePayloadHeader = true;
4446
public:
4547
FoldKnownWorkGroupSizes() : FunctionPass(ID) {}
4648
bool runOnFunction(llvm::Function& F);
@@ -64,6 +66,8 @@ using namespace IGCMD;
6466

6567
bool FoldKnownWorkGroupSizes::runOnFunction(Function& F)
6668
{
69+
ctx = getAnalysis<CodeGenContextWrapper>().getCodeGenContext();
70+
RequirePayloadHeader = ctx->m_DriverInfo.RequirePayloadHeader();
6771
visit(F);
6872
return m_changed;
6973
}
@@ -78,8 +82,6 @@ void FoldKnownWorkGroupSizes::visitCallInst(llvm::CallInst& I)
7882
return;
7983
}
8084
StringRef funcName = calledFunction->getName();
81-
CodeGenContext* ctx = getAnalysis<CodeGenContextWrapper>().getCodeGenContext();
82-
8385

8486
if (funcName.equals(WIFuncsAnalysis::GET_GLOBAL_OFFSET) &&
8587
ctx->getModuleMetaData()->compOpt.replaceGlobalOffsetsByZero)
@@ -88,8 +90,8 @@ void FoldKnownWorkGroupSizes::visitCallInst(llvm::CallInst& I)
8890
{
8991
ConstantInt* IntZero = ConstantInt::get(Type::getInt32Ty(module->getContext()), 0);
9092
I.replaceAllUsesWith(IntZero);
91-
// TODO: erase when patch token is not required
92-
//I.eraseFromParent();
93+
if (!RequirePayloadHeader)
94+
I.eraseFromParent();
9395
m_changed = true;
9496
}
9597
}

IGC/Compiler/Optimizer/OpenCLPasses/WIFuncs/WIFuncsAnalysis.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ using namespace IGC;
4242
#define PASS_ANALYSIS false
4343
IGC_INITIALIZE_PASS_BEGIN(WIFuncsAnalysis, PASS_FLAG, PASS_DESCRIPTION, PASS_CFG_ONLY, PASS_ANALYSIS)
4444
IGC_INITIALIZE_PASS_DEPENDENCY(MetaDataUtilsWrapper)
45+
IGC_INITIALIZE_PASS_DEPENDENCY(CodeGenContextWrapper)
4546
IGC_INITIALIZE_PASS_END(WIFuncsAnalysis, PASS_FLAG, PASS_DESCRIPTION, PASS_CFG_ONLY, PASS_ANALYSIS)
4647

4748
char WIFuncsAnalysis::ID = 0;
@@ -68,6 +69,7 @@ WIFuncsAnalysis::WIFuncsAnalysis() : ModulePass(ID)
6869
bool WIFuncsAnalysis::runOnModule(Module& M)
6970
{
7071
m_pMDUtils = getAnalysis<MetaDataUtilsWrapper>().getMetaDataUtils();
72+
m_ctx = getAnalysis<CodeGenContextWrapper>().getCodeGenContext();
7173
// Run on all functions defined in this module
7274
for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I)
7375
{
@@ -104,11 +106,14 @@ bool WIFuncsAnalysis::runOnFunction(Function& F)
104106
//Analyze the implicit arguments needed by this function
105107
SmallVector<ImplicitArg::ArgType, ImplicitArg::NUM_IMPLICIT_ARGS> implicitArgs;
106108

109+
const bool RequirePayloadHeader = m_ctx->m_DriverInfo.RequirePayloadHeader();
110+
107111
// All OpenCL kernels receive R0 and Payload Header implicitly
108112
if (isEntryFunc(m_pMDUtils, &F))
109113
{
110114
implicitArgs.push_back(ImplicitArg::R0);
111-
implicitArgs.push_back(ImplicitArg::PAYLOAD_HEADER);
115+
if (RequirePayloadHeader)
116+
implicitArgs.push_back(ImplicitArg::PAYLOAD_HEADER);
112117
}
113118
else
114119
{
@@ -125,11 +130,15 @@ bool WIFuncsAnalysis::runOnFunction(Function& F)
125130
{
126131
implicitArgs.push_back(ImplicitArg::R0);
127132
}
128-
if (m_hasGlobalOffset)
133+
if (m_hasGlobalOffset && RequirePayloadHeader)
129134
{
130135
implicitArgs.push_back(ImplicitArg::PAYLOAD_HEADER);
131136
}
132137
}
138+
if (m_hasGlobalOffset && !RequirePayloadHeader)
139+
{
140+
implicitArgs.push_back(ImplicitArg::PAYLOAD_HEADER);
141+
}
133142
if (m_hasWorkDim)
134143
{
135144
implicitArgs.push_back(ImplicitArg::WORK_DIM);

IGC/Compiler/Optimizer/OpenCLPasses/WIFuncs/WIFuncsAnalysis.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ IN THE SOFTWARE.
2525
#pragma once
2626

2727
#include "Compiler/MetaDataUtilsWrapper.h"
28+
#include "Compiler/CodeGenContextWrapper.hpp"
2829

2930
#include "common/LLVMWarningsPush.hpp"
3031
#include <llvm/Pass.h>
@@ -59,6 +60,7 @@ namespace IGC
5960
void getAnalysisUsage(llvm::AnalysisUsage& AU) const override
6061
{
6162
AU.addRequired<MetaDataUtilsWrapper>();
63+
AU.addRequired<CodeGenContextWrapper>();
6264
}
6365

6466
/// @brief Main entry point.
@@ -121,6 +123,8 @@ namespace IGC
121123
bool m_hasStackCalls = false;
122124
/// @brief MetaData utils used to generate LLVM metadata
123125
IGCMD::MetaDataUtils* m_pMDUtils = nullptr;
126+
/// @brief context for compilation
127+
IGC::CodeGenContext* m_ctx = nullptr;
124128
};
125129

126130
} // namespace IGC

0 commit comments

Comments
 (0)