Skip to content

Commit 1ee2aa0

Browse files
committed
Align llvm-spirv with removing size from lifetime intrinsics
The proper fix will be done in Khronos. The change is needed to fix the build after c23b4fb
1 parent 7a75962 commit 1ee2aa0

File tree

2 files changed

+6
-33
lines changed

2 files changed

+6
-33
lines changed

llvm-spirv/lib/SPIRV/SPIRVReader.cpp

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1876,43 +1876,19 @@ Value *SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F,
18761876
case OpLifetimeStart: {
18771877
SPIRVLifetimeStart *LTStart = static_cast<SPIRVLifetimeStart *>(BV);
18781878
IRBuilder<> Builder(BB);
1879-
SPIRVWord Size = LTStart->getSize();
1880-
ConstantInt *S = nullptr;
18811879
auto *Var = transValue(LTStart->getObject(), F, BB);
1882-
Var = Var->stripPointerCasts();
1883-
if (Size)
1884-
S = Builder.getInt64(Size);
1885-
if (Size == 0) {
1886-
auto *Alloca = cast<AllocaInst>(Var);
1887-
if (Alloca->getAllocatedType()->isSized())
1888-
Size = M->getDataLayout().getTypeAllocSize(Alloca->getAllocatedType());
1889-
else
1890-
Size = static_cast<SPIRVWord>(-1);
1891-
}
1892-
CallInst *Start = Builder.CreateLifetimeStart(Var, S);
1880+
CallInst *Start = Builder.CreateLifetimeStart(Var);
18931881
return mapValue(BV, Start);
18941882
}
18951883

18961884
case OpLifetimeStop: {
18971885
SPIRVLifetimeStop *LTStop = static_cast<SPIRVLifetimeStop *>(BV);
18981886
IRBuilder<> Builder(BB);
1899-
SPIRVWord Size = LTStop->getSize();
1900-
ConstantInt *S = nullptr;
19011887
auto *Var = transValue(LTStop->getObject(), F, BB);
1902-
Var = Var->stripPointerCasts();
1903-
if (Size)
1904-
S = Builder.getInt64(Size);
1905-
if (Size == 0) {
1906-
auto *Alloca = cast<AllocaInst>(Var);
1907-
if (Alloca->getAllocatedType()->isSized())
1908-
Size = M->getDataLayout().getTypeAllocSize(Alloca->getAllocatedType());
1909-
else
1910-
Size = static_cast<SPIRVWord>(-1);
1911-
}
19121888
for (const auto &I : Var->users())
19131889
if (auto *II = getLifetimeStartIntrinsic(dyn_cast<Instruction>(I)))
1914-
return mapValue(BV, Builder.CreateLifetimeEnd(II->getOperand(1), S));
1915-
return mapValue(BV, Builder.CreateLifetimeEnd(Var, S));
1890+
return mapValue(BV, Builder.CreateLifetimeEnd(II->getOperand(1)));
1891+
return mapValue(BV, Builder.CreateLifetimeEnd(Var));
19161892
}
19171893

19181894
case OpStore: {

llvm-spirv/lib/SPIRV/SPIRVWriter.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4841,14 +4841,11 @@ SPIRVValue *LLVMToSPIRVBase::transIntrinsicInst(IntrinsicInst *II,
48414841
Op OC = (II->getIntrinsicID() == Intrinsic::lifetime_start)
48424842
? OpLifetimeStart
48434843
: OpLifetimeStop;
4844-
int64_t Size = dyn_cast<ConstantInt>(II->getOperand(0))->getSExtValue();
4845-
if (Size == -1)
4846-
Size = 0;
4847-
Value *LLVMPtrOp = II->getOperand(1);
4844+
Value *LLVMPtrOp = II->getOperand(0);
48484845
unsigned PtrAS = cast<PointerType>(LLVMPtrOp->getType())->getAddressSpace();
48494846
auto *PtrOp = transValue(LLVMPtrOp, BB);
48504847
if (PtrAS == SPIRAS_Private)
4851-
return BM->addLifetimeInst(OC, PtrOp, Size, BB);
4848+
return BM->addLifetimeInst(OC, PtrOp, 0, BB);
48524849
// If pointer address space is Generic - use original allocation.
48534850
BM->getErrorLog().checkError(
48544851
PtrAS == SPIRAS_Generic, SPIRVEC_InvalidInstruction, II,
@@ -4857,7 +4854,7 @@ SPIRVValue *LLVMToSPIRVBase::transIntrinsicInst(IntrinsicInst *II,
48574854
auto *UI = static_cast<SPIRVUnary *>(PtrOp);
48584855
PtrOp = UI->getOperand(0);
48594856
}
4860-
return BM->addLifetimeInst(OC, PtrOp, Size, BB);
4857+
return BM->addLifetimeInst(OC, PtrOp, 0, BB);
48614858
}
48624859
// We don't want to mix translation of regular code and debug info, because
48634860
// it creates a mess, therefore translation of debug intrinsics is

0 commit comments

Comments
 (0)