Uploaded image for project: 'Embedded Software & Tools'
  1. Embedded Software & Tools
  2. EXT_EP-9184

Under -o4, compiler may assume a global variable is constant, if it's only set in files containing inline asm()

    XMLWordPrintable

Details

    • Bug
    • Status: Fixed
    • Medium
    • Resolution: Fixed
    • Code Generation Tools
    • CODEGEN-5674
    • Hide
      ARM_18.1.0.LTS
       C2000_18.1.0.LTS
      Show
      ARM_18.1.0.LTS  C2000_18.1.0.LTS
    • Hide
      PRU_2.3.2
       PRU_2.4.0*
       ARM_19.6.0.STS
      Show
      PRU_2.3.2  PRU_2.4.0*  ARM_19.6.0.STS
    • Hide
      First, compiling with -o3 (or less) instead of -o4 will avoid the problem.

      Second, making g_sys_opmode volatile does indeed work around the problem. Since the "volatile" qualifier tells the compiler that something is modifying the variable outside the compiler's view, that's exactly what is needed to keep it from being assumed constant.

      Third, removing the asm() from main.c will work around the problem, by including main.c in the recompilation. I modified EINT/DINT and EALLOW/EDIS macros in F2806x_Device.h and two cpu.h files, making them use the intrinsics __enable_interrupts, __disable_interrupts, __eallow, and __edis. As it happens, __enable_interrupts and __disable_interrupts control both INTM and DBGM, while the macros control them individually, so this may not be a completely satisfactory solution.
      Show
      First, compiling with -o3 (or less) instead of -o4 will avoid the problem. Second, making g_sys_opmode volatile does indeed work around the problem. Since the "volatile" qualifier tells the compiler that something is modifying the variable outside the compiler's view, that's exactly what is needed to keep it from being assumed constant. Third, removing the asm() from main.c will work around the problem, by including main.c in the recompilation. I modified EINT/DINT and EALLOW/EDIS macros in F2806x_Device.h and two cpu.h files, making them use the intrinsics __enable_interrupts, __disable_interrupts, __eallow, and __edis. As it happens, __enable_interrupts and __disable_interrupts control both INTM and DBGM, while the macros control them individually, so this may not be a completely satisfactory solution.
    • The immediate trigger for the bug is that main.c contains asm() statements. That's the only file that sets g_sys_opmode; other...

    Description

      Under -o4, compiler may assume a global variable is constant, if it's only set in files containing inline asm()

      Attachments

        Activity

          People

            syncuser TI User
            syncuser TI User
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: