[all-commits] [llvm/llvm-project] f8f481: [TargetLowering][COFF] Allow GlobalAlias in lowerR...

Andy Lim via All-commits all-commits at lists.llvm.org
Fri Sep 18 16:46:03 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: f8f4816496f6126f371350819d48017d1c330b56
      https://github.com/llvm/llvm-project/commit/f8f4816496f6126f371350819d48017d1c330b56
  Author: Andy Lim <andysjlim at chromium.org>
  Date:   2026-09-18 (Fri, 18 Sep 2026)

  Changed paths:
    M llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
    A llvm/test/MC/COFF/ir-to-imgrel-reject.ll
    M llvm/test/MC/COFF/ir-to-imgrel.ll

  Log Message:
  -----------
  [TargetLowering][COFF] Allow GlobalAlias in lowerRelativeReference (#220674)

In commit 2b321e2f293a (#203171), splitAndWriteThinLTOBitcode was
updated to create a GlobalAlias with external linkage for promoted
internal globals instead of renaming them directly.

When generating COFF object files on Windows (such as MSVC RTTI
CompleteObjectLocator structures), relative references against
@__ImageBase (e.g. sub (ptrtoint @alias to i64), (ptrtoint @__ImageBase
to i64))
are lowered to IMAGE_REL_AMD64_ADDR32NB (VK_COFF_IMGREL32) relocations
in TargetLoweringObjectFileCOFF::lowerRelativeReference.

Previously, lowerRelativeReference checked `!isa<GlobalObject>(LHS)`,
which rejected GlobalAlias instances. As a result,
lowerRelativeReference returned nullptr, and AsmPrinter fell back to
emitting a raw MC subtraction expression. This caused
WinCOFFObjectWriter
to fail with:
\"error: symbol '__ImageBase' can not be undefined in a subtraction
expression\"
because @__ImageBase is an undefined external symbol resolved at link
time.
Fix this by checking !LHS->getAliaseeObject() instead of
`!isa<GlobalObject>(LHS)`, allowing GlobalAliases whose underlying
aliasee is a GlobalObject to be lowered to VK_COFF_IMGREL32.

*Note: AI assistance was used for creating the PR and review feedback
exploration.*



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