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

[PowerPC] Attributes 'zeroext and signext' are incompatible! ptr @omp_get_proc_bind fatal error: error in backend: Broken module found, compilation aborted! #63807

Open
pkubaj opened this issue Jul 11, 2023 · 5 comments
Assignees

Comments

@pkubaj
Copy link
Contributor

pkubaj commented Jul 11, 2023

FreeBSD 14.0-CURRENT
powerpc64, powerpc64le
llvm-devel 17.0.d20230622_1

Reproducer:

struct CommandCaller {
  CommandCaller();
};
extern "C" {
typedef enum {} omp_proc_bind_t;
omp_proc_bind_t omp_get_proc_bind();
}
CommandCaller::CommandCaller() { omp_get_proc_bind(); }

Compile with:

clang++-devel -cc1 -triple powerpc64le-unknown-freebsd14.0 -emit-obj -O1 -fopenmp CommandCaller-6f8d3a.cpp

Result:

Attributes 'zeroext and signext' are incompatible!
ptr @omp_get_proc_bind
fatal error: error in backend: Broken module found, compilation aborted!
@pkubaj pkubaj changed the title [PowerPC] root@talos-powerpc64le:~/metaeuk # clang++-devel -cc1 -triple powerpc64-unknown-freebsd14.0 -emit-obj -O1 -Weverything -Werror -fopenmp CommandCaller-6f8d3a.cpp Attributes 'zeroext and signext' are incompatible! ptr @omp_get_proc_bind fatal error: error in backend: Broken module found, compilation aborted! [PowerPC] Attributes 'zeroext and signext' are incompatible! ptr @omp_get_proc_bind fatal error: error in backend: Broken module found, compilation aborted! Jul 11, 2023
@llvmbot
Copy link
Collaborator

llvmbot commented Jul 11, 2023

@llvm/issue-subscribers-backend-powerpc

@ecnelises
Copy link
Member

ecnelises commented Jul 12, 2023

It looks like happening here:

auto addAttrSet = [&](AttributeSet &FnAS, const AttributeSet &AS,
bool Param = true) -> void {
bool HasSignExt = AS.hasAttribute(Attribute::SExt);
bool HasZeroExt = AS.hasAttribute(Attribute::ZExt);
if (HasSignExt || HasZeroExt) {
assert(AS.getNumAttributes() == 1 &&
"Currently not handling extension attr combined with others.");
if (Param) {
if (auto AK = TargetLibraryInfo::getExtAttrForI32Param(T, HasSignExt))
FnAS = FnAS.addAttribute(Ctx, AK);
} else
if (auto AK = TargetLibraryInfo::getExtAttrForI32Return(T, HasSignExt))
FnAS = FnAS.addAttribute(Ctx, AK);
} else {
FnAS = FnAS.addAttributes(Ctx, AS);
}
};

Here AS has signext, FnAS has zeroext. The function applies signext to FnAS so that we get declare signext zeroext i32 @omp_get_proc_bind().

@nemanjai
Copy link
Member

@ecnelises Do you plan to propose a fix for this?

@ecnelises
Copy link
Member

I will try looking into this

@ecnelises ecnelises self-assigned this Sep 28, 2023
@ecnelises
Copy link
Member

Return type of omp_get_proc_bind is specified as signext in OMPKinds.def. However the compiler sees enum{} as unsigned because no candidate option is negative. So one workaround is to add a random option equal to -1 in definition of omp_proc_bind_t.

Some other archs (x86_64, aarch64) do not add ext flag to return types. SystemZ has similar behavior to PPC, so -triple s390x also crashes. Maybe return type needs adjustment? FYI @JonPsson

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants