diff --git a/src/absil/ilwritepdb.fs b/src/absil/ilwritepdb.fs index 1b82f9352dd..e25211b3cce 100644 --- a/src/absil/ilwritepdb.fs +++ b/src/absil/ilwritepdb.fs @@ -493,7 +493,7 @@ let writePdbInfo fixupOverlappingSequencePoints showTimes f fpdb info cvChunk = match Map.tryFind k res with | Some xsR -> xsR := sp :: !xsR; res | None -> Map.add k (ref [sp]) res - + let res = Array.fold add res sps let res = Map.toList res // ordering may not be stable List.map (fun (_,x) -> Array.ofList !x) res @@ -502,22 +502,27 @@ let writePdbInfo fixupOverlappingSequencePoints showTimes f fpdb info cvChunk = if spset.Length > 0 then Array.sortInPlaceWith SequencePoint.orderByOffset spset let sps = - spset |> Array.map (fun sp -> - // Ildiag.dprintf "token 0x%08lx has an sp at offset 0x%08x\n" minfo.MethToken sp.Offset - (sp.Offset, sp.Line, sp.Column,sp.EndLine, sp.EndColumn)) - // Use of alloca in implementation of pdbDefineSequencePoints can give stack overflow here + spset |> Array.map (fun sp -> + // Ildiag.dprintf "token 0x%08lx has an sp at offset 0x%08x\n" minfo.MethToken sp.Offset + (sp.Offset, sp.Line, sp.Column,sp.EndLine, sp.EndColumn)) + // Use of alloca in implementation of pdbDefineSequencePoints can give stack overflow here if sps.Length < 5000 then - pdbDefineSequencePoints !pdbw (getDocument spset.[0].Document) sps) + pdbDefineSequencePoints !pdbw (getDocument spset.[0].Document) sps) // Write the scopes - let rec writePdbScope top sco = - if top || sco.Locals.Length <> 0 || sco.Children.Length <> 0 then - pdbOpenScope !pdbw sco.StartOffset + let rec writePdbScope parent sco = + if parent = None || sco.Locals.Length <> 0 || sco.Children.Length <> 0 then + // Only nest scopes if the child scope is a different size from + let nested = + match parent with + | Some p -> sco.StartOffset <> p.StartOffset || sco.EndOffset <> p.EndOffset + | None -> true + if nested then pdbOpenScope !pdbw sco.StartOffset sco.Locals |> Array.iter (fun v -> pdbDefineLocalVariable !pdbw v.Name v.Signature v.Index) - sco.Children |> Array.iter (writePdbScope false) - pdbCloseScope !pdbw sco.EndOffset - writePdbScope true minfo.RootScope + sco.Children |> Array.iter (writePdbScope (if nested then Some sco else parent)) + if nested then pdbCloseScope !pdbw sco.EndOffset + writePdbScope None minfo.RootScope pdbCloseMethod !pdbw end) reportTime showTimes "PDB: Wrote methods" diff --git a/tests/fsharpqa/Source/CodeGen/EmittedIL/SerializableAttribute/ToplevelModule.il.bsl b/tests/fsharpqa/Source/CodeGen/EmittedIL/SerializableAttribute/ToplevelModule.il.bsl index 042143d9677..3c9df2a50c3 100644 --- a/tests/fsharpqa/Source/CodeGen/EmittedIL/SerializableAttribute/ToplevelModule.il.bsl +++ b/tests/fsharpqa/Source/CodeGen/EmittedIL/SerializableAttribute/ToplevelModule.il.bsl @@ -1720,21 +1720,19 @@ { // Code size 14 (0xe) .maxstack 3 - .locals init ([0] string V_0, - [1] string greeting) - .line 12,12 : 9,31 + .locals init ([0] string greeting, + [1] string V_1) + .line 12,12 : 9,31 '' IL_0000: nop IL_0001: call string ABC::get_greeting() IL_0006: stloc.0 - .line 22,22 : 13,35 + .line 22,22 : 13,35 '' IL_0007: call string ABC/ABC::get_greeting() IL_000c: stloc.1 IL_000d: ret } // end of method $ABC::.cctor - } // end of class ''.$ABC - // ============================================================= // *********** DISASSEMBLY COMPLETE *********************** diff --git a/tests/fsharpqa/Source/CodeGen/EmittedIL/SerializableAttribute/ToplevelModuleP.il.bsl b/tests/fsharpqa/Source/CodeGen/EmittedIL/SerializableAttribute/ToplevelModuleP.il.bsl index a504b86ed4e..93b55d4bd13 100644 --- a/tests/fsharpqa/Source/CodeGen/EmittedIL/SerializableAttribute/ToplevelModuleP.il.bsl +++ b/tests/fsharpqa/Source/CodeGen/EmittedIL/SerializableAttribute/ToplevelModuleP.il.bsl @@ -1692,18 +1692,17 @@ { // Code size 14 (0xe) .maxstack 3 - .locals init ([0] string V_0, - [1] string greeting) - .line 12,12 : 9,31 + .locals init ([0] string greeting, + [1] string V_1) + .line 12,12 : 9,31 '' IL_0000: nop IL_0001: call string ABC::get_greeting() IL_0006: stloc.0 - .line 22,22 : 13,35 + .line 22,22 : 13,35 '' IL_0007: call string ABC/ABC::get_greeting() IL_000c: stloc.1 IL_000d: ret } // end of method $ABC::.cctor - } // end of class ''.$ABC diff --git a/tests/fsharpqa/Source/CodeGen/EmittedIL/SerializableAttribute/ToplevelNamespace.il.bsl b/tests/fsharpqa/Source/CodeGen/EmittedIL/SerializableAttribute/ToplevelNamespace.il.bsl index 4ec579e7517..2c1b74c902a 100644 --- a/tests/fsharpqa/Source/CodeGen/EmittedIL/SerializableAttribute/ToplevelNamespace.il.bsl +++ b/tests/fsharpqa/Source/CodeGen/EmittedIL/SerializableAttribute/ToplevelNamespace.il.bsl @@ -2513,18 +2513,17 @@ { // Code size 14 (0xe) .maxstack 3 - .locals init ([0] string V_0, - [1] string greeting) - .line 19,19 : 9,31 + .locals init ([0] string greeting, + [1] string V_1) + .line 19,19 : 9,31 '' IL_0000: nop IL_0001: call string XYZ.ABC::get_greeting() IL_0006: stloc.0 - .line 29,29 : 13,35 + .line 29,29 : 13,35 '' IL_0007: call string XYZ.ABC/ABC::get_greeting() IL_000c: stloc.1 IL_000d: ret } // end of method $ToplevelNamespace::.cctor - } // end of class ''.$ToplevelNamespace diff --git a/tests/fsharpqa/Source/CodeGen/EmittedIL/SerializableAttribute/ToplevelNamespaceP.il.bsl b/tests/fsharpqa/Source/CodeGen/EmittedIL/SerializableAttribute/ToplevelNamespaceP.il.bsl index 6e206df9ecc..dc494245d5b 100644 --- a/tests/fsharpqa/Source/CodeGen/EmittedIL/SerializableAttribute/ToplevelNamespaceP.il.bsl +++ b/tests/fsharpqa/Source/CodeGen/EmittedIL/SerializableAttribute/ToplevelNamespaceP.il.bsl @@ -2471,18 +2471,17 @@ { // Code size 14 (0xe) .maxstack 3 - .locals init ([0] string V_0, - [1] string greeting) - .line 19,19 : 9,31 + .locals init ([0] string greeting, + [1] string V_1) + .line 19,19 : 9,31 '' IL_0000: nop IL_0001: call string XYZ.ABC::get_greeting() IL_0006: stloc.0 - .line 29,29 : 13,35 + .line 29,29 : 13,35 '' IL_0007: call string XYZ.ABC/ABC::get_greeting() IL_000c: stloc.1 IL_000d: ret } // end of method $ToplevelNamespace::.cctor - } // end of class ''.$ToplevelNamespace diff --git a/tests/fsharpqa/Source/Conformance/DeclarationElements/LetBindings/Basic/ManyLetBindings.fs b/tests/fsharpqa/Source/Conformance/DeclarationElements/LetBindings/Basic/ManyLetBindings.fs new file mode 100644 index 00000000000..f5ca30545c0 --- /dev/null +++ b/tests/fsharpqa/Source/Conformance/DeclarationElements/LetBindings/Basic/ManyLetBindings.fs @@ -0,0 +1,515 @@ +module TestCase +open System + +let x0 = "0" +let x1 = "1" +let x2 = "2" +let x3 = "3" +let x4 = "4" +let x5 = "5" +let x6 = "6" +let x7 = "7" +let x8 = "8" +let x9 = "9" +let x10 = "10" +let x11 = "11" +let x12 = "12" +let x13 = "13" +let x14 = "14" +let x15 = "15" +let x16 = "16" +let x17 = "17" +let x18 = "18" +let x19 = "19" +let x20 = "20" +let x21 = "21" +let x22 = "22" +let x23 = "23" +let x24 = "24" +let x25 = "25" +let x26 = "26" +let x27 = "27" +let x28 = "28" +let x29 = "29" +let x30 = "30" +let x31 = "31" +let x32 = "32" +let x33 = "33" +let x34 = "34" +let x35 = "35" +let x36 = "36" +let x37 = "37" +let x38 = "38" +let x39 = "39" +let x40 = "40" +let x41 = "41" +let x42 = "42" +let x43 = "43" +let x44 = "44" +let x45 = "45" +let x46 = "46" +let x47 = "47" +let x48 = "48" +let x49 = "49" +let x50 = "50" +let x51 = "51" +let x52 = "52" +let x53 = "53" +let x54 = "54" +let x55 = "55" +let x56 = "56" +let x57 = "57" +let x58 = "58" +let x59 = "59" +let x60 = "60" +let x61 = "61" +let x62 = "62" +let x63 = "63" +let x64 = "64" +let x65 = "65" +let x66 = "66" +let x67 = "67" +let x68 = "68" +let x69 = "69" +let x70 = "70" +let x71 = "71" +let x72 = "72" +let x73 = "73" +let x74 = "74" +let x75 = "75" +let x76 = "76" +let x77 = "77" +let x78 = "78" +let x79 = "79" +let x80 = "80" +let x81 = "81" +let x82 = "82" +let x83 = "83" +let x84 = "84" +let x85 = "85" +let x86 = "86" +let x87 = "87" +let x88 = "88" +let x89 = "89" +let x90 = "90" +let x91 = "91" +let x92 = "92" +let x93 = "93" +let x94 = "94" +let x95 = "95" +let x96 = "96" +let x97 = "97" +let x98 = "98" +let x99 = "99" +let x100 = "100" +let x101 = "101" +let x102 = "102" +let x103 = "103" +let x104 = "104" +let x105 = "105" +let x106 = "106" +let x107 = "107" +let x108 = "108" +let x109 = "109" +let x110 = "110" +let x111 = "111" +let x112 = "112" +let x113 = "113" +let x114 = "114" +let x115 = "115" +let x116 = "116" +let x117 = "117" +let x118 = "118" +let x119 = "119" +let x120 = "120" +let x121 = "121" +let x122 = "122" +let x123 = "123" +let x124 = "124" +let x125 = "125" +let x126 = "126" +let x127 = "127" +let x128 = "128" +let x129 = "129" +let x130 = "130" +let x131 = "131" +let x132 = "132" +let x133 = "133" +let x134 = "134" +let x135 = "135" +let x136 = "136" +let x137 = "137" +let x138 = "138" +let x139 = "139" +let x140 = "140" +let x141 = "141" +let x142 = "142" +let x143 = "143" +let x144 = "144" +let x145 = "145" +let x146 = "146" +let x147 = "147" +let x148 = "148" +let x149 = "149" +let x150 = "150" +let x151 = "151" +let x152 = "152" +let x153 = "153" +let x154 = "154" +let x155 = "155" +let x156 = "156" +let x157 = "157" +let x158 = "158" +let x159 = "159" +let x160 = "160" +let x161 = "161" +let x162 = "162" +let x163 = "163" +let x164 = "164" +let x165 = "165" +let x166 = "166" +let x167 = "167" +let x168 = "168" +let x169 = "169" +let x170 = "170" +let x171 = "171" +let x172 = "172" +let x173 = "173" +let x174 = "174" +let x175 = "175" +let x176 = "176" +let x177 = "177" +let x178 = "178" +let x179 = "179" +let x180 = "180" +let x181 = "181" +let x182 = "182" +let x183 = "183" +let x184 = "184" +let x185 = "185" +let x186 = "186" +let x187 = "187" +let x188 = "188" +let x189 = "189" +let x190 = "190" +let x191 = "191" +let x192 = "192" +let x193 = "193" +let x194 = "194" +let x195 = "195" +let x196 = "196" +let x197 = "197" +let x198 = "198" +let x199 = "199" +let x200 = "200" +let x201 = "201" +let x202 = "202" +let x203 = "203" +let x204 = "204" +let x205 = "205" +let x206 = "206" +let x207 = "207" +let x208 = "208" +let x209 = "209" +let x210 = "210" +let x211 = "211" +let x212 = "212" +let x213 = "213" +let x214 = "214" +let x215 = "215" +let x216 = "216" +let x217 = "217" +let x218 = "218" +let x219 = "219" +let x220 = "220" +let x221 = "221" +let x222 = "222" +let x223 = "223" +let x224 = "224" +let x225 = "225" +let x226 = "226" +let x227 = "227" +let x228 = "228" +let x229 = "229" +let x230 = "230" +let x231 = "231" +let x232 = "232" +let x233 = "233" +let x234 = "234" +let x235 = "235" +let x236 = "236" +let x237 = "237" +let x238 = "238" +let x239 = "239" +let x240 = "240" +let x241 = "241" +let x242 = "242" +let x243 = "243" +let x244 = "244" +let x245 = "245" +let x246 = "246" +let x247 = "247" +let x248 = "248" +let x249 = "249" +let x250 = "250" +let x251 = "251" +let x252 = "252" +let x253 = "253" +let x254 = "254" +let x255 = "255" +let x256 = "256" +let x257 = "257" +let x258 = "258" +let x259 = "259" +let x260 = "260" +let x261 = "261" +let x262 = "262" +let x263 = "263" +let x264 = "264" +let x265 = "265" +let x266 = "266" +let x267 = "267" +let x268 = "268" +let x269 = "269" +let x270 = "270" +let x271 = "271" +let x272 = "272" +let x273 = "273" +let x274 = "274" +let x275 = "275" +let x276 = "276" +let x277 = "277" +let x278 = "278" +let x279 = "279" +let x280 = "280" +let x281 = "281" +let x282 = "282" +let x283 = "283" +let x284 = "284" +let x285 = "285" +let x286 = "286" +let x287 = "287" +let x288 = "288" +let x289 = "289" +let x290 = "290" +let x291 = "291" +let x292 = "292" +let x293 = "293" +let x294 = "294" +let x295 = "295" +let x296 = "296" +let x297 = "297" +let x298 = "298" +let x299 = "299" +let x300 = "300" +let x301 = "301" +let x302 = "302" +let x303 = "303" +let x304 = "304" +let x305 = "305" +let x306 = "306" +let x307 = "307" +let x308 = "308" +let x309 = "309" +let x310 = "310" +let x311 = "311" +let x312 = "312" +let x313 = "313" +let x314 = "314" +let x315 = "315" +let x316 = "316" +let x317 = "317" +let x318 = "318" +let x319 = "319" +let x320 = "320" +let x321 = "321" +let x322 = "322" +let x323 = "323" +let x324 = "324" +let x325 = "325" +let x326 = "326" +let x327 = "327" +let x328 = "328" +let x329 = "329" +let x330 = "330" +let x331 = "331" +let x332 = "332" +let x333 = "333" +let x334 = "334" +let x335 = "335" +let x336 = "336" +let x337 = "337" +let x338 = "338" +let x339 = "339" +let x340 = "340" +let x341 = "341" +let x342 = "342" +let x343 = "343" +let x344 = "344" +let x345 = "345" +let x346 = "346" +let x347 = "347" +let x348 = "348" +let x349 = "349" +let x350 = "350" +let x351 = "351" +let x352 = "352" +let x353 = "353" +let x354 = "354" +let x355 = "355" +let x356 = "356" +let x357 = "357" +let x358 = "358" +let x359 = "359" +let x360 = "360" +let x361 = "361" +let x362 = "362" +let x363 = "363" +let x364 = "364" +let x365 = "365" +let x366 = "366" +let x367 = "367" +let x368 = "368" +let x369 = "369" +let x370 = "370" +let x371 = "371" +let x372 = "372" +let x373 = "373" +let x374 = "374" +let x375 = "375" +let x376 = "376" +let x377 = "377" +let x378 = "378" +let x379 = "379" +let x380 = "380" +let x381 = "381" +let x382 = "382" +let x383 = "383" +let x384 = "384" +let x385 = "385" +let x386 = "386" +let x387 = "387" +let x388 = "388" +let x389 = "389" +let x390 = "390" +let x391 = "391" +let x392 = "392" +let x393 = "393" +let x394 = "394" +let x395 = "395" +let x396 = "396" +let x397 = "397" +let x398 = "398" +let x399 = "399" +let x400 = "400" +let x401 = "401" +let x402 = "402" +let x403 = "403" +let x404 = "404" +let x405 = "405" +let x406 = "406" +let x407 = "407" +let x408 = "408" +let x409 = "409" +let x410 = "410" +let x411 = "411" +let x412 = "412" +let x413 = "413" +let x414 = "414" +let x415 = "415" +let x416 = "416" +let x417 = "417" +let x418 = "418" +let x419 = "419" +let x420 = "420" +let x421 = "421" +let x422 = "422" +let x423 = "423" +let x424 = "424" +let x425 = "425" +let x426 = "426" +let x427 = "427" +let x428 = "428" +let x429 = "429" +let x430 = "430" +let x431 = "431" +let x432 = "432" +let x433 = "433" +let x434 = "434" +let x435 = "435" +let x436 = "436" +let x437 = "437" +let x438 = "438" +let x439 = "439" +let x440 = "440" +let x441 = "441" +let x442 = "442" +let x443 = "443" +let x444 = "444" +let x445 = "445" +let x446 = "446" +let x447 = "447" +let x448 = "448" +let x449 = "449" +let x450 = "450" +let x451 = "451" +let x452 = "452" +let x453 = "453" +let x454 = "454" +let x455 = "455" +let x456 = "456" +let x457 = "457" +let x458 = "458" +let x459 = "459" +let x460 = "460" +let x461 = "461" +let x462 = "462" +let x463 = "463" +let x464 = "464" +let x465 = "465" +let x466 = "466" +let x467 = "467" +let x468 = "468" +let x469 = "469" +let x470 = "470" +let x471 = "471" +let x472 = "472" +let x473 = "473" +let x474 = "474" +let x475 = "475" +let x476 = "476" +let x477 = "477" +let x478 = "478" +let x479 = "479" +let x480 = "480" +let x481 = "481" +let x482 = "482" +let x483 = "483" +let x484 = "484" +let x485 = "485" +let x486 = "486" +let x487 = "487" +let x488 = "488" +let x489 = "489" +let x490 = "490" +let x491 = "491" +let x492 = "492" +let x493 = "493" +let x494 = "494" +let x495 = "495" +let x496 = "496" +let x497 = "497" +let x498 = "498" +let x499 = "499" +let x500 = "500" +let x501 = "501" +let x502 = "502" +let x503 = "503" +let x504 = "504" +let x505 = "505" +let x506 = "506" +let x507 = "507" +let x508 = "508" +let x509 = "509" +let x510 = "510" +let x511 = "511" diff --git a/tests/fsharpqa/Source/Conformance/DeclarationElements/LetBindings/Basic/env.lst b/tests/fsharpqa/Source/Conformance/DeclarationElements/LetBindings/Basic/env.lst index 97702ef99d1..1b523e68034 100644 --- a/tests/fsharpqa/Source/Conformance/DeclarationElements/LetBindings/Basic/env.lst +++ b/tests/fsharpqa/Source/Conformance/DeclarationElements/LetBindings/Basic/env.lst @@ -4,6 +4,8 @@ SOURCE=Pathological04.fs SCFLAGS=-a # Pathological04.fs SOURCE=E_Pathological05.fs SCFLAGS=--test:ErrorRanges # E_Pathological05.fs SOURCE=E_Pathological06.fs SCFLAGS=--test:ErrorRanges # E_Pathological06.fs + + SOURCE=ManyLetBindings.fs SCFLAGS="--debug:full --optimize-" # ManyLetBindings.fs SOURCE=SanityCheck.fs # SanityCheck.fs SOURCE=nestedLetBindings.fs # nestedLetBindings.fs