From c0e23d6814d64bfbdca0a9d1e827a5574e1dbe1c Mon Sep 17 00:00:00 2001 From: Kai Nacke Date: Sun, 22 Mar 2015 13:55:53 +0100 Subject: [PATCH] LLVM 3.7: llvm::GetElementPtrInst() requires the pointed-to type. Currently, the pointer type is passed which causes an assertion. Also add assertion to verify that parameter ptr is really of a pointer type. --- gen/tollvm.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/gen/tollvm.cpp b/gen/tollvm.cpp index 7da2111dc2..80160e1fd8 100644 --- a/gen/tollvm.cpp +++ b/gen/tollvm.cpp @@ -307,9 +307,11 @@ LLIntegerType* DtoSize_t() LLValue* DtoGEP1(LLValue* ptr, LLValue* i0, const char* var, llvm::BasicBlock* bb) { + LLPointerType* p = isaPointer(ptr); + assert(p && "GEP expects a pointer type"); return llvm::GetElementPtrInst::Create( #if LDC_LLVM_VER >= 307 - ptr->getType(), + p->getElementType(), #endif ptr, i0, var, bb ? bb : gIR->scopebb()); } @@ -318,10 +320,12 @@ LLValue* DtoGEP1(LLValue* ptr, LLValue* i0, const char* var, llvm::BasicBlock* b LLValue* DtoGEP(LLValue* ptr, LLValue* i0, LLValue* i1, const char* var, llvm::BasicBlock* bb) { + LLPointerType* p = isaPointer(ptr); + assert(p && "GEP expects a pointer type"); LLValue* v[] = { i0, i1 }; return llvm::GetElementPtrInst::Create( #if LDC_LLVM_VER >= 307 - ptr->getType(), + p->getElementType(), #endif ptr, v, var, bb ? bb : gIR->scopebb()); } @@ -330,9 +334,11 @@ LLValue* DtoGEP(LLValue* ptr, LLValue* i0, LLValue* i1, const char* var, llvm::B LLValue* DtoGEPi1(LLValue* ptr, unsigned i, const char* var, llvm::BasicBlock* bb) { + LLPointerType* p = isaPointer(ptr); + assert(p && "GEP expects a pointer type"); return llvm::GetElementPtrInst::Create( #if LDC_LLVM_VER >= 307 - ptr->getType(), + p->getElementType(), #endif ptr, DtoConstUint(i), var, bb ? bb : gIR->scopebb()); } @@ -341,10 +347,12 @@ LLValue* DtoGEPi1(LLValue* ptr, unsigned i, const char* var, llvm::BasicBlock* b LLValue* DtoGEPi(LLValue* ptr, unsigned i0, unsigned i1, const char* var, llvm::BasicBlock* bb) { + LLPointerType* p = isaPointer(ptr); + assert(p && "GEP expects a pointer type"); LLValue* v[] = { DtoConstUint(i0), DtoConstUint(i1) }; return llvm::GetElementPtrInst::Create( #if LDC_LLVM_VER >= 307 - ptr->getType(), + p->getElementType(), #endif ptr, v, var, bb ? bb : gIR->scopebb()); }