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.
Add a llvm-extract -func foo -S < %s test that @cv is otherwise changed to a declaration.