2008-03-19 Zoltan Varga <vargaz@gmail.com>
[mono.git] / mono / mini / iltests.il.in
1 .assembly iltests {}
2 .assembly extern TestDriver {}
3 .assembly extern mscorlib {}
4
5 .class public auto ansi sealed beforefieldinit Tests {
6
7         .method static public int32 Main(string[] args) il managed {
8                 .entrypoint
9                 
10                 ldtoken Tests
11                 call       class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
12                 ldarg.0
13                 call       int32 [TestDriver]TestDriver::RunTests(class [mscorlib]System.Type, string[])
14                 ret
15         }
16
17         // make sure the register allocator works when the return value of
18         // 'div' is discarded
19         .method static public int32 test_0_div_regalloc () il managed {
20                 .locals init (
21                         int32 i
22                 )
23
24                 ldloc 0
25                 ldc.i4.s 0xa
26                 div
27                 pop
28                 ldc.i4.0
29                 ret
30         }
31         
32         
33         .method static public int32 test_1_ceq_to_i4 () il managed {
34                 .locals init (
35                         int32   foo
36                 )
37                 ldc.i4 500
38                 stloc foo
39                 ldloc foo
40                 ldc.i4 500
41                 ceq
42                 stloc foo
43                 ldloc foo
44                 ret
45         }
46         
47         .method static public int32 test_3_shl_regvars () il managed {
48                 .locals init (
49                         int32   a,
50                         int32   b,
51                         int32   r1,
52                         int32   r2,
53                         int32   r3
54                 )
55                         
56                 ldc.i4.2
57                 stloc      a
58                 ldc.i4.1
59                 stloc      b
60         
61                 ldloc      a
62                 ldloc      b
63                 shl 
64                 stloc      r1
65                 
66                 ldloc      a
67                 ldloc      b
68                 shl 
69                 stloc      r2
70                 
71                 ldloc      a
72                 ldloc      b
73                 shl 
74                 stloc      r3
75                 
76                 ldloc      r1
77                 ldc.i4.4
78                 ceq
79                 
80                 ldloc      r2
81                 ldc.i4.4
82                 ceq
83                 
84                 ldloc      r3
85                 ldc.i4.4
86                 ceq
87                 
88                 add
89                 add
90                 
91                 ret
92         }
93         
94         .method static public int32 test_1_fceq_to_i4 () il managed {
95         
96                 .locals init (
97                         float64 foo,
98                         int32   val
99                 )
100
101                 ldc.r8      2
102                 stloc       foo
103                 
104                 ldloc       foo
105                 ldc.r8      2
106                 ceq
107                 stloc       val
108                 
109                 ldloc       val
110                 ret
111         }
112
113         //
114         // This should be manually checked. Basically under -O=linears,
115         // you should not see tons of register spilling.
116         //
117         .method static public int32 test_1_bytedreg_free () il managed {
118                 .locals init (
119                         int32   foo
120                 )
121                 ldc.i4 500
122                 stloc foo
123                 ldloc foo
124                 ldc.i4 500
125                 ceq
126                 stloc foo
127                 
128                 ldloc foo
129                 ldc.i4 1
130                 ceq
131                 stloc foo
132
133                 ldloc foo
134                 ldc.i4 1
135                 ceq
136                 stloc foo
137
138                 ldloc foo
139                 ldc.i4 1
140                 ceq
141                 stloc foo
142                 
143                 ldloc foo
144                 ldc.i4 1
145                 ceq
146                 stloc foo
147                 
148                 ldloc foo
149                 ret
150         }
151         
152         //
153         // This should be manually checked. Basically under -O=linears,
154         // you should not see tons of register spilling.
155         //
156         .method static public int32 test_0_bytesreg1_free () il managed {
157                 .locals init (
158                         unsigned int8      dest,
159                         int32              src,
160                         unsigned int8&     pdest
161                 )
162
163                 ldloca     dest
164                 stloc      pdest
165                 
166                 ldloc      pdest
167                 ldloc      src
168                 stind.i1
169                 
170                 ldloc      pdest
171                 ldloc      src
172                 stind.i1
173                 
174                 ldloc      pdest
175                 ldloc      src
176                 stind.i1
177                 
178                 ldloc      pdest
179                 ldloc      src
180                 stind.i1
181                 
182                 ldloc      pdest
183                 ldloc      src
184                 stind.i1
185                 
186                 ldloc      pdest
187                 ldloc      src
188                 stind.i1
189                 
190                 ldloc      pdest
191                 ldind.i1
192                 ret
193         }
194         
195         .method static public int32 test_1_shift_regvar () il managed {
196         
197                 .locals init (
198                         int32   v7FFFFFFF,
199                         int32   v1
200                 )
201                 
202                 ldc.i4  0x7FFFFFFF
203                 stloc   v7FFFFFFF
204         
205                 ldc.i4.1
206                 stloc v1
207                 
208                 ldloc   v7FFFFFFF
209                 ldloc   v1
210                 shl
211                 ldc.i4  0xFFFFFFFE
212                 ceq
213                 ret
214         }
215         
216         // this only happens with the managed pointer, not an unmanaged one.
217         .method static public int32 test_0_foo () il managed {
218         
219                 .locals init (
220                         int32&  buf
221                 )
222                 
223                 ldc.i4.5
224                 localloc
225                 
226                 stloc buf
227                 ldloc buf
228                 
229                 ldind.i4
230                 
231                 ret
232         }
233
234         .method static public int32 test_0_localloc () cil managed {
235                 .locals init (native int, native int, native int, native int, int32)
236
237                 ldc.i4 6
238                 localloc
239                 conv.i
240                 stloc.0
241
242                 ldc.i4 6
243                 localloc
244                 conv.i
245                 stloc.1
246
247                 ldc.i4 6
248                 localloc
249                 conv.i
250                 stloc.2
251
252                 // Variable length
253                 ldc.i4 128
254                 stloc.s 4
255                 ldloc.s 4
256                 localloc
257                 conv.i
258                 stloc.3
259
260                 // Check zero initialized
261                 ldloc.0
262                 ldind.i4
263                 ldc.i4.0
264                 beq OK1
265                 ldc.i4.1
266                 br FAIL
267
268 OK1:
269                 ldloc.3
270                 ldind.i4
271                 ldc.i4.0
272                 beq OK2
273                 ldc.i4.2
274                 br FAIL
275
276 OK2:
277                 ldloc.3
278                 ldc.i4.s 124
279                 add
280                 ldind.i4
281                 ldc.i4.0
282                 beq OK3
283                 ldc.i4.3
284                 br FAIL
285
286 OK3:
287                 ldloc.1
288                 ldc.i4 999999
289                 stind.i4
290                 ldloc.1
291                 ldind.i4
292                 ldc.i4 999999
293                 beq OK4
294                 ldc.i4.4
295                 br FAIL
296
297 OK4:
298                 ldloc.0
299                 ldc.i4 999999
300                 stind.i4
301                 ldloc.0
302                 ldind.i4
303                 ldc.i4 999999
304                 beq OK5
305                 ldc.i4.5
306                 br FAIL
307
308 OK5:
309                 // Try allocations bigger than one page
310                 ldc.i4 8196
311                 localloc
312                 conv.i
313                 stloc.3
314                 ldloc.3
315                 ldc.i4 8192
316                 add
317                 ldc.i4 99
318                 stind.i4
319                 ldloc.3
320                 ldc.i4 8192
321                 add
322                 ldind.i4
323                 ldc.i4 99
324                 beq PASS
325                 ldc.i4.6
326                 br FAIL
327
328 FAIL:
329                 ret
330
331 PASS:   ldc.i4.0
332                 ret
333         }
334
335     .method private static void do_localloc () cil managed {
336         .maxstack 3
337         .locals init (
338                 unsigned int8*  V_0)
339         IL_0000:  ldc.i4.1
340         IL_0001:  ldc.i4 131072
341         IL_0006:  mul
342         IL_0007:  localloc
343         IL_0009:  stloc.0
344         IL_000a:  ret
345     }
346
347         // Check that localloc can't be inlined
348         .method static public int32 test_0_localloc_inline () cil managed {
349                 .maxstack 16
350                 .locals init (
351                         int32 i
352                 )
353
354                 ldc.i4.0
355         stloc.0
356         br COND
357
358 START:  call void class Tests::do_localloc()
359         ldloc.0
360         ldc.i4.1
361         add
362         stloc.0
363 COND:   ldloc.0
364         ldc.i4 1000
365         blt START
366
367                 ldc.i4.0
368                 ret
369         }       
370         
371         .method static public int32 test_3_copy_used_bug () il managed {
372
373                 .locals init (
374                         int32 size,
375                         int32 res
376                 )
377
378                 ldc.i4 0
379                 stloc res
380
381                 ldc.i4 1
382                 stloc size
383
384                 ldloc size
385                 ldloc size
386                 ldloc size
387                 add
388                 stloc size
389                 ldloc size
390                 add
391                 stloc res
392
393                 ldloc res
394                 ret
395         }
396
397         // demonstrate that the copy_used_var is not a fix for the above bug
398         .method static public int32 test_3_copy_used_indir_bug () il managed {
399
400                 .locals init (
401                         int32 size,
402                         int32 res
403                 )
404
405                 ldc.i4 0
406                 stloc res
407
408                 ldc.i4 1
409                 stloc size
410
411                 ldloc size
412                 ldloca size
413                 ldloc size
414                 ldloc size
415                 add
416                 stind.i4
417                 ldloc size
418                 add
419                 stloc res
420
421                 ldloc res
422                 ret
423         }
424
425         .method static public void do_nothing (int32 a) il managed {
426                 ret
427         }
428         
429         // demonstrate the block_split failure: needs -O=inline
430         // mini -O=inline --compile Tests:test_0_split_block_bug iltests.exe
431         .method static public int32 test_0_split_block_bug () il managed {
432
433                 .locals init (
434                         int32 i1
435                 )
436
437                 ldc.i4 1
438                 stloc i1
439  test_label:
440                 ldloc i1
441                 call void class Tests::do_nothing (int32)
442                 ldc.i4 0
443                 brtrue test_label
444                 
445                 ldc.i4 0
446                 ret
447         }
448
449         .method public void inline_do_nothing () il managed {
450                 ret
451         }
452         .method static public int32 test_1_checkthis_inlining () il managed {
453                 ldnull
454                 call instance void class Tests::inline_do_nothing ()
455                 ldc.i4 1
456                 ret
457         }
458
459         .class nested private auto ansi sealed beforefieldinit TailCallStruct 
460                 extends [mscorlib]System.ValueType {
461                 .field public int32 a
462                 .field public int32 b
463         }
464
465         .method static valuetype Tests/TailCallStruct tail1 (valuetype Tests/TailCallStruct arg) {
466                 ldarga 0
467                 ldarga 0
468                 ldfld int32 Tests/TailCallStruct::a
469                 ldc.i4.1
470                 add
471                 stfld int32 Tests/TailCallStruct::a
472                 ldarga 0
473                 ldarga 0
474                 ldfld int32 Tests/TailCallStruct::a
475                 ldc.i4.2
476                 add
477                 stfld int32 Tests/TailCallStruct::a
478                 ldarg.0
479                 ret
480         }
481
482         .method static valuetype Tests/TailCallStruct tail2 (valuetype Tests/TailCallStruct arg) {
483                 ldarg.0
484                 tail.
485                 call valuetype Tests/TailCallStruct Tests::tail1 (valuetype Tests/TailCallStruct)
486                 ret
487         }
488
489 #if arch != __ppc__
490         //
491         // Tail calls are not supported on PowerPC.
492         // 
493         .method static public int32 test_0_tail_calls () il managed {
494                 .maxstack 16
495                 .locals init (
496                         valuetype Tests/TailCallStruct arg
497                 )
498                 ldloca 0
499                 ldc.i4.2
500                 stfld int32 Tests/TailCallStruct::a
501                 ldloca 0
502                 ldc.i4.4
503                 stfld int32 Tests/TailCallStruct::b
504                 ldloc.0
505                 call valuetype Tests/TailCallStruct Tests::tail2 (valuetype Tests/TailCallStruct)
506                 stloc.0
507                 ldloca 0
508                 ldfld int32 Tests/TailCallStruct::a
509                 ldloca 0
510                 ldfld int32 Tests/TailCallStruct::b
511                 add
512                 ldc.i4 9
513                 sub
514                 ret
515         }
516
517         .method static public int32 tail3 (int32 i, int32 j) il managed {
518                 ldarg.0
519                 ldarg.1
520                 add
521                 ret
522         }
523
524         .method static public int32 tail4 (int32 i, int32 j) il managed {
525                 .maxstack 16
526                 .locals init (
527                         int32 k)
528
529                 // Test arg0 allocated to a register
530                 ldarg.0
531                 ldarg.0
532                 ldarg.0
533                 ldarg.0
534                 add
535                 add
536                 add
537                 starg 0
538
539                 // Test switched up argument variables as the actual arguments
540                 ldarg.1
541                 ldarg.0
542                 tail.
543                 call int32 Tests::tail3 (int32, int32)
544                 ret
545         }
546
547         .method static public int32 test_24_tail_calls2 () il managed {
548                 .maxstack 16
549                 .locals init (
550                         int32 i,
551                         int32 j)
552
553                 ldc.i4.4
554                 stloc.0
555                 ldc.i4.8
556                 stloc.1
557
558                 ldloc.0 
559                 ldloc.1
560                 call int32 Tests::tail4 (int32, int32)
561                 ret
562         }
563 #endif
564
565         .method public static int32 test_5_jmp () cil managed {
566                 jmp int32 Tests::jmp2 ()
567                 ldc.i4.0
568                 ret
569         }
570
571         .method public static int32 jmp2 () cil managed {
572                 ldc.i4.5
573                 ret
574         }               
575
576         .method static public int32 test_11_switch_with_nonempty_stack () il managed {
577                 .maxstack 16
578
579                 ldc.i4.5
580                 ldc.i4.6
581                 ldc.i4.1
582                 switch (L0, L1)
583         L0: 
584                 add
585                 ret
586         L1:
587                 add
588                 ret
589         }
590  
591     .method public static int32 test_5_endfinally_with_nonempty_stack () il managed {
592                 .maxstack 16
593
594         .try {
595           leave IL_0
596         }
597         finally  {
598           ldc.i4.0
599           endfinally
600         }
601         IL_0:  ldc.i4.5
602                 ret
603     }
604
605         .method public static int32 test_0_conv_ovf_i8_neg () il managed {
606                 .maxstack 16
607
608                 ldc.i4.m1
609                 conv.ovf.i8
610                 conv.i4
611                 ldc.i4.m1
612                 beq L_OK
613                 ldc.i4.1
614                 ret
615         L_OK:
616                 ldc.i4.0
617                 ret
618         }               
619
620         .method public static int32 test_1234_conv_u4 () cil managed {
621                 .maxstack 16
622
623                 ldc.i4 1234
624                 conv.u4
625                 conv.i4
626                 ret
627         }
628
629         .method public static int32 test_0_conv_ovf_i_un () cil managed {
630                 .maxstack 16
631
632                 ldc.i4 1234
633                 conv.ovf.i.un
634                 conv.i4
635                 ldc.i4 1234
636                 beq L1
637                 ldc.i4.1
638                 ret
639         L1:
640                 ldc.i4 0x7fffffff
641                 conv.ovf.i.un
642                 conv.i4
643                 ldc.i4 0x7fffffff
644                 beq L2
645                 ldc.i4.2
646                 ret
647         L2:
648                 sizeof [mscorlib]System.IntPtr
649                 ldc.i4 8
650                 beq L5
651                 .try {
652                         ldc.i4 0x80000000
653                         conv.ovf.i.un
654                         leave L4
655                 } catch [mscorlib]System.OverflowException {
656                         pop
657                         leave L5
658                 }
659         L4: 
660                 ldc.i4.3
661                 ret
662         L5:
663                 ldc.i4.0
664                 ret
665         }
666
667         .method public static int32 test_0_conv_ovf_u_un () cil managed {
668                 .maxstack 16
669
670                 ldc.i4 1234
671                 conv.ovf.u.un
672                 conv.i4
673                 ldc.i4 1234
674                 beq L1
675                 ldc.i4.1
676                 ret
677         L1:
678                 ldc.i4.0
679                 ret
680         }
681
682         .method public static int32 test_2_lconv_to_ovf_i4_un () cil managed {
683                 .maxstack 16
684                 .locals init (int32 res)
685
686                 ldc.i4 0x7fffffff
687                 conv.u8
688                 conv.ovf.i4.un
689                 pop
690
691                 ldc.i4.2
692                 stloc res
693
694         .try {
695                         ldc.i8 0x80000000
696                         conv.ovf.i4.un
697                         pop
698                         ldc.i4.0
699                         stloc res
700                         leave RET
701                 } catch [mscorlib]System.OverflowException {
702                         pop
703                         leave IL_0
704                 }
705
706         IL_0:
707
708         .try {
709                         ldc.i8 0xffffffff80000000
710                         conv.ovf.i4.un
711                         pop
712                         ldc.i4.1
713                         stloc res
714                         leave RET
715                 } catch [mscorlib]System.OverflowException {
716                         pop
717                         leave RET
718                 }
719
720         RET:
721                 ldloc res
722                 ret
723         }
724
725     .method public static int32 test_1_lconv_to_ovf_i_un () cil managed {
726                 .maxstack 16
727                 .locals init (int32 res)
728
729                 ldc.i4 0x7fffffff
730                 conv.u8
731                 conv.ovf.i.un
732                 conv.i4
733                 pop
734
735                 ldc.i4.1
736                 ret
737         }
738
739         .method public static int32 test_32_lconv_to_u8 () cil managed
740         {
741                 .maxstack 16
742
743                 ldc.i4 32
744                 conv.i8
745                 conv.u8
746                 conv.i4
747                 ret
748         }                               
749
750         .method public static int32 test_32_lconv_to_i8 () cil managed
751         {
752                 .maxstack 16
753
754                 ldc.i4 32
755                 conv.i8
756                 conv.i8
757                 conv.i4
758                 ret
759         }                               
760
761         .method public static int32 test_15_lconv_to_u () cil managed
762         {
763         ldc.i8 0x10000000f
764                 conv.u
765                 conv.i4
766                 ret
767         }
768
769         .method public static int32 test_0_get_type_from_handle_on_bblock_boundary () cil managed 
770         {
771                 .maxstack 16
772         
773                 ldc.i4.1
774                 brfalse OBJECT
775         
776                 ldtoken [mscorlib]System.String
777                 br AFTER
778         OBJECT:
779                 ldtoken [mscorlib]System.Object
780         AFTER:
781                 call class [mscorlib]'System.Type' class [mscorlib]'System.Type'::'GetTypeFromHandle'(valuetype [mscorlib]'System.RuntimeTypeHandle')
782                 callvirt instance string class [mscorlib]System.Type::get_FullName ()
783                 ldstr "System.String"
784                 callvirt instance bool class [mscorlib]System.Object::Equals(object)
785                 ldc.i4.0
786                 ceq
787                 ret 
788         }
789                 
790         .method public static int32 test_0_bug59580  ()
791         {
792                 ldc.r4          float32(0x7FC00000)
793                 ldc.r4          float32(0x7FC00000)
794                 bge.un          pass
795                 br              fail
796         pass:
797                 ldc.i4.0
798                 ret
799         fail:
800                 ldc.i4.1
801                 ret
802         }
803         
804         .method public static int32 test_1_bug60056  () {
805                 .locals init (int32 m5)
806                         
807                 ldc.i4.m1
808                 stloc.0
809                 
810                 ldc.i4.1
811                 conv.u8
812                 
813                 ldloc.0
814                 conv.i8
815                 mul
816                 
817                 ldc.i4.m1
818                 conv.i8
819                 ceq
820                 ret
821         }
822         
823         .method public static int32 test_1_conv_u8_cfold  () {
824                 ldc.i4.m1
825                 conv.u8
826                 
827                 ldc.i8 0x00000000ffffffff
828                 
829                 ceq
830                 ret
831         }
832         
833         .method public static int32 test_1_array_type_mismatch_ldelema  () {
834                 .locals init (int32 r)
835                 
836                         ldc.i4.1
837                         newarr string
838                         ldc.i4.0 
839                         ldelema string
840                         pop
841                 
842                 .try {
843                         ldc.i4.1
844                         newarr string
845                         ldc.i4.0 
846                         ldelema object
847                         pop
848                         
849                         leave end
850                 } catch [mscorlib]System.ArrayTypeMismatchException {
851                         pop
852                         ldc.i4.1
853                         stloc.0
854                         leave end
855                 }
856         end:
857                 ldloc.0
858                 ret
859         }
860
861         .method public static int32 test_1_conv_ovf_i8_with_i4 () {
862                         ldc.i4.m1 
863                         conv.ovf.i8
864                         conv.ovf.i4
865                         neg
866                         ret
867         }
868
869         // bug #72148
870     .method public static int32 test_0_initlocals_float_ptr () {
871         .maxstack 3
872         .locals init (
873                 float32[]       V_0,
874                 float32& pinned V_1,
875                 unsigned int32  V_2)
876                         ldc.i4.s 0x0f
877                         newarr [mscorlib]System.Single
878                         stloc.0 
879                         ldloc.0 
880                         ldc.i4.0 
881                         ldc.r4 1.13
882                         stelem.r4 
883                         ldloc.0 
884                         ldc.i4.0 
885                         ldelema [mscorlib]System.Single
886                         stloc.1 
887                         ldloc.1 
888                         conv.i 
889                         ldind.u4 
890                         stloc.2 
891                         ldc.i4.0
892                         ret
893         }
894
895         .method public static int32 test_7_conv_ovf_u8_un () {
896         .maxstack  2
897         .locals    init (unsigned int64)
898
899         ldc.i4.7
900         conv.ovf.u8.un
901         stloc.0
902                 ldloc.0
903                 conv.i4
904         ret
905         }
906
907         .method public static int32 test_1_bug_74591 () {
908                 .maxstack 16
909                 .locals init (int32)
910
911                 ldc.i4.m1
912                 stloc.0
913                 ldloc.0
914                 conv.ovf.i8
915                 ldc.i4.m1
916                 conv.ovf.i8
917                 mul.ovf
918                 conv.i4
919                 ret
920         }
921
922         .class nested public auto ansi Integer
923                 extends [mscorlib]System.Object {
924
925                 .field public bool n
926
927             .method public hidebysig  specialname  rtspecialname 
928            instance default void .ctor (unsigned int64 i, bool n)  cil managed 
929             {
930                         .maxstack 8
931                         ldarg.0
932                         call instance void class [mscorlib]System.Object::.ctor()
933                         ldarg.0
934                         ldarg.2
935                         stfld bool Tests/Integer::n
936                         ret
937                 }
938         }
939
940         .method public static int32 test_1_bug_74726 () {
941                 .maxstack 16
942
943                 ldc.i4.2
944                 conv.ovf.u8
945                 ldc.i4.1
946                 conv.ovf.u8
947                 mul.ovf.un
948                 ldc.i4.1
949                 newobj instance void class Tests/Integer::.ctor(unsigned int64, bool)
950                 ldfld bool Tests/Integer::n
951                 ldc.i4.1
952                 ceq
953                 ret
954         }
955
956         .class nested private auto ansi sealed xxx
957         extends [mscorlib]System.ValueType
958    {
959      .field  public   object a
960
961      .method public hidebysig  specialname  rtspecialname 
962             instance default void .ctor ()  cil managed 
963      {
964                  .maxstack 8
965                  ret 
966      }
967    } // end of class xxx
968
969         .method public static int32 test_0_newobj_vtype () {
970                 .maxstack 6
971                 .locals init (
972                         valuetype Tests/xxx V_0
973                 )
974
975                 newobj instance void valuetype Tests/xxx::.ctor ()
976                 stloc.0
977                 ldloca.s 0
978                 ldfld object Tests/xxx::a
979                 brfalse OK
980                 ldc.i4.s 1
981                 ret
982         OK:
983                 ldc.i4.s 0
984                 ret
985         }
986
987         .method public static int32 test_1_filters () {
988                 .maxstack 16
989                 .locals init (
990                         int32 res
991                 )
992
993                 .try { // 0
994                         .try {
995                                 ldstr "OnErrorSub test Exception"
996                                 newobj instance void class [mscorlib]System.Exception::.ctor(string)
997                                 throw 
998                                 leave.s IL_0033
999                         }
1000                         filter {
1001                                 pop
1002                                 ldc.i4.0
1003                                 endfilter
1004                         } {
1005                                 pop
1006                                 // Should not be called
1007                                 ldc.i4.2
1008                                 stloc res
1009                                 leave.s IL_0033
1010                         }
1011                 }
1012                 filter {
1013                         pop
1014                         ldc.i4.1
1015                         endfilter 
1016                 } {
1017                   pop
1018                   ldc.i4.1
1019                   stloc res       
1020                   leave.s IL_0033
1021
1022                 }
1023                 IL_0033:
1024                 ldloc res
1025                 ret
1026         }
1027
1028         .class nested private auto ansi sealed beforefieldinit TheStruct
1029                 extends [mscorlib]System.ValueType {
1030                 .field public int32 a
1031                 .field public int32 b
1032         }
1033
1034         .method public static int32 test_5_cpobj () {
1035                 .maxstack 8
1036                 .locals init (  
1037                                 valuetype Tests/TheStruct v_0, 
1038                                 valuetype Tests/TheStruct v_1
1039                                          )
1040
1041                 ldloca v_0
1042                 ldc.i4.2
1043                 stfld int32 Tests/TheStruct::a
1044
1045                 ldloca v_0
1046                 ldc.i4.3
1047                 stfld int32 Tests/TheStruct::b
1048
1049                 ldloca v_1
1050                 ldloca v_0
1051                 cpobj Tests/TheStruct
1052
1053                 ldloca v_1
1054                 ldfld int32 Tests/TheStruct::a
1055                 ldloca v_1
1056                 ldfld int32 Tests/TheStruct::b
1057                 add
1058
1059                 ret
1060         }
1061
1062         .method public static int32 test_5_ldobj_stloc_optimization () {
1063                 .maxstack 8
1064                 .locals init (  
1065                                 valuetype Tests/TheStruct v_0, 
1066                                 valuetype Tests/TheStruct v_1
1067                                          )
1068
1069                 ldloca v_0
1070                 ldc.i4.2
1071                 stfld int32 Tests/TheStruct::a
1072
1073                 ldloca v_0
1074                 ldc.i4.3
1075                 stfld int32 Tests/TheStruct::b
1076
1077                 ldloca v_0
1078                 ldobj valuetype Tests/TheStruct
1079                 stloc.s v_1
1080
1081                 ldloca v_1
1082                 ldfld int32 Tests/TheStruct::a
1083                 ldloca v_1
1084                 ldfld int32 Tests/TheStruct::b
1085                 add
1086
1087                 ret
1088         }
1089
1090         .method public static int32 test_1_cpobj_reference () {
1091                 .maxstack 8
1092                 .locals init (  
1093                                 object v_0, 
1094                                 object v_1
1095                                          )
1096
1097                 newobj instance void object::.ctor()
1098                 stloc v_0
1099
1100                 ldloca v_1
1101                 ldloca v_0
1102                 cpobj object
1103
1104                 ldloc v_0
1105                 ldloc v_1
1106                 ceq
1107                 ret
1108         }
1109
1110         .method public static int32 test_1_initobj_reference () {
1111                 .maxstack 8
1112                 .locals init (  
1113                                 object v_0
1114                                          )
1115
1116                 newobj instance void object::.ctor()
1117                 stloc v_0
1118
1119                 ldloca v_0
1120                 initobj object
1121
1122                 ldloc v_0
1123                 ldnull
1124                 ceq
1125                 ret
1126         }
1127
1128         .method public static int32 test_1_ldobj_reference () {
1129                 .maxstack 8
1130                 .locals init (  
1131                                 object v_0
1132                                          )
1133
1134                 newobj instance void object::.ctor()
1135                 stloc v_0
1136
1137                 ldloc v_0
1138                 ldloca v_0
1139                 ldobj object
1140                 ceq
1141                 ret
1142         }
1143
1144         .method public static int32 test_5_vtype_on_bb_boundary () {
1145                 .maxstack 8
1146                 .locals init (  
1147                                 valuetype Tests/TheStruct v_0, 
1148                                 valuetype Tests/TheStruct v_1
1149                                          )
1150
1151                 ldloca v_0
1152                 ldc.i4.2
1153                 stfld int32 Tests/TheStruct::a
1154
1155                 ldloca v_0
1156                 ldc.i4.3
1157                 stfld int32 Tests/TheStruct::b
1158
1159                 ldloc v_0
1160                 br L_0
1161         L_0: stloc v_1
1162
1163                 ldloca v_1
1164                 ldfld int32 Tests/TheStruct::a
1165                 ldloca v_1
1166                 ldfld int32 Tests/TheStruct::b
1167                 add
1168                 ret
1169         }
1170
1171         .method public static int32 test_5_different_in_stacks () cil managed {
1172                 .maxstack 16
1173
1174                         ldc.i4.1
1175                         ldc.i4.1
1176                         beq L_0
1177
1178                         ldc.i4.3
1179                         ldc.i4.3
1180                         br L_1
1181                         ldc.i4.3
1182                         ldc.i4.3
1183                         br L_2
1184          L_0:   ldc.i4.2
1185                         ldc.i4.3
1186                         ldc.i4.1
1187                         ldc.i4.1
1188                         beq L_2
1189          L_1:   add
1190                         ret
1191          L_2:   add
1192                         ret
1193         }
1194
1195         .method public static int32 test_3_larray_get_set () {
1196                 .locals init (
1197                         int32[2]        V_0)
1198                           
1199                         ldc.i4.2 
1200                         newobj instance void int32[0...]::.ctor(int32)
1201                         stloc.0 
1202                         ldloc.0 
1203                         ldc.i4.0 
1204                         ldc.i4 1
1205                         call instance void int32[0...]::Set(int32, int32)
1206                     ldloc.0 
1207                     ldc.i4.1 
1208                         ldc.i4 2
1209                         call instance void int32[0...]::Set(int32, int32)
1210
1211                         ldloc.0
1212                         ldc.i4.0
1213                         call instance int32 int32[0...]::Get(int32)
1214                         ldloc.0
1215                         ldc.i4.1
1216                         call instance int32 int32[0...]::Get(int32)
1217                         add
1218                         ret
1219         }
1220
1221         .method public static int32 test_0_pop_side_effects () {
1222                 .try {
1223                         ldc.r8 1
1224                         ldc.r8 0
1225                         div
1226                         ckfinite
1227                         pop
1228                         leave FAIL
1229                 }
1230                 catch [mscorlib]System.ArithmeticException {
1231                         pop
1232                         leave L_0
1233                 }
1234                 L_0:
1235                 ldc.i4.0
1236                 ret
1237                 FAIL:
1238                 ldc.i4.1
1239                 ret
1240         }
1241
1242         .method public static void regalloc_regress_78314_helper (object o) cil managed
1243         {
1244                 ret
1245         }
1246
1247         .method public static int32 test_1_regalloc_regress_78314 () cil managed
1248         {
1249     // Code size       68 (0x44)
1250     .maxstack  6
1251     .locals init (int32 V_0, bool V_1)
1252     IL_0000:  ldc.i4.0
1253     IL_0001:  stloc.0
1254     IL_0002:  br.s       IL_003b
1255
1256     IL_0004:
1257     IL_001e:  ldc.i4.s   10
1258     IL_0020:  ldloc.0
1259     IL_0021:  shl
1260     IL_0022:  ldc.i4.s   10
1261     IL_0024:  ldloc.0
1262     IL_0025:  shl
1263     IL_0026:  ceq
1264     IL_0028:  box        [mscorlib]System.Boolean
1265     IL_0032:  call       void Tests::regalloc_regress_78314_helper(object)
1266     IL_0037:  ldloc.0
1267     IL_0038:  ldc.i4.1
1268     IL_0039:  add
1269     IL_003a:  stloc.0
1270     IL_003b:  ldloc.0
1271     IL_003c:  ldc.i4.8
1272     IL_003f:  blt.s      IL_0004
1273
1274         ldloc.0
1275         ldc.i4.8
1276         ceq
1277         conv.i4
1278         ret     
1279   }
1280
1281         .method public static void try_block_end_remove_if_useless () cil managed {
1282             .maxstack  8
1283
1284             T_START:
1285                 ldstr   "Start"
1286                         pop
1287                 leave.s COMPLETE
1288             T1_END:
1289
1290             COMPLETE:
1291                 ret
1292
1293             F1_START:
1294                 ldstr   "Finally1"
1295                         pop
1296                 endfinally
1297             F1_END:
1298
1299             .try T_START to T1_END finally handler F1_START to F1_END
1300         }
1301
1302         .method public static int32 test_0_try_block_end_remove_if_useless () cil managed {
1303                 call void class Tests::try_block_end_remove_if_useless ()
1304                 ldc.i4.0
1305                 ret
1306         }
1307
1308    .method private static int32 test_0_regress_78629_switch_next_ins_target ()  cil managed
1309     {
1310         ldc.i4.0
1311         switch (target)
1312         target: ldstr "bar"
1313                 pop
1314                 ldc.i4.0
1315         ret
1316     }
1317
1318         // This belongs to basic-float.cs, but its hard to tell mcs/csc to
1319         // generate the non .un version of the opcodes
1320     .method private static  hidebysig 
1321            default int32 test_4_float_branch_nan ()  cil managed 
1322     {
1323         // Method begins at RVA 0x27a4
1324         // Code size 74 (0x4a)
1325         .maxstack 2
1326         .locals init (
1327                 float64 V_0,
1328                 float64 V_1,
1329                 int32   V_2)
1330         IL_0000:  ldc.r8 (00 00 00 00 00 00 f8 ff)
1331         IL_0009:  stloc.0 
1332         IL_000a:  ldc.r8 1.
1333         IL_0013:  stloc.1 
1334         IL_0014:  ldc.i4.0 
1335         IL_0015:  stloc.2 
1336         IL_0016:  ldloc.0 
1337         IL_0017:  ldloc.1 
1338         IL_0018:  bge.s IL_001a
1339
1340                                 br L1
1341         IL_001a:  ldloc.2 
1342         IL_001b:  ret 
1343         L1:
1344         IL_001c:  ldloc.2 
1345         IL_001d:  ldc.i4.1 
1346         IL_001e:  add 
1347         IL_001f:  stloc.2 
1348         IL_0020:  ldloc.0 
1349         IL_0021:  ldloc.1 
1350         IL_0022:  ble.s IL_002e
1351                                 br L2
1352         IL_002e:  ldloc.2 
1353         IL_002f:  ret 
1354         L2:
1355         IL_0030:  ldloc.2 
1356         IL_0031:  ldc.i4.1 
1357         IL_0032:  add 
1358         IL_0033:  stloc.2 
1359         IL_0034:  ldloc.0 
1360         IL_0035:  ldloc.1 
1361         IL_0036:  blt.s IL_0038
1362                                 br L3           
1363         IL_0038:  ldloc.2 
1364         IL_0039:  ret 
1365         L3:
1366         IL_003a:  ldloc.2 
1367         IL_003b:  ldc.i4.1 
1368         IL_003c:  add 
1369         IL_003d:  stloc.2 
1370         IL_003e:  ldloc.0 
1371         IL_003f:  ldloc.1 
1372         IL_0040:  bgt.s IL_0042
1373                                 br L4
1374         IL_0042:  ldloc.2 
1375         IL_0043:  ret 
1376         L4:
1377         IL_0044:  ldloc.2 
1378         IL_0045:  ldc.i4.1 
1379         IL_0046:  add 
1380         IL_0047:  stloc.2 
1381         IL_0048:  ldloc.2 
1382         IL_0049:  ret 
1383     } // end of method Tests::test_5_float_branch_nan
1384
1385     .method private static  hidebysig
1386            default void regress_80622_inner (object x)  cil managed
1387     {
1388                 .locals (unsigned int8 i)
1389         // Method begins at RVA 0x2050
1390         // Code size 14 (0xe)
1391         .maxstack 8
1392         IL_1000:  ldarg.0
1393         IL_1001:  unbox unsigned int8
1394         IL_1006:  ldobj unsigned int8
1395         IL_000b:  conv.ovf.i4.un
1396         IL_000c:  pop
1397         IL_000d:  ret
1398     }
1399
1400     // method line 2
1401     .method private static  hidebysig
1402            default int32 test_0_regress_80622 ()  cil managed
1403     {
1404         .maxstack 8
1405         IL_0000:  ldc.i4 255
1406         IL_0005:  box unsigned int8
1407         IL_000a:  call void class Tests::regress_80622_inner (object)
1408                 ldc.i4.0
1409         IL_000f:  ret
1410     }
1411
1412         .method private static default int32 test_0_regresss_80190 () cil managed
1413         {
1414             .maxstack  2
1415             .locals init (int32 V_0,
1416                      int32* V_1)
1417             IL_0000:  nop
1418             IL_0001:  nop
1419             IL_0002:  ldloca.s   V_0
1420             IL_0004:  conv.u
1421             IL_0005:  stloc.1
1422             IL_0006:  ldloc.1
1423             IL_0007:  ldc.i4.3
1424             IL_0008:  stind.i4
1425             IL_0009:  nop
1426                                   ldc.i4.0
1427                                   ret
1428         }
1429
1430         .class interface nested public auto ansi abstract IFaceWithStaticMethod
1431         {
1432             .method public static  specialname 
1433                default void foo ()  cil managed noinlining 
1434             {
1435                 .maxstack 0
1436                 IL_0000:  ret 
1437         }
1438         }
1439         
1440         .class nested public auto ansi AClass extends [mscorlib]System.Object implements Tests/IFaceWithStaticMethod
1441         {
1442             .method public hidebysig  specialname  rtspecialname 
1443            instance default void .ctor ()  cil managed 
1444             {
1445                         .maxstack 8
1446                         ret
1447                 }
1448
1449         }
1450
1451         // Test that static methods in interfaces are ignored during vtable construction
1452         .method private static default int32 test_0_ifaces_with_static_methods () cil managed
1453         {
1454                 .maxstack 16
1455
1456                 newobj instance void class Tests/AClass::.ctor()
1457                 pop
1458                 ldc.i4.0
1459                 ret
1460         }
1461
1462         .method private static hidebysig default int32 Foo<T> (!!T n)  cil managed {
1463                 ldarg.0
1464                 box !!0
1465                 brtrue HAS_VALUE
1466                 ldc.i4.0
1467                 ret
1468 HAS_VALUE:      ldc.i4.1
1469                 ret
1470         }
1471
1472         // bug 78019
1473         .method static public int32 test_0_nullable_box_brtrue () cil managed {
1474
1475                 .locals init (valuetype [mscorlib]System.Nullable`1<int32> V_0)
1476
1477                 ldloc.0
1478                 call int32 class Tests::Foo<valuetype [mscorlib]System.Nullable`1<int32>> (!!0)
1479                 ret
1480         }
1481
1482 }