[all-commits] [llvm/llvm-project] 37561b: -fno-semantic-interposition: Don't set dso_local o...

Fangrui Song via All-commits all-commits at lists.llvm.org
Wed May 19 16:08:47 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 37561ba89b7de57bd8ff5ae0691d02604885d4ee
      https://github.com/llvm/llvm-project/commit/37561ba89b7de57bd8ff5ae0691d02604885d4ee
  Author: Fangrui Song <i at maskray.me>
  Date:   2021-05-19 (Wed, 19 May 2021)

  Changed paths:
    M clang/lib/CodeGen/CodeGenModule.cpp
    M clang/test/CodeGen/SystemZ/builtins-systemz-zvector-constrained.c
    M clang/test/CodeGen/attr-weakref2.c
    M clang/test/CodeGen/semantic-interposition.c
    M clang/test/CodeGenCUDA/device-stub.cu
    M clang/test/CodeGenCUDA/device-var-linkage.cu
    M clang/test/CodeGenCUDA/managed-var.cu
    M clang/test/CodeGenCUDA/static-device-var-rdc.cu
    M clang/test/OpenMP/declare_target_only_one_side_compilation.cpp

  Log Message:
  -----------
  -fno-semantic-interposition: Don't set dso_local on GlobalVariable

`clang -fpic -fno-semantic-interposition` may set dso_local on variables for -fpic.

GCC folks consider there are 'address interposition' and 'semantic interposition',
and 'disabling semantic interposition' can optimize function calls but
cannot change variable references to use local aliases
(https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100483).

This patch removes dso_local for variables in
`clang -fpic -fno-semantic-interposition` mode so that the built shared objects can
work with copy relocations. Building llvm-project tiself with
-fno-semantic-interposition (D102453) should now be safe with trunk Clang.

Example:
```
// a.c
int var;
int *addr() { return var; }

// old: cannot be interposed
movslq  .Lvar$local(%rip), %rax
// new: can be interposed
movq    var at GOTPCREL(%rip), %rax
movslq  (%rax), %rax
```

The local alias lowering for `GlobalVariable`s is kept in case there is a
future option allowing local aliases.

Reviewed By: rnk

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




More information about the All-commits mailing list