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

[CIR][ABI][AArch64][Lowering] Fix the callsite for nested unions #1169

Merged
merged 3 commits into from
Nov 26, 2024

Conversation

bruteforceboy
Copy link
Contributor

@bruteforceboy bruteforceboy commented Nov 26, 2024

For example, the following reaches "NYI" when lowering to AArch64:

typedef struct {
  union {
    struct {
      char a, b;
    };
    char c;
  };
} A;

void foo(A a) {}

void bar() {
  A a;
  foo(a);
}

Currently, the value of the struct becomes a bitcast operation, so we can simply extend findAlloca to be able to trace the source alloca properly, then use that for the coercion through memory. I have also added a test for this case.

Comment on lines +322 to +324
// LLVM: %[[#V3:]] = load %struct.NESTED_U, ptr %[[#V1]], align 1
// LLVM: %[[#V4:]] = load %union.anon.0, ptr %[[#V1]], align 1
// LLVM: %[[#V5:]] = load %struct.anon.1, ptr %[[#V1]], align 1
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like these are dead, at least in the IR parts you're checking? (It might be useful to use CHECK-NEXT to indicate when you're checking the whole IR vs. portions of it.) Not a big deal, optimizations should be able to easily remove them; I guess it's just a result of the extra type casts we need to do at the CIR level.

Copy link
Member

Choose a reason for hiding this comment

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

True! Maybe if it's not relevant just use {{.*}} instead of giving it a name next time!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

noted

@bcardosolopes bcardosolopes merged commit 676b861 into llvm:main Nov 26, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants