Cleanup: Remove unused code in backend, silence some warnings.

This removed quite some clutter that has presumably piled up because LDC is seldom built with a lot of warnings enabled due to DMDFE.
This commit is contained in:
David Nadlinger 2011-04-24 12:21:33 +02:00
parent 009ce6e161
commit 7a24e12736
15 changed files with 25 additions and 69 deletions

View file

@ -635,9 +635,7 @@ void X86_64TargetABI::rewriteFunctionType(TypeFunction* tf) {
// Arguments that are in memory are of no interest to us. // Arguments that are in memory are of no interest to us.
if (arg.byref) if (arg.byref)
continue; continue;
Type* ty = arg.type->toBasetype();
fixup(arg); fixup(arg);
if (Logger::enabled()) if (Logger::enabled())
Logger::cout() << "New arg type: " << *arg.ltype << '\n'; Logger::cout() << "New arg type: " << *arg.ltype << '\n';

View file

@ -1306,9 +1306,9 @@ DValue* DtoCastArray(Loc& loc, DValue* u, Type* to)
Logger::cout() << "uvalTy = " << *uval->getType() << '\n'; Logger::cout() << "uvalTy = " << *uval->getType() << '\n';
assert(isaPointer(uval->getType())); assert(isaPointer(uval->getType()));
const LLArrayType* arrty = isaArray(uval->getType()->getContainedType(0));
/*const LLArrayType* arrty = isaArray(uval->getType()->getContainedType(0));
/*if(arrty->getNumElements()*fromtype->nextOf()->size() != tosize*totype->nextOf()->size()) if(arrty->getNumElements()*fromtype->nextOf()->size() != tosize*totype->nextOf()->size())
{ {
error(loc, "invalid cast from '%s' to '%s', the sizes are not the same", fromtype->toChars(), totype->toChars()); error(loc, "invalid cast from '%s' to '%s', the sizes are not the same", fromtype->toChars(), totype->toChars());
fatal(); fatal();

View file

@ -10,13 +10,6 @@
namespace opts { namespace opts {
// Helper function
static char toLower(char c) {
if (isupper(c))
return tolower(c);
return c;
}
bool FlagParser::parse(cl::Option &O, llvm::StringRef ArgName, llvm::StringRef Arg, bool &Val) { bool FlagParser::parse(cl::Option &O, llvm::StringRef ArgName, llvm::StringRef Arg, bool &Val) {
// Make a std::string out of it to make comparisons easier // Make a std::string out of it to make comparisons easier
// (and avoid repeated conversion) // (and avoid repeated conversion)
@ -55,7 +48,7 @@ MultiSetter::MultiSetter(bool invert, bool* p, ...) {
locations.push_back(p); locations.push_back(p);
va_list va; va_list va;
va_start(va, p); va_start(va, p);
while (p = va_arg(va, bool*)) { while ((p = va_arg(va, bool*))) {
locations.push_back(p); locations.push_back(p);
} }
} }

View file

@ -293,7 +293,6 @@ DValue* DtoCastClass(DValue* val, Type* _to)
// get the from class // get the from class
ClassDeclaration* cd = fc->sym->isClassDeclaration(); ClassDeclaration* cd = fc->sym->isClassDeclaration();
DtoResolveClass(cd); // add this DtoResolveClass(cd); // add this
IrStruct* irstruct = cd->ir.irStruct;
IrTypeClass* typeclass = fc->irtype->isClass(); IrTypeClass* typeclass = fc->irtype->isClass();
// find interface impl // find interface impl
@ -332,7 +331,6 @@ DValue* DtoCastClass(DValue* val, Type* _to)
// x -> class // x -> class
else { else {
Logger::println("to class"); Logger::println("to class");
int poffset;
// interface -> class // interface -> class
if (fc->sym->isInterfaceDeclaration()) { if (fc->sym->isInterfaceDeclaration()) {
Logger::println("interface cast"); Logger::println("interface cast");

View file

@ -22,7 +22,6 @@ const llvm::StructType* DtoComplexType(Type* type)
const LLType* DtoComplexBaseType(Type* t) const LLType* DtoComplexBaseType(Type* t)
{ {
TY ty = t->toBasetype()->ty; TY ty = t->toBasetype()->ty;
const LLType* base;
if (ty == Tcomplex32) { if (ty == Tcomplex32) {
return LLType::getFloatTy(gIR->context()); return LLType::getFloatTy(gIR->context());
} }
@ -46,11 +45,7 @@ LLConstant* DtoConstComplex(Type* _ty, long double re, long double im)
{ {
TY ty = _ty->toBasetype()->ty; TY ty = _ty->toBasetype()->ty;
llvm::ConstantFP* fre;
llvm::ConstantFP* fim;
Type* base = 0; Type* base = 0;
if (ty == Tcomplex32) { if (ty == Tcomplex32) {
base = Type::tfloat32; base = Type::tfloat32;
} }
@ -132,8 +127,6 @@ void DtoComplexSet(LLValue* c, LLValue* re, LLValue* im)
void DtoGetComplexParts(Loc& loc, Type* to, DValue* val, LLValue*& re, LLValue*& im) void DtoGetComplexParts(Loc& loc, Type* to, DValue* val, LLValue*& re, LLValue*& im)
{ {
const LLType* base = DtoComplexBaseType(to);
Type* baserety; Type* baserety;
Type* baseimty; Type* baseimty;
TY ty = to->toBasetype()->ty; TY ty = to->toBasetype()->ty;
@ -403,7 +396,7 @@ LLValue* DtoComplexEquals(Loc& loc, TOK op, DValue* lhs, DValue* rhs)
{ {
Type* type = lhs->getType(); Type* type = lhs->getType();
llvm::Value *lhs_re, *lhs_im, *rhs_re, *rhs_im, *res_re, *res_im; llvm::Value *lhs_re, *lhs_im, *rhs_re, *rhs_im;
// lhs values // lhs values
DtoGetComplexParts(loc, type, lhs, lhs_re, lhs_im); DtoGetComplexParts(loc, type, lhs, lhs_re, lhs_im);

View file

@ -279,8 +279,7 @@ const llvm::FunctionType* DtoFunctionType(FuncDeclaration* fdecl)
static llvm::Function* DtoDeclareVaFunction(FuncDeclaration* fdecl) static llvm::Function* DtoDeclareVaFunction(FuncDeclaration* fdecl)
{ {
TypeFunction* f = (TypeFunction*)fdecl->type->toBasetype(); DtoVaFunctionType(fdecl);
const llvm::FunctionType* fty = DtoVaFunctionType(fdecl);
llvm::Function* func = 0; llvm::Function* func = 0;
if (fdecl->llvmInternal == LLVMva_start) if (fdecl->llvmInternal == LLVMva_start)
@ -370,8 +369,6 @@ void DtoResolveFunction(FuncDeclaration* fdecl)
static void set_param_attrs(TypeFunction* f, llvm::Function* func, FuncDeclaration* fdecl) static void set_param_attrs(TypeFunction* f, llvm::Function* func, FuncDeclaration* fdecl)
{ {
int funcNumArgs = func->getArgumentList().size();
LLSmallVector<llvm::AttributeWithIndex, 9> attrs; LLSmallVector<llvm::AttributeWithIndex, 9> attrs;
llvm::AttributeWithIndex PAWI; llvm::AttributeWithIndex PAWI;
@ -648,7 +645,6 @@ void DtoDefineFunction(FuncDeclaration* fd)
// assert(f->irtype); // assert(f->irtype);
llvm::Function* func = fd->ir.irFunc->func; llvm::Function* func = fd->ir.irFunc->func;
const llvm::FunctionType* functype = func->getFunctionType();
// sanity check // sanity check
assert(mustDefineSymbol(fd)); assert(mustDefineSymbol(fd));

View file

@ -91,8 +91,8 @@ struct IRAsmBlock
LLValue* (*retfixup)(IRBuilderHelper b, LLValue* orig); // Modifies retval LLValue* (*retfixup)(IRBuilderHelper b, LLValue* orig); // Modifies retval
IRAsmBlock(AsmBlockStatement* b) IRAsmBlock(AsmBlockStatement* b)
: asmBlock(b), retty(NULL), retn(0), retemu(false), retfixup(NULL), : outputcount(0), asmBlock(b), retty(NULL), retn(0), retemu(false),
outputcount(0) retfixup(NULL)
{} {}
}; };

View file

@ -117,7 +117,6 @@ int linkExecutable(const char* argv0)
args.push_back("-disable-opt"); args.push_back("-disable-opt");
else else
{ {
const char* s = 0;
switch(optLevel()) switch(optLevel())
{ {
case 0: case 0:

View file

@ -906,8 +906,6 @@ void DtoConstInitGlobal(VarDeclaration* vd)
Logger::println("DtoConstInitGlobal(%s) @ %s", vd->toChars(), vd->loc.toChars()); Logger::println("DtoConstInitGlobal(%s) @ %s", vd->toChars(), vd->loc.toChars());
LOG_SCOPE; LOG_SCOPE;
Dsymbol* par = vd->toParent();
// build the initializer // build the initializer
LLConstant* initVal = DtoConstInitializer(vd->loc, vd->type, vd->init); LLConstant* initVal = DtoConstInitializer(vd->loc, vd->type, vd->init);
@ -922,8 +920,6 @@ void DtoConstInitGlobal(VarDeclaration* vd)
glob->constInit = initVal; glob->constInit = initVal;
// assign the initializer // assign the initializer
llvm::GlobalVariable* globalvar = llvm::cast<llvm::GlobalVariable>(glob->value);
if (!(vd->storage_class & STCextern) && mustDefineSymbol(vd)) if (!(vd->storage_class & STCextern) && mustDefineSymbol(vd))
{ {
if (Logger::enabled()) if (Logger::enabled())
@ -1040,7 +1036,7 @@ DValue* DtoDeclarationExp(Dsymbol* declaration)
if (Logger::enabled()) if (Logger::enabled())
Logger::cout() << "llvm value for decl: " << *vd->ir.irLocal->value << '\n'; Logger::cout() << "llvm value for decl: " << *vd->ir.irLocal->value << '\n';
if (!vd->isRef()) if (!vd->isRef())
DValue* ie = DtoInitializer(vd->ir.irLocal->value, vd->init); DtoInitializer(vd->ir.irLocal->value, vd->init); // TODO: Remove altogether?
} }
return new DVarValue(vd->type, vd, vd->ir.getIrValue()); return new DVarValue(vd->type, vd, vd->ir.getIrValue());
@ -1058,13 +1054,13 @@ DValue* DtoDeclarationExp(Dsymbol* declaration)
f->codegen(Type::sir); f->codegen(Type::sir);
} }
// alias declaration // alias declaration
else if (AliasDeclaration* a = declaration->isAliasDeclaration()) else if (declaration->isAliasDeclaration())
{ {
Logger::println("AliasDeclaration - no work"); Logger::println("AliasDeclaration - no work");
// do nothing // do nothing
} }
// enum // enum
else if (EnumDeclaration* e = declaration->isEnumDeclaration()) else if (declaration->isEnumDeclaration())
{ {
Logger::println("EnumDeclaration - no work"); Logger::println("EnumDeclaration - no work");
// do nothing // do nothing
@ -1144,7 +1140,6 @@ LLValue* DtoRawVarDeclaration(VarDeclaration* var, LLValue* addr)
assert(!var->aliassym); assert(!var->aliassym);
// alloca if necessary // alloca if necessary
LLValue* allocaval = NULL;
if (!addr && (!var->ir.irLocal || !var->ir.irLocal->value)) if (!addr && (!var->ir.irLocal || !var->ir.irLocal->value))
{ {
addr = DtoAlloca(var->type, var->toChars()); addr = DtoAlloca(var->type, var->toChars());
@ -1459,7 +1454,6 @@ bool mustDefineSymbol(Dsymbol* s)
// so they shouldn't end up in object code. // so they shouldn't end up in object code.
assert(fd->type->ty == Tfunction); assert(fd->type->ty == Tfunction);
TypeFunction* tf = (TypeFunction*) fd->type;
// * If we define extra static constructors, static destructors // * If we define extra static constructors, static destructors
// and unittests they'll get registered to run, and we won't // and unittests they'll get registered to run, and we won't
// be calling them directly anyway. // be calling them directly anyway.
@ -1706,7 +1700,7 @@ LLValue* makeLValue(Loc& loc, DValue* value)
valuePointer = value->getRVal(); valuePointer = value->getRVal();
needsMemory = !DtoIsPassedByRef(valueType); needsMemory = !DtoIsPassedByRef(valueType);
} }
else if (DVarValue* var = value->isVar()) { else if (value->isVar()) {
valuePointer = value->getLVal(); valuePointer = value->getLVal();
needsMemory = false; needsMemory = false;
} }

View file

@ -303,7 +303,7 @@ LLValue* DtoNestedContext(Loc loc, Dsymbol* sym)
return llvm::UndefValue::get(getVoidPtrType()); return llvm::UndefValue::get(getVoidPtrType());
} }
if (nestedCtx == NCHybrid) { if (nestedCtx == NCHybrid) {
class FuncDeclaration* fd = 0; struct FuncDeclaration* fd = 0;
#if DMDV2 #if DMDV2
if (AggregateDeclaration *ad = sym->isAggregateDeclaration()) if (AggregateDeclaration *ad = sym->isAggregateDeclaration())
// If sym is a nested struct or a nested class, pass the frame // If sym is a nested struct or a nested class, pass the frame
@ -499,7 +499,7 @@ void DtoCreateNestedContext(FuncDeclaration* fd) {
if (parfd->isStatic()) if (parfd->isStatic())
break; break;
} }
else if (ClassDeclaration* parcd = par->isClassDeclaration()) else if (par->isClassDeclaration())
{ {
// nothing needed // nothing needed
} }

View file

@ -260,7 +260,7 @@ void IfStatement::toIR(IRState* p)
Logger::cout() << "if conditional: " << *cond_val << '\n'; Logger::cout() << "if conditional: " << *cond_val << '\n';
cond_val = DtoCast(loc, cond_e, Type::tbool)->getRVal(); cond_val = DtoCast(loc, cond_e, Type::tbool)->getRVal();
} }
LLValue* ifgoback = llvm::BranchInst::Create(ifbb, elsebb, cond_val, gIR->scopebb()); llvm::BranchInst::Create(ifbb, elsebb, cond_val, gIR->scopebb());
// replace current scope // replace current scope
gIR->scope() = IRScope(ifbb,elsebb); gIR->scope() = IRScope(ifbb,elsebb);
@ -352,7 +352,7 @@ void WhileStatement::toIR(IRState* p)
delete cond_e; delete cond_e;
// conditional branch // conditional branch
LLValue* ifbreak = llvm::BranchInst::Create(whilebodybb, endbb, cond_val, p->scopebb()); llvm::BranchInst::Create(whilebodybb, endbb, cond_val, p->scopebb());
// rewrite scope // rewrite scope
gIR->scope() = IRScope(whilebodybb,endbb); gIR->scope() = IRScope(whilebodybb,endbb);
@ -412,7 +412,7 @@ void DoStatement::toIR(IRState* p)
delete cond_e; delete cond_e;
// conditional branch // conditional branch
LLValue* ifbreak = llvm::BranchInst::Create(dowhilebb, endbb, cond_val, gIR->scopebb()); llvm::BranchInst::Create(dowhilebb, endbb, cond_val, gIR->scopebb());
// rewrite the scope // rewrite the scope
gIR->scope() = IRScope(endbb,oldend); gIR->scope() = IRScope(endbb,oldend);
@ -520,7 +520,7 @@ void BreakStatement::toIR(IRState* p)
// get the loop statement the label refers to // get the loop statement the label refers to
Statement* targetLoopStatement = target->statement; Statement* targetLoopStatement = target->statement;
ScopeStatement* tmp; ScopeStatement* tmp;
while(tmp = targetLoopStatement->isScopeStatement()) while((tmp = targetLoopStatement->isScopeStatement()))
targetLoopStatement = tmp->statement; targetLoopStatement = tmp->statement;
// find the right break block and jump there // find the right break block and jump there
@ -577,7 +577,7 @@ void ContinueStatement::toIR(IRState* p)
// get the loop statement the label refers to // get the loop statement the label refers to
Statement* targetLoopStatement = target->statement; Statement* targetLoopStatement = target->statement;
ScopeStatement* tmp; ScopeStatement* tmp;
while(tmp = targetLoopStatement->isScopeStatement()) while((tmp = targetLoopStatement->isScopeStatement()))
targetLoopStatement = tmp->statement; targetLoopStatement = tmp->statement;
// find the right continue block and jump there // find the right continue block and jump there
@ -1178,7 +1178,6 @@ void ForeachStatement::toIR(IRState* p)
// what to iterate // what to iterate
DValue* aggrval = aggr->toElem(p); DValue* aggrval = aggr->toElem(p);
Type* aggrtype = aggr->type->toBasetype();
// get length and pointer // get length and pointer
LLValue* niters = DtoArrayLen(aggrval); LLValue* niters = DtoArrayLen(aggrval);
@ -1196,7 +1195,6 @@ void ForeachStatement::toIR(IRState* p)
niters = gIR->ir->CreateBitCast(niters, keytype, "foreachtrunckey"); niters = gIR->ir->CreateBitCast(niters, keytype, "foreachtrunckey");
} }
LLConstant* delta = 0;
if (op == TOKforeach) { if (op == TOKforeach) {
new llvm::StoreInst(zerokey, keyvar, p->scopebb()); new llvm::StoreInst(zerokey, keyvar, p->scopebb());
} }
@ -1231,7 +1229,6 @@ void ForeachStatement::toIR(IRState* p)
p->scope() = IRScope(bodybb,nextbb); p->scope() = IRScope(bodybb,nextbb);
// get value for this iteration // get value for this iteration
LLConstant* zero = LLConstantInt::get(keytype,0,false);
LLValue* loadedKey = p->ir->CreateLoad(keyvar,"tmp"); LLValue* loadedKey = p->ir->CreateLoad(keyvar,"tmp");
LLValue* gep = DtoGEP1(val,loadedKey); LLValue* gep = DtoGEP1(val,loadedKey);

View file

@ -681,7 +681,6 @@ DValue* AddExp::toElem(IRState* p)
Type* t = type->toBasetype(); Type* t = type->toBasetype();
Type* e1type = e1->type->toBasetype(); Type* e1type = e1->type->toBasetype();
Type* e1next = e1type->nextOf() ? e1type->nextOf()->toBasetype() : NULL;
Type* e2type = e2->type->toBasetype(); Type* e2type = e2->type->toBasetype();
errorOnIllegalArrayOp(this, e1, e2); errorOnIllegalArrayOp(this, e1, e2);
@ -863,7 +862,6 @@ DValue* CallExp::toElem(IRState* p)
DFuncValue* dfnval = fnval->isFunc(); DFuncValue* dfnval = fnval->isFunc();
// handle magic intrinsics (mapping to instructions) // handle magic intrinsics (mapping to instructions)
bool va_intrinsic = false;
if (dfnval && dfnval->func) if (dfnval && dfnval->func)
{ {
FuncDeclaration* fndecl = dfnval->func; FuncDeclaration* fndecl = dfnval->func;
@ -1017,7 +1015,7 @@ DValue* AddrExp::toElem(IRState* p)
fd->codegen(Type::sir); fd->codegen(Type::sir);
return new DFuncValue(fd, fd->ir.irFunc->func); return new DFuncValue(fd, fd->ir.irFunc->func);
} }
else if (DImValue* im = v->isIm()) { else if (v->isIm()) {
Logger::println("is immediate"); Logger::println("is immediate");
return v; return v;
} }
@ -1189,7 +1187,6 @@ DValue* DotVarExp::toElem(IRState* p)
DValue* l = e1->toElem(p); DValue* l = e1->toElem(p);
Type* t = type->toBasetype();
Type* e1type = e1->type->toBasetype(); Type* e1type = e1->type->toBasetype();
//Logger::println("e1type=%s", e1type->toChars()); //Logger::println("e1type=%s", e1type->toChars());
@ -1335,7 +1332,6 @@ DValue* IndexExp::toElem(IRState* p)
p->arrays.pop_back(); p->arrays.pop_back();
LLValue* zero = DtoConstUint(0); LLValue* zero = DtoConstUint(0);
LLValue* one = DtoConstUint(1);
LLValue* arrptr = 0; LLValue* arrptr = 0;
if (e1type->ty == Tpointer) { if (e1type->ty == Tpointer) {
@ -1485,7 +1481,6 @@ DValue* CmpExp::toElem(IRState* p)
DValue* r = e2->toElem(p); DValue* r = e2->toElem(p);
Type* t = e1->type->toBasetype(); Type* t = e1->type->toBasetype();
Type* e2t = e2->type->toBasetype();
LLValue* eval = 0; LLValue* eval = 0;
@ -1610,8 +1605,6 @@ DValue* EqualExp::toElem(IRState* p)
LLValue* rv = r->getRVal(); LLValue* rv = r->getRVal();
Type* t = e1->type->toBasetype(); Type* t = e1->type->toBasetype();
Type* e2t = e2->type->toBasetype();
//assert(t == e2t);
LLValue* eval = 0; LLValue* eval = 0;
@ -1683,7 +1676,7 @@ DValue* PostExp::toElem(IRState* p)
LOG_SCOPE; LOG_SCOPE;
DValue* l = e1->toElem(p); DValue* l = e1->toElem(p);
DValue* r = e2->toElem(p); e2->toElem(p);
LLValue* val = l->getRVal(); LLValue* val = l->getRVal();
LLValue* post = 0; LLValue* post = 0;
@ -2305,7 +2298,7 @@ DValue* CommaExp::toElem(IRState* p)
return new DVarValue(type, V); return new DVarValue(type, V);
} }
DValue* u = e1->toElem(p); e1->toElem(p);
DValue* v = e2->toElem(p); DValue* v = e2->toElem(p);
assert(e2->type == type); assert(e2->type == type);
return v; return v;
@ -2408,8 +2401,6 @@ DValue* CatExp::toElem(IRState* p)
Logger::print("CatExp::toElem: %s @ %s\n", toChars(), type->toChars()); Logger::print("CatExp::toElem: %s @ %s\n", toChars(), type->toChars());
LOG_SCOPE; LOG_SCOPE;
Type* t = type->toBasetype();
bool arrNarr = e1->type->toBasetype() == e2->type->toBasetype(); bool arrNarr = e1->type->toBasetype() == e2->type->toBasetype();
// array ~ array // array ~ array

View file

@ -812,5 +812,5 @@ void Module::genmoduleinfo()
std::vector<LLConstant*> appendInits(1, magicinit); std::vector<LLConstant*> appendInits(1, magicinit);
LLConstant* appendInit = LLConstantArray::get(appendArrTy, appendInits); LLConstant* appendInit = LLConstantArray::get(appendArrTy, appendInits);
std::string appendName("llvm.global_ctors"); std::string appendName("llvm.global_ctors");
llvm::GlobalVariable* appendVar = new llvm::GlobalVariable(*gIR->module, appendArrTy, true, llvm::GlobalValue::AppendingLinkage, appendInit, appendName); new llvm::GlobalVariable(*gIR->module, appendArrTy, true, llvm::GlobalValue::AppendingLinkage, appendInit, appendName);
} }

View file

@ -374,7 +374,6 @@ llvm::GlobalVariable * IrStruct::getInterfaceVtbl(BaseClass * b, bool new_instan
// start with the interface info // start with the interface info
VarDeclarationIter interfaces_idx(ClassDeclaration::classinfo->fields, 3); VarDeclarationIter interfaces_idx(ClassDeclaration::classinfo->fields, 3);
Type* first = interfaces_idx->type->nextOf()->pointerTo();
// index into the interfaces array // index into the interfaces array
llvm::Constant* idxs[2] = { llvm::Constant* idxs[2] = {
@ -475,8 +474,6 @@ LLConstant * IrStruct::getClassInfoInterfaces()
const LLType* voidptrptr_type = DtoType( const LLType* voidptrptr_type = DtoType(
Type::tvoid->pointerTo()->pointerTo()); Type::tvoid->pointerTo()->pointerTo());
const LLType* our_type = stripModifiers(type)->irtype->isClass()->getPA().get();
for (size_t i = 0; i < n; ++i) for (size_t i = 0; i < n; ++i)
{ {
BaseClass* it = interfacesWithVtbls[i]; BaseClass* it = interfacesWithVtbls[i];

View file

@ -3,7 +3,7 @@
#include "ir/irtype.h" #include "ir/irtype.h"
class IrFuncTy; struct IrFuncTy;
/// ///
class IrTypeFunction : public IrType class IrTypeFunction : public IrType