home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / gnu / gcc / help / 2118 < prev    next >
Encoding:
Text File  |  1992-09-14  |  2.5 KB  |  120 lines

  1. Newsgroups: gnu.gcc.help
  2. Path: sparky!uunet!spool.mu.edu!umn.edu!umeecs!sparky.eecs.umich.edu!burks
  3. From: burks@sparky.eecs.umich.edu (Timothy Burks)
  4. Subject: gcc 2.2.2: inlining problems
  5. Message-ID: <1992Sep14.165825.664@zip.eecs.umich.edu>
  6. Sender: news@zip.eecs.umich.edu (Mr. News)
  7. Organization: University of Michigan EECS Dept., Ann Arbor, MI
  8. Date: Mon, 14 Sep 1992 16:58:25 GMT
  9. Lines: 109
  10.  
  11.  
  12.  
  13. How can I get gcc to inline this code (taken from the gcc.info files)?
  14.  
  15.  
  16. ------- start of test.C ----------------------------------
  17. static inline int inc (int *a) {(*a)++;}
  18.  
  19. main () {
  20.     int a = 0;
  21.     inc (&a);
  22.     inc (&a);
  23.     inc (&a);
  24. }
  25. ------- end of test.C -------------------------------------
  26.  
  27.  
  28. When I compile w/ gcc 2.2.2 (using -S and -Winline), I get 
  29. no warnings and the following decmips assembly code:
  30.  
  31.  
  32. ------- start of test.s ----------------------------------
  33.     .file    1 "test.C"
  34.  
  35.  # GNU C++ 2.2.2 [AL 1.1, MM 19] DECstation running ultrix compiled by GNU C
  36.  
  37.  # Cc1 defaults:
  38.  
  39.  # Cc1 arguments (-G value = 8, Cpu = default, ISA = 1):
  40.  # -quiet -dumpbase -Winline -o
  41.  
  42. gcc2_compiled.:
  43.     .text
  44.     .align    2
  45.     .globl    main
  46.  
  47.     .loc    1 3
  48.     .ent    main
  49. main:
  50.     subu    $sp,$sp,40        # vars= 8, regs= 2/0, args = 16, extra= 8
  51.     .frame    $fp,0,$31
  52.     .mask    0xc0000000,-20
  53.     .fmask    0x00000000,0
  54.     sw    $31,20($sp)
  55.     sw    $fp,16($sp)
  56.     addu    $fp,$sp,40    # set up frame pointer
  57.     jal    __main
  58.     sw    $0,-12($fp)
  59.     subu    $2,$fp,12
  60.     move    $4,$2
  61.     jal    inc__FPi ****************** NON-INLINED REFERENCE!
  62.     subu    $2,$fp,12
  63.     move    $4,$2
  64.     jal    inc__FPi ****************** NON-INLINED REFERENCE!
  65.     subu    $2,$fp,12
  66.     move    $4,$2
  67.     jal    inc__FPi ****************** NON-INLINED REFERENCE!
  68.     move    $2,$0
  69.     j    $L3
  70.     j    $L3
  71. $L3:
  72.     subu    $sp,$fp,40        # sp not trusted  here
  73.     lw    $31,20($sp)
  74.     lw    $fp,16($sp)
  75.     addu    $sp,$sp,40
  76.     j    $31
  77.     .end    main
  78.     .align    2
  79.  
  80.     .loc    1 1
  81.     .ent    inc__FPi
  82. inc__FPi:
  83.     subu    $sp,$sp,16        # vars= 0, regs= 1/0, args = 0, extra= 8
  84.     .frame    $fp,0,$31
  85.     .mask    0x40000000,-16
  86.     .fmask    0x00000000,0
  87.     sw    $fp,0($sp)
  88.     addu    $fp,$sp,16    # set up frame pointer
  89.     move    $2,$4
  90.     lw    $3,0($2)
  91.     addu    $4,$3,1
  92.     sw    $4,0($2)
  93.     j    $L2
  94.     j    $L1
  95. $L2:
  96. $L1:
  97.     subu    $sp,$fp,16        # sp not trusted  here
  98.     lw    $fp,0($sp)
  99.     addu    $sp,$sp,16
  100.     j    $31
  101.     .end    inc__FPi
  102.  
  103. ------- end of test.s -------------------------------------
  104.  
  105. I get similar results when I compile on a SPARC.
  106.  
  107. Thanks,
  108.  
  109. Tim
  110. ----
  111. MMMM   MMMM  Tim Burks
  112.  MM M M MM   University of Michigan/Advanced Computer Architecture Lab
  113.  MM  M  MM   Ann Arbor, MI 48109
  114. MMMM   MMMM  burks@eecs.umich.edu 
  115. -- 
  116. MMMM   MMMM  Tim Burks
  117.  MM M M MM   University of Michigan/Advanced Computer Architecture Lab
  118.  MM  M  MM   Ann Arbor, MI 48109
  119. MMMM   MMMM  burks@eecs.umich.edu 
  120.