[LLVMbugs] [Bug 19287] New: LLVM type mismatch assertion during codegen with -fdelayed-template-parsing and inalloca

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sun Mar 30 11:28:08 PDT 2014


http://llvm.org/bugs/show_bug.cgi?id=19287

            Bug ID: 19287
           Summary: LLVM type mismatch assertion during codegen with
                    -fdelayed-template-parsing and inalloca
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: LLVM Codegen
          Assignee: unassignedclangbugs at nondot.org
          Reporter: rnk at google.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

This was reduced from a clang self-host on Windows, which currently fails to
compile VariantValue.cpp.

I think the problem is that we build the inalloca type before we have complete
types for the function pointer prototype, so we get some opaque types, which we
then fail to replace or bitcast away.

The IR in the problematic constructor looks like:
define linkonce_odr x86_thiscallcc %"class.F::K"*
@"\01??0K at F@@QAE at P6A_NHPAH0V?$A at VD@@@@@ZVvector@@@Z"(%"class.F::K"* returned
%this, <{ {}*, %class.vector }>* inalloca) #0 {

And then we try to store Value to Addr:
Value   %2 = load {}** %p1, align 4
Addr   %Func2 = bitcast {}** %Func to i1 (i32, i32*, i32*, %class.A*)**

$ cat t.ii
template <class _Ty> _Ty &&move(_Ty &&);
class vector {
public:
  typedef vector;
  ~vector();
};
template <typename T> class A {
public:
  operator vector();
};
template <typename T> A<T> makeArrayRef(const T);
template <typename ResultT, typename ArgT, ResultT(A<const ArgT *>)>
struct B {};
class C {};
template <typename T> class Matcher {
public:
  Matcher(void *);
};
class D {
public:
  template <typename T> D(const Matcher<T>);
  template <typename T> Matcher<T> m_fn1() const;
};
template <typename T> class G : public Matcher<int> {
public:
  G(const Matcher &p1) : Matcher(0) {}
};
typedef bool (*VariadicOperatorFunction)(int, int *, int *, A<D>);
class H : public C {
public:
  H(VariadicOperatorFunction, vector);
};
template <typename T> Matcher<T> D::m_fn1() const {
  Matcher<T>(new H(0, makeArrayRef(*this)));
}
template <typename T> G<T> makeAllOfComposite(A<const Matcher<T> *>);
template <typename T, typename InnerT>
G<T> makeDynCastAllOfComposite(A<const Matcher<InnerT> *> p1) {
  G<T>(D(makeAllOfComposite(p1)).m_fn1<T>());
}
template <typename TargetT>
class I : B<G<int>, Matcher<TargetT>, makeDynCastAllOfComposite> {};
I<int> a;
class F {
  class J : C {};
  F m_fn1();
  class K;
};
class F::K : public F::J {
public:
  K(VariadicOperatorFunction p1, vector p2) : Func(p1) {}
  VariadicOperatorFunction Func;
  vector Args;
};
F F::m_fn1() {
  vector b;
  K(0, move(b));
}

$ ./bin/clang-cl -c t.ii -w -GR- -m32
clang-3.5: ../lib/IR/Instructions.cpp:1085: void llvm::StoreInst::AssertOK():
Assertion `getOperand(0)->getType() ==
cast<PointerType>(getOperand(1)->getType())->getElementType() && "Ptr must be a
pointer to Val type!"' failed.
0  clang-3.5       0x0000000000fc56a5 llvm::sys::PrintStackTrace(_IO_FILE*) +
37
1  clang-3.5       0x0000000000fc5de3
2  libpthread.so.0 0x00007f6d8ba01cb0
3  libc.so.6       0x00007f6d8ac34425 gsignal + 53
4  libc.so.6       0x00007f6d8ac37b8b abort + 379
5  libc.so.6       0x00007f6d8ac2d0ee
6  libc.so.6       0x00007f6d8ac2d192
7  clang-3.5       0x0000000000d574de
8  clang-3.5       0x0000000001647ebc
clang::CodeGen::CodeGenFunction::EmitStoreOfScalar(llvm::Value*, llvm::Value*,
bool, unsigned int, clang::QualType, llvm::MDNode*, bool, clang::QualType,
unsigned long) + 1276
9  clang-3.5       0x000000000163b39c
clang::CodeGen::CodeGenFunction::EmitStoreThroughLValue(clang::CodeGen::RValue,
clang::CodeGen::LValue, bool) + 1212
10 clang-3.5       0x00000000016292f4
clang::CodeGen::CodeGenFunction::EmitScalarInit(clang::Expr const*,
clang::ValueDecl const*, clang::CodeGen::LValue, bool) + 388
11 clang-3.5       0x000000000162bb71
clang::CodeGen::CodeGenFunction::EmitExprAsInit(clang::Expr const*,
clang::ValueDecl const*, clang::CodeGen::LValue, bool) + 657
12 clang-3.5       0x000000000161a1ef
clang::CodeGen::CodeGenFunction::EmitInitializerForField(clang::FieldDecl*,
clang::CodeGen::LValue, clang::Expr*, llvm::ArrayRef<clang::VarDecl*>) + 943
13 clang-3.5       0x00000000016223d8
14 clang-3.5       0x000000000161bfe9
clang::CodeGen::CodeGenFunction::EmitCtorPrologue(clang::CXXConstructorDecl
const*, clang::CXXCtorType, clang::CodeGen::FunctionArgList&) + 1577
15 clang-3.5       0x000000000161b3ae
clang::CodeGen::CodeGenFunction::EmitConstructorBody(clang::CodeGen::FunctionArgList&)
+ 590
16 clang-3.5       0x0000000001599fb0
clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl,
llvm::Function*, clang::CodeGen::CGFunctionInfo const&) + 656
17 clang-3.5       0x00000000016062c0
clang::CodeGen::CodeGenModule::EmitCXXConstructor(clang::CXXConstructorDecl
const*, clang::CXXCtorType) + 352
18 clang-3.5       0x00000000015a3596
clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl,
llvm::GlobalValue*) + 294
19 clang-3.5       0x00000000015a029e
clang::CodeGen::CodeGenModule::EmitDeferred() + 46
20 clang-3.5       0x00000000015a008d clang::CodeGen::CodeGenModule::Release()
+ 13
21 clang-3.5       0x0000000001557f43
22 clang-3.5       0x0000000001a00263 clang::ParseAST(clang::Sema&, bool, bool)
+ 515
23 clang-3.5       0x000000000155712e clang::CodeGenAction::ExecuteAction() +
142
24 clang-3.5       0x00000000011250b0 clang::FrontendAction::Execute() + 112
25 clang-3.5       0x00000000010ff3ed
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 925
26 clang-3.5       0x00000000011980df
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 2959
27 clang-3.5       0x00000000006a13fc cc1_main(char const**, char const**, char
const*, void*) + 700
28 clang-3.5       0x000000000069fd53 main + 9203
29 libc.so.6       0x00007f6d8ac1f76d __libc_start_main + 237
30 clang-3.5       0x000000000069d831

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140330/52e5d35c/attachment.html>


More information about the llvm-bugs mailing list