Skip to content

Commit b79ee5a

Browse files
author
iclsrc
committed
Merge from 'sycl' to 'sycl-web' (7 commits)
2 parents f8987f4 + f087179 commit b79ee5a

File tree

68 files changed

+2032
-714
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+2032
-714
lines changed

clang/test/CodeGenSYCL/address-space-cond-op.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ struct S {
1111
// CHECK-NEXT: [[LHS_ADDR:%.*]] = alloca ptr addrspace(4), align 8
1212
// CHECK-NEXT: [[COND_ADDR_ASCAST:%.*]] = addrspacecast ptr [[COND_ADDR]] to ptr addrspace(4)
1313
// CHECK-NEXT: [[LHS_ADDR_ASCAST:%.*]] = addrspacecast ptr [[LHS_ADDR]] to ptr addrspace(4)
14+
// CHECK-NEXT: [[AGG_RESULT_ASCAST:%.*]] = addrspacecast ptr [[AGG_RESULT:%.*]] to ptr addrspace(4)
1415
// CHECK-NEXT: [[FROMBOOL:%.*]] = zext i1 [[COND:%.*]] to i8
1516
// CHECK-NEXT: store i8 [[FROMBOOL]], ptr addrspace(4) [[COND_ADDR_ASCAST]], align 1
1617
// CHECK-NEXT: store ptr addrspace(4) [[LHS:%.*]], ptr addrspace(4) [[LHS_ADDR_ASCAST]], align 8
@@ -25,7 +26,7 @@ struct S {
2526
// CHECK-NEXT: br label [[COND_END]]
2627
// CHECK: cond.end:
2728
// CHECK-NEXT: [[COND_LVALUE:%.*]] = phi ptr addrspace(4) [ [[TMP1]], [[COND_TRUE]] ], [ [[RHS_ASCAST]], [[COND_FALSE]] ]
28-
// CHECK-NEXT: call void @llvm.memcpy.p0.p4.i64(ptr align 2 [[AGG_RESULT:%.*]], ptr addrspace(4) align 2 [[COND_LVALUE]], i64 2, i1 false)
29+
// CHECK-NEXT: call void @llvm.memcpy.p4.p4.i64(ptr addrspace(4) align 2 [[AGG_RESULT_ASCAST]], ptr addrspace(4) align 2 [[COND_LVALUE]], i64 2, i1 false)
2930
// CHECK-NEXT: ret void
3031
//
3132
S foo(bool cond, S &lhs, S rhs) {

clang/test/CodeGenSYCL/nvptx-short-ptr.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020

2121
// Targeting a 32-bit NVPTX, check that we see universal 32-bit pointers (the
2222
// option changes nothing)
23-
// CHECK32: target datalayout = "e-p:32:32-p6:32:32-p7:32:32-i64:64-i128:128-v16:16-v32:32-n16:32:64"
23+
// CHECK32: target datalayout = "e-p:32:32-p6:32:32-p7:32:32-i64:64-i128:128-i256:256-v16:16-v32:32-n16:32:64"
2424

2525
// Targeting a 64-bit NVPTX target, check that we see 32-bit pointers for
2626
// shared (3), const (4), and local (5) address spaces only.
27-
// CHECK64-DEFAULT: target datalayout = "e-p6:32:32-i64:64-i128:128-v16:16-v32:32-n16:32:64"
28-
// CHECK64-SHORT: target datalayout = "e-p3:32:32-p4:32:32-p5:32:32-p6:32:32-p7:32:32-i64:64-i128:128-v16:16-v32:32-n16:32:64"
27+
// CHECK64-DEFAULT: target datalayout = "e-p6:32:32-i64:64-i128:128-i256:256-v16:16-v32:32-n16:32:64"
28+
// CHECK64-SHORT: target datalayout = "e-p3:32:32-p4:32:32-p5:32:32-p6:32:32-p7:32:32-i64:64-i128:128-i256:256-v16:16-v32:32-n16:32:64"

devops/dependencies-igc-dev.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"linux": {
33
"igc_dev": {
4-
"github_tag": "igc-dev-5572ee3",
5-
"version": "5572ee3",
6-
"updated_at": "2025-09-28T11:41:20Z",
7-
"url": "https://api.github.com/repos/intel/intel-graphics-compiler/actions/artifacts/4125423999/zip",
4+
"github_tag": "igc-dev-e146785",
5+
"version": "e146785",
6+
"updated_at": "2025-10-02T03:05:40Z",
7+
"url": "https://api.github.com/repos/intel/intel-graphics-compiler/actions/artifacts/4161218080/zip",
88
"root": "{DEPS_ROOT}/opencl/runtime/linux/oclgpu"
99
}
1010
}

llvm-spirv/include/LLVMSPIRVExtensions.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,4 @@ EXT(SPV_INTEL_bfloat16_arithmetic)
8080
EXT(SPV_INTEL_ternary_bitwise_function)
8181
EXT(SPV_INTEL_int4)
8282
EXT(SPV_INTEL_function_variants)
83+
EXT(SPV_INTEL_shader_atomic_bfloat16)

llvm-spirv/include/LLVMSPIRVOpts.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,14 +273,14 @@ class TranslatorOpts {
273273
}
274274

275275
void setFnVarFeatures(std::vector<uint32_t> Features) noexcept {
276-
FnVarFeatures = Features;
276+
FnVarFeatures = std::move(Features);
277277
}
278278
std::vector<uint32_t> getFnVarFeatures() const noexcept {
279279
return FnVarFeatures;
280280
}
281281

282282
void setFnVarCapabilities(std::vector<uint32_t> Capabilities) noexcept {
283-
FnVarCapabilities = Capabilities;
283+
FnVarCapabilities = std::move(Capabilities);
284284
}
285285
std::vector<uint32_t> getFnVarCapabilities() const noexcept {
286286
return FnVarCapabilities;
@@ -289,7 +289,9 @@ class TranslatorOpts {
289289
void setFnVarSpecEnable(bool Val) noexcept { FnVarSpecEnable = Val; }
290290
bool getFnVarSpecEnable() const noexcept { return FnVarSpecEnable; }
291291

292-
void setFnVarSpvOut(std::string Val) noexcept { FnVarSpvOut = Val; }
292+
void setFnVarSpvOut(std::string Val) noexcept {
293+
FnVarSpvOut = std::move(Val);
294+
}
293295
std::string getFnVarSpvOut() const noexcept { return FnVarSpvOut; }
294296

295297
// Check that options passed to --fnvar-xxx flags make sense. Return true on

llvm-spirv/lib/SPIRV/LLVMToSPIRVDbgTran.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,13 +1310,14 @@ SPIRVEntry *LLVMToSPIRVDbgTran::transDbgFunction(const DISubprogram *Func) {
13101310
if (DISubprogram *FuncDecl = Func->getDeclaration())
13111311
Ops.push_back(transDbgEntry(FuncDecl)->getId());
13121312
else {
1313-
Ops.push_back(getDebugInfoNoneId());
13141313
if (BM->getDebugInfoEIS() == SPIRVEIS_NonSemantic_Shader_DebugInfo_200) {
13151314
// Translate targetFuncName mostly for Fortran trampoline function if it
13161315
// is the case
13171316
StringRef TargetFunc = Func->getTargetFuncName();
1318-
if (!TargetFunc.empty())
1317+
if (!TargetFunc.empty()) {
1318+
Ops.push_back(getDebugInfoNoneId());
13191319
Ops.push_back(BM->getString(TargetFunc.str())->getId());
1320+
}
13201321
}
13211322
}
13221323

llvm-spirv/lib/SPIRV/Mangler/ManglingUtils.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ static const char *PrimitiveNames[PRIMITIVE_NUM] = {
9393
"intel_sub_group_avc_ime_result_dual_reference_streamin_t"
9494
};
9595

96+
// clang-format off
9697
const char *MangledTypes[PRIMITIVE_NUM] = {
9798
"b", // BOOL
9899
"h", // UCHAR
@@ -106,7 +107,7 @@ const char *MangledTypes[PRIMITIVE_NUM] = {
106107
"Dh", // HALF
107108
"f", // FLOAT
108109
"d", // DOUBLE
109-
"u6__bf16", // __BF16
110+
"DF16b", // __BF16
110111
"v", // VOID
111112
"z", // VarArg
112113
"14ocl_image1d_ro", // PRIMITIVE_IMAGE1D_RO_T
@@ -175,6 +176,7 @@ const char *MangledTypes[PRIMITIVE_NUM] = {
175176
"55ocl_intel_sub_group_avc_ime_single_reference_streamin_t", // PRIMITIVE_SUB_GROUP_AVC_IME_SINGLE_REF_STREAMIN_T
176177
"53ocl_intel_sub_group_avc_ime_dual_reference_streamin_t" // PRIMITIVE_SUB_GROUP_AVC_IME_DUAL_REF_STREAMIN_T
177178
};
179+
// clang-format on
178180

179181
const char *ReadableAttribute[ATTR_NUM] = {
180182
"restrict", "volatile", "const", "__private",

llvm-spirv/lib/SPIRV/SPIRVRegularizeLLVM.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,42 @@ void SPIRVRegularizeLLVMBase::cleanupConversionToNonStdIntegers(Module *M) {
421421
}
422422
}
423423

424+
void SPIRVRegularizeLLVMBase::replacePrivateConstGlobalsWithAllocas(Module *M) {
425+
SmallVector<GlobalVariable *> GlobalsToRemove;
426+
for (auto &GV : M->globals()) {
427+
428+
if (!GV.isConstant() || !GV.hasInternalLinkage() ||
429+
!(GV.getAddressSpace() == SPIRAS_Private) || !GV.hasInitializer() ||
430+
GV.getName().starts_with("llvm.compiler.used") ||
431+
GV.getName().starts_with("llvm.used"))
432+
continue;
433+
434+
SmallVector<User *> Users(GV.users());
435+
// TODO: Handle other llvm::User types, for example, constant expressions.
436+
if (llvm::any_of(Users, [](User *U) { return !isa<Instruction>(U); }))
437+
continue;
438+
439+
DenseMap<Function *, AllocaInst *> LocalCopies;
440+
for (User *U : Users) {
441+
Instruction *Inst = cast<Instruction>(U);
442+
Function *F = Inst->getFunction();
443+
AllocaInst *&AI = LocalCopies[F];
444+
if (!AI) {
445+
IRBuilder<> Builder(&*F->getEntryBlock().getFirstInsertionPt());
446+
AI = Builder.CreateAlloca(GV.getValueType(), nullptr, GV.getName());
447+
if (GV.getAlign())
448+
AI->setAlignment(GV.getAlign().value());
449+
Builder.CreateStore(GV.getInitializer(), AI);
450+
}
451+
Inst->replaceUsesOfWith(&GV, AI);
452+
}
453+
GlobalsToRemove.push_back(&GV);
454+
}
455+
456+
for (GlobalVariable *GV : GlobalsToRemove)
457+
GV->eraseFromParent();
458+
}
459+
424460
bool SPIRVRegularizeLLVMBase::runRegularizeLLVM(Module &Module) {
425461
M = &Module;
426462
Ctx = &M->getContext();
@@ -582,6 +618,7 @@ bool SPIRVRegularizeLLVMBase::regularize() {
582618
addKernelEntryPoint(M);
583619
expandSYCLTypeUsing(M);
584620
cleanupConversionToNonStdIntegers(M);
621+
replacePrivateConstGlobalsWithAllocas(M);
585622

586623
// Kernels called by other kernels
587624
std::vector<Function *> CalledKernels;

llvm-spirv/lib/SPIRV/SPIRVRegularizeLLVM.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,11 @@ class SPIRVRegularizeLLVMBase {
102102
// non-standard integer types.
103103
void cleanupConversionToNonStdIntegers(llvm::Module *M);
104104

105+
// Move internal constants in the private address space to function-scope
106+
// variables. Such globals would otherwise be translated with Function storage
107+
// class which is invalid for global variables in SPIR-V.
108+
void replacePrivateConstGlobalsWithAllocas(llvm::Module *M);
109+
105110
// According to the specification, the operands of a shift instruction must be
106111
// a scalar/vector of integer. When LLVM-IR contains a shift instruction with
107112
// i1 operands, they are treated as a bool. We need to extend them to i32 to

llvm-spirv/lib/SPIRV/SPIRVUtil.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -528,8 +528,8 @@ ParamType lastFuncParamType(StringRef MangledName) {
528528
char Mangled = Copy.back();
529529
std::string Mangled2 = Copy.substr(Copy.size() - 2);
530530

531-
std::string Mangled6 = Copy.substr(Copy.size() - 6);
532-
if (Mangled6 == "__bf16") {
531+
std::string Mangled5 = Copy.substr(Copy.size() - 5);
532+
if (Mangled5 == "DF16b") {
533533
return ParamType::FLOAT;
534534
}
535535

0 commit comments

Comments
 (0)