Skip to content

Commit

Permalink
[SYCL][Fusion] Set IsNewDbgInfoFormat when creating new functions (#…
Browse files Browse the repository at this point in the history
…12712)

Set `IsNewDbgInfoFormat` to the default value for functions created in
the SYCL Kernel Fusion pipeline. This prepares `sycl-fusion` for
migration to the new debug info format.

---------

Signed-off-by: Victor Perez <victor.perez@codeplay.com>
  • Loading branch information
victor-eds committed Feb 15, 2024
1 parent 5337a8a commit f910a4c
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 2 deletions.
1 change: 1 addition & 0 deletions sycl-fusion/jit-compiler/lib/fusion/FusionHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ Expected<std::unique_ptr<Module>> helper::FusionHelper::addFusedKernel(
// correct name and signature only during the fusion pass.
auto *F = Function::Create(FT, GlobalValue::LinkageTypes::ExternalLinkage,
"fused_kernel", *NewMod);
F->IsNewDbgInfoFormat = UseNewDbgInfoFormat;

// Attach metadata to the function stub.
// The metadata specifies the name of the fused kernel (as the
Expand Down
1 change: 1 addition & 0 deletions sycl-fusion/passes/cleanup/Cleanup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ static Function *createMaskedFunction(const BitVector &Mask, Function *F,
FunctionType *NFTy = createMaskedFunctionType(Mask, F->getFunctionType());
Function *NF = Function::Create(NFTy, F->getLinkage(), F->getAddressSpace(),
F->getName(), F->getParent());
NF->IsNewDbgInfoFormat = UseNewDbgInfoFormat;
copyAttributesFrom(Mask, NF, F);
NF->setComdat(F->getComdat());
NF->takeName(F);
Expand Down
7 changes: 5 additions & 2 deletions sycl-fusion/passes/internalization/Internalization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -564,8 +564,11 @@ getPromotedFunctionDeclaration(Function *F, ArrayRef<PromotionInfo> PromInfos,
// declaration.
FunctionType *NewTy =
ChangeTypes ? getPromotedFunctionType(Ty, PromInfos, AS) : Ty;
return Function::Create(NewTy, F->getLinkage(), F->getAddressSpace(),
F->getName(), F->getParent());
Function *NewF =
Function::Create(NewTy, F->getLinkage(), F->getAddressSpace(),
F->getName(), F->getParent());
NewF->IsNewDbgInfoFormat = UseNewDbgInfoFormat;
return NewF;
}

///
Expand Down
1 change: 1 addition & 0 deletions sycl-fusion/passes/kernel-fusion/Builtins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ getOrCreateGetGlobalLinearIDFunction(const TargetFusionInfo &TargetInfo,
auto *Ty = FunctionType::get(Builder.getIntNTy(N), /*isVarArg*/ false);
F = Function::Create(Ty, Function::LinkageTypes::InternalLinkage, Name, M);
TargetInfo.setMetadataForGeneratedFunction(F);
F->IsNewDbgInfoFormat = UseNewDbgInfoFormat;

auto *EntryBlock = BasicBlock::Create(Context, "entry", F);
Builder.SetInsertPoint(EntryBlock);
Expand Down
1 change: 1 addition & 0 deletions sycl-fusion/passes/kernel-fusion/SYCLKernelFusion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,7 @@ Error SYCLKernelFusion::fuseKernel(
Function *FusedFunction = Function::createWithDefaultAttr(
FT, GlobalValue::LinkageTypes::ExternalLinkage,
M.getDataLayout().getProgramAddressSpace(), KernelName->getString(), &M);
FusedFunction->IsNewDbgInfoFormat = UseNewDbgInfoFormat;
{
auto DefaultAttr = FusedFunction->getAttributes();
// Add uniform function attributes, i.e., attributes with identical value on
Expand Down
9 changes: 9 additions & 0 deletions sycl-fusion/passes/target/TargetFusionInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicsAMDGPU.h"
#include "llvm/IR/IntrinsicsNVPTX.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/TargetParser/Triple.h"

using namespace jit_compiler;

extern llvm::cl::opt<bool> UseNewDbgInfoFormat;

template <typename ForwardIt, typename KeyTy>
static ForwardIt mapArrayLookup(ForwardIt Begin, ForwardIt End,
const KeyTy &Key) {
Expand Down Expand Up @@ -227,6 +230,7 @@ class SPIRVTargetFusionInfo : public TargetFusionInfoImpl {
F->setAttributes(
AttributeList::get(LLVMMod->getContext(), FnAttrs, {}, {}));
F->setCallingConv(CallingConv::SPIR_FUNC);
F->IsNewDbgInfoFormat = UseNewDbgInfoFormat;
}

// See
Expand Down Expand Up @@ -393,6 +397,7 @@ class SPIRVTargetFusionInfo : public TargetFusionInfoImpl {
Attribute::get(Ctx, Attribute::AttrKind::NoUnwind)}),
{}, {}));
F->setCallingConv(CallingConv::SPIR_FUNC);
F->IsNewDbgInfoFormat = UseNewDbgInfoFormat;
}

auto *Call = Builder.CreateCall(F, {Builder.getInt32(Idx)});
Expand All @@ -415,6 +420,7 @@ class SPIRVTargetFusionInfo : public TargetFusionInfoImpl {
/*isVarArg*/ false);
auto *F = Function::Create(Ty, Function::InternalLinkage, Name, *M);
setMetadataForGeneratedFunction(F);
F->IsNewDbgInfoFormat = UseNewDbgInfoFormat;

auto *EntryBlock = BasicBlock::Create(Ctx, "entry", F);
Builder.SetInsertPoint(EntryBlock);
Expand Down Expand Up @@ -559,6 +565,7 @@ class NVPTXAMDGCNTargetFusionInfoBase : public TargetFusionInfoImpl {
/*isVarArg*/ false);
F = Function::Create(Ty, Function::InternalLinkage, GetGlobalIDName, M);
setMetadataForGeneratedFunction(F);
F->IsNewDbgInfoFormat = UseNewDbgInfoFormat;

auto *EntryBlock = BasicBlock::Create(Builder.getContext(), "entry", F);
Builder.SetInsertPoint(EntryBlock);
Expand Down Expand Up @@ -618,6 +625,7 @@ class NVPTXAMDGCNTargetFusionInfoBase : public TargetFusionInfoImpl {
/*isVarArg*/ false);
auto *F = Function::Create(FTy, Function::InternalLinkage, Name, *M);
setMetadataForGeneratedFunction(F);
F->IsNewDbgInfoFormat = UseNewDbgInfoFormat;

auto *EntryBlock = BasicBlock::Create(Ctx, "entry", F);
Builder.SetInsertPoint(EntryBlock);
Expand All @@ -635,6 +643,7 @@ class NVPTXAMDGCNTargetFusionInfoBase : public TargetFusionInfoImpl {
auto *FTy = FunctionType::get(Builder.getInt32Ty(), /*isVarArg*/ false);
auto *F = Function::Create(FTy, Function::InternalLinkage, Name, *M);
setMetadataForGeneratedFunction(F);
F->IsNewDbgInfoFormat = UseNewDbgInfoFormat;

auto *EntryBlock = BasicBlock::Create(Ctx, "entry", F);
Builder.SetInsertPoint(EntryBlock);
Expand Down

0 comments on commit f910a4c

Please sign in to comment.