Skip to content

Commit 8ff5355

Browse files
author
Dmitry Sidorov
authored
[NFCI] 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>
1 parent 095a8c2 commit 8ff5355

File tree

1 file changed

+0
-20
lines changed

1 file changed

+0
-20
lines changed

lib/SPIRV/SPIRVReader.cpp

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

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

271254
void SPIRVToLLVM::setCallingConv(CallInst *Call) {
@@ -1884,9 +1867,6 @@ Value *SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F,
18841867
IRBuilder<> Builder(BB);
18851868
auto *Var = transValue(LTStop->getObject(), F, BB);
18861869
Var = Var->stripPointerCasts();
1887-
for (const auto &I : Var->users())
1888-
if (auto *II = getLifetimeStartIntrinsic(dyn_cast<Instruction>(I)))
1889-
return mapValue(BV, Builder.CreateLifetimeEnd(II->getOperand(0)));
18901870
return mapValue(BV, Builder.CreateLifetimeEnd(Var));
18911871
}
18921872

0 commit comments

Comments
 (0)