Skip to content

Commit e1a182f

Browse files
smilczekigcbot
authored andcommitted
Minor fixes and refactors.
Change dyn_cast to cast where it's clear cast was intended. - Change dyn_cast to cast where it's clear cast was intended. - Fix lock scope in Dump.cpp. - Pass sectName by ref in RelocSection constructor.
1 parent fa94ba3 commit e1a182f

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

IGC/Compiler/CustomSafeOptPass.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ void CustomSafeOptPass::mergeDotAddToDp4a(llvm::CallInst *I) {
396396
};
397397

398398
// found %id213- = call i32 @llvm.genx.GenISA.dp4a.ss.i32(i32 0, i32 %305, i32 %345)
399-
GenIntrinsicInst *instr = dyn_cast<GenIntrinsicInst>(I);
399+
GenIntrinsicInst *instr = cast<GenIntrinsicInst>(I);
400400

401401
if (ConstantInt *CI = dyn_cast<ConstantInt>(instr->getOperand(0))) {
402402
// make sure operand(0) value is (i32 0)
@@ -6286,7 +6286,7 @@ void InsertBranchOpt::atomicSplitOpt(Function &F, int mode) {
62866286
NewInst = builder.CreateCall(pLdIntrinsic, ld_FunctionArgList);
62876287
}
62886288
// Stateless atomic
6289-
else if ( (dyn_cast<GenIntrinsicInst>(inst))->getIntrinsicID() == GenISAIntrinsic::GenISA_intatomicrawA64 )
6289+
else if ( (cast<GenIntrinsicInst>(inst))->getIntrinsicID() == GenISAIntrinsic::GenISA_intatomicrawA64 )
62906290
{
62916291
NewInst = builder.CreateLoad( inst->getType(), inst->getOperand( 0 ) );
62926292
return NewInst;
@@ -6393,7 +6393,7 @@ void InsertBranchOpt::atomicSplitOpt(Function &F, int mode) {
63936393
}
63946394

63956395
IRBuilder<> builder(inst);
6396-
Instruction *src = dyn_cast<Instruction>(inst->getOperand(srcID));
6396+
Instruction *src = cast<Instruction>(inst->getOperand(srcID));
63976397
Instruction *readI = nullptr;
63986398
Instruction *ThenTerm = nullptr;
63996399
Instruction *ElseTerm = nullptr;
@@ -6408,7 +6408,7 @@ void InsertBranchOpt::atomicSplitOpt(Function &F, int mode) {
64086408
// use the original atomic add/sub/umax inst
64096409
// else
64106410
// use typedread or load
6411-
Instruction *condInst = dyn_cast<Instruction>(builder.CreateICmp(ICmpInst::ICMP_NE, src, builder.getInt32(0)));
6411+
Instruction *condInst = cast<Instruction>(builder.CreateICmp(ICmpInst::ICMP_NE, src, builder.getInt32(0)));
64126412
splitBBAndName(condInst, inst, &ThenTerm, &ElseTerm, MergeBlock);
64136413
inst->moveBefore(ThenTerm);
64146414

@@ -6423,7 +6423,7 @@ void InsertBranchOpt::atomicSplitOpt(Function &F, int mode) {
64236423
// use the original atomic umax/umin inst src
64246424
readI = createReadFromAtomic(builder, inst, isTyped);
64256425
CmpInst::Predicate predicate = (op == AtomicOp::EATOMIC_UMAX) ? ICmpInst::ICMP_UGT : ICmpInst::ICMP_ULT;
6426-
Instruction *condInst = dyn_cast<Instruction>(builder.CreateICmp(predicate, src, readI));
6426+
Instruction *condInst = cast<Instruction>(builder.CreateICmp(predicate, src, readI));
64276427

64286428
splitBBAndName(condInst, inst, &ThenTerm, nullptr, MergeBlock);
64296429
inst->moveBefore(ThenTerm);

IGC/ZEBinWriter/zebin/source/ZEELFObjectBuilder.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ class ZEELFObjectBuilder {
318318

319319
class RelocSection : public Section {
320320
public:
321-
RelocSection(SectionID myID, SectionID targetID, std::string sectName, bool isRelFormat)
321+
RelocSection(SectionID myID, SectionID targetID, const std::string &sectName, bool isRelFormat)
322322
: Section(myID), m_TargetID(targetID), m_sectName(sectName), m_isRelFormat(isRelFormat) {}
323323

324324
Kind getKind() const { return RELOC; }

IGC/common/debug/Dump.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,14 +222,14 @@ std::string DumpName::AbsolutePath(OutputFolderName folder) const {
222222
if (m_hash.has_value()) {
223223

224224
if (m_type.has_value() && IGC_IS_FLAG_ENABLED(EnableShaderNumbering)) {
225+
hashMapLock.lock();
225226
bool increment = shaderHashMap.insert({m_hash->asmHash, shaderNum}).second;
226227
// Need to serialize access to the shaderNum counter in case different threads need to dump the same shader at
227228
// once.
228-
hashMapLock.lock();
229229
if (increment)
230230
shaderNum++;
231-
hashMapLock.unlock();
232231
ss << "_" << shaderHashMap[m_hash->asmHash] << "_";
232+
hashMapLock.unlock();
233233
}
234234

235235
if (m_hash->asmHash != 0) {

0 commit comments

Comments
 (0)