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

[Clang] Fix incorrect passing of _BitInt args #90741

Merged
merged 3 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clang/lib/CodeGen/Targets/AArch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ AArch64ABIInfo::classifyArgumentType(QualType Ty, bool IsVariadic,

if (const auto *EIT = Ty->getAs<BitIntType>())
if (EIT->getNumBits() > 128)
return getNaturalAlignIndirect(Ty);
return getNaturalAlignIndirect(Ty, false);

return (isPromotableIntegerTypeForABI(Ty) && isDarwinPCS()
? ABIArgInfo::getExtend(Ty)
Expand Down
14 changes: 14 additions & 0 deletions clang/test/CodeGen/aarch64-bitint-argpass.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// REQUIRES: arm-registered-target
// RUN: %clang_cc1 -triple aarch64-none-elf \
// RUN: -O2 \
// RUN: -emit-llvm -fexperimental-max-bitint-width=1024 -o - %s | FileCheck %s
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we integrate this into some existing test file for aarch64 calling conventions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think such test file exists for aarch64. I tried searching for smth like that in CodeGen, couldn't find any file which would be suitable for this test.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Digging a bit into the history, I found clang/test/CodeGen/ext-int-cc.c . Which apparently has broken CHECK-NOT lines.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for pointing me to this ! I didn't expect there would a general tests for all ABIs ! I have adjusted the test so it correctly checks for sizes >128. Probably better fix would be to correctly set BITINT_MAXWIDTH in AArch64 target, but that is story for separate patch.


_BitInt(129) v = -1;
int h(_BitInt(129));

// CHECK: declare i32 @h(ptr noundef)
int largerthan128() {
return h(v);
}


Loading