[OpenMP][PowerPC] Assertion failed: ((Args.size() == FTy->getNumParams() || (FTy->isVarArg() && Args.size() > FTy->getNumParams())) && "Calling a function with bad signature!")
FreeBSD 14.3-RELEASE LLVM 21.0.d20250403 powerpc64, powerpc64le
Reproducer:
void apply_round_stamp(void);
void apply_round_stamp(void) {
int _Complex strength = 0;
#pragma omp parallel default(firstprivate)
(void)strength;
}
Build with:
/usr/local/llvm-devel/bin/clang -cc1 -triple powerpc64le-portbld-freebsd14.3 -emit-obj -debug-info-kind=standalone -fopenmp introspection_liquify-2805ea.c
@llvm/issue-subscribers-backend-powerpc
Author: Piotr Kubaj (pkubaj)
Reproducer:
void apply_round_stamp(void);
void apply_round_stamp(void) {
int _Complex strength = 0;
#pragma omp parallel default(firstprivate)
(void)strength;
}
Build with:
/usr/local/llvm-devel/bin/clang -cc1 -triple powerpc64le-portbld-freebsd14.3 -emit-obj -debug-info-kind=standalone -fopenmp introspection_liquify-2805ea.c
@llvm/issue-subscribers-openmp
Author: Piotr Kubaj (pkubaj)
Reproducer:
void apply_round_stamp(void);
void apply_round_stamp(void) {
int _Complex strength = 0;
#pragma omp parallel default(firstprivate)
(void)strength;
}
Build with:
/usr/local/llvm-devel/bin/clang -cc1 -triple powerpc64le-portbld-freebsd14.3 -emit-obj -debug-info-kind=standalone -fopenmp introspection_liquify-2805ea.c
Looked into this but its neither a powerpc backend issue or an IR issue. Rather the problem is in the lowering of the OpenMP ast to IR for the compex int as an argument to one of the outlined functions. I tried compiling the same test case and options on aarch64 and powerpc (32-bit) targets and both work as expected. On those targets the complex int argument is passed either as an i64 or a pointer to a stucture, where on powerpc64 it is passed as 2 i32s. Looking at the good cases I see an outlined function, and then a second outlined function with "debug" appended that gets called from the first outlined function. On powerpc32:
; Function Attrs: noinline norecurse nounwind optnone
define internal void @apply_round_stamp.omp_outlined(ptr noalias noundef %.global_tid., ptr noalias noundef %.bound_tid., ptr noundef nonnull align 4 dereferenceable(8) %strength) #1 !dbg !35 {
entry:
%.global_tid..addr = alloca ptr, align 4
%.bound_tid..addr = alloca ptr, align 4
%strength.addr = alloca ptr, align 4
store ptr %.global_tid., ptr %.global_tid..addr, align 4
#dbg_declare(ptr %.global_tid..addr, !36, !DIExpression(), !37)
store ptr %.bound_tid., ptr %.bound_tid..addr, align 4
#dbg_declare(ptr %.bound_tid..addr, !38, !DIExpression(), !37)
store ptr %strength, ptr %strength.addr, align 4
#dbg_declare(ptr %strength.addr, !39, !DIExpression(), !37)
%0 = load ptr, ptr %strength.addr, align 4, !dbg !40, !nonnull !10, !align !31
%1 = load ptr, ptr %.global_tid..addr, align 4, !dbg !40
%2 = load ptr, ptr %.bound_tid..addr, align 4, !dbg !40
%3 = load ptr, ptr %strength.addr, align 4, !dbg !40
call void @apply_round_stamp.omp_outlined_debug__(ptr %1, ptr %2, ptr %3) #2, !dbg !40
ret void, !dbg !40
}
define internal void @apply_round_stamp.omp_outlined_debug__(ptr noalias noundef %.global_tid., ptr noalias noundef %.bound_tid., ptr noundef nonnull align 4 dereferenceable(8) %strength)
On AArch64:
; Function Attrs: noinline norecurse nounwind optnone
define internal void @apply_round_stamp.omp_outlined(ptr noalias noundef %.global_tid., ptr noalias noundef %.bound_tid., i64 noundef %strength) #1 !dbg !30 {
entry:
%.global_tid..addr = alloca ptr, align 8
%.bound_tid..addr = alloca ptr, align 8
%strength.addr = alloca i64, align 8
store ptr %.global_tid., ptr %.global_tid..addr, align 8
#dbg_declare(ptr %.global_tid..addr, !34, !DIExpression(), !35)
store ptr %.bound_tid., ptr %.bound_tid..addr, align 8
#dbg_declare(ptr %.bound_tid..addr, !36, !DIExpression(), !35)
store i64 %strength, ptr %strength.addr, align 8
#dbg_declare(ptr %strength.addr, !37, !DIExpression(), !35)
%0 = load ptr, ptr %.global_tid..addr, align 8, !dbg !38
%1 = load ptr, ptr %.bound_tid..addr, align 8, !dbg !38
%2 = load i64, ptr %strength.addr, align 4, !dbg !38
call void @apply_round_stamp.omp_outlined_debug__(ptr %0, ptr %1, i64 %2) #2, !dbg !38
ret void, !dbg !38
}
define internal void @apply_round_stamp.omp_outlined_debug__(ptr noalias noundef %.global_tid., ptr noalias noundef %.bound_tid., i64 noundef %strength.coerce)
On PowerPC64 where the compiler hits an assertion failure we have created the outlined_debug__ function with the signature
define internal void @apply_round_stamp.omp_outlined_debug__(ptr noalias noundef %.global_tid., ptr noalias noundef %.bound_tid., i32 noundef %strength.coerce0, i32 noundef %strength.coerce1) but pass in only 3 arguments to the llvm::CallInst constructor missing the second i32 argument.
%0 = load ptr, ptr %.global_tid..addr, align 8, !dbg !16
%1 = load ptr, ptr %.bound_tid..addr, align 8, !dbg !16
%2 = load i32, ptr %strength.addr, align 4, !dbg !16
@llvm/issue-subscribers-clang-codegen
Author: Piotr Kubaj (pkubaj)
Reproducer:
void apply_round_stamp(void);
void apply_round_stamp(void) {
int _Complex strength = 0;
#pragma omp parallel default(firstprivate)
(void)strength;
}
Build with:
/usr/local/llvm-devel/bin/clang -cc1 -triple powerpc64le-portbld-freebsd14.3 -emit-obj -debug-info-kind=standalone -fopenmp introspection_liquify-2805ea.c