[all-commits] [llvm/llvm-project] fa792c: [AsmPrinter] Always emit global equivalents if the...

dianqk via All-commits all-commits at lists.llvm.org
Tue Jul 8 11:28:12 PDT 2025


  Branch: refs/heads/release/20.x
  Home:   https://github.com/llvm/llvm-project
  Commit: fa792cd4c630b1b85a599f19204d1f36e0fa3a41
      https://github.com/llvm/llvm-project/commit/fa792cd4c630b1b85a599f19204d1f36e0fa3a41
  Author: dianqk <dianqk at dianqk.net>
  Date:   2025-07-08 (Tue, 08 Jul 2025)

  Changed paths:
    M llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
    A llvm/test/MC/X86/gotpcrel-non-globals.ll

  Log Message:
  -----------
  [AsmPrinter] Always emit global equivalents if there is non-global uses (#145648)

A case found from https://github.com/rust-lang/rust/issues/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 630d55cce45f8b409367914ef372047c8c43c511)



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list