Mercurial > projects > ldc
comparison gen/llvmhelpers.cpp @ 1189:c0091f3b72f1
Make sure debug info is only declared once per alloca.
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Thu, 02 Apr 2009 20:56:39 +0200 |
parents | 8baf611f0009 |
children | a5bfed1f6775 |
comparison
equal
deleted
inserted
replaced
1188:442ab244c455 | 1189:c0091f3b72f1 |
---|---|
1080 // we don't handle globals with this one | 1080 // we don't handle globals with this one |
1081 assert(!var->isDataseg()); | 1081 assert(!var->isDataseg()); |
1082 | 1082 |
1083 // we don't handle aliases either | 1083 // we don't handle aliases either |
1084 assert(!var->aliassym); | 1084 assert(!var->aliassym); |
1085 | |
1086 // alloca if necessary | |
1087 LLValue* allocaval = NULL; | |
1088 if (!addr && (!var->ir.irLocal || !var->ir.irLocal->value)) | |
1089 { | |
1090 addr = DtoAlloca(DtoType(var->type), var->toChars()); | |
1091 | |
1092 // add debug info | |
1093 if (global.params.symdebug) | |
1094 DtoDwarfLocalVariable(addr, var); | |
1095 } | |
1085 | 1096 |
1086 // referenced by nested function? | 1097 // referenced by nested function? |
1087 #if DMDV2 | 1098 #if DMDV2 |
1088 if (var->nestedrefs.dim) | 1099 if (var->nestedrefs.dim) |
1089 #else | 1100 #else |
1090 if (var->nestedref) | 1101 if (var->nestedref) |
1091 #endif | 1102 #endif |
1092 { | 1103 { |
1093 assert(var->ir.irLocal); | 1104 assert(var->ir.irLocal); |
1094 if(!var->ir.irLocal->value) | 1105 if(!var->ir.irLocal->value) |
1095 var->ir.irLocal->value = addr ? addr : DtoAlloca(DtoType(var->type), var->toChars()); | 1106 { |
1107 assert(addr); | |
1108 var->ir.irLocal->value = addr; | |
1109 } | |
1096 else | 1110 else |
1097 assert(!addr || addr == var->ir.irLocal->value); | 1111 assert(!addr || addr == var->ir.irLocal->value); |
1098 | 1112 |
1099 // store the address into the nested vars array | 1113 // store the address into the nested vars array |
1100 assert(var->ir.irLocal->nestedIndex >= 0); | 1114 assert(var->ir.irLocal->nestedIndex >= 0); |
1111 assert(!addr || addr == var->ir.irLocal->value); | 1125 assert(!addr || addr == var->ir.irLocal->value); |
1112 return var->ir.irLocal->value; | 1126 return var->ir.irLocal->value; |
1113 } | 1127 } |
1114 | 1128 |
1115 assert(!var->ir.isSet()); | 1129 assert(!var->ir.isSet()); |
1130 assert(addr); | |
1116 var->ir.irLocal = new IrLocal(var); | 1131 var->ir.irLocal = new IrLocal(var); |
1117 var->ir.irLocal->value = addr ? addr : DtoAlloca(DtoType(var->type), var->toChars()); | 1132 var->ir.irLocal->value = addr; |
1118 } | 1133 } |
1119 | |
1120 // add debug info | |
1121 if (global.params.symdebug) | |
1122 DtoDwarfLocalVariable(var->ir.irLocal->value, var); | |
1123 | 1134 |
1124 // return the alloca | 1135 // return the alloca |
1125 return var->ir.irLocal->value; | 1136 return var->ir.irLocal->value; |
1126 } | 1137 } |
1127 | 1138 |