From 49bffc7940799caf659e520a1953e90710588352 Mon Sep 17 00:00:00 2001 From: =?utf8?q?G=C3=B6tz=20Lindenmaier?= Date: Fri, 30 Apr 2004 09:00:03 +0000 Subject: [PATCH] added configure support for heap analyses [r2825] --- README | 23 ++++++++++++++++++++++ config.h.in | 3 +++ configure | 29 ++++++++++++++++++++++++++++ configure.in | 15 +++++++++++++++ firmjni/Makefile.in | 36 +++++++++++++++++++++++------------ firmjni/auxilliary/Heapanal.c | 8 +++++--- ir/ir/irdump.c | 10 ++++------ 7 files changed, 103 insertions(+), 21 deletions(-) diff --git a/README b/README index b8a83f450..2f00c8ed9 100644 --- a/README +++ b/README @@ -19,3 +19,26 @@ To generate FIRM code from a compiler frontend read the documentation "libFIRM: A Library for Compiler Optimization Reaserch Implementing Firm", UKA tech-report 2002-5. About Firm you can learn in UKA tech-report 1999-14. + + + +You can generate a Java Native Interface for the library. For this +configure libfirm with --enable-firmjni and give the path to +the jni headers, e.g. +--with-includedir=/usr/public2/java/jdk1.3.1-sun/include/:/usr/ + public2/java/jdk1.3.1-sun/include/linux/. +Then go to .//firmjni and call make. To test the native +interface go on to testprograms and call make test. + + +If you are using the library for heap analysis with libfirm you +have to configure libfirm with --enable-heapanalysis. If you +use the heap analysis through the java native interface you +must in addition give the paths to the heap analysis installation: +--with-includedir= +--with-libdir= + + + +You can also give the paths by setting environment variables +CPPFLAGS and LDFLAGS before configuring. diff --git a/config.h.in b/config.h.in index dc66640ca..88e6cd9c7 100644 --- a/config.h.in +++ b/config.h.in @@ -88,6 +88,9 @@ /* Define to 1 if Firm statistics are activated */ #undef FIRM_STATISTICS +/* Define to 1 for heap analysis support */ +#undef DO_HEAPANALYSIS + /* Define the right volatile token */ #undef volatile diff --git a/configure b/configure index 6f23d98f1..d9cc0737f 100755 --- a/configure +++ b/configure @@ -829,6 +829,7 @@ Optional Features: --enable-profile enable profiling --enable-autodoc enable auto documentation --enable-firmjni check for tools necesarry to construct a java native interface for Firm + --enable-heapanalysis Compile with heap analysis. --disable-libiberty disable own libiberty parts --enable-statistics enable Firm statistics @@ -1305,6 +1306,33 @@ else fi; +# Check whether --enable-heapanalysis or --disable-heapanalysis was given. +if test "${enable_heapanalysis+set}" = set; then + enableval="$enable_heapanalysis" + enable_heapanalysis=$enableval +else + enable_heapanalysis="no" +fi; +if test "$enable_heapanalysis" = "no"; then + +cat >>confdefs.h <<\_ACEOF +#define DO_HEAPANALYSIS 0 +_ACEOF + + echo "$as_me:$LINENO: result: heapanalysis disabled" >&5 +echo "${ECHO_T}heapanalysis disabled" >&6 +else + +cat >>confdefs.h <<\_ACEOF +#define DO_HEAPANALYSIS 1 +_ACEOF + + echo "$as_me:$LINENO: result: heapanalysis enabled" >&5 +echo "${ECHO_T}heapanalysis enabled" >&6 +fi + + + # Check whether --enable-libiberty or --disable-libiberty was given. if test "${enable_libiberty+set}" = set; then enableval="$enable_libiberty" @@ -4861,6 +4889,7 @@ s,@enable_debug_libfirm@,$enable_debug_libfirm,;t t s,@enable_profile_libfirm@,$enable_profile_libfirm,;t t s,@enable_auto_documentation@,$enable_auto_documentation,;t t s,@enable_firm_jni@,$enable_firm_jni,;t t +s,@enable_heapanalysis@,$enable_heapanalysis,;t t s,@disable_libiberty@,$disable_libiberty,;t t s,@enable_statistics@,$enable_statistics,;t t s,@CC@,$CC,;t t diff --git a/configure.in b/configure.in index b46dcca0c..b2610e404 100644 --- a/configure.in +++ b/configure.in @@ -93,6 +93,21 @@ fi], [enable_firm_jni=no]) AC_SUBST(enable_firm_jni) +dnl set heap analyses support +dnl ------------------------- +AC_ARG_ENABLE(heapanalysis, [ --enable-heapanalysis Compile with heap analysis.], + [enable_heapanalysis=$enableval], [enable_heapanalysis="no"]) +if test "$enable_heapanalysis" = "no"; then + AC_DEFINE(DO_HEAPANALYSIS, 0, [Don't compile with heap analysis]) + AC_MSG_RESULT([heapanalysis disabled]) +else + AC_DEFINE(DO_HEAPANALYSIS, 1, [Compile with heap analysis]) + AC_MSG_RESULT([heapanalysis enabled]) +fi +AC_SUBST(enable_heapanalysis) + +dnl to be used!! AM_CONDITIONAL(FIRM_HEAPANALYSIS, test "$enable_heapanalysis" != "no") + dnl disable linking of libiberty parts (xmalloc, xprintf, obstack, ...) dnl ---------------------- AC_ARG_ENABLE(libiberty, diff --git a/firmjni/Makefile.in b/firmjni/Makefile.in index 1b2966663..51f07cd1d 100644 --- a/firmjni/Makefile.in +++ b/firmjni/Makefile.in @@ -15,6 +15,8 @@ srcdir = @srcdir@ topdir = .. subdir = firmjni +enable_heapanal := @enable_heapanalysis@ + # The library implementing the JNI methods. This name is also # known to the generator for the JNI interface and used in the # static initializer. @@ -23,6 +25,8 @@ LIBNAME = libfirmjni.so # The name of the package containing the Firm JNI PACKAGENAME = firmjni +include $(topdir)/MakeRules + # where to put libfirmjni.so libdir = @libdir@ # where to put the directory firmjni containing the generated @@ -39,16 +43,12 @@ HFILES = $(MEMBERS:.m=.h) JAVAFILES = $(MEMBERS:.m=.java) CLASSFILES = $(MEMBERS:.m=.class) -CPPFLAGS = -I$(top_srcdir)/ir/ir -I$(top_srcdir)/ir/common \ +CPPFLAGS += -I$(top_srcdir)/ir/ir -I$(top_srcdir)/ir/common \ -I$(top_srcdir)/ir/ident -I$(top_srcdir)/ir/tr \ -I$(top_srcdir)/ir/tv -I$(top_srcdir)/ir/debug \ - -I$(top_srcdir)/ir/ana -I$(top_srcdir)/ir/st \ - -I$(top_srcdir)/../opt/heapanal \ - -I$(top_srcdir)/include \ - -I/usr/local/jdk1.3.1/include \ - -I/usr/local/jdk1.3.1/include/freebsd @CPPFLAGS@ + -I$(top_srcdir)/ir/ana -I$(top_srcdir)/ir/st -LDFLAGS += $(topdir) +LDFLAGS += -I$(topdir) FIRM_HEADERS=$(notdir $(FIRM_PATH_HEADERS)) MEMBERS=$(subst .h,.m,$(shell echo $(FIRM_HEADERS)|$(SHELL_TOUPPER))) @@ -68,10 +68,15 @@ FIRM_PATH_HEADERS=common/firm.h common/firm_common.h \ ir/iropt.h ir/irgopt.h ir/ircgopt.h \ ana/irouts.h ana/irdom.h ana/irloop.h ana/cgana.h \ ir/irgmod.h tr/typegmod.h + FIRM_SOURCE_DIR_HEADERS=$(addprefix $(SOURCE_DIR)/,$(FIRM_HEADERS)) # hand implemented members -IMPL_MEMBERS = Dbginfo.m Heapanal.m +IMPL_MEMBERS = Dbginfo.m + +ifeq ($(enable_heapanal),yes) +IMPL_MEMBERS += Heapanal.m +endif # The directory containing crecoder.jar and, for now, # remove_cpp_comands.perl @@ -106,10 +111,10 @@ Type_or_entity.h: Type_or_entity.class Dbginfo.java: - cp aux/Dbginfo.java aux/Dbginfo.c . + cp $(top_srcdir)/firmjni/aux/Dbginfo.java $(top_srcdir)/firmjni/aux/Dbginfo.c . Heapanal.java: - cp aux/Heapanal.java aux/Heapanal.c . + cp $(top_srcdir)/firmjni/aux/Heapanal.java $(top_srcdir)/firmjni/aux/Heapanal.c . %.h: %.class javah -classpath $(topdir) -o $@ $(PACKAGENAME).$(<:.class=) @@ -120,9 +125,16 @@ Heapanal.java: $(OFILES): gcc $(CPPFLAGS) -c $(@:.o=.c) -o $@ + +ifeq ($(enable_heapanal),yes) +HEAPANALLIB = -lheapanal +else +HEAPANALLIB = +endif + + jni: $(HFILES) $(OFILES) # ../libfirm.a - gcc -shared -fPIC -o $(LIBNAME) *.o -lfirm -L.. -lheapanal -L../../opt/heapanal \ - -liberty -L../../sw/lib + gcc -shared -fPIC -o $(LIBNAME) *.o -lfirm -L.. $(HEAPANALLIB) $(LDFLAGS) -liberty -L../../sw/lib install: cp libfirmjni.so $(libdir) diff --git a/firmjni/auxilliary/Heapanal.c b/firmjni/auxilliary/Heapanal.c index a3e3e4011..2a9b6bf28 100644 --- a/firmjni/auxilliary/Heapanal.c +++ b/firmjni/auxilliary/Heapanal.c @@ -2,10 +2,9 @@ # include "Heapanal.h" -# include "firm.h" +# include "libfirm/firm.h" # include "irsimpletype.h" -# include "src/heapanal.h" -# include "src/interprete.h" +# include "heapanal/heapanal.h" /* boilerplate stuff: */ #include "libfirm/irvrfy.h" @@ -157,6 +156,9 @@ void Java_firmjni_Heapanal_analHeap__ (JNIEnv *env, jclass clazz) /* * $Log$ + * Revision 1.3 2004/04/30 09:00:01 goetz + * added configure support for heap analyses + * * Revision 1.2 2004/04/29 13:59:11 liekweg * Removed C++-Style comments --flo * diff --git a/ir/ir/irdump.c b/ir/ir/irdump.c index f705e2265..4ad1aab6d 100644 --- a/ir/ir/irdump.c +++ b/ir/ir/irdump.c @@ -42,9 +42,7 @@ # include "pmap.h" # include "eset.h" -/* #undef HEAPANAL */ -#undef HEAPANAL -#ifdef HEAPANAL +#ifdef DO_HEAPANALYSIS void dump_chi_term(FILE *FL, ir_node *n); void dump_state(FILE *FL, ir_node *n); int get_opt_dump_abstvals(void); @@ -797,7 +795,7 @@ static void dump_node(ir_node *n) dump_node_vcgattr(n, bad); fprintf(F, "}\n"); dump_const_node_local(n); -#ifdef HEAPANAL +#ifdef DO_HEAPANALYSIS dump_chi_term(F, n); dump_state(F, n); #endif @@ -993,7 +991,7 @@ dump_whole_block(ir_node *block) { fprintf(F, "\" label: \""); dump_node_opcode(F, block); fprintf (F, " %ld", get_irn_node_nr(block)); -#ifdef HEAPANAL +#ifdef DO_HEAPANALYSIS if (get_opt_dump_abstvals()) fprintf (F, " seqno: %d", (int)get_Block_seqno(block)); #endif @@ -1012,7 +1010,7 @@ dump_whole_block(ir_node *block) { /* Close the vcg information for the block */ fprintf(F, "}\n"); dump_const_node_local(block); -#ifdef HEAPANAL +#ifdef DO_HEAPANALYSIS dump_chi_term(F, block); #endif fprintf(F, "\n"); -- 2.20.1