Skip to content

Commit 5354028

Browse files
MrSidimssys-ce-bb
authored andcommitted
Remove getLifetimeStartIntrinsic function from SPIRVReader (#3373)
With new lifetime.start/end rules, which are: "The argument is either a pointer to an alloca instruction or a poison value." it became obsolete on main branch. Note, no test is possible to add on the main branch. Moreover, it seem to be redundant overall, as IR like this was legal: %0 = alloca ... %1 = bitcast %0 call void @llvm.lifetime.start(..., %1) %2 = bitcast %0 call void @llvm.lifetime.end(..., %2) Further implecations, and why this patch will be backported on older branches. Right now there is a possibility to have a round-trip translation failed, when it goes from main to pre-opaque pointers branches as a bitcast from alloca to i8* will be inserted before lifetime.start call. Later, due to the current logic, this bitcast will be reused for lifetime.end call. But, lifetime.end won't always post-dominate lifetime.start (in this case the object will be considered dead at function return block), hence the bitcast won't dominate the lifetime.stop call, invalidating the generated module. Signed-off-by: Sidorov, Dmitry <dmitry.sidorov@intel.com> --------- Signed-off-by: Sidorov, Dmitry <dmitry.sidorov@intel.com> Original commit: KhronosGroup/SPIRV-LLVM-Translator@8ff535506896489
1 parent d734733 commit 5354028

File tree

1 file changed

+0
-20
lines changed

1 file changed

+0
-20
lines changed

llvm-spirv/lib/SPIRV/SPIRVReader.cpp

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -251,23 +251,6 @@ translateSEVMetadata(SPIRVValue *BV, llvm::LLVMContext &Context) {
251251
return RetAttr;
252252
}
253253

254-
IntrinsicInst *SPIRVToLLVM::getLifetimeStartIntrinsic(Instruction *I) {
255-
auto *II = dyn_cast<IntrinsicInst>(I);
256-
if (II && II->getIntrinsicID() == Intrinsic::lifetime_start)
257-
return II;
258-
// Bitcast might be inserted during translation of OpLifetimeStart
259-
auto *BC = dyn_cast<BitCastInst>(I);
260-
if (BC) {
261-
for (const auto &U : BC->users()) {
262-
II = dyn_cast<IntrinsicInst>(U);
263-
if (II && II->getIntrinsicID() == Intrinsic::lifetime_start)
264-
return II;
265-
;
266-
}
267-
}
268-
return nullptr;
269-
}
270-
271254
SPIRVErrorLog &SPIRVToLLVM::getErrorLog() { return BM->getErrorLog(); }
272255

273256
void SPIRVToLLVM::setCallingConv(CallInst *Call) {
@@ -1887,9 +1870,6 @@ Value *SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F,
18871870
IRBuilder<> Builder(BB);
18881871
auto *Var = transValue(LTStop->getObject(), F, BB);
18891872
Var = Var->stripPointerCasts();
1890-
for (const auto &I : Var->users())
1891-
if (auto *II = getLifetimeStartIntrinsic(dyn_cast<Instruction>(I)))
1892-
return mapValue(BV, Builder.CreateLifetimeEnd(II->getOperand(0)));
18931873
return mapValue(BV, Builder.CreateLifetimeEnd(Var));
18941874
}
18951875

0 commit comments

Comments
 (0)