[LTO][MC] Discard non-prevailing defined symbols in module-level assembly
authorYuanfang Chen <yuanfang.chen@sony.com>
Thu, 18 Mar 2021 22:32:29 +0000 (15:32 -0700)
committerYuanfang Chen <yuanfang.chen@sony.com>
Thu, 18 Mar 2021 22:33:42 +0000 (15:33 -0700)
commitb4a8c0ebb6d49f757c687833d85f843aaeb19133
tree49e5bdab5f57216fca93eabcae74e63d2e12e817
parent2df65f87c1ea81008768e14522e5d9277234ba70
[LTO][MC] Discard non-prevailing defined symbols in module-level assembly

This is the alternative approach to D96931.

In LTO, for each module with inlineasm block, prepend directive ".lto_discard <sym>, <sym>*" to the beginning of the inline
asm.  ".lto_discard" is both a module inlineasm block marker and (optionally) provides a list of symbols to be discarded.

In MC while emitting for inlineasm, discard symbol binding & symbol
definitions according to ".lto_disard".

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D98762
llvm/include/llvm/MC/MCContext.h
llvm/include/llvm/MC/MCParser/MCAsmParser.h
llvm/lib/LTO/LTO.cpp
llvm/lib/MC/MCParser/AsmParser.cpp
llvm/lib/MC/MCParser/ELFAsmParser.cpp
llvm/test/LTO/X86/inline-asm-lto-discard.ll [new file with mode: 0644]
llvm/test/LTO/X86/inline-asm-lto-discard2.ll [new file with mode: 0644]
llvm/test/MC/ELF/lto-discard.s [new file with mode: 0644]