[PATCH] D73833: Add -keep-constinit commandline option to llvm-extract

Juneyoung Lee via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Feb 1 09:42:10 PST 2020


aqjune created this revision.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.

This adds -keep-constinit option to llvm-extract which preserves initializers of
used global constants.

For example:

  $ cat a.ll
  @g = constant i32 0
  define void @f() {
    %v = load i32, i32* @g
    ret i32 %v
  }
  
  $ llvm-extract --func=f a.ll -S -o -
  @g = external constant i32
  define void @f() { .. }
  
  $ llvm-extract --func=f a.ll -keep-constinit -S -o -
  @g = constant i32 0
  define void @f() { .. }

This option is useful in checking whether a function that uses a constant global is optimized correctly.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73833

Files:
  llvm/docs/CommandGuide/llvm-extract.rst
  llvm/include/llvm/Transforms/IPO.h
  llvm/lib/Transforms/IPO/ExtractGV.cpp
  llvm/test/tools/llvm-extract/keep-constinit.ll
  llvm/tools/llvm-extract/llvm-extract.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D73833.241884.patch
Type: text/x-patch
Size: 4752 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200201/326abbda/attachment.bin>


More information about the llvm-commits mailing list