[PATCH] D26146: [ThinLTO] Prevent exporting of locals used/defined in module level asm

Teresa Johnson via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 31 06:07:46 PDT 2016


tejohnson created this revision.
tejohnson added a reviewer: mehdi_amini.
tejohnson added subscribers: llvm-commits, krasin, johanengelen.

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 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.


https://reviews.llvm.org/D26146

Files:
  include/llvm/IR/ModuleSummaryIndex.h
  include/llvm/Support/TargetRegistry.h
  lib/Analysis/LLVMBuild.txt
  lib/Analysis/ModuleSummaryAnalysis.cpp
  lib/Bitcode/Writer/BitcodeWriter.cpp
  lib/IR/ModuleSummaryIndex.cpp
  lib/Object/IRObjectFile.cpp
  test/LTO/X86/current-section.ll
  test/ThinLTO/X86/Inputs/module_asm2.ll
  test/ThinLTO/X86/module_asm2.ll
  tools/opt/opt.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26146.76391.patch
Type: text/x-patch
Size: 13269 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161031/773c6d5b/attachment.bin>


More information about the llvm-commits mailing list