comparison gen/llvmhelpers.cpp @ 1411:e57859ca8f1e

Fix `scope(exit) foreach (ref v; arr) foo(v);`
author Frits van Bommel <fvbommel wxs.nl>
date Fri, 22 May 2009 21:38:01 +0200
parents afecdb8ee962
children 3f5ea912149d
comparison
equal deleted inserted replaced
1410:cc2d8a7388c7 1411:e57859ca8f1e
1053 // normal local variable 1053 // normal local variable
1054 else 1054 else
1055 { 1055 {
1056 // if this already has storage, it must've been handled already 1056 // if this already has storage, it must've been handled already
1057 if (var->ir.irLocal && var->ir.irLocal->value) { 1057 if (var->ir.irLocal && var->ir.irLocal->value) {
1058 assert(!addr || addr == var->ir.irLocal->value); 1058 if (addr && addr != var->ir.irLocal->value) {
1059 return var->ir.irLocal->value; 1059 // This can happen, for example, in scope(exit) blocks which
1060 // are translated to IR multiple times.
1061 // That *should* only happen after the first one is completely done
1062 // though, so just set the address.
1063 IF_LOG {
1064 Logger::println("Replacing LLVM address of %s", var->toChars());
1065 LOG_SCOPE;
1066 Logger::cout() << "Old val: " << *var->ir.irLocal->value << '\n';
1067 Logger::cout() << "New val: " << *addr << '\n';
1068 }
1069 var->ir.irLocal->value = addr;
1070 }
1071 return addr;
1060 } 1072 }
1061 1073
1062 assert(!var->ir.isSet()); 1074 assert(!var->ir.isSet());
1063 assert(addr); 1075 assert(addr);
1064 var->ir.irLocal = new IrLocal(var); 1076 var->ir.irLocal = new IrLocal(var);