Would gatekeeper help review this patch?

https://bugs.open64.net/show_bug.cgi?id=768
Nystrom alias issue: sig fualt in ipa_link when connecting parameters
See bugzilla for test case and compliation command line.

function _ZNV2c52f7Ez c5::f7(...) volatile is defined in both
alias_vararg1.c and alias_vararg2.cpp
In alias_vararg1.c its doesn't have any parameter.
In alias_vararg2.cpp, it is a vararg method.
In ipa_link, symbol resolution pick up function defined in alias_vararg1.c.
However in TY_merge, second function's TY flag TY_is_varargs is merged to
first function's TY.

ConstraintGraph::connect is adding edge from actual constraint graph node to
formal constraint graph node.
1. match actual and fromals one by one.
2. if actual is more than formal and callee is a vararg function (from its
TY)
    extra actual will have copy edge to callee's last formal constraint
graph node.
    callee's last formal constraint graph node is assumed to be a special
_varArgs constraint graph node when callee is vararg function.
    Because in ConstraintGraph::buildCG(WN *entryWN), it will add
_varArgs constraint
graph node at the end of constraint graph build.

In this case, the problem is after symbol resolution and type merge,
function is vararg however it doesn't have varArgs formal constraint graph
node which violate current assumpation in ConstraintGraph::connect.

Fix is in ConstraintGraph::connect

1. If last_formal cg node is NULL, don't connect remaining actual nodes with
last_formal cg node.

    This is safe, last_formal cg node is NULL means callee has no formal and
is actually not vararg, its vararg flag comes form type merge.

   callee doesn't use any actual's cg node's points to info, because actual
is not used in callee.

2. Another fix is, when callee's last formal constraint graph node is not
vararg (cg node's ST info has no flag CG_ST_FLAGS_VARARGS).

   This also means callee's TY flag TY_is_varargs comes from IPA type merge.
callee itself is not vararg function.

    Don't connect extra actual cg node to last formal cg node in this case.

Index: osprey/ipa/main/analyze/ipa_nystrom_alias_analyzer.cxx
===================================================================
--- osprey/ipa/main/analyze/ipa_nystrom_alias_analyzer.cxx      (revision
3575)
+++ osprey/ipa/main/analyze/ipa_nystrom_alias_analyzer.cxx      (working
copy)
@@ -1797,13 +1797,14 @@
   // If we have more actuals than formals either we either have a
   // signature mismatch or varargs.  For now we don't worry about
   // the other mismatch cases.
-  if (actualIter != cs->parms().end() &&
+  // It is possible lastFormal is NULL, and PU is vararg.
+  // When PU is a merged result (merge vararg PU into a non vararg PU).
+  // It's safe to not add any points to to callee, no actual param usage.
+  if (lastFormal != NULL && actualIter != cs->parms().end() &&
       formalIter == callee->parameters().end() &&
-      TY_is_varargs(ST_pu_type(calleeST))) {
+      TY_is_varargs(ST_pu_type(calleeST)) &&
+      lastFormal->stInfo()->checkFlags(CG_ST_FLAGS_VARARGS)) {
     // Hook up remaining actuals to the "varargs" node
-    FmtAssert(callee->stInfo(lastFormal->cg_st_idx())
-                  ->checkFlags(CG_ST_FLAGS_VARARGS),
-                  ("Expect last formal to be varargs!\n"));
     for ( ; actualIter != cs->parms().end(); ++actualIter) {
       ConstraintGraphNode *actual = cgNode(*actualIter);
       if (actual->checkFlags(CG_NODE_FLAGS_NOT_POINTER))


Regards
Shi Hui
------------------------------------------------------------------------------
WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network 
management toolset available today.  Delivers lowest initial 
acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd
_______________________________________________
Open64-devel mailing list
Open64-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/open64-devel

Reply via email to