<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, May 17, 2016 at 6:07 PM, Chandler Carruth <span dir="ltr"><<a href="mailto:chandlerc@gmail.com" target="_blank">chandlerc@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div>Thanks for the detailed write-up, and sorry to Rafael and Mehdi that it's on a new thread. =/</div><div><div><div><br></div><div dir="ltr">On Tue, May 17, 2016 at 5:59 PM Peter Collingbourne via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">pcc created this revision.<br>
pcc added reviewers: rafael, joker.eph, chandlerc, majnemer.<br>
pcc added a subscriber: llvm-commits.<br>
Herald added a reviewer: tstellarAMD.<br>
Herald added subscribers: jfb, mzolotukhin, joker.eph, arsenm.<br>
<br>
If a local_unnamed_addr attribute is attached to a global, the address<br>
is known to be insignificant within the module. It is distinct from the<br>
existing unnamed_addr attribute in that it only describes a local property<br>
of the module rather than a global property of the symbol.<br>
<br>
This attribute is intended to be used by the code generator and LTO to allow<br>
the linker to decide whether the global needs to be in the symbol table. It is<br>
possible to exclude a global from the symbol table if three things are true:<br>
- This attribute is present on every instance of the global (which means that<br>
  the normal rule that the global must have a unique address can be broken without<br>
  being observable by the program by performing comparisons against the global's<br>
  address)<br>
- The global has linkonce_odr linkage (which means that each linkage unit must have<br>
  its own copy of the global if it requires one, and the copy in each linkage unit<br>
  must be the same)<br>
- It is a constant or a function (which means that the program cannot observe that<br>
  the unique-address rule has been broken by writing to the global)<br>
<br>
Although this attribute could in principle be computed from the module<br>
contents, LTO clients (i.e. linkers) will normally need to be able to compute<br>
this property as part of symbol resolution, and it would be inefficient to<br>
materialize every module just to compute it.<br></blockquote><div><br></div></div></div><div>Cool, this last part is really key.</div><div><br></div><div><br></div><div>My real problem with adding this as a normal attribute is that I'm not sure what it really means. Is it just a "cache" of some local analysis? Do we expect things to invalidate it if they make the address significant within a module? Is this something that would be "blessed" by some frontends?</div><div><br></div><div>I feel like, from your description, this really is just intended to solve the problem of materializing all of the module. It would seem that for that purpose something more akin to the "summary" information used by ThinLTO would be a better tool than an attribute which has to have a semantic contract for the IR.</div><div><br></div><div>What do you think?</div></div></div></blockquote><div><br></div><div>To a certain extent this is a summary of the module contents, and in most cases I'd expect the property to simply summarize the module.</div><div><br></div><div>However, it is also a property that should be preserved if a pass introduces an address comparison. Modulo bugs, the new comparison should be "benign" -- if the original program could not observe the address, the optimized program shouldn't be able to observe it either.</div><div><br></div><div>One example of this would be a comparison of a vptr against a vtable or function address for speculative devirtualization, or in general any form of PGO that relies on global addresses. The introduction of such a comparison doesn't invalidate the unnamed_addr property (which we do currently apply to vtables), as the program would still have the same semantics if we, say, merged two identical vtables. The same applies to the local_unnamed_addr property.</div><div><br></div><div> Regarding frontends, yes, I'd expect that if a frontend knows that all address comparisons within a module are benign, it could apply this property.<br></div><div><br></div><div>Thanks,</div><div>Peter</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div><div>
<br>
See:<br>
<a href="http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20160509/356401.html" rel="noreferrer" target="_blank">http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20160509/356401.html</a><br>
<a href="http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20160516/356738.html" rel="noreferrer" target="_blank">http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20160516/356738.html</a><br>
for earlier discussion.<br>
<br>
Part of the fix for PR27553.<br>
<br>
<a href="http://reviews.llvm.org/D20348" rel="noreferrer" target="_blank">http://reviews.llvm.org/D20348</a><br>
<br>
Files:<br>
  docs/BitCodeFormat.rst<br>
  docs/LangRef.rst<br>
  include/llvm/IR/GlobalValue.h<br>
  lib/Analysis/InstructionSimplify.cpp<br>
  lib/AsmParser/LLLexer.cpp<br>
  lib/AsmParser/LLParser.cpp<br>
  lib/AsmParser/LLParser.h<br>
  lib/AsmParser/LLToken.h<br>
  lib/Bitcode/Reader/BitcodeReader.cpp<br>
  lib/Bitcode/Writer/BitcodeWriter.cpp<br>
  lib/CodeGen/Analysis.cpp<br>
  lib/CodeGen/AsmPrinter/AsmPrinter.cpp<br>
  lib/CodeGen/TargetLoweringObjectFileImpl.cpp<br>
  lib/ExecutionEngine/Orc/IndirectionUtils.cpp<br>
  lib/IR/AsmWriter.cpp<br>
  lib/IR/Core.cpp<br>
  lib/IR/Globals.cpp<br>
  lib/IR/IRBuilder.cpp<br>
  lib/IR/Verifier.cpp<br>
  lib/Linker/IRMover.cpp<br>
  lib/Linker/LinkModules.cpp<br>
  lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp<br>
  lib/Target/TargetLoweringObjectFile.cpp<br>
  lib/Transforms/IPO/ConstantMerge.cpp<br>
  lib/Transforms/IPO/GlobalOpt.cpp<br>
  lib/Transforms/IPO/MergeFunctions.cpp<br>
  lib/Transforms/Instrumentation/AddressSanitizer.cpp<br>
  lib/Transforms/Instrumentation/GCOVProfiling.cpp<br>
  lib/Transforms/Instrumentation/InstrProfiling.cpp<br>
  lib/Transforms/Scalar/LoopIdiomRecognize.cpp<br>
  lib/Transforms/Utils/FunctionImportUtils.cpp<br>
  lib/Transforms/Utils/GlobalStatus.cpp<br>
  lib/Transforms/Utils/SimplifyCFG.cpp<br>
  test/Assembler/local-unnamed-addr.ll<br>
  test/Bitcode/compatibility.ll<br>
  test/CodeGen/PowerPC/weak_def_can_be_hidden.ll<br>
  test/CodeGen/X86/weak_def_can_be_hidden.ll<br>
  test/Feature/OperandBundles/pr26510.ll<br>
  test/LTO/X86/cfi_endproc.ll<br>
  test/LTO/X86/linkonce_odr_func.ll<br>
  test/Other/constant-fold-gep.ll<br>
  test/Transforms/GlobalOpt/2010-10-19-WeakOdr.ll<br>
  test/Transforms/GlobalOpt/alias-used-address-space.ll<br>
  test/Transforms/GlobalOpt/alias-used.ll<br>
  test/Transforms/GlobalOpt/assume.ll<br>
  test/Transforms/GlobalOpt/constantfold-initializers.ll<br>
  test/Transforms/GlobalOpt/ctor-list-opt-inbounds.ll<br>
  test/Transforms/GlobalOpt/invariant.group.barrier.ll<br>
  test/Transforms/GlobalOpt/invoke.ll<br>
  test/Transforms/GlobalOpt/pr21191.ll<br>
  test/Transforms/GlobalOpt/unnamed-addr.ll<br>
  test/tools/gold/X86/coff.ll<br>
  test/tools/gold/X86/emit-llvm.ll<br>
  tools/gold/gold-plugin.cpp<br>
<br></div></div>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div><div dir="ltr">-- <div>Peter</div></div></div>
</div></div>