llvm-project/llvm/lib/Object
Teresa Johnson 6955feebf3 [ThinLTO] Prevent exporting of locals used/defined in module level asm
Summary:
This patch uses the same approach added for inline asm in r285513 to
similarly prevent promotion/renaming of locals used or defined in module
level asm.

All static global values defined in normal IR and used in module level asm
should be included on either the llvm.used or llvm.compiler.used global.
The former were already being flagged as NoRename in the summary, and
I've simply added llvm.compiler.used values to this handling.

Module level asm may also contain defs of values. We need to prevent
export of any refs to local values defined in module level asm (e.g. a
ref in normal IR), since that also requires renaming/promotion of the
local. To do that, the summary index builder looks at all values in the
module level asm string that are not marked Weak or Global, which is
exactly the set of locals that are defined. A summary is created for
each of these local defs and flagged as NoRename.

This required adding handling to the BitcodeWriter to look at GV
declarations to see if they have a summary (rather than skipping them
all).

Finally, added an assert to IRObjectFile::CollectAsmUndefinedRefs to
ensure that an MCAsmParser is available, otherwise the module asm parse
would silently fail. Initialized the asm parser in the opt tool for use
in testing this fix.

Fixes PR30610.

Reviewers: mehdi_amini

Subscribers: johanengelen, krasin, llvm-commits

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

llvm-svn: 286297
2016-11-08 21:53:35 +00:00
..
Archive.cpp [Object] Replace TimeValue with std::chrono 2016-10-24 13:38:27 +00:00
ArchiveWriter.cpp [Object] Replace TimeValue with std::chrono 2016-10-24 13:38:27 +00:00
Binary.cpp Change Archive::create() from ErrorOr<...> to Expected<...> and update 2016-06-29 20:35:44 +00:00
CMakeLists.txt [CMake] Restrict libxar linkage to just llvm-objdump 2016-05-26 16:32:40 +00:00
COFFObjectFile.cpp [lli/COFF] Set the correct alignment for common symbols 2016-11-02 17:32:19 +00:00
ELF.cpp [RISCV] Add RISC-V ELF defines 2016-11-01 16:59:37 +00:00
ELFObjectFile.cpp [llvm-objdump] Support detection of feature bits from the object and implement this for Mips. 2016-06-16 09:17:03 +00:00
Error.cpp [Object/ELF] - Make getSymbol() return Error. 2016-11-03 08:40:55 +00:00
IRObjectFile.cpp [ThinLTO] Prevent exporting of locals used/defined in module level asm 2016-11-08 21:53:35 +00:00
LLVMBuild.txt
MachOObjectFile.cpp Add support for the ARM_THREAD_STATE64 and 2016-11-03 20:51:28 +00:00
MachOUniversal.cpp [lib/Object] Modernize. NFCI. 2016-11-07 21:01:42 +00:00
ModuleSummaryIndexObjectFile.cpp Apply another batch of fixes from clang-tidy's performance-unnecessary-value-param. 2016-06-17 20:41:14 +00:00
Object.cpp Thread Expected<...> up from libObject’s getSymbolAddress() for symbols to allow 2016-06-24 18:24:42 +00:00
ObjectFile.cpp Object: Add a missing return in ObjectFile::createObjectFile 2016-10-18 05:17:23 +00:00
RecordStreamer.cpp [IRObjectFile] Handle undefined weak symbols in RecordStreamer. 2016-09-15 17:54:22 +00:00
RecordStreamer.h [IRObjectFile] Handle undefined weak symbols in RecordStreamer. 2016-09-15 17:54:22 +00:00
SymbolSize.cpp [SymbolSize] Skip sorting by index, just assign by index. 2015-06-29 16:05:00 +00:00
SymbolicFile.cpp Replace "fallthrough" comments with LLVM_FALLTHROUGH 2016-08-17 05:10:15 +00:00