[llvm-commits] [llvm-gcc] Patch needed?

Reid Spencer rspencer at reidspencer.com
Sun Feb 18 12:14:34 PST 2007


Chris,

On Sun, 2007-02-18 at 11:57 -0800, Chris Lattner wrote:
> On Feb 18, 2007, at 12:03 AM, Reid Spencer wrote:
> 
> > Hi,
> >
> > I found a situation where the following patch is needed. Building
> > llvm-gcc head (with cummulative patch) fails with SEGV while compiling
> > the libstdc++. This patch is a bandaid and I don't know if its the
> > correct thing or not as TYPE_SIZE(Type) should probably not be  
> > null, but
> > it is.
> >
> > You can probably replicate this by doing a clean llvm-gcc build
> > including the latest patches.
> 
> Very strange, maybe it just hasn't hit the mirror yet, but mainline  
> already has that:
> 
> bool isPassedByInvisibleReference(tree Type) {
>    // FIXME: Search for TREE_ADDRESSABLE in calls.c, and see if there  
> are other
>    // cases that make arguments automatically passed in by reference.
>    return TREE_ADDRESSABLE(Type) || TREE_CODE(TYPE_SIZE(Type)) !=  
> INTEGER_CST;
> }

The mirror doesn't have (last time I checked) the second term of that
expression. However, if you note my patch below, I changed the second
term from:

TREE_CODE(TYPE_SIZE(Type) != INTEGER_CST

to

(TYPE_SIZE(Type) && TREE_CODE(TYPE_SIZE(Type)) != INTEGER_CST)

the key point being that this logic needs to guard against
TYPE_SIZE(Type) == 0x0 because TREE_CODE(0) leads to SEGV.  This can and
does happen. The question is, should TYPE_SIZE(Type) be 0x0 and if not,
then it should be handled at a higher level in the logic. Note that
isPassedByInvisibleReference only has one caller in the same file.

Reid.

> 
> -Chris
> 
> > Reid.
> >
> > Index: llvm-types.cpp
> > ===================================================================
> > --- llvm-types.cpp      (revision 276)
> > +++ llvm-types.cpp      (working copy)
> > @@ -58,7 +58,7 @@
> >  // refined and replaced by another LLVM Type. This is achieved by
> > maintaining
> >  // a map.
> >
> > -// Collection of LLVM Types and their names
> > +// Collection of LLVM Types
> >  static std::vector<const Type *> LTypes;
> >  typedef DenseMap<const Type *, unsigned> LTypesMapTy;
> >  static LTypesMapTy LTypesMap;
> > @@ -212,7 +212,8 @@
> >  bool isPassedByInvisibleReference(tree Type) {
> >    // FIXME: Search for TREE_ADDRESSABLE in calls.c, and see if there
> > are other
> >    // cases that make arguments automatically passed in by reference.
> > -  return TREE_ADDRESSABLE(Type);
> > +  return TREE_ADDRESSABLE(Type) ||
> > +         (TYPE_SIZE(Type) && TREE_CODE(TYPE_SIZE(Type)) !=
> > INTEGER_CST);
> >  }
> >
> >  /// GetTypeName - Return a fully qualified (with namespace prefixes)
> > name for
> >
> >
> > _______________________________________________
> > llvm-commits mailing list
> > llvm-commits at cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
> 




More information about the llvm-commits mailing list