Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Continuations] Support new LLVM #2873

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,11 @@ findIntrImplEntryByIntrinsicCall(CallInst *Call);
// during DXILContPostProcess, so we cannot remove all unused declarations right
// at the end of LowerRaytracingPipeline.
bool removeUnusedFunctionDecls(Module *Mod, bool OnlyIntrinsics = true);

// Replacement for PointerType::getWithSamePointeeType that works with new LLVM.
// Returns a typed pointer type if the pointer type is typed.
PointerType *getWithSamePointeeType(PointerType *PtrTy, unsigned AddressSpace);

} // namespace llvm

#endif
11 changes: 11 additions & 0 deletions shared/continuations/lib/ContinuationsUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,14 @@ bool llvm::removeUnusedFunctionDecls(Module *Mod, bool OnlyIntrinsics) {

return DidChange;
}

PointerType *llvm::getWithSamePointeeType(PointerType *PtrTy,
unsigned AddressSpace) {
#if LLVM_MAIN_REVISION && LLVM_MAIN_REVISION < 482880
return PointerType::getWithSamePointeeType(PtrTy, AddressSpace);
#else
// New version of the code (also handles unknown version, which we treat as
// latest)
return PointerType::get(PtrTy->getContext(), AddressSpace);
#endif
}
7 changes: 0 additions & 7 deletions shared/continuations/lib/LowerRaytracingPipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,6 @@ struct PayloadCopyHelper {
// Pointer to the node field in the local payload
auto *LocalFieldPtr =
B.CreateInBoundsGEP(&PayloadTy, LocalPayload, PayloadIdxList);
assert(cast<PointerType>(LocalFieldPtr->getType())
->isOpaqueOrPointeeTypeMatches(FieldTy));

// If the field is serialized in multiple intervals in the global,
// we perform a manual bytewise copy using i32 and i8.
Expand Down Expand Up @@ -953,11 +951,6 @@ void LowerRaytracingPipelinePassImpl::copyPayload(
Payload,
Layout.SerializationTy->getPointerTo(Payload->getAddressSpace()));

assert(cast<PointerType>(PayloadSerialization->getType())
->isOpaqueOrPointeeTypeMatches(Layout.SerializationTy));
assert(cast<PointerType>(LocalPayload->getType())
->isOpaqueOrPointeeTypeMatches(&PayloadTy));

PayloadCopyHelper Helper{
*Mod,
B,
Expand Down
11 changes: 5 additions & 6 deletions shared/continuations/lib/RegisterBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,16 +194,16 @@ Value *RegisterBufferPass::computeMemAddr(IRBuilder<> &Builder,
Value *MemSrc = computeMemAddr(Builder, Src);
New = Builder.CreateCast(
Inst->getOpcode(), MemSrc,
PointerType::getWithSamePointeeType(
cast<PointerType>(Inst->getDestTy()), Data.Addrspace));
getWithSamePointeeType(cast<PointerType>(Inst->getDestTy()),
Data.Addrspace));
} else if (auto *Inst = dyn_cast<ConstantExpr>(Address)) {
if (Inst->isCast()) {
auto *Src = Inst->getOperand(0);
Value *MemSrc = computeMemAddr(Builder, Src);
New = Builder.CreateCast(
static_cast<Instruction::CastOps>(Inst->getOpcode()), MemSrc,
PointerType::getWithSamePointeeType(
cast<PointerType>(Inst->getType()), Data.Addrspace));
getWithSamePointeeType(cast<PointerType>(Inst->getType()),
Data.Addrspace));
} else {
LLVM_DEBUG(Address->dump());
llvm_unreachable(
Expand Down Expand Up @@ -242,8 +242,7 @@ Value *RegisterBufferPass::handleSingleLoadStore(
// Change load/store to use addrspace(20)
auto *AddressType = cast<PointerType>(Address->getType());
Address = Builder.CreateAddrSpaceCast(
Address, PointerType::getWithSamePointeeType(AddressType,
GlobalRegisterAddrspace));
Address, getWithSamePointeeType(AddressType, GlobalRegisterAddrspace));

// If only registers are accessed, emit a simple load/store
if (TotalElementCount <= Data.RegisterCount)
Expand Down
Loading