Mercurial > projects > ldc
diff gen/runtime.cpp @ 1418:f5f8c21ce6ef
Make "`aa[key]`" use the same runtime call as "`key in aa`". The runtime calls
these were using were different, but with equivalent definitions.
With `ldc -O3`, the following functions now all compile to the exact same code:
{{{
int[int] y;
void foo(int x) {
if (x in y) {
auto z = x in y;
sink(*z);
}
}
void bar(int x) {
if (x in y) {
sink(y[x]);
}
}
void baz(int x) {
if (auto p = x in y) {
sink(*p);
}
}
}}}
author | Frits van Bommel <fvbommel wxs.nl> |
---|---|
date | Mon, 25 May 2009 12:50:40 +0200 |
parents | 551b01341728 |
children | 9344fecd24f0 |
line wrap: on
line diff
--- a/gen/runtime.cpp Sat May 23 23:18:47 2009 +0200 +++ b/gen/runtime.cpp Mon May 25 12:50:40 2009 +0200 @@ -659,19 +659,6 @@ ->setAttributes(Attr_1_4_NoCapture); } - // void* _aaGetRvalue(AA aa, TypeInfo keyti, size_t valuesize, void* pkey) - { - std::string fname("_aaGetRvalue"); - std::vector<const LLType*> types; - types.push_back(aaTy); - types.push_back(typeInfoTy); - types.push_back(sizeTy); - types.push_back(voidPtrTy); - const llvm::FunctionType* fty = llvm::FunctionType::get(voidPtrTy, types, false); - llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M) - ->setAttributes(Attr_ReadOnly_1_4_NoCapture); - } - // void* _aaIn(AA aa, TypeInfo keyti, void* pkey) { std::string fname("_aaIn");