@@ -392,40 +392,6 @@ class ToConstElemVisitor : public Visitor {
392392 IF_LOG Logger::println (" AddrExp::toConstElem: %s @ %s" , e->toChars (),
393393 e->type ->toChars ());
394394 LOG_SCOPE;
395- // FIXME: this should probably be generalized more so we don't
396- // need to have a case for each thing we can take the address of
397-
398- // address of global variable
399- if (auto vexp = e->e1 ->isVarExp ()) {
400- result = DtoConstSymbolAddress (e->loc , vexp->var );
401- return ;
402- }
403-
404- // address of indexExp
405- if (auto iexp = e->e1 ->isIndexExp ()) {
406- // indexee must be global static array var
407- VarExp *vexp = iexp->e1 ->isVarExp ();
408- assert (vexp);
409- VarDeclaration *vd = vexp->var ->isVarDeclaration ();
410- assert (vd);
411- assert (vd->type ->toBasetype ()->ty == TY::Tsarray);
412- DtoResolveVariable (vd);
413- assert (isIrGlobalCreated (vd));
414-
415- // get index
416- LLConstant *index = toConstElem (iexp->e2 , p);
417- assert (index->getType () == DtoSize_t ());
418-
419- // gep
420- LLConstant *idxs[2 ] = {DtoConstSize_t (0 ), index};
421- LLConstant *val = isaConstant (getIrGlobal (vd)->value );
422- LLConstant *gep = llvm::ConstantExpr::getGetElementPtr (
423- DtoType (vd->type ), val, idxs, true );
424-
425- assert (e->type ->toBasetype ()->ty == TY::Tpointer);
426- result = gep;
427- return ;
428- }
429395
430396 if (auto se = e->e1 ->isStructLiteralExp ()) {
431397 result = p->getStructLiteralGlobal (se);
@@ -449,12 +415,7 @@ class ToConstElemVisitor : public Visitor {
449415 return ;
450416 }
451417
452- if (e->e1 ->op == EXP::slice || e->e1 ->op == EXP::dotVariable) {
453- visit (static_cast <Expression *>(e));
454- return ;
455- }
456-
457- llvm_unreachable (" unsupported AddrExp in ToConstElemVisitor" );
418+ visit (static_cast <Expression *>(e));
458419 }
459420
460421 // ////////////////////////////////////////////////////////////////////////////
0 commit comments