[PATCH] D11861: [IR] Add token types

David Majnemer via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 7 22:39:52 PDT 2015


majnemer created this revision.
majnemer added reviewers: chandlerc, sanjoy, reames, pgavlin, JosephTremoulet, rnk.
majnemer added a subscriber: llvm-commits.

This introduces the basic functionality to support "token types".
The motivation stems from the need to perform operations on a Value
whose provenance cannot be obscured.

There are several applications for such a type but my immediate
motivation stems from WinEH.  Our personality routine enforces a
single-entry - single-exit regime for cleanups.  After several rounds of
optimizations, we may be left with a terminator whose "cleanup-entry
block" is not entirely clear because control flow has merged two
cleanups together.  We have experimented with using labels as operands
inside of instructions which are not terminators to indicate where we
came from but found that LLVM does not expect such exotic uses of
BasicBlocks.

Instead, we can use this new type to clearly associate the "entry point"
and "exit point" of our cleanup.  This is done by having the cleanuppad
yield a Token and consuming it at the cleanupret.
The token type makes it impossible to obscure or otherwise hide the
Value, making it trivial to track the relationship between the two
points.

What is the burden to the optimizer?  Well, it turns out we have already
paid down this cost by accepting that there are certain calls that we
are not permitted to duplicate, optimizations have to watch out for
such instructions anyway.  There are additional places in the optimizer
that we will probably have to update but early examination has given me
the impression that this will not be heroic.

http://reviews.llvm.org/D11861

Files:
  docs/LangRef.rst
  include/llvm-c/Core.h
  include/llvm/Bitcode/LLVMBitCodes.h
  include/llvm/IR/Type.h
  lib/Analysis/CodeMetrics.cpp
  lib/Analysis/LoopInfo.cpp
  lib/AsmParser/LLLexer.cpp
  lib/Bitcode/Reader/BitcodeReader.cpp
  lib/Bitcode/Writer/BitcodeWriter.cpp
  lib/IR/AsmWriter.cpp
  lib/IR/Core.cpp
  lib/IR/Instructions.cpp
  lib/IR/LLVMContextImpl.cpp
  lib/IR/LLVMContextImpl.h
  lib/IR/Type.cpp
  lib/IR/Verifier.cpp
  lib/Target/CppBackend/CPPBackend.cpp
  lib/Transforms/IPO/MergeFunctions.cpp
  lib/Transforms/Scalar/JumpThreading.cpp
  lib/Transforms/Utils/InlineFunction.cpp
  lib/Transforms/Utils/SimplifyCFG.cpp
  test/Assembler/token.ll
  test/Verifier/token1.ll
  test/Verifier/token2.ll
  test/Verifier/token3.ll
  test/Verifier/token4.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D11861.31573.patch
Type: text/x-patch
Size: 16721 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150808/d9398073/attachment.bin>


More information about the llvm-commits mailing list