[all-commits] [llvm/llvm-project] 578d2e: [llvm-extract] Add -keep-const-init commandline op...

Juneyoung Lee via All-commits all-commits at lists.llvm.org
Sun Feb 2 21:30:34 PST 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 578d2e2cb14106a93dc820cff25a7f2bc93629bc
      https://github.com/llvm/llvm-project/commit/578d2e2cb14106a93dc820cff25a7f2bc93629bc
  Author: Juneyoung Lee <aqjune at gmail.com>
  Date:   2020-02-03 (Mon, 03 Feb 2020)

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

  Log Message:
  -----------
  [llvm-extract] Add -keep-const-init commandline option

Summary:
This adds -keep-const-init option to llvm-extract which preserves initializers of
used global constants.

For example:

```
$ cat a.ll
@g = constant i32 0
define i32 @f() {
  %v = load i32, i32* @g
  ret i32 %v
}

$ llvm-extract --func=f a.ll -S -o -
@g = external constant i32
define i32 @f() { .. }

$ llvm-extract --func=f a.ll -keep-const-init -S -o -
@g = constant i32 0
define i32 @f() { .. }
```

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

Reviewers: jsji, MaskRay, david2050

Reviewed By: MaskRay

Subscribers: hiraditya, llvm-commits

Tags: #llvm

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




More information about the All-commits mailing list