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

MergeFunction can't merge functions because of jump tables #92201

Closed
yamt opened this issue May 15, 2024 · 3 comments · Fixed by #92498
Closed

MergeFunction can't merge functions because of jump tables #92201

yamt opened this issue May 15, 2024 · 3 comments · Fixed by #92498

Comments

@yamt
Copy link
Contributor

yamt commented May 15, 2024

i observed MergeFunc missing merging opportunities due to switch jump tables.

workarounds i can think of:

  • -fno-jump-tables
  • move mergefunc before switch jump tables transformation
  • move mergefunc after constmerge, which would merge switch jump tables
@nikic
Copy link
Contributor

nikic commented May 15, 2024

move mergefunc after constmerge, which would merge switch jump tables

This sounds reasonable to me. I think it is a lot more likely that MergeFuncs can benefit from ConstMerge than the other way around.

@PiJoules
Copy link
Contributor

@yamt do you have a small example of IR where there's missed merging?

@yamt
Copy link
Contributor Author

yamt commented May 15, 2024

@yamt do you have a small example of IR where there's missed merging?

see:
https://github.com/yamt/garbage/tree/ebf39eafc3e61df66f109cc1115b3fde0fa79327/llvm/mergefunc/1

mergefunc can't merge functions because of tables:
https://github.com/yamt/garbage/blob/ebf39eafc3e61df66f109cc1115b3fde0fa79327/llvm/mergefunc/1/log#L5855-L5914

in the final output, functions are identical because of later constmerge:
https://github.com/yamt/garbage/blob/ebf39eafc3e61df66f109cc1115b3fde0fa79327/llvm/mergefunc/1/a.ll

yamt added a commit to yamt/llvm-project that referenced this issue May 17, 2024
Constmerge can fold switch jump tables, possibly making functions
identical again. It can help mergefunc.
On the otherhand, the opposite seems unlikely.

Fixes llvm#92201
yamt added a commit to yamt/llvm-project that referenced this issue Jun 26, 2024
Constmerge can fold switch jump tables, possibly making functions
identical again. It can help mergefunc.
On the otherhand, the opposite seems unlikely.

Fixes llvm#92201
@nikic nikic closed this as completed in 5d79110 Jul 5, 2024
kbluck pushed a commit to kbluck/llvm-project that referenced this issue Jul 6, 2024
Constmerge can fold switch jump tables, possibly making functions
identical again. It can help mergefunc.
On the other hand, the opposite seems unlikely.

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

Successfully merging a pull request may close this issue.

4 participants