aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJeff Law <law@redhat.com>2013-10-26 04:14:34 -0600
committerJeff Law <law@gcc.gnu.org>2013-10-26 04:14:34 -0600
commit98906124e3aa4cb17695d900fe19498e5bde63e4 (patch)
treedb4fb2e3b3425e4080112ab6c0fa8e4922a5a2d7 /gcc
parent19b632c6dd5e1e901ae1bac3fc92164a724ccab5 (diff)
downloadgcc-98906124e3aa4cb17695d900fe19498e5bde63e4.zip
gcc-98906124e3aa4cb17695d900fe19498e5bde63e4.tar.gz
gcc-98906124e3aa4cb17695d900fe19498e5bde63e4.tar.bz2
Makefile.def (target_modules): Remove libmudflap
* Makefile.def (target_modules): Remove libmudflap (languages): Remove check-target-libmudflap). * Makefile.in: Rebuilt. * Makefile.tpl (check-target-libmudflap-c++): Remove. * configure.ac (target_libraries): Remove target-libmudflap. Remove checks which disabled libmudflap on some systems. * configure: Rebuilt. * libmudflap: Directory removed. * Makefile.in (C_COMMON_OBJS): Remove tree-mudflap. (OBJS): Remove tree-nomudflap.o (GTFILES): Remove tree-mudflap.c * builtins.c (expand_builtin_alloc): Remove mudflap support. * gcc.c (MFWRAP_SPEC, MFLIB_SPEC): Likewise. (mfwrap_spec, mflib_spec): Likewise. (cpp_unique_options, cc1_options, static_specs): Likewise. * gimplify (gimplify_vla_decl, build_va_arg_indirect_ref): Likewise. * passes.def: Likewise. * toplev.c (compile_file, process_options): Likewise. * tree-inline.c (copy_tree_r): Likewise. * tree-pass.,h (make_pass_mudflap_1, make_pass_mudflap_2): Likewise. * varasm.c (make_decl_rtl, make_decl_rtl_for_debug): Likewise. (build_constant_desc, output_constant_def_contents): Likewise. (categorize_decl_for_section): Likewise. * tree-mudflap.c: Removed. * tree-mudflap.h: Removed. * tree-nomudflap.c: Removed. * bfin/uclinux.h (MFWRAP_SPEC): Remove. * moxie/uclinux.h (MFWRAP_SPEC): Likewise. * rs6000/aix.h (MFWRAP_SPEC, MFLIB_SPEC): Likewise. * config/sol2.h (MFLIB_SPEC): Likewise. * doc/install.texi: Remove mudflap references. * doc/passes.texi: Similarly. * doc/sourcebuild.texi: Similarly. * doc/invoke.texi: Remove mudlfap related options. * c-family/c-common.c (c_define_builtins): Remove mudflap support. * c-family/c.opt: Ignore and warn for mudflap options. * g++.dg/torture/pr49309.C: Removed. * gcc.dg/dfp/pr35739.c: Removed. From-SVN: r204090
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog29
-rw-r--r--gcc/Makefile.in8
-rw-r--r--gcc/builtins.c4
-rw-r--r--gcc/c-family/ChangeLog5
-rw-r--r--gcc/c-family/c-common.c4
-rw-r--r--gcc/c-family/c.opt12
-rw-r--r--gcc/config/bfin/uclinux.h8
-rw-r--r--gcc/config/moxie/uclinux.h8
-rw-r--r--gcc/config/rs6000/aix.h24
-rw-r--r--gcc/config/sol2.h5
-rw-r--r--gcc/doc/install.texi2
-rw-r--r--gcc/doc/invoke.texi41
-rw-r--r--gcc/doc/passes.texi31
-rw-r--r--gcc/doc/sourcebuild.texi4
-rw-r--r--gcc/gcc.c25
-rw-r--r--gcc/gimplify.c7
-rw-r--r--gcc/passes.def2
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/torture/pr49309.C16
-rw-r--r--gcc/testsuite/gcc.dg/dfp/pr35739.c16
-rw-r--r--gcc/toplev.c8
-rw-r--r--gcc/tree-inline.c10
-rw-r--r--gcc/tree-mudflap.c1450
-rw-r--r--gcc/tree-mudflap.h34
-rw-r--r--gcc/tree-nomudflap.c169
-rw-r--r--gcc/tree-pass.h2
-rw-r--r--gcc/varasm.c31
27 files changed, 57 insertions, 1903 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 29035aa..2e90a39 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,32 @@
+2013-10-26 Jeff Law <law@redhat.com>
+
+ * Makefile.in (C_COMMON_OBJS): Remove tree-mudflap.
+ (OBJS): Remove tree-nomudflap.o
+ (GTFILES): Remove tree-mudflap.c
+ * builtins.c (expand_builtin_alloc): Remove mudflap support.
+ * gcc.c (MFWRAP_SPEC, MFLIB_SPEC): Likewise.
+ (mfwrap_spec, mflib_spec): Likewise.
+ (cpp_unique_options, cc1_options, static_specs): Likewise.
+ * gimplify (gimplify_vla_decl, build_va_arg_indirect_ref): Likewise.
+ * passes.def: Likewise.
+ * toplev.c (compile_file, process_options): Likewise.
+ * tree-inline.c (copy_tree_r): Likewise.
+ * tree-pass.,h (make_pass_mudflap_1, make_pass_mudflap_2): Likewise.
+ * varasm.c (make_decl_rtl, make_decl_rtl_for_debug): Likewise.
+ (build_constant_desc, output_constant_def_contents): Likewise.
+ (categorize_decl_for_section): Likewise.
+ * tree-mudflap.c: Removed.
+ * tree-mudflap.h: Removed.
+ * tree-nomudflap.c: Removed.
+ * bfin/uclinux.h (MFWRAP_SPEC): Remove.
+ * moxie/uclinux.h (MFWRAP_SPEC): Likewise.
+ * rs6000/aix.h (MFWRAP_SPEC, MFLIB_SPEC): Likewise.
+ * config/sol2.h (MFLIB_SPEC): Likewise.
+ * doc/install.texi: Remove mudflap references.
+ * doc/passes.texi: Similarly.
+ * doc/sourcebuild.texi: Similarly.
+ * doc/invoke.texi: Remove mudlfap related options.
+
2013-10-25 Vladimir Makarov <vmakarov@redhat.com>
PR rtl-optimization/58759
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index f519455..29609fd 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -1132,14 +1132,11 @@ GCC_OBJS = gcc.o ggc-none.o
c-family-warn = $(STRICT_WARN)
# Language-specific object files shared by all C-family front ends.
-# FIXME: tree-mudflap is C-family only, but it is also part of the middle-end.
-# The mudflap machinery should be properly separated from the front ends, and
-# perhaps turned into a plugin.
C_COMMON_OBJS = c-family/c-common.o c-family/c-cppbuiltin.o c-family/c-dump.o \
c-family/c-format.o c-family/c-gimplify.o c-family/c-lex.o \
c-family/c-omp.o c-family/c-opts.o c-family/c-pch.o \
c-family/c-ppoutput.o c-family/c-pragma.o c-family/c-pretty-print.o \
- c-family/c-semantics.o c-family/c-ada-spec.o tree-mudflap.o \
+ c-family/c-semantics.o c-family/c-ada-spec.o \
c-family/array-notation-common.o c-family/c-ubsan.o
# Language-independent object files.
@@ -1388,7 +1385,6 @@ OBJS = \
tree-iterator.o \
tree-loop-distribution.o \
tree-nested.o \
- tree-nomudflap.o \
tree-nrv.o \
tree-object-size.o \
tree-outof-ssa.o \
@@ -2252,7 +2248,7 @@ GTFILES = $(CPP_ID_DATA_H) $(srcdir)/input.h $(srcdir)/coretypes.h \
$(srcdir)/sdbout.c $(srcdir)/stor-layout.c \
$(srcdir)/stringpool.c $(srcdir)/tree.c $(srcdir)/varasm.c \
$(srcdir)/gimple.h \
- $(srcdir)/tree-mudflap.c $(srcdir)/gimple-ssa.h \
+ $(srcdir)/gimple-ssa.h \
$(srcdir)/tree-ssanames.c $(srcdir)/tree-eh.c $(srcdir)/tree-ssa-address.c \
$(srcdir)/tree-cfg.c \
$(srcdir)/tree-dfa.c \
diff --git a/gcc/builtins.c b/gcc/builtins.c
index b380c2c..10758ca 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -4362,10 +4362,6 @@ expand_builtin_alloca (tree exp, bool cannot_accumulate)
bool alloca_with_align = (DECL_FUNCTION_CODE (get_callee_fndecl (exp))
== BUILT_IN_ALLOCA_WITH_ALIGN);
- /* Emit normal call if we use mudflap. */
- if (flag_mudflap)
- return NULL_RTX;
-
valid_arglist
= (alloca_with_align
? validate_arglist (exp, INTEGER_TYPE, INTEGER_TYPE, VOID_TYPE)
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index 25bb465..1fab5a8 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -1,3 +1,8 @@
+2013-10-26 Jeff Law <law@redhat.com>
+
+ * c-family/c-common.c (c_define_builtins): Remove mudflap support.
+ * c-family/c.opt: Ignore and warn for mudflap options.
+
2013-10-24 Tobias Burnus <burnus@net-b.de>
PR other/33426
diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index d830288..b20fdd6 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -39,7 +39,6 @@ along with GCC; see the file COPYING3. If not see
#include "diagnostic.h"
#include "tree-iterator.h"
#include "hashtab.h"
-#include "tree-mudflap.h"
#include "opts.h"
#include "cgraph.h"
#include "target-def.h"
@@ -5220,9 +5219,6 @@ c_define_builtins (tree va_list_ref_type_node, tree va_list_arg_type_node)
targetm.init_builtins ();
build_common_builtin_nodes ();
-
- if (flag_mudflap)
- mudflap_init ();
}
/* Like get_identifier, but avoid warnings about null arguments when
diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt
index e8dde93..b862eb9 100644
--- a/gcc/c-family/c.opt
+++ b/gcc/c-family/c.opt
@@ -538,8 +538,7 @@ C ObjC Var(warn_missing_prototypes) Warning
Warn about global functions without prototypes
Wmudflap
-C ObjC C++ ObjC++ Var(warn_mudflap) Init(1) Warning
-Warn about constructs not instrumented by -fmudflap
+C ObjC C++ ObjC++ Ignore Warn(switch %qs is no longer supported)
Wmultichar
C ObjC C++ ObjC++ Warning
@@ -997,16 +996,13 @@ C ObjC C++ ObjC++ Var(flag_ms_extensions)
Don't warn about uses of Microsoft extensions
fmudflap
-C ObjC C++ ObjC++ RejectNegative Report Var(flag_mudflap)
-Add mudflap bounds-checking instrumentation for single-threaded program
+C ObjC C++ ObjC++ Ignore Warn(switch %qs is no longer supported)
fmudflapth
-C ObjC C++ ObjC++ RejectNegative Report Var(flag_mudflap,2)
-Add mudflap bounds-checking instrumentation for multi-threaded program
+C ObjC C++ ObjC++ Ignore Warn(switch %qs is no longer supported)
fmudflapir
-C ObjC C++ ObjC++ RejectNegative Report Var(flag_mudflap_ignore_reads)
-Ignore read operations when inserting mudflap instrumentation
+C ObjC C++ ObjC++ Ignore Warn(switch %qs is no longer supported)
fname-mangling-version-
C++ ObjC++ Joined Ignore Warn(switch %qs is no longer supported)
diff --git a/gcc/config/bfin/uclinux.h b/gcc/config/bfin/uclinux.h
index 63cba99..848515c 100644
--- a/gcc/config/bfin/uclinux.h
+++ b/gcc/config/bfin/uclinux.h
@@ -32,14 +32,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
%{mfast-fp:-lbffastfp} %G %L %{mfast-fp:-lbffastfp} %G \
"
-/* Like the definition in gcc.c, but for purposes of uClinux, every link is
- static. */
-#define MFWRAP_SPEC " %{fmudflap|fmudflapth: \
- --wrap=malloc --wrap=free --wrap=calloc --wrap=realloc\
- --wrap=mmap --wrap=munmap --wrap=alloca\
- %{fmudflapth: --wrap=pthread_create\
-}} %{fmudflap|fmudflapth: --wrap=main}"
-
#undef TARGET_SUPPORTS_SYNC_CALLS
#define TARGET_SUPPORTS_SYNC_CALLS 1
diff --git a/gcc/config/moxie/uclinux.h b/gcc/config/moxie/uclinux.h
index 85c65f25..fb8c925 100644
--- a/gcc/config/moxie/uclinux.h
+++ b/gcc/config/moxie/uclinux.h
@@ -30,13 +30,5 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#define TARGET_OS_CPP_BUILTINS() GNU_USER_TARGET_OS_CPP_BUILTINS()
-/* Like the definition in gcc.c, but for purposes of uClinux, every link is
- static. */
-#define MFWRAP_SPEC " %{fmudflap|fmudflapth: \
- --wrap=malloc --wrap=free --wrap=calloc --wrap=realloc\
- --wrap=mmap --wrap=munmap --wrap=alloca\
- %{fmudflapth: --wrap=pthread_create\
-}} %{fmudflap|fmudflapth: --wrap=main}"
-
#undef TARGET_LIBC_HAS_FUNCTION
#define TARGET_LIBC_HAS_FUNCTION no_c99_libc_has_function
diff --git a/gcc/config/rs6000/aix.h b/gcc/config/rs6000/aix.h
index f81666a..a11bd57 100644
--- a/gcc/config/rs6000/aix.h
+++ b/gcc/config/rs6000/aix.h
@@ -66,30 +66,6 @@
/* Because of the above, we must have gcc search itself to find libgcc.a. */
#define LINK_LIBGCC_SPECIAL_1
-#define MFWRAP_SPEC " %{static: %{fmudflap|fmudflapth: \
- -brename:malloc,__wrap_malloc -brename:__real_malloc,malloc \
- -brename:free,__wrap_free -brename:__real_free,free \
- -brename:calloc,__wrap_calloc -brename:__real_calloc,calloc \
- -brename:realloc,__wrap_realloc -brename:__real_realloc,realloc \
- -brename:mmap,__wrap_mmap -brename:__real_mmap,mmap \
- -brename:munmap,__wrap_munmap -brename:__real_munmap,munmap \
- -brename:alloca,__wrap_alloca -brename:__real_alloca,alloca \
-} %{fmudflapth: \
- -brename:pthread_create,__wrap_pthread_create \
- -brename:__real_pthread_create,pthread_create \
- -brename:pthread_join,__wrap_pthread_join \
- -brename:__real_pthread_join,pthread_join \
- -brename:pthread_exit,__wrap_pthread_exit \
- -brename:__real_pthread_exit,pthread_exit \
-}} %{fmudflap|fmudflapth: \
- -brename:main,__wrap_main -brename:__real_main,main \
-}"
-
-#define MFLIB_SPEC " %{fmudflap: -lmudflap \
- %{static:%(link_gcc_c_sequence) -lmudflap}} \
- %{fmudflapth: -lmudflapth -lpthread \
- %{static:%(link_gcc_c_sequence) -lmudflapth}} "
-
/* Names to predefine in the preprocessor for this target machine. */
#define TARGET_OS_AIX_CPP_BUILTINS() \
do \
diff --git a/gcc/config/sol2.h b/gcc/config/sol2.h
index b606595..749e168 100644
--- a/gcc/config/sol2.h
+++ b/gcc/config/sol2.h
@@ -194,11 +194,6 @@ along with GCC; see the file COPYING3. If not see
#endif /* HAVE_LD_EH_FRAME && TARGET_DL_ITERATE_PHDR */
#endif
-#ifndef USE_GLD
-/* The default MFLIB_SPEC is GNU ld specific. */
-#define MFLIB_SPEC ""
-#endif
-
/* collect2.c can only parse GNU nm -n output. Solaris nm needs -png to
produce the same format. */
#define NM_FLAGS "-png"
diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi
index 5cb4d3c..308f3e8 100644
--- a/gcc/doc/install.texi
+++ b/gcc/doc/install.texi
@@ -1391,7 +1391,7 @@ addition, @samp{libstdc++}'s include files will be installed into
@option{--with-gxx-include-dir=@var{dirname}}. Using this option is
particularly useful if you intend to use several versions of GCC in
parallel. This is currently supported by @samp{libgfortran},
-@samp{libjava}, @samp{libmudflap}, @samp{libstdc++}, and @samp{libobjc}.
+@samp{libjava}, @samp{libstdc++}, and @samp{libobjc}.
@item --enable-languages=@var{lang1},@var{lang2},@dots{}
Specify that only a particular subset of compilers and
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index d9d81a9..ab25922 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -256,7 +256,6 @@ Objective-C and Objective-C++ Dialects}.
-Wlogical-op -Wlong-long @gol
-Wmain -Wmaybe-uninitialized -Wmissing-braces -Wmissing-field-initializers @gol
-Wmissing-include-dirs @gol
--Wno-mudflap @gol
-Wno-multichar -Wnonnull -Wno-overflow @gol
-Woverlength-strings -Wpacked -Wpacked-bitfield-compat -Wpadded @gol
-Wparentheses -Wpedantic-ms-format -Wno-pedantic-ms-format @gol
@@ -308,7 +307,7 @@ Objective-C and Objective-C++ Dialects}.
-fdump-tree-ch @gol
-fdump-tree-ssa@r{[}-@var{n}@r{]} -fdump-tree-pre@r{[}-@var{n}@r{]} @gol
-fdump-tree-ccp@r{[}-@var{n}@r{]} -fdump-tree-dce@r{[}-@var{n}@r{]} @gol
--fdump-tree-gimple@r{[}-raw@r{]} -fdump-tree-mudflap@r{[}-@var{n}@r{]} @gol
+-fdump-tree-gimple@r{[}-raw@r{]} @gol
-fdump-tree-dom@r{[}-@var{n}@r{]} @gol
-fdump-tree-dse@r{[}-@var{n}@r{]} @gol
-fdump-tree-phiprop@r{[}-@var{n}@r{]} @gol
@@ -384,7 +383,7 @@ Objective-C and Objective-C++ Dialects}.
-floop-parallelize-all -flto -flto-compression-level @gol
-flto-partition=@var{alg} -flto-report -flto-report-wpa -fmerge-all-constants @gol
-fmerge-constants -fmodulo-sched -fmodulo-sched-allow-regmoves @gol
--fmove-loop-invariants fmudflap -fmudflapir -fmudflapth -fno-branch-count-reg @gol
+-fmove-loop-invariants -fno-branch-count-reg @gol
-fno-defer-pop -fno-function-cse -fno-guess-branch-probability @gol
-fno-inline -fno-math-errno -fno-peephole -fno-peephole2 @gol
-fno-sched-interblock -fno-sched-spec -fno-signed-zeros @gol
@@ -4991,11 +4990,6 @@ This option is only supported for C and Objective-C@. It is implied by
This option is only active when @option{-fstack-protector} is active. It
warns about functions that are not protected against stack smashing.
-@item -Wno-mudflap
-@opindex Wno-mudflap
-Suppress warnings about constructs that cannot be instrumented by
-@option{-fmudflap}.
-
@item -Woverlength-strings
@opindex Woverlength-strings
@opindex Wno-overlength-strings
@@ -6200,11 +6194,6 @@ by appending @file{.store_copyprop} to the source file name.
Dump each function after dead code elimination. The file name is made by
appending @file{.dce} to the source file name.
-@item mudflap
-@opindex fdump-tree-mudflap
-Dump each function after adding mudflap instrumentation. The file name is
-made by appending @file{.mudflap} to the source file name.
-
@item sra
@opindex fdump-tree-sra
Dump each function after performing scalar replacement of aggregates. The
@@ -7071,32 +7060,6 @@ assumptions based on that.
The default is @option{-fzero-initialized-in-bss}.
-@item -fmudflap -fmudflapth -fmudflapir
-@opindex fmudflap
-@opindex fmudflapth
-@opindex fmudflapir
-@cindex bounds checking
-@cindex mudflap
-For front-ends that support it (C and C++), instrument all risky
-pointer/array dereferencing operations, some standard library
-string/heap functions, and some other associated constructs with
-range/validity tests. Modules so instrumented should be immune to
-buffer overflows, invalid heap use, and some other classes of C/C++
-programming errors. The instrumentation relies on a separate runtime
-library (@file{libmudflap}), which is linked into a program if
-@option{-fmudflap} is given at link time. Run-time behavior of the
-instrumented program is controlled by the @env{MUDFLAP_OPTIONS}
-environment variable. See @code{env MUDFLAP_OPTIONS=-help a.out}
-for its options.
-
-Use @option{-fmudflapth} instead of @option{-fmudflap} to compile and to
-link if your program is multi-threaded. Use @option{-fmudflapir}, in
-addition to @option{-fmudflap} or @option{-fmudflapth}, if
-instrumentation should ignore pointer reads. This produces less
-instrumentation (and therefore faster execution) and still provides
-some protection against outright memory corrupting writes, but allows
-erroneously read data to propagate within a program.
-
@item -fthread-jumps
@opindex fthread-jumps
Perform optimizations that check to see if a jump branches to a
diff --git a/gcc/doc/passes.texi b/gcc/doc/passes.texi
index 045f964..d8e4315 100644
--- a/gcc/doc/passes.texi
+++ b/gcc/doc/passes.texi
@@ -225,20 +225,6 @@ stuff quickly rather than wait until later when it's more work to get
rid of it. This pass is located in @file{tree-cfg.c} and described by
@code{pass_remove_useless_stmts}.
-@item Mudflap declaration registration
-
-If mudflap (@pxref{Optimize Options,,-fmudflap -fmudflapth
--fmudflapir,gcc,Using the GNU Compiler Collection (GCC)}) is
-enabled, we generate code to register some variable declarations with
-the mudflap runtime. Specifically, the runtime tracks the lifetimes of
-those variable declarations that have their addresses taken, or whose
-bounds are unknown at compile time (@code{extern}). This pass generates
-new exception handling constructs (@code{try}/@code{finally}), and so
-must run before those are lowered. In addition, the pass enqueues
-declarations of static variables whose lifetimes extend to the entire
-program. The pass is located in @file{tree-mudflap.c} and is described
-by @code{pass_mudflap_1}.
-
@item OpenMP lowering
If OpenMP generation (@option{-fopenmp}) is enabled, this pass lowers
@@ -576,18 +562,6 @@ run last so that we have as much time as possible to prove that the
statement is not reachable. It is located in @file{tree-cfg.c} and
is described by @code{pass_warn_function_return}.
-@item Mudflap statement annotation
-
-If mudflap is enabled, we rewrite some memory accesses with code to
-validate that the memory access is correct. In particular, expressions
-involving pointer dereferences (@code{INDIRECT_REF}, @code{ARRAY_REF},
-etc.) are replaced by code that checks the selected address range
-against the mudflap runtime's database of valid regions. This check
-includes an inline lookup into a direct-mapped cache, based on
-shift/mask operations of the pointer value, with a fallback function
-call into the runtime. The pass is located in @file{tree-mudflap.c} and
-is described by @code{pass_mudflap_2}.
-
@item Leave static single assignment form
This pass rewrites the function such that it is in normal form. At
@@ -968,10 +942,7 @@ This pass outputs the assembler code for the function. The source files
are @file{final.c} plus @file{insn-output.c}; the latter is generated
automatically from the machine description by the tool @file{genoutput}.
The header file @file{conditions.h} is used for communication between
-these files. If mudflap is enabled, the queue of deferred declarations
-and any addressed constants (e.g., string literals) is processed by
-@code{mudflap_finish_file} into a synthetic constructor function
-containing calls into the mudflap runtime.
+these files.
@item Debugging information output
diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi
index 90bd0bd..1a70916 100644
--- a/gcc/doc/sourcebuild.texi
+++ b/gcc/doc/sourcebuild.texi
@@ -103,10 +103,6 @@ The runtime support library for transactional memory.
@item libjava
The Java runtime library.
-@item libmudflap
-The @code{libmudflap} library, used for instrumenting pointer and array
-dereferencing operations.
-
@item libobjc
The Objective-C and Objective-C++ runtime library.
diff --git a/gcc/gcc.c b/gcc/gcc.c
index 2bbc942..2298249 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -523,28 +523,12 @@ proper position among the other output files. */
#define LIB_SPEC "%{!shared:%{g*:-lg} %{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}}"
#endif
-/* mudflap specs */
-#ifndef MFWRAP_SPEC
-/* XXX: valid only for GNU ld */
-/* XXX: should exactly match hooks provided by libmudflap.a */
-#define MFWRAP_SPEC " %{static: %{fmudflap|fmudflapth: \
- --wrap=malloc --wrap=free --wrap=calloc --wrap=realloc\
- --wrap=mmap --wrap=mmap64 --wrap=munmap --wrap=alloca\
-} %{fmudflapth: --wrap=pthread_create\
-}} %{fmudflap|fmudflapth: --wrap=main}"
-#endif
-#ifndef MFLIB_SPEC
-#define MFLIB_SPEC "%{fmudflap|fmudflapth: -export-dynamic}"
-#endif
-
/* When using -fsplit-stack we need to wrap pthread_create, in order
to initialize the stack guard. We always use wrapping, rather than
shared library ordering, and we keep the wrapper function in
libgcc. This is not yet a real spec, though it could become one;
it is currently just stuffed into LINK_SPEC. FIXME: This wrapping
- only works with GNU ld and gold. FIXME: This is incompatible with
- -fmudflap when linking statically, which wants to do its own
- wrapping. */
+ only works with GNU ld and gold. */
#define STACK_SPLIT_SPEC " %{fsplit-stack: --wrap=pthread_create}"
#ifndef LIBASAN_SPEC
@@ -820,8 +804,6 @@ static const char *asm_spec = ASM_SPEC;
static const char *asm_final_spec = ASM_FINAL_SPEC;
static const char *link_spec = LINK_SPEC;
static const char *lib_spec = LIB_SPEC;
-static const char *mfwrap_spec = MFWRAP_SPEC;
-static const char *mflib_spec = MFLIB_SPEC;
static const char *link_gomp_spec = "";
static const char *libgcc_spec = LIBGCC_SPEC;
static const char *endfile_spec = ENDFILE_SPEC;
@@ -862,8 +844,6 @@ static const char *cpp_unique_options =
%{remap} %{g3|ggdb3|gstabs3|gcoff3|gxcoff3|gvms3:-dD}\
%{!iplugindir*:%{fplugin*:%:find-plugindir()}}\
%{H} %C %{D*&U*&A*} %{i*} %Z %i\
- %{fmudflap:-D_MUDFLAP -include mf-runtime.h}\
- %{fmudflapth:-D_MUDFLAP -D_MUDFLAPTH -include mf-runtime.h}\
%{E|M|MM:%W{o*}}";
/* This contains cpp options which are common with cc1_options and are passed
@@ -895,7 +875,6 @@ static const char *cc1_options =
%{-help=*:--help=%*}\
%{!fsyntax-only:%{S:%W{o*}%{!o*:-o %b.s}}}\
%{fsyntax-only:-o %j} %{-param*}\
- %{fmudflap|fmudflapth:-fno-builtin -fno-merge-constants}\
%{coverage:-fprofile-arcs -ftest-coverage}";
static const char *asm_options =
@@ -1309,8 +1288,6 @@ static struct spec_list static_specs[] =
INIT_STATIC_SPEC ("endfile", &endfile_spec),
INIT_STATIC_SPEC ("link", &link_spec),
INIT_STATIC_SPEC ("lib", &lib_spec),
- INIT_STATIC_SPEC ("mfwrap", &mfwrap_spec),
- INIT_STATIC_SPEC ("mflib", &mflib_spec),
INIT_STATIC_SPEC ("link_gomp", &link_gomp_spec),
INIT_STATIC_SPEC ("libgcc", &libgcc_spec),
INIT_STATIC_SPEC ("startfile", &startfile_spec),
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index d5b535d2..4b4eb4c 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -51,7 +51,6 @@ along with GCC; see the file COPYING3. If not see
#include "langhooks-def.h" /* FIXME: for lhd_set_decl_assembler_name */
#include "tree-pass.h" /* FIXME: only for PROP_gimple_any */
-#include "tree-mudflap.h"
#include "expr.h"
#include "tm_p.h"
@@ -1236,8 +1235,7 @@ gimplify_bind_expr (tree *expr_p, gimple_seq *pre_p)
gimple stack_restore;
/* Save stack on entry and restore it on exit. Add a try_finally
- block to achieve this. Note that mudflap depends on the
- format of the emitted code: see mx_register_decls(). */
+ block to achieve this. */
build_stack_save_restore (&stack_save, &stack_restore);
gimplify_seq_add_stmt (&cleanup, stack_restore);
@@ -1395,8 +1393,7 @@ static void
gimplify_vla_decl (tree decl, gimple_seq *seq_p)
{
/* This is a variable-sized decl. Simplify its size and mark it
- for deferred expansion. Note that mudflap depends on the format
- of the emitted code: see mx_register_decls(). */
+ for deferred expansion. */
tree t, addr, ptr_type;
gimplify_one_sizepos (&DECL_SIZE (decl), seq_p);
diff --git a/gcc/passes.def b/gcc/passes.def
index 84eb3f3..404b790 100644
--- a/gcc/passes.def
+++ b/gcc/passes.def
@@ -34,7 +34,6 @@ along with GCC; see the file COPYING3. If not see
NEXT_PASS (pass_warn_unused_result);
NEXT_PASS (pass_diagnose_omp_blocks);
NEXT_PASS (pass_diagnose_tm_blocks);
- NEXT_PASS (pass_mudflap_1);
NEXT_PASS (pass_lower_omp);
NEXT_PASS (pass_lower_cf);
NEXT_PASS (pass_lower_tm);
@@ -305,7 +304,6 @@ along with GCC; see the file COPYING3. If not see
NEXT_PASS (pass_cleanup_eh);
NEXT_PASS (pass_lower_resx);
NEXT_PASS (pass_nrv);
- NEXT_PASS (pass_mudflap_2);
NEXT_PASS (pass_cleanup_cfg_post_optimizing);
NEXT_PASS (pass_warn_function_noreturn);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 6b98112..9a979e2 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2013-10-26 Jeff Law <law@redhat.com>
+
+ * g++.dg/torture/pr49309.C: Removed.
+ * gcc.dg/dfp/pr35739.c: Removed.
+
2013-10-25 Vladimir Makarov <vmakarov@redhat.com>
PR rtl-optimization/58759
diff --git a/gcc/testsuite/g++.dg/torture/pr49309.C b/gcc/testsuite/g++.dg/torture/pr49309.C
deleted file mode 100644
index f96967d..0000000
--- a/gcc/testsuite/g++.dg/torture/pr49309.C
+++ /dev/null
@@ -1,16 +0,0 @@
-// PR tree-optimization/49309
-// { dg-do compile }
-// { dg-skip-if "" { *-*-* } { "-flto" } { "" } }
-// { dg-options "-fpreprocessed -fmudflap" }
-
-struct A
-{
- int i;
-
- A();
- A(const A&);
-};
-
-inline void foo(A a) { a = A(); }
-
-void bar() { foo(A()); }
diff --git a/gcc/testsuite/gcc.dg/dfp/pr35739.c b/gcc/testsuite/gcc.dg/dfp/pr35739.c
deleted file mode 100644
index 0fc9d47..0000000
--- a/gcc/testsuite/gcc.dg/dfp/pr35739.c
+++ /dev/null
@@ -1,16 +0,0 @@
-/* PR c/35739 */
-/* { dg-do compile { target *-*-linux* *-*-gnu* } } */
-/* { dg-options "-O -fpreprocessed -fmudflap" } */
-
-_Decimal128
-foo (int n, ...)
-{
- int i;
- _Decimal128 j = 0;
- __builtin_va_list ap;
- __builtin_va_start (ap, n);
- for (i = 0; i < n; i++)
- j += __builtin_va_arg (ap, _Decimal128);
- __builtin_va_end (ap);
- return j;
-}
diff --git a/gcc/toplev.c b/gcc/toplev.c
index cc8e905..db269b7 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -68,7 +68,6 @@ along with GCC; see the file COPYING3. If not see
#include "coverage.h"
#include "value-prof.h"
#include "alloc-pool.h"
-#include "tree-mudflap.h"
#include "asan.h"
#include "tsan.h"
#include "gimple.h"
@@ -568,10 +567,6 @@ compile_file (void)
basically finished. */
if (in_lto_p || !flag_lto || flag_fat_lto_objects)
{
- /* Likewise for mudflap static object registrations. */
- if (flag_mudflap)
- mudflap_finish_file ();
-
/* File-scope initialization for AddressSanitizer. */
if (flag_sanitize & SANITIZE_ADDRESS)
asan_finish_file ();
@@ -1287,9 +1282,6 @@ process_options (void)
"and -ftree-loop-linear)");
#endif
- if (flag_mudflap && flag_lto)
- sorry ("mudflap cannot be used together with link-time optimization");
-
/* One region RA really helps to decrease the code size. */
if (flag_ira_region == IRA_REGION_AUTODETECT)
flag_ira_region
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index 8852311..a20e73b 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -34,7 +34,6 @@ along with GCC; see the file COPYING3. If not see
#include "basic-block.h"
#include "tree-iterator.h"
#include "intl.h"
-#include "tree-mudflap.h"
#include "gimple.h"
#include "gimple-ssa.h"
#include "tree-cfg.h"
@@ -4592,10 +4591,6 @@ copy_tree_r (tree *tp, int *walk_subtrees, void *data ATTRIBUTE_UNUSED)
/* Copy the node. */
new_tree = copy_node (*tp);
- /* Propagate mudflap marked-ness. */
- if (flag_mudflap && mf_marked_p (*tp))
- mf_mark (new_tree);
-
*tp = new_tree;
/* Now, restore the chain, if appropriate. That will cause
@@ -4617,11 +4612,6 @@ copy_tree_r (tree *tp, int *walk_subtrees, void *data ATTRIBUTE_UNUSED)
tree new_tree;
new_tree = copy_node (*tp);
-
- /* Propagate mudflap marked-ness. */
- if (flag_mudflap && mf_marked_p (*tp))
- mf_mark (new_tree);
-
CONSTRUCTOR_ELTS (new_tree) = vec_safe_copy (CONSTRUCTOR_ELTS (*tp));
*tp = new_tree;
}
diff --git a/gcc/tree-mudflap.c b/gcc/tree-mudflap.c
deleted file mode 100644
index a150311..0000000
--- a/gcc/tree-mudflap.c
+++ /dev/null
@@ -1,1450 +0,0 @@
-/* Mudflap: narrow-pointer bounds-checking by tree rewriting.
- Copyright (C) 2002-2013 Free Software Foundation, Inc.
- Contributed by Frank Ch. Eigler <fche@redhat.com>
- and Graydon Hoare <graydon@redhat.com>
-
-This file is part of GCC.
-
-GCC is free software; you can redistribute it and/or modify it under
-the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 3, or (at your option) any later
-version.
-
-GCC is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-for more details.
-
-You should have received a copy of the GNU General Public License
-along with GCC; see the file COPYING3. If not see
-<http://www.gnu.org/licenses/>. */
-
-
-#include "config.h"
-#include "system.h"
-#include "coretypes.h"
-#include "tm.h"
-#include "tree.h"
-#include "tm_p.h"
-#include "basic-block.h"
-#include "flags.h"
-#include "function.h"
-#include "tree-inline.h"
-#include "gimple.h"
-#include "tree-iterator.h"
-#include "cgraph.h"
-#include "tree-cfg.h"
-#include "tree-mudflap.h"
-#include "tree-pass.h"
-#include "hashtab.h"
-#include "diagnostic.h"
-#include "demangle.h"
-#include "langhooks.h"
-#include "ggc.h"
-#include "tree-ssa-address.h"
-
-extern void add_bb_to_loop (basic_block, struct loop *);
-
-/* Internal function decls */
-
-
-/* Options. */
-#define flag_mudflap_threads (flag_mudflap == 2)
-
-/* Helpers. */
-static tree mf_build_string (const char *string);
-static tree mf_varname_tree (tree);
-static tree mf_file_function_line_tree (location_t);
-
-/* Indirection-related instrumentation. */
-static void mf_decl_cache_locals (void);
-static void mf_decl_clear_locals (void);
-static void mf_xform_statements (void);
-static unsigned int execute_mudflap_function_ops (void);
-
-/* Addressable variables instrumentation. */
-static void mf_xform_decls (gimple_seq, tree);
-static tree mx_xfn_xform_decls (gimple_stmt_iterator *, bool *,
- struct walk_stmt_info *);
-static gimple_seq mx_register_decls (tree, gimple_seq, location_t);
-static unsigned int execute_mudflap_function_decls (void);
-
-/* Return true if DECL is artificial stub that shouldn't be instrumented by
- mf. We should instrument clones of non-artificial functions. */
-static inline bool
-mf_artificial (const_tree decl)
-{
- return DECL_ARTIFICIAL (DECL_ORIGIN (decl));
-}
-
-/* ------------------------------------------------------------------------ */
-/* Some generally helpful functions for mudflap instrumentation. */
-
-/* Build a reference to a literal string. */
-static tree
-mf_build_string (const char *string)
-{
- size_t len = strlen (string);
- tree result = mf_mark (build_string (len + 1, string));
-
- TREE_TYPE (result) = build_array_type
- (char_type_node, build_index_type (size_int (len)));
- TREE_CONSTANT (result) = 1;
- TREE_READONLY (result) = 1;
- TREE_STATIC (result) = 1;
-
- result = build1 (ADDR_EXPR, build_pointer_type (char_type_node), result);
-
- return mf_mark (result);
-}
-
-/* Create a properly typed STRING_CST node that describes the given
- declaration. It will be used as an argument for __mf_register().
- Try to construct a helpful string, including file/function/variable
- name. */
-
-static tree
-mf_varname_tree (tree decl)
-{
- const char *buf_contents;
- tree result;
-
- gcc_assert (decl);
-
- pretty_printer buf;
-
- /* Add FILENAME[:LINENUMBER[:COLUMNNUMBER]]. */
- {
- expanded_location xloc = expand_location (DECL_SOURCE_LOCATION (decl));
- const char *sourcefile;
- unsigned sourceline = xloc.line;
- unsigned sourcecolumn = 0;
- sourcecolumn = xloc.column;
- sourcefile = xloc.file;
- if (sourcefile == NULL && current_function_decl != NULL_TREE)
- sourcefile = DECL_SOURCE_FILE (current_function_decl);
- if (sourcefile == NULL)
- sourcefile = "<unknown file>";
-
- pp_string (&buf, sourcefile);
-
- if (sourceline != 0)
- {
- pp_colon (&buf);
- pp_decimal_int (&buf, sourceline);
-
- if (sourcecolumn != 0)
- {
- pp_colon (&buf);
- pp_decimal_int (&buf, sourcecolumn);
- }
- }
- }
-
- if (current_function_decl != NULL_TREE)
- {
- /* Add (FUNCTION) */
- pp_string (&buf, " (");
- {
- const char *funcname = NULL;
- if (DECL_NAME (current_function_decl))
- funcname = lang_hooks.decl_printable_name (current_function_decl, 1);
- if (funcname == NULL)
- funcname = "anonymous fn";
-
- pp_string (&buf, funcname);
- }
- pp_string (&buf, ") ");
- }
- else
- pp_space (&buf);
-
- /* Add <variable-declaration>, possibly demangled. */
- {
- const char *declname = NULL;
-
- if (DECL_NAME (decl) != NULL)
- {
- if (strcmp ("GNU C++", lang_hooks.name) == 0)
- {
- /* The gcc/cp decl_printable_name hook doesn't do as good a job as
- the libiberty demangler. */
- declname = cplus_demangle (IDENTIFIER_POINTER (DECL_NAME (decl)),
- DMGL_AUTO | DMGL_VERBOSE);
- }
- if (declname == NULL)
- declname = lang_hooks.decl_printable_name (decl, 3);
- }
- if (declname == NULL)
- declname = "<unnamed variable>";
-
- pp_string (&buf, declname);
- }
-
- /* Return the lot as a new STRING_CST. */
- buf_contents = ggc_strdup (pp_formatted_text (&buf));
- result = mf_build_string (buf_contents);
- pp_clear_output_area (&buf);
-
- return result;
-}
-
-
-/* And another friend, for producing a simpler message. */
-
-static tree
-mf_file_function_line_tree (location_t location)
-{
- expanded_location xloc = expand_location (location);
- const char *file = NULL, *colon, *line, *op, *name, *cp;
- char linecolbuf[30]; /* Enough for two decimal numbers plus a colon. */
- char *string;
- tree result;
-
- /* Add FILENAME[:LINENUMBER[:COLUMNNUMBER]]. */
- file = xloc.file;
- if (file == NULL && current_function_decl != NULL_TREE)
- file = DECL_SOURCE_FILE (current_function_decl);
- if (file == NULL)
- file = "<unknown file>";
-
- if (xloc.line > 0)
- {
- if (xloc.column > 0)
- sprintf (linecolbuf, "%d:%d", xloc.line, xloc.column);
- else
- sprintf (linecolbuf, "%d", xloc.line);
- colon = ":";
- line = linecolbuf;
- }
- else
- colon = line = "";
-
- /* Add (FUNCTION). */
- name = lang_hooks.decl_printable_name (current_function_decl, 1);
- if (name)
- {
- op = " (";
- cp = ")";
- }
- else
- op = name = cp = "";
-
- string = concat (file, colon, line, op, name, cp, NULL);
- result = mf_build_string (string);
- free (string);
-
- return result;
-}
-
-
-/* global tree nodes */
-
-/* Global tree objects for global variables and functions exported by
- mudflap runtime library. mf_init_extern_trees must be called
- before using these. */
-
-/* uintptr_t (usually "unsigned long") */
-static GTY (()) tree mf_uintptr_type;
-
-/* struct __mf_cache { uintptr_t low; uintptr_t high; }; */
-static GTY (()) tree mf_cache_struct_type;
-
-/* struct __mf_cache * const */
-static GTY (()) tree mf_cache_structptr_type;
-
-/* extern struct __mf_cache __mf_lookup_cache []; */
-static GTY (()) tree mf_cache_array_decl;
-
-/* extern unsigned char __mf_lc_shift; */
-static GTY (()) tree mf_cache_shift_decl;
-
-/* extern uintptr_t __mf_lc_mask; */
-static GTY (()) tree mf_cache_mask_decl;
-
-/* Their function-scope local shadows, used in single-threaded mode only. */
-
-/* auto const unsigned char __mf_lc_shift_l; */
-static GTY (()) tree mf_cache_shift_decl_l;
-
-/* auto const uintptr_t __mf_lc_mask_l; */
-static GTY (()) tree mf_cache_mask_decl_l;
-
-/* extern void __mf_check (void *ptr, size_t sz, int type, const char *); */
-static GTY (()) tree mf_check_fndecl;
-
-/* extern void __mf_register (void *ptr, size_t sz, int type, const char *); */
-static GTY (()) tree mf_register_fndecl;
-
-/* extern void __mf_unregister (void *ptr, size_t sz, int type); */
-static GTY (()) tree mf_unregister_fndecl;
-
-/* extern void __mf_init (); */
-static GTY (()) tree mf_init_fndecl;
-
-/* extern int __mf_set_options (const char*); */
-static GTY (()) tree mf_set_options_fndecl;
-
-
-/* Helper for mudflap_init: construct a decl with the given category,
- name, and type, mark it an external reference, and pushdecl it. */
-static inline tree
-mf_make_builtin (enum tree_code category, const char *name, tree type)
-{
- tree decl = mf_mark (build_decl (UNKNOWN_LOCATION,
- category, get_identifier (name), type));
- TREE_PUBLIC (decl) = 1;
- DECL_EXTERNAL (decl) = 1;
- lang_hooks.decls.pushdecl (decl);
- /* The decl was declared by the compiler. */
- DECL_ARTIFICIAL (decl) = 1;
- /* And we don't want debug info for it. */
- DECL_IGNORED_P (decl) = 1;
- return decl;
-}
-
-/* Helper for mudflap_init: construct a tree corresponding to the type
- struct __mf_cache { uintptr_t low; uintptr_t high; };
- where uintptr_t is the FIELD_TYPE argument. */
-static inline tree
-mf_make_mf_cache_struct_type (tree field_type)
-{
- /* There is, abominably, no language-independent way to construct a
- RECORD_TYPE. So we have to call the basic type construction
- primitives by hand. */
- tree fieldlo = build_decl (UNKNOWN_LOCATION,
- FIELD_DECL, get_identifier ("low"), field_type);
- tree fieldhi = build_decl (UNKNOWN_LOCATION,
- FIELD_DECL, get_identifier ("high"), field_type);
-
- tree struct_type = make_node (RECORD_TYPE);
- DECL_CONTEXT (fieldlo) = struct_type;
- DECL_CONTEXT (fieldhi) = struct_type;
- DECL_CHAIN (fieldlo) = fieldhi;
- TYPE_FIELDS (struct_type) = fieldlo;
- TYPE_NAME (struct_type) = get_identifier ("__mf_cache");
- layout_type (struct_type);
-
- return struct_type;
-}
-
-/* Initialize the global tree nodes that correspond to mf-runtime.h
- declarations. */
-void
-mudflap_init (void)
-{
- static bool done = false;
- tree mf_const_string_type;
- tree mf_cache_array_type;
- tree mf_check_register_fntype;
- tree mf_unregister_fntype;
- tree mf_init_fntype;
- tree mf_set_options_fntype;
-
- if (done)
- return;
- done = true;
-
- mf_uintptr_type = lang_hooks.types.type_for_mode (ptr_mode,
- /*unsignedp=*/true);
- mf_const_string_type
- = build_pointer_type (build_qualified_type
- (char_type_node, TYPE_QUAL_CONST));
-
- mf_cache_struct_type = mf_make_mf_cache_struct_type (mf_uintptr_type);
- mf_cache_structptr_type = build_pointer_type (mf_cache_struct_type);
- mf_cache_array_type = build_array_type (mf_cache_struct_type, 0);
- mf_check_register_fntype =
- build_function_type_list (void_type_node, ptr_type_node, size_type_node,
- integer_type_node, mf_const_string_type, NULL_TREE);
- mf_unregister_fntype =
- build_function_type_list (void_type_node, ptr_type_node, size_type_node,
- integer_type_node, NULL_TREE);
- mf_init_fntype =
- build_function_type_list (void_type_node, NULL_TREE);
- mf_set_options_fntype =
- build_function_type_list (integer_type_node, mf_const_string_type, NULL_TREE);
-
- mf_cache_array_decl = mf_make_builtin (VAR_DECL, "__mf_lookup_cache",
- mf_cache_array_type);
- mf_cache_shift_decl = mf_make_builtin (VAR_DECL, "__mf_lc_shift",
- unsigned_char_type_node);
- mf_cache_mask_decl = mf_make_builtin (VAR_DECL, "__mf_lc_mask",
- mf_uintptr_type);
- /* Don't process these in mudflap_enqueue_decl, should they come by
- there for some reason. */
- mf_mark (mf_cache_array_decl);
- mf_mark (mf_cache_shift_decl);
- mf_mark (mf_cache_mask_decl);
- mf_check_fndecl = mf_make_builtin (FUNCTION_DECL, "__mf_check",
- mf_check_register_fntype);
- mf_register_fndecl = mf_make_builtin (FUNCTION_DECL, "__mf_register",
- mf_check_register_fntype);
- mf_unregister_fndecl = mf_make_builtin (FUNCTION_DECL, "__mf_unregister",
- mf_unregister_fntype);
- mf_init_fndecl = mf_make_builtin (FUNCTION_DECL, "__mf_init",
- mf_init_fntype);
- mf_set_options_fndecl = mf_make_builtin (FUNCTION_DECL, "__mf_set_options",
- mf_set_options_fntype);
-}
-
-
-/* ------------------------------------------------------------------------ */
-/* This is the second part of the mudflap instrumentation. It works on
- low-level GIMPLE using the CFG, because we want to run this pass after
- tree optimizations have been performed, but we have to preserve the CFG
- for expansion from trees to RTL.
- Below is the list of transformations performed on statements in the
- current function.
-
- 1) Memory reference transforms: Perform the mudflap indirection-related
- tree transforms on memory references.
-
- 2) Mark BUILTIN_ALLOCA calls not inlineable.
-
- */
-
-static unsigned int
-execute_mudflap_function_ops (void)
-{
- struct gimplify_ctx gctx;
-
- /* Don't instrument functions such as the synthetic constructor
- built during mudflap_finish_file. */
- if (mf_marked_p (current_function_decl)
- || mf_artificial (current_function_decl))
- return 0;
-
- push_gimplify_context (&gctx);
-
- /* In multithreaded mode, don't cache the lookup cache parameters. */
- if (! flag_mudflap_threads)
- mf_decl_cache_locals ();
-
- mf_xform_statements ();
-
- if (! flag_mudflap_threads)
- mf_decl_clear_locals ();
-
- pop_gimplify_context (NULL);
- return 0;
-}
-
-/* Insert a gimple_seq SEQ on all the outgoing edges out of BB. Note that
- if BB has more than one edge, STMT will be replicated for each edge.
- Also, abnormal edges will be ignored. */
-
-static void
-insert_edge_copies_seq (gimple_seq seq, basic_block bb)
-{
- edge e;
- edge_iterator ei;
- unsigned n_copies = -1;
-
- FOR_EACH_EDGE (e, ei, bb->succs)
- if (!(e->flags & EDGE_ABNORMAL))
- n_copies++;
-
- FOR_EACH_EDGE (e, ei, bb->succs)
- if (!(e->flags & EDGE_ABNORMAL))
- gsi_insert_seq_on_edge (e, n_copies-- > 0 ? gimple_seq_copy (seq) : seq);
-}
-
-/* Create and initialize local shadow variables for the lookup cache
- globals. Put their decls in the *_l globals for use by
- mf_build_check_statement_for. */
-
-static void
-mf_decl_cache_locals (void)
-{
- gimple g;
- gimple_seq seq = NULL;
-
- /* Build the cache vars. */
- mf_cache_shift_decl_l
- = mf_mark (create_tmp_reg (TREE_TYPE (mf_cache_shift_decl),
- "__mf_lookup_shift_l"));
-
- mf_cache_mask_decl_l
- = mf_mark (create_tmp_reg (TREE_TYPE (mf_cache_mask_decl),
- "__mf_lookup_mask_l"));
-
- /* Build initialization nodes for the cache vars. We just load the
- globals into the cache variables. */
- g = gimple_build_assign (mf_cache_shift_decl_l, mf_cache_shift_decl);
- gimple_set_location (g, DECL_SOURCE_LOCATION (current_function_decl));
- gimple_seq_add_stmt (&seq, g);
-
- g = gimple_build_assign (mf_cache_mask_decl_l, mf_cache_mask_decl);
- gimple_set_location (g, DECL_SOURCE_LOCATION (current_function_decl));
- gimple_seq_add_stmt (&seq, g);
-
- insert_edge_copies_seq (seq, ENTRY_BLOCK_PTR);
-
- gsi_commit_edge_inserts ();
-}
-
-
-static void
-mf_decl_clear_locals (void)
-{
- /* Unset local shadows. */
- mf_cache_shift_decl_l = NULL_TREE;
- mf_cache_mask_decl_l = NULL_TREE;
-}
-
-static void
-mf_build_check_statement_for (tree base, tree limit,
- gimple_stmt_iterator *instr_gsi,
- location_t location, tree dirflag)
-{
- gimple_stmt_iterator gsi;
- basic_block cond_bb, then_bb, join_bb;
- edge e;
- tree cond, t, u, v;
- tree mf_base;
- tree mf_elem;
- tree mf_limit;
- gimple g;
- gimple_seq seq, stmts;
-
- /* We first need to split the current basic block, and start altering
- the CFG. This allows us to insert the statements we're about to
- construct into the right basic blocks. */
-
- cond_bb = gimple_bb (gsi_stmt (*instr_gsi));
- gsi = *instr_gsi;
- gsi_prev (&gsi);
- if (! gsi_end_p (gsi))
- e = split_block (cond_bb, gsi_stmt (gsi));
- else
- e = split_block_after_labels (cond_bb);
- cond_bb = e->src;
- join_bb = e->dest;
-
- /* A recap at this point: join_bb is the basic block at whose head
- is the gimple statement for which this check expression is being
- built. cond_bb is the (possibly new, synthetic) basic block the
- end of which will contain the cache-lookup code, and a
- conditional that jumps to the cache-miss code or, much more
- likely, over to join_bb. */
-
- /* Create the bb that contains the cache-miss fallback block (mf_check). */
- then_bb = create_empty_bb (cond_bb);
- make_edge (cond_bb, then_bb, EDGE_TRUE_VALUE);
- make_single_succ_edge (then_bb, join_bb, EDGE_FALLTHRU);
-
- /* Mark the pseudo-fallthrough edge from cond_bb to join_bb. */
- e = find_edge (cond_bb, join_bb);
- e->flags = EDGE_FALSE_VALUE;
- e->count = cond_bb->count;
- e->probability = REG_BR_PROB_BASE;
-
- /* Update dominance info. Note that bb_join's data was
- updated by split_block. */
- if (dom_info_available_p (CDI_DOMINATORS))
- {
- set_immediate_dominator (CDI_DOMINATORS, then_bb, cond_bb);
- set_immediate_dominator (CDI_DOMINATORS, join_bb, cond_bb);
- }
-
- /* Update loop info. */
- if (current_loops)
- add_bb_to_loop (then_bb, cond_bb->loop_father);
-
- /* Build our local variables. */
- mf_elem = create_tmp_reg (mf_cache_structptr_type, "__mf_elem");
- mf_base = create_tmp_reg (mf_uintptr_type, "__mf_base");
- mf_limit = create_tmp_reg (mf_uintptr_type, "__mf_limit");
-
- /* Build: __mf_base = (uintptr_t) <base address expression>. */
- seq = NULL;
- t = fold_convert_loc (location, mf_uintptr_type,
- unshare_expr (base));
- t = force_gimple_operand (t, &stmts, false, NULL_TREE);
- gimple_seq_add_seq (&seq, stmts);
- g = gimple_build_assign (mf_base, t);
- gimple_set_location (g, location);
- gimple_seq_add_stmt (&seq, g);
-
- /* Build: __mf_limit = (uintptr_t) <limit address expression>. */
- t = fold_convert_loc (location, mf_uintptr_type,
- unshare_expr (limit));
- t = force_gimple_operand (t, &stmts, false, NULL_TREE);
- gimple_seq_add_seq (&seq, stmts);
- g = gimple_build_assign (mf_limit, t);
- gimple_set_location (g, location);
- gimple_seq_add_stmt (&seq, g);
-
- /* Build: __mf_elem = &__mf_lookup_cache [(__mf_base >> __mf_shift)
- & __mf_mask]. */
- t = build2 (RSHIFT_EXPR, mf_uintptr_type, mf_base,
- flag_mudflap_threads ? mf_cache_shift_decl
- : mf_cache_shift_decl_l);
- t = build2 (BIT_AND_EXPR, mf_uintptr_type, t,
- flag_mudflap_threads ? mf_cache_mask_decl
- : mf_cache_mask_decl_l);
- t = build4 (ARRAY_REF,
- TREE_TYPE (TREE_TYPE (mf_cache_array_decl)),
- mf_cache_array_decl, t, NULL_TREE, NULL_TREE);
- t = build1 (ADDR_EXPR, mf_cache_structptr_type, t);
- t = force_gimple_operand (t, &stmts, false, NULL_TREE);
- gimple_seq_add_seq (&seq, stmts);
- g = gimple_build_assign (mf_elem, t);
- gimple_set_location (g, location);
- gimple_seq_add_stmt (&seq, g);
-
- /* Quick validity check.
-
- if (__mf_elem->low > __mf_base
- || (__mf_elem_high < __mf_limit))
- {
- __mf_check ();
- ... and only if single-threaded:
- __mf_lookup_shift_1 = f...;
- __mf_lookup_mask_l = ...;
- }
-
- It is expected that this body of code is rarely executed so we mark
- the edge to the THEN clause of the conditional jump as unlikely. */
-
- /* Construct t <-- '__mf_elem->low > __mf_base'. */
- t = build3 (COMPONENT_REF, mf_uintptr_type,
- build1 (INDIRECT_REF, mf_cache_struct_type, mf_elem),
- TYPE_FIELDS (mf_cache_struct_type), NULL_TREE);
- t = build2 (GT_EXPR, boolean_type_node, t, mf_base);
-
- /* Construct '__mf_elem->high < __mf_limit'.
-
- First build:
- 1) u <-- '__mf_elem->high'
- 2) v <-- '__mf_limit'.
-
- Then build 'u <-- (u < v). */
-
- u = build3 (COMPONENT_REF, mf_uintptr_type,
- build1 (INDIRECT_REF, mf_cache_struct_type, mf_elem),
- DECL_CHAIN (TYPE_FIELDS (mf_cache_struct_type)), NULL_TREE);
-
- v = mf_limit;
-
- u = build2 (LT_EXPR, boolean_type_node, u, v);
-
- /* Build the composed conditional: t <-- 't || u'. Then store the
- result of the evaluation of 't' in a temporary variable which we
- can use as the condition for the conditional jump. */
- t = build2 (TRUTH_OR_EXPR, boolean_type_node, t, u);
- t = force_gimple_operand (t, &stmts, false, NULL_TREE);
- gimple_seq_add_seq (&seq, stmts);
- cond = create_tmp_reg (boolean_type_node, "__mf_unlikely_cond");
- g = gimple_build_assign (cond, t);
- gimple_set_location (g, location);
- gimple_seq_add_stmt (&seq, g);
-
- /* Build the conditional jump. 'cond' is just a temporary so we can
- simply build a void COND_EXPR. We do need labels in both arms though. */
- g = gimple_build_cond (NE_EXPR, cond, boolean_false_node, NULL_TREE,
- NULL_TREE);
- gimple_set_location (g, location);
- gimple_seq_add_stmt (&seq, g);
-
- /* At this point, after so much hard work, we have only constructed
- the conditional jump,
-
- if (__mf_elem->low > __mf_base
- || (__mf_elem_high < __mf_limit))
-
- The lowered GIMPLE tree representing this code is in the statement
- list starting at 'head'.
-
- We can insert this now in the current basic block, i.e. the one that
- the statement we're instrumenting was originally in. */
- gsi = gsi_last_bb (cond_bb);
- gsi_insert_seq_after (&gsi, seq, GSI_CONTINUE_LINKING);
-
- /* Now build up the body of the cache-miss handling:
-
- __mf_check();
- refresh *_l vars.
-
- This is the body of the conditional. */
-
- seq = NULL;
- /* u is a string, so it is already a gimple value. */
- u = mf_file_function_line_tree (location);
- /* NB: we pass the overall [base..limit] range to mf_check. */
- v = fold_build2_loc (location, PLUS_EXPR, mf_uintptr_type,
- fold_build2_loc (location,
- MINUS_EXPR, mf_uintptr_type, mf_limit, mf_base),
- build_int_cst (mf_uintptr_type, 1));
- v = force_gimple_operand (v, &stmts, true, NULL_TREE);
- gimple_seq_add_seq (&seq, stmts);
- g = gimple_build_call (mf_check_fndecl, 4, mf_base, v, dirflag, u);
- gimple_seq_add_stmt (&seq, g);
-
- if (! flag_mudflap_threads)
- {
- if (stmt_ends_bb_p (g))
- {
- gsi = gsi_start_bb (then_bb);
- gsi_insert_seq_after (&gsi, seq, GSI_CONTINUE_LINKING);
- e = split_block (then_bb, g);
- then_bb = e->dest;
- seq = NULL;
- }
-
- g = gimple_build_assign (mf_cache_shift_decl_l, mf_cache_shift_decl);
- gimple_seq_add_stmt (&seq, g);
-
- g = gimple_build_assign (mf_cache_mask_decl_l, mf_cache_mask_decl);
- gimple_seq_add_stmt (&seq, g);
- }
-
- /* Insert the check code in the THEN block. */
- gsi = gsi_start_bb (then_bb);
- gsi_insert_seq_after (&gsi, seq, GSI_CONTINUE_LINKING);
-
- *instr_gsi = gsi_start_bb (join_bb);
-}
-
-
-/* Check whether the given decl, generally a VAR_DECL or PARM_DECL, is
- eligible for instrumentation. For the mudflap1 pass, this implies
- that it should be registered with the libmudflap runtime. For the
- mudflap2 pass this means instrumenting an indirection operation with
- respect to the object.
-*/
-static int
-mf_decl_eligible_p (tree decl)
-{
- return ((TREE_CODE (decl) == VAR_DECL || TREE_CODE (decl) == PARM_DECL)
- /* The decl must have its address taken. In the case of
- arrays, this flag is also set if the indexes are not
- compile-time known valid constants. */
- /* XXX: not sufficient: return-by-value structs! */
- && TREE_ADDRESSABLE (decl)
- /* The type of the variable must be complete. */
- && COMPLETE_OR_VOID_TYPE_P (TREE_TYPE (decl))
- /* The decl hasn't been decomposed somehow. */
- && !DECL_HAS_VALUE_EXPR_P (decl));
-}
-
-
-static void
-mf_xform_derefs_1 (gimple_stmt_iterator *iter, tree *tp,
- location_t location, tree dirflag)
-{
- tree type, base, limit, addr, size, t;
-
- /* Don't instrument read operations. */
- if (dirflag == integer_zero_node && flag_mudflap_ignore_reads)
- return;
-
- /* Don't instrument marked nodes. */
- if (mf_marked_p (*tp))
- return;
-
- t = *tp;
- type = TREE_TYPE (t);
-
- if (type == error_mark_node)
- return;
-
- size = TYPE_SIZE_UNIT (type);
-
- switch (TREE_CODE (t))
- {
- case ARRAY_REF:
- case COMPONENT_REF:
- {
- /* This is trickier than it may first appear. The reason is
- that we are looking at expressions from the "inside out" at
- this point. We may have a complex nested aggregate/array
- expression (e.g. "a.b[i].c"), maybe with an indirection as
- the leftmost operator ("p->a.b.d"), where instrumentation
- is necessary. Or we may have an innocent "a.b.c"
- expression that must not be instrumented. We need to
- recurse all the way down the nesting structure to figure it
- out: looking just at the outer node is not enough. */
- tree var;
- int component_ref_only = (TREE_CODE (t) == COMPONENT_REF);
- /* If we have a bitfield component reference, we must note the
- innermost addressable object in ELT, from which we will
- construct the byte-addressable bounds of the bitfield. */
- tree elt = NULL_TREE;
- int bitfield_ref_p = (TREE_CODE (t) == COMPONENT_REF
- && DECL_BIT_FIELD_TYPE (TREE_OPERAND (t, 1)));
-
- /* Iterate to the top of the ARRAY_REF/COMPONENT_REF
- containment hierarchy to find the outermost VAR_DECL. */
- var = TREE_OPERAND (t, 0);
- while (1)
- {
- if (bitfield_ref_p && elt == NULL_TREE
- && (TREE_CODE (var) == ARRAY_REF
- || TREE_CODE (var) == COMPONENT_REF))
- elt = var;
-
- if (TREE_CODE (var) == ARRAY_REF)
- {
- component_ref_only = 0;
- var = TREE_OPERAND (var, 0);
- }
- else if (TREE_CODE (var) == COMPONENT_REF)
- var = TREE_OPERAND (var, 0);
- else if (INDIRECT_REF_P (var)
- || TREE_CODE (var) == MEM_REF)
- {
- base = TREE_OPERAND (var, 0);
- break;
- }
- else if (TREE_CODE (var) == VIEW_CONVERT_EXPR)
- {
- var = TREE_OPERAND (var, 0);
- if (CONSTANT_CLASS_P (var)
- && TREE_CODE (var) != STRING_CST)
- return;
- }
- else
- {
- gcc_assert (TREE_CODE (var) == VAR_DECL
- || TREE_CODE (var) == PARM_DECL
- || TREE_CODE (var) == RESULT_DECL
- || TREE_CODE (var) == STRING_CST);
- /* Don't instrument this access if the underlying
- variable is not "eligible". This test matches
- those arrays that have only known-valid indexes,
- and thus are not labeled TREE_ADDRESSABLE. */
- if (! mf_decl_eligible_p (var) || component_ref_only)
- return;
- else
- {
- base = build1 (ADDR_EXPR,
- build_pointer_type (TREE_TYPE (var)), var);
- break;
- }
- }
- }
-
- /* Handle the case of ordinary non-indirection structure
- accesses. These have only nested COMPONENT_REF nodes (no
- INDIRECT_REF), but pass through the above filter loop.
- Note that it's possible for such a struct variable to match
- the eligible_p test because someone else might take its
- address sometime. */
-
- /* We need special processing for bitfield components, because
- their addresses cannot be taken. */
- if (bitfield_ref_p)
- {
- tree field = TREE_OPERAND (t, 1);
-
- if (TREE_CODE (DECL_SIZE_UNIT (field)) == INTEGER_CST)
- size = DECL_SIZE_UNIT (field);
-
- if (elt)
- elt = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (elt)),
- elt);
- addr = fold_convert_loc (location, ptr_type_node, elt ? elt : base);
- addr = fold_build_pointer_plus_loc (location,
- addr, byte_position (field));
- }
- else
- addr = build1 (ADDR_EXPR, build_pointer_type (type), t);
-
- limit = fold_build2_loc (location, MINUS_EXPR, mf_uintptr_type,
- fold_build2_loc (location, PLUS_EXPR, mf_uintptr_type,
- fold_convert (mf_uintptr_type, addr),
- size),
- integer_one_node);
- }
- break;
-
- case INDIRECT_REF:
- addr = TREE_OPERAND (t, 0);
- base = addr;
- limit = fold_build_pointer_plus_hwi_loc
- (location, fold_build_pointer_plus_loc (location, base, size), -1);
- break;
-
- case MEM_REF:
- if (addr_expr_of_non_mem_decl_p (TREE_OPERAND (t, 0)))
- return;
-
- addr = fold_build_pointer_plus_loc (location, TREE_OPERAND (t, 0),
- TREE_OPERAND (t, 1));
- base = addr;
- limit = fold_build_pointer_plus_hwi_loc (location,
- fold_build_pointer_plus_loc (location,
- base, size), -1);
- break;
-
- case TARGET_MEM_REF:
- if (addr_expr_of_non_mem_decl_p (TMR_BASE (t)))
- return;
-
- addr = tree_mem_ref_addr (ptr_type_node, t);
- base = addr;
- limit = fold_build_pointer_plus_hwi_loc (location,
- fold_build_pointer_plus_loc (location,
- base, size), -1);
- break;
-
- case ARRAY_RANGE_REF:
- warning (OPT_Wmudflap,
- "mudflap checking not yet implemented for ARRAY_RANGE_REF");
- return;
-
- case BIT_FIELD_REF:
- /* ??? merge with COMPONENT_REF code above? */
- {
- tree ofs, rem, bpu;
-
- /* If we're not dereferencing something, then the access
- must be ok. */
- if (TREE_CODE (TREE_OPERAND (t, 0)) != INDIRECT_REF)
- return;
-
- bpu = bitsize_int (BITS_PER_UNIT);
- ofs = fold_convert (bitsizetype, TREE_OPERAND (t, 2));
- rem = size_binop_loc (location, TRUNC_MOD_EXPR, ofs, bpu);
- ofs = size_binop_loc (location, TRUNC_DIV_EXPR, ofs, bpu);
-
- size = fold_convert (bitsizetype, TREE_OPERAND (t, 1));
- size = size_binop_loc (location, PLUS_EXPR, size, rem);
- size = size_binop_loc (location, CEIL_DIV_EXPR, size, bpu);
- size = fold_convert (sizetype, size);
-
- addr = TREE_OPERAND (TREE_OPERAND (t, 0), 0);
- addr = fold_convert (ptr_type_node, addr);
- addr = fold_build_pointer_plus_loc (location, addr, ofs);
-
- base = addr;
- limit = fold_build_pointer_plus_hwi_loc (location,
- fold_build_pointer_plus_loc (location,
- base, size), -1);
- }
- break;
-
- default:
- return;
- }
-
- mf_build_check_statement_for (base, limit, iter, location, dirflag);
-}
-/* Transform
- 1) Memory references.
-*/
-static void
-mf_xform_statements (void)
-{
- basic_block bb, next;
- gimple_stmt_iterator i;
- int saved_last_basic_block = last_basic_block;
- enum gimple_rhs_class grhs_class;
-
- bb = ENTRY_BLOCK_PTR ->next_bb;
- do
- {
- next = bb->next_bb;
- for (i = gsi_start_bb (bb); !gsi_end_p (i); gsi_next (&i))
- {
- gimple s = gsi_stmt (i);
-
- /* Only a few GIMPLE statements can reference memory. */
- switch (gimple_code (s))
- {
- case GIMPLE_ASSIGN:
- mf_xform_derefs_1 (&i, gimple_assign_lhs_ptr (s),
- gimple_location (s), integer_one_node);
- mf_xform_derefs_1 (&i, gimple_assign_rhs1_ptr (s),
- gimple_location (s), integer_zero_node);
- grhs_class = get_gimple_rhs_class (gimple_assign_rhs_code (s));
- if (grhs_class == GIMPLE_BINARY_RHS)
- mf_xform_derefs_1 (&i, gimple_assign_rhs2_ptr (s),
- gimple_location (s), integer_zero_node);
- break;
-
- case GIMPLE_RETURN:
- if (gimple_return_retval (s) != NULL_TREE)
- {
- mf_xform_derefs_1 (&i, gimple_return_retval_ptr (s),
- gimple_location (s),
- integer_zero_node);
- }
- break;
-
- default:
- ;
- }
- }
- bb = next;
- }
- while (bb && bb->index <= saved_last_basic_block);
-}
-
-/* ------------------------------------------------------------------------ */
-/* ADDR_EXPR transforms. Perform the declaration-related mudflap tree
- transforms on the current function.
-
- This is the first part of the mudflap instrumentation. It works on
- high-level GIMPLE because after lowering, all variables are moved out
- of their BIND_EXPR binding context, and we lose liveness information
- for the declarations we wish to instrument. */
-
-static unsigned int
-execute_mudflap_function_decls (void)
-{
- struct gimplify_ctx gctx;
-
- /* Don't instrument functions such as the synthetic constructor
- built during mudflap_finish_file. */
- if (mf_marked_p (current_function_decl)
- || mf_artificial (current_function_decl))
- return 0;
-
- push_gimplify_context (&gctx);
-
- mf_xform_decls (gimple_body (current_function_decl),
- DECL_ARGUMENTS (current_function_decl));
-
- pop_gimplify_context (NULL);
- return 0;
-}
-
-/* This struct is passed between mf_xform_decls to store state needed
- during the traversal searching for objects that have their
- addresses taken. */
-struct mf_xform_decls_data
-{
- tree param_decls;
-};
-
-
-/* Synthesize a CALL_EXPR and a TRY_FINALLY_EXPR, for this chain of
- _DECLs if appropriate. Arrange to call the __mf_register function
- now, and the __mf_unregister function later for each. Return the
- gimple sequence after synthesis. */
-gimple_seq
-mx_register_decls (tree decl, gimple_seq seq, location_t location)
-{
- gimple_seq finally_stmts = NULL;
- gimple_stmt_iterator initially_stmts = gsi_start (seq);
-
- while (decl != NULL_TREE)
- {
- if (mf_decl_eligible_p (decl)
- /* Not already processed. */
- && ! mf_marked_p (decl)
- /* Automatic variable. */
- && ! DECL_EXTERNAL (decl)
- && ! TREE_STATIC (decl))
- {
- tree size = NULL_TREE, variable_name;
- gimple unregister_fncall, register_fncall;
- tree unregister_fncall_param, register_fncall_param;
-
- /* Variable-sized objects should have sizes already been
- gimplified when we got here. */
- size = fold_convert (size_type_node,
- TYPE_SIZE_UNIT (TREE_TYPE (decl)));
- gcc_assert (is_gimple_val (size));
-
-
- unregister_fncall_param =
- mf_mark (build1 (ADDR_EXPR,
- build_pointer_type (TREE_TYPE (decl)),
- decl));
- /* __mf_unregister (&VARIABLE, sizeof (VARIABLE), __MF_TYPE_STACK) */
- unregister_fncall = gimple_build_call (mf_unregister_fndecl, 3,
- unregister_fncall_param,
- size,
- integer_three_node);
-
-
- variable_name = mf_varname_tree (decl);
- register_fncall_param =
- mf_mark (build1 (ADDR_EXPR,
- build_pointer_type (TREE_TYPE (decl)),
- decl));
- /* __mf_register (&VARIABLE, sizeof (VARIABLE), __MF_TYPE_STACK,
- "name") */
- register_fncall = gimple_build_call (mf_register_fndecl, 4,
- register_fncall_param,
- size,
- integer_three_node,
- variable_name);
-
-
- /* Accumulate the two calls. */
- gimple_set_location (register_fncall, location);
- gimple_set_location (unregister_fncall, location);
-
- /* Add the __mf_register call at the current appending point. */
- if (gsi_end_p (initially_stmts))
- {
- if (!mf_artificial (decl))
- warning (OPT_Wmudflap,
- "mudflap cannot track %qE in stub function",
- DECL_NAME (decl));
- }
- else
- {
- gsi_insert_before (&initially_stmts, register_fncall,
- GSI_SAME_STMT);
-
- /* Accumulate the FINALLY piece. */
- gimple_seq_add_stmt (&finally_stmts, unregister_fncall);
- }
- mf_mark (decl);
- }
-
- decl = DECL_CHAIN (decl);
- }
-
- /* Actually, (initially_stmts!=NULL) <=> (finally_stmts!=NULL) */
- if (finally_stmts != NULL)
- {
- gimple stmt = gimple_build_try (seq, finally_stmts, GIMPLE_TRY_FINALLY);
- gimple_seq new_seq = NULL;
-
- gimple_seq_add_stmt (&new_seq, stmt);
- return new_seq;
- }
- else
- return seq;
-}
-
-
-/* Process every variable mentioned in BIND_EXPRs. */
-static tree
-mx_xfn_xform_decls (gimple_stmt_iterator *gsi,
- bool *handled_operands_p ATTRIBUTE_UNUSED,
- struct walk_stmt_info *wi)
-{
- struct mf_xform_decls_data *d = (struct mf_xform_decls_data *) wi->info;
- gimple stmt = gsi_stmt (*gsi);
-
- switch (gimple_code (stmt))
- {
- case GIMPLE_BIND:
- {
- /* Process function parameters now (but only once). */
- if (d->param_decls)
- {
- gimple_bind_set_body (stmt,
- mx_register_decls (d->param_decls,
- gimple_bind_body (stmt),
- gimple_location (stmt)));
- d->param_decls = NULL_TREE;
- }
-
- gimple_bind_set_body (stmt,
- mx_register_decls (gimple_bind_vars (stmt),
- gimple_bind_body (stmt),
- gimple_location (stmt)));
- }
- break;
-
- default:
- break;
- }
-
- return NULL_TREE;
-}
-
-/* Perform the object lifetime tracking mudflap transform on the given function
- tree. The tree is mutated in place, with possibly copied subtree nodes.
-
- For every auto variable declared, if its address is ever taken
- within the function, then supply its lifetime to the mudflap
- runtime with the __mf_register and __mf_unregister calls.
-*/
-
-static void
-mf_xform_decls (gimple_seq fnbody, tree fnparams)
-{
- struct mf_xform_decls_data d;
- struct walk_stmt_info wi;
- struct pointer_set_t *pset = pointer_set_create ();
-
- d.param_decls = fnparams;
- memset (&wi, 0, sizeof (wi));
- wi.info = (void*) &d;
- wi.pset = pset;
- walk_gimple_seq (fnbody, mx_xfn_xform_decls, NULL, &wi);
- pointer_set_destroy (pset);
-}
-
-
-/* ------------------------------------------------------------------------ */
-/* Externally visible mudflap functions. */
-
-
-/* Mark and return the given tree node to prevent further mudflap
- transforms. */
-static GTY ((param_is (union tree_node))) htab_t marked_trees = NULL;
-
-tree
-mf_mark (tree t)
-{
- void **slot;
-
- if (marked_trees == NULL)
- marked_trees = htab_create_ggc (31, htab_hash_pointer, htab_eq_pointer,
- NULL);
-
- slot = htab_find_slot (marked_trees, t, INSERT);
- *slot = t;
- return t;
-}
-
-int
-mf_marked_p (tree t)
-{
- void *entry;
-
- if (marked_trees == NULL)
- return 0;
-
- entry = htab_find (marked_trees, t);
- return (entry != NULL);
-}
-
-/* Remember given node as a static of some kind: global data,
- function-scope static, or an anonymous constant. Its assembler
- label is given. */
-
-/* A list of globals whose incomplete declarations we encountered.
- Instead of emitting the __mf_register call for them here, it's
- delayed until program finish time. If they're still incomplete by
- then, warnings are emitted. */
-
-static GTY (()) vec<tree, va_gc> *deferred_static_decls;
-
-/* A list of statements for calling __mf_register() at startup time. */
-static GTY (()) tree enqueued_call_stmt_chain;
-
-static void
-mudflap_register_call (tree obj, tree object_size, tree varname)
-{
- tree arg, call_stmt;
-
- arg = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (obj)), obj);
- arg = fold_convert (ptr_type_node, arg);
-
- call_stmt = build_call_expr (mf_register_fndecl, 4,
- arg,
- fold_convert (size_type_node, object_size),
- /* __MF_TYPE_STATIC */
- build_int_cst (integer_type_node, 4),
- varname);
-
- append_to_statement_list (call_stmt, &enqueued_call_stmt_chain);
-}
-
-void
-mudflap_enqueue_decl (tree obj)
-{
- if (mf_marked_p (obj))
- return;
-
- /* We don't need to process variable decls that are internally
- generated extern. If we did, we'd end up with warnings for them
- during mudflap_finish_file (). That would confuse the user,
- since the text would refer to variables that don't show up in the
- user's source code. */
- if (DECL_P (obj) && DECL_EXTERNAL (obj) && mf_artificial (obj))
- return;
-
- vec_safe_push (deferred_static_decls, obj);
-}
-
-
-void
-mudflap_enqueue_constant (tree obj)
-{
- tree object_size, varname;
-
- if (mf_marked_p (obj))
- return;
-
- if (TREE_CODE (obj) == STRING_CST)
- object_size = size_int (TREE_STRING_LENGTH (obj));
- else
- object_size = size_in_bytes (TREE_TYPE (obj));
-
- if (TREE_CODE (obj) == STRING_CST)
- varname = mf_build_string ("string literal");
- else
- varname = mf_build_string ("constant");
-
- mudflap_register_call (obj, object_size, varname);
-}
-
-
-/* Emit any file-wide instrumentation. */
-void
-mudflap_finish_file (void)
-{
- tree ctor_statements = NULL_TREE;
-
- /* No need to continue when there were errors. */
- if (seen_error ())
- return;
-
- /* Insert a call to __mf_init. */
- {
- tree call2_stmt = build_call_expr (mf_init_fndecl, 0);
- append_to_statement_list (call2_stmt, &ctor_statements);
- }
-
- /* If appropriate, call __mf_set_options to pass along read-ignore mode. */
- if (flag_mudflap_ignore_reads)
- {
- tree arg = mf_build_string ("-ignore-reads");
- tree call_stmt = build_call_expr (mf_set_options_fndecl, 1, arg);
- append_to_statement_list (call_stmt, &ctor_statements);
- }
-
- /* Process all enqueued object decls. */
- if (deferred_static_decls)
- {
- size_t i;
- tree obj;
- FOR_EACH_VEC_ELT (*deferred_static_decls, i, obj)
- {
- gcc_assert (DECL_P (obj));
-
- if (mf_marked_p (obj))
- continue;
-
- /* Omit registration for static unaddressed objects. NB:
- Perform registration for non-static objects regardless of
- TREE_USED or TREE_ADDRESSABLE, because they may be used
- from other compilation units. */
- if (! TREE_PUBLIC (obj) && ! TREE_ADDRESSABLE (obj))
- continue;
-
- /* If we're neither emitting nor referencing the symbol,
- don't register it. We have to register external symbols
- if they happen to be in other files not compiled with
- mudflap (say system libraries), and we must not register
- internal symbols that we don't emit or they'll become
- dangling references or force symbols to be emitted that
- didn't have to. */
- if (!symtab_get_node (obj))
- continue;
-
- if (! COMPLETE_TYPE_P (TREE_TYPE (obj)))
- {
- warning (OPT_Wmudflap,
- "mudflap cannot track unknown size extern %qE",
- DECL_NAME (obj));
- continue;
- }
-
- mudflap_register_call (obj,
- size_in_bytes (TREE_TYPE (obj)),
- mf_varname_tree (obj));
- }
-
- deferred_static_decls->truncate (0);
- }
-
- /* Append all the enqueued registration calls. */
- if (enqueued_call_stmt_chain)
- {
- append_to_statement_list (enqueued_call_stmt_chain, &ctor_statements);
- enqueued_call_stmt_chain = NULL_TREE;
- }
-
- cgraph_build_static_cdtor ('I', ctor_statements,
- MAX_RESERVED_INIT_PRIORITY-1);
-}
-
-
-static bool
-gate_mudflap (void)
-{
- return flag_mudflap != 0;
-}
-
-namespace {
-
-const pass_data pass_data_mudflap_1 =
-{
- GIMPLE_PASS, /* type */
- "mudflap1", /* name */
- OPTGROUP_NONE, /* optinfo_flags */
- true, /* has_gate */
- true, /* has_execute */
- TV_NONE, /* tv_id */
- PROP_gimple_any, /* properties_required */
- 0, /* properties_provided */
- 0, /* properties_destroyed */
- 0, /* todo_flags_start */
- 0, /* todo_flags_finish */
-};
-
-class pass_mudflap_1 : public gimple_opt_pass
-{
-public:
- pass_mudflap_1 (gcc::context *ctxt)
- : gimple_opt_pass (pass_data_mudflap_1, ctxt)
- {}
-
- /* opt_pass methods: */
- bool gate () { return gate_mudflap (); }
- unsigned int execute () { return execute_mudflap_function_decls (); }
-
-}; // class pass_mudflap_1
-
-} // anon namespace
-
-gimple_opt_pass *
-make_pass_mudflap_1 (gcc::context *ctxt)
-{
- return new pass_mudflap_1 (ctxt);
-}
-
-namespace {
-
-const pass_data pass_data_mudflap_2 =
-{
- GIMPLE_PASS, /* type */
- "mudflap2", /* name */
- OPTGROUP_NONE, /* optinfo_flags */
- true, /* has_gate */
- true, /* has_execute */
- TV_NONE, /* tv_id */
- ( PROP_ssa | PROP_cfg | PROP_gimple_leh ), /* properties_required */
- 0, /* properties_provided */
- 0, /* properties_destroyed */
- 0, /* todo_flags_start */
- ( TODO_verify_flow | TODO_verify_stmts
- | TODO_update_ssa ), /* todo_flags_finish */
-};
-
-class pass_mudflap_2 : public gimple_opt_pass
-{
-public:
- pass_mudflap_2 (gcc::context *ctxt)
- : gimple_opt_pass (pass_data_mudflap_2, ctxt)
- {}
-
- /* opt_pass methods: */
- bool gate () { return gate_mudflap (); }
- unsigned int execute () { return execute_mudflap_function_ops (); }
-
-}; // class pass_mudflap_2
-
-} // anon namespace
-
-gimple_opt_pass *
-make_pass_mudflap_2 (gcc::context *ctxt)
-{
- return new pass_mudflap_2 (ctxt);
-}
-
-#include "gt-tree-mudflap.h"
diff --git a/gcc/tree-mudflap.h b/gcc/tree-mudflap.h
deleted file mode 100644
index 96f38c4..0000000
--- a/gcc/tree-mudflap.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/* Mudflap: narrow-pointer bounds-checking by tree rewriting.
- Copyright (C) 2001-2013 Free Software Foundation, Inc.
- Contributed by Frank Ch. Eigler <fche@redhat.com>
-
-This file is part of GCC.
-
-GCC is free software; you can redistribute it and/or modify it under
-the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 3, or (at your option) any later
-version.
-
-GCC is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-for more details.
-
-You should have received a copy of the GNU General Public License
-along with GCC; see the file COPYING3. If not see
-<http://www.gnu.org/licenses/>. */
-
-#ifndef TREE_MUDFLAP_H
-#define TREE_MUDFLAP_H
-
-/* Instrumentation. */
-extern void mudflap_init (void);
-extern void mudflap_enqueue_decl (tree);
-extern void mudflap_enqueue_constant (tree);
-extern void mudflap_finish_file (void);
-
-/* Tree node marking. */
-extern int mf_marked_p (tree);
-extern tree mf_mark (tree);
-
-#endif /* TREE_MUDFLAP_H */
diff --git a/gcc/tree-nomudflap.c b/gcc/tree-nomudflap.c
deleted file mode 100644
index fe9ea60..0000000
--- a/gcc/tree-nomudflap.c
+++ /dev/null
@@ -1,169 +0,0 @@
-/* Mudflap: narrow-pointer bounds-checking by tree rewriting.
- Copyright (C) 2001-2013 Free Software Foundation, Inc.
- Contributed by Frank Ch. Eigler <fche@redhat.com>
-
-This file is part of GCC.
-
-GCC is free software; you can redistribute it and/or modify it under
-the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 3, or (at your option) any later
-version.
-
-GCC is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-for more details.
-
-You should have received a copy of the GNU General Public License
-along with GCC; see the file COPYING3. If not see
-<http://www.gnu.org/licenses/>. */
-
-
-#include "config.h"
-#include "system.h"
-#include "coretypes.h"
-#include "tm.h"
-#include "tree.h"
-#include "tree-inline.h"
-#include "gimple.h"
-#include "hashtab.h"
-#include "langhooks.h"
-#include "tree-mudflap.h"
-#include "tree-pass.h"
-#include "ggc.h"
-#include "diagnostic-core.h"
-
-
-
-/* This file contains placeholder functions, to be used only for
- language processors that cannot handle tree-mudflap.c directly.
- (e.g. Fortran). */
-
-static void
-nogo (void)
-{
- sorry ("mudflap: this language is not supported");
-}
-
-void
-mudflap_enqueue_decl (tree obj ATTRIBUTE_UNUSED)
-{
- nogo ();
-}
-
-void
-mudflap_enqueue_constant (tree obj ATTRIBUTE_UNUSED)
-{
- nogo ();
-}
-
-void
-mudflap_finish_file (void)
-{
- nogo ();
-}
-
-int
-mf_marked_p (tree t ATTRIBUTE_UNUSED)
-{
- nogo ();
- return 0;
-}
-
-tree
-mf_mark (tree t ATTRIBUTE_UNUSED)
-{
- nogo ();
- return NULL;
-}
-
-/* The pass structures must exist, but need not do anything. */
-
-static bool
-gate_mudflap (void)
-{
- return flag_mudflap != 0;
-}
-
-namespace {
-
-const pass_data pass_data_mudflap_1 =
-{
- GIMPLE_PASS, /* type */
- "mudflap1", /* name */
- OPTGROUP_NONE, /* optinfo_flags */
- true, /* has_gate */
- false, /* has_execute */
- TV_NONE, /* tv_id */
- 0, /* properties_required */
- 0, /* properties_provided */
- 0, /* properties_destroyed */
- 0, /* todo_flags_start */
- 0, /* todo_flags_finish */
-};
-
-class pass_mudflap_1 : public gimple_opt_pass
-{
-public:
- pass_mudflap_1 (gcc::context *ctxt)
- : gimple_opt_pass (pass_data_mudflap_1, ctxt)
- {}
-
- /* opt_pass methods: */
- bool gate () { return gate_mudflap (); }
-
-}; // class pass_mudflap_1
-
-} // anon namespace
-
-gimple_opt_pass *
-make_pass_mudflap_1 (gcc::context *ctxt)
-{
- return new pass_mudflap_1 (ctxt);
-}
-
-namespace {
-
-const pass_data pass_data_mudflap_2 =
-{
- GIMPLE_PASS, /* type */
- "mudflap2", /* name */
- OPTGROUP_NONE, /* optinfo_flags */
- true, /* has_gate */
- false, /* has_execute */
- TV_NONE, /* tv_id */
- 0, /* properties_required */
- 0, /* properties_provided */
- 0, /* properties_destroyed */
- 0, /* todo_flags_start */
- 0, /* todo_flags_finish */
-};
-
-class pass_mudflap_2 : public gimple_opt_pass
-{
-public:
- pass_mudflap_2 (gcc::context *ctxt)
- : gimple_opt_pass (pass_data_mudflap_2, ctxt)
- {}
-
- /* opt_pass methods: */
- bool gate () { return gate_mudflap (); }
-
-}; // class pass_mudflap_2
-
-} // anon namespace
-
-gimple_opt_pass *
-make_pass_mudflap_2 (gcc::context *ctxt)
-{
- return new pass_mudflap_2 (ctxt);
-}
-
-/* Instead of:
-#include "gt-tree-mudflap.h"
-We prepare a little dummy struct here.
-*/
-
-EXPORTED_CONST struct ggc_root_tab gt_ggc_r_gt_tree_mudflap_h[] = {
- LAST_GGC_ROOT_TAB
-};
diff --git a/gcc/tree-pass.h b/gcc/tree-pass.h
index e72fe9a..5237438 100644
--- a/gcc/tree-pass.h
+++ b/gcc/tree-pass.h
@@ -338,8 +338,6 @@ extern void register_pass (register_pass_info *);
extern void register_pass (opt_pass* pass, pass_positioning_ops pos,
const char* ref_pass_name, int ref_pass_inst_number);
-extern gimple_opt_pass *make_pass_mudflap_1 (gcc::context *ctxt);
-extern gimple_opt_pass *make_pass_mudflap_2 (gcc::context *ctxt);
extern gimple_opt_pass *make_pass_asan (gcc::context *ctxt);
extern gimple_opt_pass *make_pass_asan_O0 (gcc::context *ctxt);
extern gimple_opt_pass *make_pass_tsan (gcc::context *ctxt);
diff --git a/gcc/varasm.c b/gcc/varasm.c
index 52ba182..e56ca1b 100644
--- a/gcc/varasm.c
+++ b/gcc/varasm.c
@@ -46,7 +46,6 @@ along with GCC; see the file COPYING3. If not see
#include "target.h"
#include "common/common-target.h"
#include "targhooks.h"
-#include "tree-mudflap.h"
#include "cgraph.h"
#include "pointer-set.h"
#include "asan.h"
@@ -1247,10 +1246,6 @@ make_decl_rtl (tree decl)
&& SYMBOL_REF_HAS_BLOCK_INFO_P (XEXP (x, 0)))
change_symbol_block (XEXP (x, 0), get_block_for_decl (decl));
- /* Make this function static known to the mudflap runtime. */
- if (flag_mudflap && TREE_CODE (decl) == VAR_DECL)
- mudflap_enqueue_decl (decl);
-
return;
}
@@ -1387,10 +1382,6 @@ make_decl_rtl (tree decl)
If the name is changed, the macro ASM_OUTPUT_LABELREF
will have to know how to strip this information. */
targetm.encode_section_info (decl, DECL_RTL (decl), true);
-
- /* Make this function static known to the mudflap runtime. */
- if (flag_mudflap && TREE_CODE (decl) == VAR_DECL)
- mudflap_enqueue_decl (decl);
}
/* Like make_decl_rtl, but inhibit creation of new alias sets when
@@ -1400,7 +1391,7 @@ make_decl_rtl (tree decl)
rtx
make_decl_rtl_for_debug (tree decl)
{
- unsigned int save_aliasing_flag, save_mudflap_flag;
+ unsigned int save_aliasing_flag;
rtx rtl;
if (DECL_RTL_SET_P (decl))
@@ -1411,12 +1402,9 @@ make_decl_rtl_for_debug (tree decl)
we do not want to create alias sets that will throw the alias
numbers off in the comparison dumps. So... clearing
flag_strict_aliasing will keep new_alias_set() from creating a
- new set. It is undesirable to register decl with mudflap
- in this case as well. */
+ new set. */
save_aliasing_flag = flag_strict_aliasing;
flag_strict_aliasing = 0;
- save_mudflap_flag = flag_mudflap;
- flag_mudflap = 0;
rtl = DECL_RTL (decl);
/* Reset DECL_RTL back, as various parts of the compiler expects
@@ -1424,8 +1412,6 @@ make_decl_rtl_for_debug (tree decl)
SET_DECL_RTL (decl, NULL);
flag_strict_aliasing = save_aliasing_flag;
- flag_mudflap = save_mudflap_flag;
-
return rtl;
}
@@ -3206,10 +3192,6 @@ build_constant_desc (tree exp)
desc = ggc_alloc_constant_descriptor_tree ();
desc->value = copy_constant (exp);
- /* Propagate marked-ness to copied constant. */
- if (flag_mudflap && mf_marked_p (exp))
- mf_mark (desc->value);
-
/* Create a string containing the label name, in LABEL. */
labelno = const_labelno++;
ASM_GENERATE_INTERNAL_LABEL (label, "LC", labelno);
@@ -3405,8 +3387,6 @@ output_constant_def_contents (rtx symbol)
assemble_zeros (asan_red_zone_size (size));
}
}
- if (flag_mudflap)
- mudflap_enqueue_constant (exp);
}
/* Look up EXP in the table of constant descriptors. Return the rtl
@@ -6294,9 +6274,8 @@ categorize_decl_for_section (const_tree decl, int reloc)
return SECCAT_TEXT;
else if (TREE_CODE (decl) == STRING_CST)
{
- if (flag_mudflap
- || ((flag_sanitize & SANITIZE_ADDRESS)
- && asan_protect_global (CONST_CAST_TREE (decl))))
+ if ((flag_sanitize & SANITIZE_ADDRESS)
+ && asan_protect_global (CONST_CAST_TREE (decl)))
/* or !flag_merge_constants */
return SECCAT_RODATA;
else
@@ -6321,7 +6300,7 @@ categorize_decl_for_section (const_tree decl, int reloc)
}
else if (reloc & targetm.asm_out.reloc_rw_mask ())
ret = reloc == 1 ? SECCAT_DATA_REL_RO_LOCAL : SECCAT_DATA_REL_RO;
- else if (reloc || flag_merge_constants < 2 || flag_mudflap
+ else if (reloc || flag_merge_constants < 2
|| ((flag_sanitize & SANITIZE_ADDRESS)
&& asan_protect_global (CONST_CAST_TREE (decl))))
/* C and C++ don't allow different variables to share the same