1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-22 04:22:57 +02:00
llvm-mirror/test/Transforms/GlobalOpt/localize-constexpr.ll
James Molloy 2208ca52dd [GlobalOpt] Localize some globals that have non-instruction users
We currently bail out of global localization if the global has non-instruction users. However, often these can be simple bitcasts or constant-GEPs, which we can easily turn into instructions before localizing. Be a bit more aggressive.

llvm-svn: 253584
2015-11-19 18:04:33 +00:00

29 lines
585 B
LLVM

; RUN: opt -S < %s -globalopt | FileCheck %s
@G = internal global i32 42
define i8 @f() norecurse {
; CHECK-LABEL: @f
; CHECK: alloca
; CHECK-NOT: @G
; CHECK: }
store i32 42, i32* @G
%a = load i8, i8* bitcast (i32* @G to i8*)
ret i8 %a
}
@H = internal global i32 42
@Halias = internal alias i32, i32* @H
; @H can't be localized because @Halias uses it, and @Halias can't be converted to an instruction.
define i8 @g() norecurse {
; CHECK-LABEL: @g
; CHECK-NOT: alloca
; CHECK: @H
; CHECK: }
store i32 42, i32* @H
%a = load i8, i8* bitcast (i32* @H to i8*)
ret i8 %a
}