Skip to content

Backport #145690, #146068 and #144058 #182

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

Merged

Conversation

dianqk
Copy link
Member

@dianqk dianqk commented Jun 29, 2025

I assume that LLVM 20.1.7 is the final version.
I will use git merge --ff-only to merge this.

dianqk added 2 commits June 29, 2025 21:01
…es (llvm#145648)

A case found from rust-lang/rust#142752:
https://llvm.godbolt.org/z/T7ce9saWh.

We should emit `@bar_0` for the following code:

```llvm
target triple = "x86_64-unknown-linux-gnu"

@rel_0 = private unnamed_addr constant [1 x i32] [
  i32 trunc (i64 sub (i64 ptrtoint (ptr @bar_0 to i64), i64 ptrtoint (ptr @rel_0 to i64)) to i32)]
@bar_0 = internal unnamed_addr constant ptr @foo_0, align 8
@foo_0 = external global ptr, align 8

define void @foo(ptr %arg0) {
  store ptr @bar_0, ptr %arg0, align 8
  ret void
}
```

(cherry picked from commit 630d55c)
…id generating GOTPCREL relocations (llvm#146068)

The entry in a relative lookup table is a global variable with a
constant offset, such as `@gv`, `GEP @gv, 1`, and so on.

We cannot only consider the case of a trivial global variable. This PR
handles all cases using the existing `IsConstantOffsetFromGlobal`
function.

(cherry picked from commit c43282a)
@dianqk dianqk requested a review from a team June 29, 2025 13:07
…m#144058)

Code originally added in llvm#120995 and later corrected in llvm#130517 but
apparently still not correct according to llvm#141494 and
rust-lang/rust#141913.

Revert the special handling because the test written in llvm#120995 and
llvm#130517 still passes without those changes. Kept the test and improved
it with a `__DATA` section to keep the current behaviour checked in case
other changes modify the behaviour and break this edge case.

(cherry picked from commit a0662ce)
@dianqk dianqk changed the title Backport #145690 and #146068 Backport #145690, #146068 and #144058 Jun 30, 2025
@dianqk
Copy link
Member Author

dianqk commented Jul 4, 2025

Added llvm@3d63191 for rust-lang/rust#143399.

@dianqk
Copy link
Member Author

dianqk commented Jul 4, 2025

@nikic
No new version for three weeks, I think we can merge this?

@cuviper
Copy link
Member

cuviper commented Jul 4, 2025

I asked Tom yesterday, and he said he's going to make a decision next week. I let him know about the ones you've raised here too.

Copy link

@nikic nikic left a comment

Choose a reason for hiding this comment

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

Can you please use the commit from llvm#147034, so that the tests pass?

I think it's okay to merge this, we don't have to wait on the upstream release.

We don't have PACKSS for i64->i32.

Fixes: https://godbolt.org/z/qb8nxnPbK, which was introduced by ddd2f57
(cherry picked from commit 3d63191)
@dianqk dianqk force-pushed the backport-145690-and-146068 branch from a057832 to 9b1bf4c Compare July 4, 2025 14:29
@dianqk
Copy link
Member Author

dianqk commented Jul 4, 2025

Can you please use the commit from llvm#147034, so that the tests pass?

I think it's okay to merge this, we don't have to wait on the upstream release.

Done.

@dianqk
Copy link
Member Author

dianqk commented Jul 4, 2025

ninja -C build check-llvm has passed.
(I will add some pre-checks on our CI later)

@dianqk dianqk merged commit 9b1bf4c into rust-lang:rustc/20.1-2025-02-13 Jul 4, 2025
@dianqk dianqk deleted the backport-145690-and-146068 branch July 4, 2025 15:04
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.

5 participants