Hi,
​
We, ByteDance, have seen an ICE on trunk which can be reproduced with the
following symbol testcase. The problem is caused by referencing a null
pointer when applying 'n_basic_blocks_for_fn' on a thunk symbol. For the
thunk symbol, 'DECL_STRUCT_FUNCTION (cnode->decl)' will return an empty
pointer.
​
class Base {
public :
    virtual void f() {}
private:
    long x;
};
class Derived : public virtual Base {
public:
    virtual void f() {}
private:
    long y;
};
int main() {
    Derived d;
}
​
I have fixed it by adding more guard conditions and tested it with
ByteDance internal workloads.

2020-05-21 Wang Liushuai <wangliush...@bytedance.com>

gcc/lto/ChangeLog:

        * lto-dump.c (get_size): Fix the NPD error about the thunk symbol.
​
>From ce3faba067e4b911bfdafa486b1bb4258272b650 Mon Sep 17 00:00:00 2001
From: wangliushuai <wangliush...@bytedance.com>
Date: Fri, 21 May 2021 16:59:51 +0800
Subject: [PATCH] Do not load the thunk symbols.

---
 gcc/lto/lto-dump.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/lto/lto-dump.c b/gcc/lto/lto-dump.c
index 8344d3e1737..3586e208f9a 100644
--- a/gcc/lto/lto-dump.c
+++ b/gcc/lto/lto-dump.c
@@ -122,7 +122,7 @@ public:
     cgraph_node *cnode = dyn_cast<cgraph_node *> (node);
     gcc_assert (cnode);

-    return (cnode->definition && !cnode->alias)
+    return (cnode->definition && !cnode->thunk && !cnode->alias)
      ? n_basic_blocks_for_fn (DECL_STRUCT_FUNCTION (cnode->decl))
      : 0;
   }
--
2.29.2

Reply via email to