[llvm-commits] [poolalloc] r107707 - in /poolalloc/trunk/test/dsa/local: dg.exp flags.c flags.ll
Will Dietz
wdietz2 at illinois.edu
Tue Jul 6 14:44:14 PDT 2010
Author: wdietz2
Date: Tue Jul 6 16:44:13 2010
New Revision: 107707
URL: http://llvm.org/viewvc/llvm-project?rev=107707&view=rev
Log:
Add tests to verify Local sets the G/S/H/M/R flags correctly on some basic cases.
Also demonstrates how to use the -dstest options somewhat.
Added:
poolalloc/trunk/test/dsa/local/dg.exp
poolalloc/trunk/test/dsa/local/flags.c
poolalloc/trunk/test/dsa/local/flags.ll
Added: poolalloc/trunk/test/dsa/local/dg.exp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/dsa/local/dg.exp?rev=107707&view=auto
==============================================================================
--- poolalloc/trunk/test/dsa/local/dg.exp (added)
+++ poolalloc/trunk/test/dsa/local/dg.exp Tue Jul 6 16:44:13 2010
@@ -0,0 +1,3 @@
+load_lib llvm.exp
+
+RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll,c,cpp}]]
Added: poolalloc/trunk/test/dsa/local/flags.c
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/dsa/local/flags.c?rev=107707&view=auto
==============================================================================
--- poolalloc/trunk/test/dsa/local/flags.c (added)
+++ poolalloc/trunk/test/dsa/local/flags.c Tue Jul 6 16:44:13 2010
@@ -0,0 +1,52 @@
+// Go through at least one of every operation to verify flags are set appropriately...
+
+//--Make sure we can run DSA on it!
+//RUN: llvm-gcc %s -c --emit-llvm -o - | \
+//RUN: dsaopt -dsa-bu -dsa-td -disable-output
+
+//H, S, G, R, M
+
+#include <stdlib.h>
+
+//Not touched
+int global_a;
+//M
+int global_b;
+//R
+int global_c;
+//M/R
+int global_d;
+
+void func() {
+ //Don't mod/ref
+ int stack_a;
+ int * heap_a = malloc(sizeof(int));
+
+ //Mod
+ int stack_b;
+ int * heap_b = malloc(sizeof(int));
+
+ //Ref
+ int stack_c;
+ int * heap_c = malloc(sizeof(int));
+
+ //Mod/Ref
+ int stack_d;
+ int * heap_d = malloc(sizeof(int));
+
+ //Mod the b's, ref the c's
+ stack_b = stack_c;
+ *heap_b = *heap_c;
+ global_b = global_c;
+
+ //Mod/ref all the d's
+ stack_d = global_d;
+ global_d = *heap_d;
+ *heap_d = stack_d;
+
+ free(heap_a);
+ free(heap_b);
+ free(heap_c);
+ free(heap_d);
+}
+
Added: poolalloc/trunk/test/dsa/local/flags.ll
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/dsa/local/flags.ll?rev=107707&view=auto
==============================================================================
--- poolalloc/trunk/test/dsa/local/flags.ll (added)
+++ poolalloc/trunk/test/dsa/local/flags.ll Tue Jul 6 16:44:13 2010
@@ -0,0 +1,103 @@
+; ModuleID = 'flags.c'
+target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
+target triple = "x86_64-unknown-linux-gnu"
+
+;Test flag assignment on globals/stack/heap, as well as mod/ref.
+;a's are none, b's are mod, c'd as ref, d's are mod/ref.
+
+;--Stack:
+;RUN: dsaopt %s -dsa-local -analyze -dstest -print-only-flags -print-node-for-value \
+;RUN: "func:stack_a" | grep "S" | grep -v "M" | grep -v "R"
+;RUN: dsaopt %s -dsa-local -analyze -dstest -print-only-flags -print-node-for-value \
+;RUN: "func:stack_b" | grep "S" | grep "M" | grep -v "R"
+;RUN: dsaopt %s -dsa-local -analyze -dstest -print-only-flags -print-node-for-value \
+;RUN: "func:stack_c" | grep "S" | grep -v "M" | grep -v "M"
+;RUN: dsaopt %s -dsa-local -analyze -dstest -print-only-flags -print-node-for-value \
+;RUN: "func:stack_d" | grep "S" | grep "M" | grep "R"
+
+;--Heap:
+;RUN: dsaopt %s -dsa-local -analyze -dstest -print-only-flags -print-node-for-value \
+;RUN: "func:heap_a:0" | grep "H" | grep -v "M" | grep -v "R"
+;RUN: dsaopt %s -dsa-local -analyze -dstest -print-only-flags -print-node-for-value \
+;RUN: "func:heap_b:0" | grep "H" | grep "M" | grep -v "R"
+;RUN: dsaopt %s -dsa-local -analyze -dstest -print-only-flags -print-node-for-value \
+;RUN: "func:heap_c:0" | grep "H" | grep -v "M" | grep "R"
+;RUN: dsaopt %s -dsa-local -analyze -dstest -print-only-flags -print-node-for-value \
+;RUN: "func:heap_d:0" | grep "H" | grep "M" | grep "R"
+
+;--Globals:
+;RUN: dsaopt %s -dsa-local -analyze -dstest -print-only-flags -print-node-for-value \
+;RUN: "global_a" | grep "G" | grep -v "M" | grep -v "R"
+;RUN: dsaopt %s -dsa-local -analyze -dstest -print-only-flags -print-node-for-value \
+;RUN: "global_b" | grep "G" | grep "M" | grep -v "R"
+;RUN: dsaopt %s -dsa-local -analyze -dstest -print-only-flags -print-node-for-value \
+;RUN: "global_c" | grep "G" | grep -v "M" | grep "R"
+;RUN: dsaopt %s -dsa-local -analyze -dstest -print-only-flags -print-node-for-value \
+;RUN: "global_d" | grep "G" | grep "M" | grep "R"
+
+
+ at global_c = common global i32 0 ; <i32*> [#uses=1]
+ at global_b = common global i32 0 ; <i32*> [#uses=1]
+ at global_d = common global i32 0 ; <i32*> [#uses=2]
+ at global_a = common global i32 0 ; <i32*> [#uses=0]
+
+define void @func() nounwind {
+entry:
+ %stack_a = alloca i32 ; <i32*> [#uses=0]
+ %heap_a = alloca i32* ; <i32**> [#uses=2]
+ %stack_b = alloca i32 ; <i32*> [#uses=1]
+ %heap_b = alloca i32* ; <i32**> [#uses=3]
+ %stack_c = alloca i32 ; <i32*> [#uses=1]
+ %heap_c = alloca i32* ; <i32**> [#uses=3]
+ %stack_d = alloca i32 ; <i32*> [#uses=2]
+ %heap_d = alloca i32* ; <i32**> [#uses=4]
+ %"alloca point" = bitcast i32 0 to i32 ; <i32> [#uses=0]
+ %0 = call noalias i8* @malloc(i64 4) nounwind ; <i8*> [#uses=1]
+ %1 = bitcast i8* %0 to i32* ; <i32*> [#uses=1]
+ store i32* %1, i32** %heap_a, align 8
+ %2 = call noalias i8* @malloc(i64 4) nounwind ; <i8*> [#uses=1]
+ %3 = bitcast i8* %2 to i32* ; <i32*> [#uses=1]
+ store i32* %3, i32** %heap_b, align 8
+ %4 = call noalias i8* @malloc(i64 4) nounwind ; <i8*> [#uses=1]
+ %5 = bitcast i8* %4 to i32* ; <i32*> [#uses=1]
+ store i32* %5, i32** %heap_c, align 8
+ %6 = call noalias i8* @malloc(i64 4) nounwind ; <i8*> [#uses=1]
+ %7 = bitcast i8* %6 to i32* ; <i32*> [#uses=1]
+ store i32* %7, i32** %heap_d, align 8
+ %8 = load i32* %stack_c, align 4 ; <i32> [#uses=1]
+ store i32 %8, i32* %stack_b, align 4
+ %9 = load i32** %heap_c, align 8 ; <i32*> [#uses=1]
+ %10 = load i32* %9, align 4 ; <i32> [#uses=1]
+ %11 = load i32** %heap_b, align 8 ; <i32*> [#uses=1]
+ store i32 %10, i32* %11, align 4
+ %12 = load i32* @global_c, align 4 ; <i32> [#uses=1]
+ store i32 %12, i32* @global_b, align 4
+ %13 = load i32* @global_d, align 4 ; <i32> [#uses=1]
+ store i32 %13, i32* %stack_d, align 4
+ %14 = load i32** %heap_d, align 8 ; <i32*> [#uses=1]
+ %15 = load i32* %14, align 4 ; <i32> [#uses=1]
+ store i32 %15, i32* @global_d, align 4
+ %16 = load i32** %heap_d, align 8 ; <i32*> [#uses=1]
+ %17 = load i32* %stack_d, align 4 ; <i32> [#uses=1]
+ store i32 %17, i32* %16, align 4
+ %18 = load i32** %heap_a, align 8 ; <i32*> [#uses=1]
+ %19 = bitcast i32* %18 to i8* ; <i8*> [#uses=1]
+ call void @free(i8* %19) nounwind
+ %20 = load i32** %heap_b, align 8 ; <i32*> [#uses=1]
+ %21 = bitcast i32* %20 to i8* ; <i8*> [#uses=1]
+ call void @free(i8* %21) nounwind
+ %22 = load i32** %heap_c, align 8 ; <i32*> [#uses=1]
+ %23 = bitcast i32* %22 to i8* ; <i8*> [#uses=1]
+ call void @free(i8* %23) nounwind
+ %24 = load i32** %heap_d, align 8 ; <i32*> [#uses=1]
+ %25 = bitcast i32* %24 to i8* ; <i8*> [#uses=1]
+ call void @free(i8* %25) nounwind
+ br label %return
+
+return: ; preds = %entry
+ ret void
+}
+
+declare noalias i8* @malloc(i64) nounwind
+
+declare void @free(i8*) nounwind
More information about the llvm-commits
mailing list