Represent runtime preemption in the IR.
authorSean Fertile <sfertile@ca.ibm.com>
Thu, 26 Oct 2017 15:00:26 +0000 (15:00 +0000)
committerSean Fertile <sfertile@ca.ibm.com>
Thu, 26 Oct 2017 15:00:26 +0000 (15:00 +0000)
commitc70d28bff522332b0db2a7466b627fd4cff7c55d
tree58308cf2e1a61207187e385a4e370b9a6971fcba
parent2232243863bc5f3f3632a9adeab9bf3293543d42
Represent runtime preemption in the IR.

Currently we do not represent runtime preemption in the IR, which has several
drawbacks:

  1) The semantics of GlobalValues differ depending on the object file format
     you are targeting (as well as the relocation-model and -fPIE value).
  2) We have no way of disabling inlining of run time interposable functions,
     since in the IR we only know if a function is link-time interposable.
     Because of this llvm cannot support elf-interposition semantics.
  3) In LTO builds of executables we will have extra knowledge that a symbol
     resolved to a local definition and can't be preemptable, but have no way to
     propagate that knowledge through the compiler.

This patch adds preemptability specifiers to the IR with the following meaning:

dso_local --> means the compiler may assume the symbol will resolve to a
 definition within the current linkage unit and the symbol may be accessed
 directly even if the definition is not within this compilation unit.

dso_preemptable --> means that the compiler must assume the GlobalValue may be
replaced with a definition from outside the current linkage unit at runtime.

To ease transitioning dso_preemptable is treated as a 'default' in that
low-level codegen will still do the same checks it did previously to see if a
symbol should be accessed indirectly. Eventually when IR producers emit the
specifiers on all Globalvalues we can change dso_preemptable to mean 'always
access indirectly', and remove the current logic.

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

llvm-svn: 316668
20 files changed:
llvm/docs/BitCodeFormat.rst
llvm/docs/LangRef.rst
llvm/include/llvm/IR/GlobalValue.h
llvm/lib/AsmParser/LLLexer.cpp
llvm/lib/AsmParser/LLParser.cpp
llvm/lib/AsmParser/LLParser.h
llvm/lib/AsmParser/LLToken.h
llvm/lib/Bitcode/Reader/BitcodeReader.cpp
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
llvm/lib/IR/AsmWriter.cpp
llvm/lib/IR/Globals.cpp
llvm/lib/IR/Verifier.cpp
llvm/lib/Target/TargetMachine.cpp
llvm/test/Assembler/dllimport-dsolocal-diag.ll [new file with mode: 0644]
llvm/test/Assembler/ifunc-dsolocal-daig.ll [new file with mode: 0644]
llvm/test/Bitcode/dso_location.ll [new file with mode: 0644]
llvm/test/CodeGen/PowerPC/preemption.ll [new file with mode: 0644]
llvm/test/CodeGen/X86/darwin-preemption.ll [new file with mode: 0644]
llvm/test/CodeGen/X86/linux-preemption.ll [new file with mode: 0644]
llvm/test/CodeGen/X86/win32-preemption.ll [new file with mode: 0644]