Hi,
get_availability incorrectly return AVAIL_AVAILABLE when symbol is in other
partition but can be interposed at runtime. The problem is check for
DECL_EXTERNAL which is there to check for external inline functions (keyed to
other unit).
Bootstrapped/regtested x86_64-linux, plan to push it shortly.
Honza
PR ipa/122430
gcc/ChangeLog:
* cgraph.cc (cgraph_node::get_availability): Fix availability of
symbols in other partition.
gcc/testsuite/ChangeLog:
* gcc.dg/ipa/pr122430.c: New test.
diff --git a/gcc/cgraph.cc b/gcc/cgraph.cc
index 508a5559569..13efe89ebba 100644
--- a/gcc/cgraph.cc
+++ b/gcc/cgraph.cc
@@ -2833,7 +2833,7 @@ cgraph_node::get_availability (symtab_node *ref)
the inlinability hooks completely eliminated). */
else if (decl_replaceable_p (decl, semantic_interposition)
- && !DECL_EXTERNAL (decl))
+ && (!DECL_EXTERNAL (decl) || in_other_partition))
avail = AVAIL_INTERPOSABLE;
else avail = AVAIL_AVAILABLE;
diff --git a/gcc/testsuite/gcc.dg/ipa/pr122430.c
b/gcc/testsuite/gcc.dg/ipa/pr122430.c
new file mode 100644
index 00000000000..af1a1c4323d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/pr122430.c
@@ -0,0 +1,11 @@
+// { dg-do link }
+// { dg-options "-fpic -O2 -flto -flto-partition=max -fsemantic-interposition
-shared" }
+// { dg-require-effective-target fpic }
+// { dg-require-effective-target shared }
+// { dg-require-effective-target lto }
+void error () __attribute__ ((error ("error")));
+int g() { return 42; }
+int f() { int v = g();
+ if (__builtin_constant_p (v))
+ error ();
+}