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

tree-wide: port LDC to LLVM 18 #4599

Merged
merged 4 commits into from
Mar 27, 2024
Merged

Conversation

liushuyu
Copy link
Contributor

This pull request adds LLVM 18.1.x support to LDC.
LLVM recently switched to a new versioning scheme, where LLVM 18.1.0 was the first stable release of LLVM 18 series.

Aside from the usual API renaming, zext can not be used directly now and needs to be utilized through a constant folding mechanism.

@thewilsonator
Copy link
Contributor

If you could add profdata and Filecheck (as done in this PR at the very bottom), that would be great

@liushuyu
Copy link
Contributor Author

If you could add profdata and Filecheck (as done in this PR at the very bottom), that would be great

Will do. I cannot add LLVM 18 CI at the moment due to LLVM upstream missing binary packages for arm64 macOS.
I will open a separate pull request to address the CI issue.

@liushuyu
Copy link
Contributor Author

If you could add profdata and Filecheck (as done in this PR at the very bottom), that would be great

@thewilsonator Done. Added files from LLVM upstream source.

@kinke
Copy link
Member

kinke commented Mar 23, 2024

Thx a lot, much appreciated!

driver/codegenerator.cpp Outdated Show resolved Hide resolved
#else
val = llvm::ConstantFoldCastOperand(llvm::Instruction::ZExt, val, I8PtrTy, *gDataLayout);
#endif
}
Copy link
Member

Choose a reason for hiding this comment

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

This could probably be simplified to something like val = DtoConstUbyte(val->isNullValue() ? 0 : 1);.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Replaced.

Copy link
Member

Choose a reason for hiding this comment

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

@JohanEngelen: I just remembered #4559 - I guess this might be dangerous here too?

Copy link
Member

Choose a reason for hiding this comment

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

yeah, good point. At the very least, this change should be in its own PR, with careful checking.
Keep this (big) PR about LLVM18 compatibility only.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should I just revert the changes to use LLVM constant folding here?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah please, and sorry about the wrong hint.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah please, and sorry about the wrong hint.

No problem, just a partial revert away. Now pushed.

gen/tocall.cpp Outdated Show resolved Hide resolved
@kinke
Copy link
Member

kinke commented Mar 23, 2024

There's also

# Try suffixed versions to pick up the newest LLVM install available on Debian
# derivatives.
# We also want an user-specified LLVM_ROOT_DIR to take precedence over the
# system default locations such as /usr/local/bin. Executing find_program()
# multiples times is the approach recommended in the docs.
set(llvm_config_names llvm-config-17.0 llvm-config170 llvm-config-17
llvm-config-16.0 llvm-config160 llvm-config-16
llvm-config-15.0 llvm-config150 llvm-config-15
llvm-config-14.0 llvm-config140 llvm-config-14
llvm-config-13.0 llvm-config130 llvm-config-13
llvm-config-12.0 llvm-config120 llvm-config-12
llvm-config-11.0 llvm-config110 llvm-config-11
llvm-config)
find_program(LLVM_CONFIG
NAMES ${llvm_config_names}
PATHS ${LLVM_ROOT_DIR}/bin NO_DEFAULT_PATH
DOC "Path to llvm-config tool.")
find_program(LLVM_CONFIG NAMES ${llvm_config_names})
if(APPLE)
# extra fallbacks for MacPorts & Homebrew
find_program(LLVM_CONFIG
NAMES ${llvm_config_names}
PATHS /opt/local/libexec/llvm-17/bin
/opt/local/libexec/llvm-16/bin /opt/local/libexec/llvm-15/bin
/opt/local/libexec/llvm-14/bin /opt/local/libexec/llvm-13/bin
/opt/local/libexec/llvm-12/bin /opt/local/libexec/llvm-11/bin
/opt/local/libexec/llvm/bin
/usr/local/opt/llvm@17/bin
/usr/local/opt/llvm@16/bin /usr/local/opt/llvm@15/bin
/usr/local/opt/llvm@14/bin /usr/local/opt/llvm@13/bin
/usr/local/opt/llvm@12/bin /usr/local/opt/llvm@11/bin
/usr/local/opt/llvm/bin
NO_DEFAULT_PATH)
endif()
where we try to find a matching llvm-config* executable.

@liushuyu liushuyu force-pushed the llvm-18 branch 3 times, most recently from b56613e to b330225 Compare March 23, 2024 22:21
@liushuyu
Copy link
Contributor Author

CI failures seems unrelated and can be retried

gen/tocall.cpp Outdated Show resolved Hide resolved
@liushuyu liushuyu force-pushed the llvm-18 branch 2 times, most recently from 9f4849f to 4bf2630 Compare March 24, 2024 16:53
@liushuyu
Copy link
Contributor Author

@liushuyu liushuyu mentioned this pull request Mar 24, 2024
* Use getVoidPtrType helper
* Replace #define with constexpr
@kinke kinke merged commit 29ef439 into ldc-developers:master Mar 27, 2024
22 checks passed
@kinke
Copy link
Member

kinke commented Mar 27, 2024

[Following up with some fixes & additions in #4604.]

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.

None yet

4 participants