[all-commits] [llvm/llvm-project] bc5609: [GlobalValue] Make dso_local function work with co...

Fangrui Song via All-commits all-commits at lists.llvm.org
Thu Jan 13 16:37:26 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: bc56097817bec3446edd9f06e2d78eab95033027
      https://github.com/llvm/llvm-project/commit/bc56097817bec3446edd9f06e2d78eab95033027
  Author: Fangrui Song <i at maskray.me>
  Date:   2022-01-13 (Thu, 13 Jan 2022)

  Changed paths:
    M llvm/lib/IR/Globals.cpp
    M llvm/test/CodeGen/X86/linux-preemption.ll

  Log Message:
  -----------
  [GlobalValue] Make dso_local function work with comdat nodeduplicate

This fixes -fno-semantic-interposition -fsanitize-coverage incompatibility.

-fPIC -fno-semantic-interposition may add dso_local to an external linkage
function. -fsanitize-coverage instrumentation does not clear dso_local when
adding comdat nodeduplicate. This causes a compatibility issue: the function
symbol may be referenced by a PC-relative relocation without using the local
alias. In -shared mode, ld will report a relocation error.

The fix is to either clear dso_local when adding comdat nodeduplicate, or
supporting comdat nodeduplicate. The latter is more appropriate, because a
comdat nodeduplicate is like not using comdat.

Note: The comdat condition was originally added by D77429 to not use local alias
for a hidden external linkage function in a deduplicate comdat. The condition
has been unused since the code was refactored to only use local alias for
default visibility symbols.
Note: `canBenefitFromLocalAlias` is used by clang/lib/CodeGen/CodeGenModule.cpp
and we don't want to add dso_local to default visibility external linkage comdat any
(clang/test/CodeGenCUDA/usual-deallocators.cu).

Differential Revision: https://reviews.llvm.org/D117190




More information about the All-commits mailing list