aboutsummaryrefslogtreecommitdiff
path: root/test/NaCl/Localmods/test-globalopt-main.ll
blob: 90d0e3193cc804d83d7fa993dca90f88069a262e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
; RUN: opt < %s -globalopt -S | FileCheck %s

; Check that our LOCALMOD for the GlobalOpt optimization is working properly.
; The user code entry point is a function named main that has a single user:
; a call from _start.
; @globchar can be folded into an alloca inside @main, and the global can be
; deleted.

@globchar = internal global i8* null, align 8
; CHECK-NOT: @globchar = internal global

define internal i32 @main(i32 %argc, i8** %argv) {
  ; CHECK: @main(i32
entry:
  ; CHECK: %globchar = alloca i8*
  %argc.addr = alloca i32, align 4
  %argv.addr = alloca i8**, align 8
  store i32 %argc, i32* %argc.addr, align 4
  store i8** %argv, i8*** %argv.addr, align 8
  %0 = load i8*** %argv.addr, align 8
  %arrayidx = getelementptr inbounds i8** %0, i64 0
  %1 = load i8** %arrayidx, align 8
  store i8* %1, i8** @globchar, align 8
  %2 = load i8** @globchar, align 8
  %arrayidx1 = getelementptr inbounds i8* %2, i64 1
  %3 = load i8* %arrayidx1, align 1
  call void @somefunc(i8 signext %3)
  ret i32 0
}

define i32 @_start(i32 %argc, i8** %argv) {
  %rv = call i32 @main(i32 %argc, i8** %argv)
  ret i32 %rv
}

declare void @somefunc(i8 signext)