1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 11:13:28 +01:00
llvm-mirror/test/tools/llvm-extract/keep-constinit.ll
Juneyoung Lee 92f700c60b [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
2020-02-03 14:30:28 +09:00

13 lines
298 B
LLVM

; RUN: llvm-extract -func foo -keep-const-init -S < %s | FileCheck %s
; RUN: llvm-extract -func foo -S < %s | FileCheck %s --check-prefix=CHECK2
; CHECK: @cv = constant i32 0
; CHECK2: @cv = external constant i32
@cv = constant i32 0
define i32 @foo() {
%v = load i32, i32* @cv
ret i32 %v
}