Skip to content

Commit fd70c73

Browse files
pratikasharigcbot
authored andcommitted
Mark stores as volatile so they're not optimized
away. Stores emitted in kernel to write local ids to frame are never referenced in a load instruction in the kernel. This causes llvm optimizer to treat the stores as dead and they're subsequently optimized away. This change marks those stores as volatile to indicate that some callee may load data written by these stores and they shouldn't be optimized away.
1 parent 58765ab commit fd70c73

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,15 @@ void WIFuncResolution::storeImplicitBufferPtrs(llvm::Function& F)
6969
auto DataTypeI16 = Type::getInt16Ty(C);
7070
auto AllocaVec = Builder.CreateAlloca(DataTypeI16, ConstantInt::get(DataTypeI16, (uint64_t)3));
7171
auto FirstSlot = Builder.CreatePointerCast(AllocaVec, DataTypeI16->getPointerTo());
72-
Builder.CreateStore(LocalIdX, FirstSlot);
72+
Builder.CreateStore(LocalIdX, FirstSlot, true);
7373
auto SecondSlot = Builder.CreatePtrToInt(FirstSlot, Type::getInt64Ty(C));
7474
SecondSlot = Builder.CreateAdd(SecondSlot, ConstantInt::get(SecondSlot->getType(), (uint64_t)2));
7575
SecondSlot = Builder.CreateIntToPtr(SecondSlot, DataTypeI16->getPointerTo());
76-
Builder.CreateStore(LocalIdY, SecondSlot);
76+
Builder.CreateStore(LocalIdY, SecondSlot, true);
7777
auto ThirdSlot = Builder.CreatePtrToInt(FirstSlot, Type::getInt64Ty(C));
7878
ThirdSlot = Builder.CreateAdd(ThirdSlot, ConstantInt::get(ThirdSlot->getType(), (uint64_t)4));
7979
ThirdSlot = Builder.CreateIntToPtr(ThirdSlot, DataTypeI16->getPointerTo());
80-
Builder.CreateStore(LocalIdZ, ThirdSlot);
80+
Builder.CreateStore(LocalIdZ, ThirdSlot, true);
8181

8282
auto* LidFunc = GenISAIntrinsic::getDeclaration(M, GenISAIntrinsic::GenISA_SetLocalIdBufferPtr, AllocaVec->getType());
8383
Args = { AllocaVec };

0 commit comments

Comments
 (0)