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

Open
wants to merge 3 commits into
base: rustc/20.1-2025-02-13
Choose a base branch
from

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
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.

2 participants