Mercurial > projects > ldc
diff gen/classes.cpp @ 1434:5d0c043ff131
Remove code duplication for vtable loads and improve instruction naming to make
bitcode with virtual calls easier to read.
author | Frits van Bommel <fvbommel wxs.nl> |
---|---|
date | Sat, 30 May 2009 13:04:49 +0200 |
parents | 3af4ad55a004 |
children | 89e38fbfef1f |
line wrap: on
line diff
--- a/gen/classes.cpp Sat May 30 12:58:04 2009 +0200 +++ b/gen/classes.cpp Sat May 30 13:04:49 2009 +0200 @@ -514,7 +514,7 @@ ////////////////////////////////////////////////////////////////////////////////////////// -LLValue* DtoVirtualFunctionPointer(DValue* inst, FuncDeclaration* fdecl) +LLValue* DtoVirtualFunctionPointer(DValue* inst, FuncDeclaration* fdecl, char* name) { // sanity checks assert(fdecl->isVirtual()); @@ -533,7 +533,9 @@ // load vtbl ptr funcval = DtoLoad(funcval); // index vtbl - funcval = DtoGEPi(funcval, 0, fdecl->vtblIndex, fdecl->toChars()); + std::string vtblname = name; + vtblname.append("@vtbl"); + funcval = DtoGEPi(funcval, 0, fdecl->vtblIndex, vtblname.c_str()); // load funcptr funcval = DtoAlignedLoad(funcval); @@ -542,6 +544,10 @@ // cast to final funcptr type funcval = DtoBitCast(funcval, getPtrToType(DtoType(fdecl->type))); + + // postpone naming until after casting to get the name in call instructions + funcval->setName(name); + if (Logger::enabled()) Logger::cout() << "funcval casted: " << *funcval << '\n';