This fixes PR64059 where a call to get_dynamic_type wasn't guarded by flag_devirtualize.
Tested on powerpc64-unknown-linux-gnu. Preapproved by Honza on bugzilla. Commited to trunk. PR ipa/64059 * ipa-prop.c (ipa_analyze_call_uses): Don't call get_dynamic_type when devirtualization is disabled. PR ipa/64059 * g++.dg/ipa/pr64059.C: New test. diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c index 2e0016bfbe66..eeffda449d9b 100644 --- a/gcc/ipa-prop.c +++ b/gcc/ipa-prop.c @@ -2155,7 +2155,7 @@ ipa_analyze_call_uses (struct func_body_info *fbi, gcall *call) if (cs && !cs->indirect_unknown_callee) return; - if (cs->indirect_info->polymorphic) + if (cs->indirect_info->polymorphic && flag_devirtualize) { tree instance; tree target = gimple_call_fn (call); diff --git a/gcc/testsuite/g++.dg/ipa/pr64059.C b/gcc/testsuite/g++.dg/ipa/pr64059.C new file mode 100644 index 000000000000..0269b45458d9 --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/pr64059.C @@ -0,0 +1,56 @@ +// { dg-options "-r -nostdlib -O2 -flto -fno-devirtualize" } +// { dg-require-effective-target lto } + +class A; +class B +{ +public: + A *operator->(); +}; +class C +{ +public: + virtual void m_fn1 (); +}; +class A +{ +public: + C *m_fn2 (); +}; +class D +{ +public: + void + m_fn3 () + { + list_m->m_fn2 ()->m_fn1 (); + } + B list_m; +}; + +class F +{ +public: + D m_fn4 (); +}; +class G +{ +public: + F m_fn5 (int, int); +}; +class H +{ +public: + void + m_fn6 () + { + fieldEngine_m.m_fn5 (0, 0).m_fn4 ().m_fn3 (); + } + G fieldEngine_m; +}; + +void +fn1 (H a) +{ + a.m_fn6 (); +} -- 2.1.3 -- Markus