Skip to content

Commit 61e417b

Browse files
krystian-andrzejewskiigcbot
authored andcommitted
Allow customizing function patch names
This change is to allow the compiler to set a customized fuction patch names.
1 parent bbdc8e9 commit 61e417b

File tree

7 files changed

+19
-10
lines changed

7 files changed

+19
-10
lines changed

IGC/Compiler/CISACodeGen/CISABuilder.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5658,9 +5658,10 @@ void CEncoder::Compile(bool hasSymbolTable, GenXFunctionGroupAnalysis *&pFGA) {
56585658
}
56595659
}
56605660

5661-
dbgInfo = IGC::aligned_malloc(dbgSize, sizeof(void *));
5662-
5663-
memcpy_s(dbgInfo, dbgSize, genxdbgInfo, dbgSize);
5661+
if (dbgSize > 0) {
5662+
dbgInfo = IGC::aligned_malloc(dbgSize, sizeof(void *));
5663+
memcpy_s(dbgInfo, dbgSize, genxdbgInfo, dbgSize);
5664+
}
56645665

56655666
freeBlock(genxdbgInfo);
56665667
}

IGC/Compiler/CISACodeGen/CShader.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,10 +614,13 @@ void CShader::AllocateNOSConstants(uint &offset) {
614614
offset += m_State.m_NOSBufferSize;
615615
}
616616

617-
CVariable *CShader::CreateFunctionSymbol(llvm::Function *pFunc) {
617+
CVariable *CShader::CreateFunctionSymbol(llvm::Function *pFunc, StringRef symbolName) {
618618
// Functions with uses in this module requires relocation
619619
CVariable *funcAddr = GetSymbol(pFunc);
620620
std::string funcName = pFunc->getName().str();
621+
if (!symbolName.empty()) {
622+
funcName = symbolName.str();
623+
}
621624
encoder.AddVISASymbol(funcName, funcAddr);
622625
encoder.Push();
623626

IGC/Compiler/CISACodeGen/EmitVISAPass.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8991,9 +8991,9 @@ void EmitPass::EmitGenIntrinsicMessage(llvm::GenIntrinsicInst *inst) {
89918991
emitPredicatedStore(inst);
89928992
break;
89938993
default:
8994-
// we assume that some of gen-intrinsic should always be pattern-matched
8995-
// away, therefore we do not handle them in visa-emission. let us know if
8996-
// you see a case that hits this assertion by those intrinsics
8994+
// we assume that some of gen-intrinsic should always be pattern-matched away,
8995+
// therefore we do not handle them in visa-emission.
8996+
// let us know if you see a case that hits this assertion by those intrinsics
89978997
inst->print(IGC::Debug::ods());
89988998
IGC_ASSERT_MESSAGE(0, "unknown intrinsic");
89998999
break;

IGC/Compiler/CISACodeGen/ShaderCodeGen.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ class CShader {
264264
void CreateConstantBufferOutput(SKernelProgram *pKernelProgram) {
265265
m_State.CreateConstantBufferOutput(pKernelProgram);
266266
}
267-
CVariable *CreateFunctionSymbol(llvm::Function *pFunc);
267+
CVariable *CreateFunctionSymbol(llvm::Function *pFunc, StringRef symbolName = "");
268268
CVariable *CreateGlobalSymbol(llvm::GlobalVariable *pGlobal);
269269

270270
CVariable *GetStructVariable(llvm::Value *v);

IGC/GenISAIntrinsics/GenIntrinsicInst.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1753,6 +1753,7 @@ class GetShaderRecordPtrIntrinsic : public GenIntrinsicInst {
17531753
static inline bool classof(const Value *V) { return isa<GenIntrinsicInst>(V) && classof(cast<GenIntrinsicInst>(V)); }
17541754

17551755
Function *getContinuationFn() const { return cast<Function>(getOperand(0)->stripPointerCasts()); }
1756+
uint32_t getContinuationID() const { return (uint32_t)cast<ConstantInt>(getOperand(1))->getZExtValue(); }
17561757
};
17571758

17581759
class PayloadPtrIntrinsic : public GenIntrinsicInst {

IGC/GenISAIntrinsics/generator/Intrinsic_generator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,13 @@ def get_argument_entry(cls, arg, is_last):
139139
@classmethod
140140
def get_comment(cls ,comment):
141141
if cls.use_comments:
142-
output = '"{}"'.format(comment)
142+
output = '"{}"'.format(comment.strip())
143143
return output
144144
return '""'
145145

146146
@staticmethod
147147
def get_argument_comment(comment, is_last):
148-
output = IntrinsicFormatter.get_comment(comment)
148+
output = IntrinsicFormatter.get_comment(comment.strip())
149149
if not is_last:
150150
output = "{},".format(output)
151151
return output

IGC/GenISAIntrinsics/generator/input/Intrinsic_definitions.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11094,6 +11094,10 @@ intrinsics:
1109411094
name: Arg0
1109511095
type_definition: *p0_i8_
1109611096
comment: ""
11097+
- !<ArgumentDefinition>
11098+
name: Arg1
11099+
type_definition: *i32
11100+
comment: "continuation index"
1109711101
attributes:
1109811102
- !AttributeID "NoUnwind"
1109911103
- !AttributeID "WillReturn"

0 commit comments

Comments
 (0)