summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/Inline/dynamic_alloca_test.ll
blob: cccf2d9b46c9ed464e3c9836a1d556846dab822e (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
; Test that functions with dynamic allocas get inlined in a case where
; naively inlining it would result in a miscompilation.

; RUN: llvm-upgrade < %s | llvm-as | opt -inline | llvm-dis | \
; RUN:   grep llvm.stacksave
; RUN: llvm-upgrade < %s | llvm-as | opt -inline | llvm-dis | not grep callee

declare void %ext(int*)
implementation

internal void %callee(uint %N) {
	%P = alloca int, uint %N     ;; dynamic alloca
	call void %ext(int* %P)
	ret void
}

void %foo(uint %N) {
	br label %Loop
Loop:
	%count = phi uint [0, %0], [%next, %Loop]
	%next = add uint %count, 1
	call void %callee(uint %N)
	%cond = seteq uint %count, 100000
	br bool %cond, label %out, label %Loop
out:
	ret void
}

OpenPOWER on IntegriCloud