[LLVMbugs] ICE in LLVM GCC4 Front End

Bill Wendling isanbard at gmail.com
Mon Sep 11 21:35:30 PDT 2006


Hi,

The following program causes the LLVM GCC4 front end to ICE:

struct A {
   virtual ~A();
};

template <typename Ty>
struct B : public A {
   ~B () { delete [] val; }
private:
     Ty* val;
};

template <typename Ty>
struct C : public A {
   C ();
   ~C ();
};

template <typename Ty>
struct D : public A {
     D () {}
   private:
     B<C<Ty> > blocks;
};

template class D<double>;

I'm far from an expert on this area of the code base, so I'm  
submitting this as a proposed fix:

Index: gcc/llvm-convert.cpp
===================================================================
--- gcc/llvm-convert.cpp        (revision 166)
+++ gcc/llvm-convert.cpp        (working copy)
@@ -2189,11 +2189,13 @@
///
Value *TreeToLLVM::EmitPtrBinOp(tree exp, unsigned Opc) {
    Value *LHS = Emit(TREE_OPERAND(exp, 0), 0);
+  const Type *ElTy = cast<PointerType>(LHS->getType())- 
 >getElementType();

    // If this is an expression like (P+4), try to turn this into
    // "getelementptr P, 1".
    if ((Opc == Instruction::Add || Opc == Instruction::Sub) &&
-      TREE_CODE(TREE_OPERAND(exp, 1)) == INTEGER_CST) {
+      TREE_CODE(TREE_OPERAND(exp, 1)) == INTEGER_CST &&
+      !ElTy->isAbstract()) {
      int64_t Offset = getINTEGER_CSTVal(TREE_OPERAND(exp, 1));

      // If POINTER_SIZE is 32-bits, sign extend the offset.
@@ -2201,7 +2203,6 @@
        Offset = (Offset << 32) >> 32;

      // Figure out how large the element pointed to is.
-    const Type *ElTy = cast<PointerType>(LHS->getType())- 
 >getElementType();
      int64_t EltSize = TD.getTypeSize(ElTy);

      // If EltSize exactly divides Offset, then we know that we can  
turn this




More information about the llvm-bugs mailing list