[LLVMbugs] [Bug 2496] New: likely volatile bug

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Wed Jun 25 11:36:59 PDT 2008


http://llvm.org/bugs/show_bug.cgi?id=2496

           Summary: likely volatile bug
           Product: new-bugs
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: regehr at cs.utah.edu
                CC: llvmbugs at cs.uiuc.edu


This bug is seen using svn 52695 targetting ia32, running on Ubuntu Feisty.

At -O1 the volatile variable g_45 is read 6 times, and at -O3 it is read 4
times.  I compile with -fwrapv to avoid potential undefined integer overflow
behavior.

I apologize for the large testcase, I couldn't reduce it further.


unsigned short context;
typedef signed char int8_t;
typedef short int int16_t;
typedef int int32_t;
typedef unsigned short int uint16_t;
typedef unsigned int uint32_t;

static inline unsigned int
lshift_u_s (unsigned int left, int right)
{
  if ((right < 0) || (right >= sizeof (unsigned int) * 8)
      || (left > ((2147483647 * 2U + 1U) >> right)))
    {
      return left;
    }
  return left << right;
}

static inline int
rshift_s_u (int left, unsigned int right)
{
  if ((left < 0) || (right >= sizeof (int) * 8))
    {
      return left;
    }
  return left >> right;
}

static inline unsigned long int
mod_rhs (const long int rhs)
{
  if (rhs == 0)
    return 1;
  return rhs;
}

int32_t volatile g_45 ;
signed char g_47 = (signed char) 1;

int32_t func_38 (int8_t p_39);
int32_t func_38 (int8_t p_39)
{
  return 1;
}

int32_t func_73 (uint32_t p_75);
int32_t func_73 (uint32_t p_75)
{
  return g_47;
}

int32_t func_24 (int16_t p_35);
int32_t func_24 (int16_t p_35)
{
  int32_t tmp;
  if (p_35)
    {
      tmp = func_38 (g_45);
      if (tmp)
        rshift_s_u (g_45, 1);
    }
  else if (g_45)
    {
      g_47 = 0;
      while (g_47)
        g_47 = g_47 - 1;
    }
  return 1;
}

int32_t func_22 (void);
int32_t func_22 (void)
{
  int16_t tmp = func_73 (1);
  int16_t x = tmp;
  func_24 (x);
  return 1;
}

int32_t func_9 (int16_t p_11);
int32_t func_9 (int16_t p_11)
{
  return 1;
}

int32_t func_7 (uint32_t p_8);
int32_t func_7 (uint32_t p_8)
{
  int16_t tmp = func_22 ();
  int32_t tmp___0 = func_22 ();
  func_9 (tmp___0);
  return 1;
}

void func_1 (void);
void func_1 (void)
{
  unsigned long tmp___1;
  unsigned int tmp___2;
  int32_t tmp___3;
  unsigned long tmp___4;
  tmp___2 = lshift_u_s (1, 1);
  tmp___3 = func_7 (1);
  tmp___4 = mod_rhs (1);
  if ((tmp___2 != 1) + tmp___3 % tmp___4)
    {
      func_22 ();
    }
  tmp___1 = mod_rhs (1);
  func_73 (1 % tmp___1);
}

int main (void)
{
  func_1 ();
  printf ("checksum = %04X\n", context);
  return 0;
}


-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list