Skip to content

Commit 906cad5

Browse files
bokrzesiigcbot
authored andcommitted
Argument of "intel_sub_group_ballot" was promoted from i1 to i8 which caused linker issues
The argument of this function was promoted from `declare (..) spir_func i32 @intel_sub_group_ballot(i1 zeroext)` to `declare spir_func i32 @intel_sub_group_ballot(i8 zeroext)` which caused problems during BiF linking due to mismatch. This PR adds yet another rule to the exceptions. Additionally "annotated_function" extraction required adjustments for opaque pointers.
1 parent 2acccd1 commit 906cad5

File tree

3 files changed

+43
-2
lines changed

3 files changed

+43
-2
lines changed

IGC/AdaptorOCL/dllInterfaceCompute.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -880,7 +880,20 @@ void RebuildGlobalAnnotations(IGC::OpenCLProgramContext &oclContext, Module *pKe
880880
auto annotations_array = cast<ConstantArray>(globalAnnotations->getOperand(0));
881881
for (const auto &op : annotations_array->operands()) {
882882
auto annotation_struct = cast<ConstantStruct>(op.get());
883-
auto annotated_function = cast<Function>(annotation_struct->getOperand(0)->getOperand(0));
883+
auto operand0 = annotation_struct->getOperand(0);
884+
885+
Function *annotated_function = nullptr;
886+
887+
// On typed pointers it was: struct -> bitcast -> functionPointer
888+
// On opaque pointer the bitcast is just "ptr", so it is: struct -> functionPointer
889+
// Non-opaque pointers path should be removed after transition to opaque pointers.
890+
if (IGCLLVM::isOpaquePointerTy(operand0->getType())) {
891+
annotated_function = cast<Function>(operand0);
892+
} else {
893+
annotated_function = cast<Function>(operand0->getOperand(0));
894+
}
895+
896+
IGC_ASSERT_MESSAGE(annotated_function, "Annotated function was not found!");
884897

885898
if (requiresRecompilation(annotated_function)) {
886899
newGlobalAnnotations.push_back(annotation_struct);

IGC/AdaptorOCL/preprocess_spvir/PromoteBools.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,9 @@ Function *PromoteBools::promoteFunction(Function *function) {
501501
}
502502

503503
#if !defined(WDDM_ANDROID_IGC)
504-
if (BiFManager::BiFManagerHandler::IsBiF(function) || function->getName().startswith("__builtin_IB_")) {
504+
if (BiFManager::BiFManagerHandler::IsBiF(function)
505+
|| function->getName().startswith("__builtin_IB_")
506+
|| function->getName() == "intel_sub_group_ballot") {
505507
return function;
506508
}
507509
#endif
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
;=========================== begin_copyright_notice ============================
2+
;
3+
; Copyright (C) 2025 Intel Corporation
4+
;
5+
; SPDX-License-Identifier: MIT
6+
;
7+
;============================ end_copyright_notice =============================
8+
9+
; RUN: igc_opt --opaque-pointers -igc-promote-bools -S %s | FileCheck %s
10+
; ------------------------------------------------
11+
; Ensure that "intel_sub_group_ballot" is excluded from i1 to i8 promotion.
12+
; ------------------------------------------------
13+
14+
; CHECK: define dso_local spir_func i32 @intel_sub_group_ballot(i1 noundef zeroext %0)
15+
; CHECK: [[TMP0:%[0-9]+]] = tail call spir_func i32 @__builtin_IB_WaveBallot(i1
16+
17+
; Function Attrs: convergent norecurse nounwind
18+
define dso_local spir_func i32 @intel_sub_group_ballot(i1 noundef zeroext %0) {
19+
%2 = tail call spir_func i32 @__builtin_IB_WaveBallot(i1 noundef zeroext %0)
20+
ret i32 %2
21+
}
22+
23+
; CHECK: declare spir_func i32 @__builtin_IB_WaveBallot(i1 noundef zeroext)
24+
25+
; Function Attrs: convergent nounwind
26+
declare spir_func i32 @__builtin_IB_WaveBallot(i1 noundef zeroext) local_unnamed_addr

0 commit comments

Comments
 (0)