Hi, This patch doesn't allow instrumentation thunks calls while merging constructors and destructors. Not isntrumented code is not affeceted. Bootstrapped and tested on x86_64-unknown-linux-gnu. OK for trunk?
Thanks, Ilya -- gcc/ 2015-04-02 Ilya Enkovich <ilya.enkov...@intel.com> * ipa.c (ipa_cdtor_merge): Skip instrumentation thunks. gcc/testsuite/ 2015-04-02 Ilya Enkovich <ilya.enkov...@intel.com> * gcc.dg/lto/chkp-ctor-merge_0.c: New. diff --git a/gcc/ipa.c b/gcc/ipa.c index b3752de..84ab542 100644 --- a/gcc/ipa.c +++ b/gcc/ipa.c @@ -1159,8 +1159,10 @@ ipa_cdtor_merge (void) { struct cgraph_node *node; FOR_EACH_DEFINED_FUNCTION (node) - if (DECL_STATIC_CONSTRUCTOR (node->decl) - || DECL_STATIC_DESTRUCTOR (node->decl)) + if ((DECL_STATIC_CONSTRUCTOR (node->decl) + || DECL_STATIC_DESTRUCTOR (node->decl)) + && !(node->thunk.thunk_p + && node->thunk.add_pointer_bounds_args)) record_cdtor_fn (node); build_cdtor_fns (); static_ctors.release (); diff --git a/gcc/testsuite/gcc.dg/lto/chkp-ctor-merge_0.c b/gcc/testsuite/gcc.dg/lto/chkp-ctor-merge_0.c new file mode 100644 index 0000000..ac4095b --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/chkp-ctor-merge_0.c @@ -0,0 +1,23 @@ +/* { dg-lto-do run } */ +/* { dg-require-effective-target mpx } */ +/* { dg-lto-options { { -O2 -flto -fcheck-pointer-bounds -mmpx -nodefaultlibs -lc } } } */ + +int glob = 1; + +void __attribute__((constructor)) +ctor1 () +{ + glob += 1; +} + + +void __attribute__((constructor)) +ctor2 () +{ + glob -= 2; +} + +int main (int argc, const char **argv) +{ + return glob; +}