Skip to content

possible volatile bug -- too many loads #3148

@regehr

Description

@regehr
Bugzilla Link 2776
Resolution WORKSFORME
Resolved on Oct 05, 2008 13:48
Version unspecified
OS Linux
CC @lattner

Extended Description

This is for r55873 on Ubuntu Hardy on ia32. Looks to me like the right answer is loading g_45 just one time.

regehr@john-home:~/volatile/tmp26$ llvm-gcc -O1 -S --emit-llvm small.c -o foo.s ; llvm-as -f foo.s ; lli --force-interpreter --interpreter-print-volatile foo.s.bc
Volatile load %0 = volatile load i32* @​g_45, align 4 ; [#uses=0]
Volatile load %5 = volatile load i32* @​g_124, align 4 ; [#uses=1]
checksum = 0

regehr@john-home:~/volatile/tmp26$ llvm-gcc -O3 -S --emit-llvm small.c -o foo.s ; llvm-as -f foo.s ; lli --force-interpreter --interpreter-print-volatile foo.s.bc
Volatile load %0 = volatile load i32* @​g_45, align 4 ; [#uses=0]
Volatile load %1 = volatile load i32* @​g_45, align 4 ; [#uses=0]
Volatile load %2 = volatile load i32* @​g_124, align 4 ; [#uses=0]
Volatile load %1 = volatile load i32* @​g_45, align 4 ; [#uses=0]
checksum = 0

regehr@john-home:~/volatile/tmp26$ cat small.c

#include <stdio.h>

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;

uint32_t g_20;
volatile uint32_t g_45 ;
int32_t g_83;
volatile uint32_t g_124;
volatile uint32_t g_208;

int32_t func_100 (uint32_t p_103);
int32_t func_100 (uint32_t p_103)
{
return 1;
}

int32_t func_119 (uint32_t p_120);
int32_t func_119 (uint32_t p_120)
{
return 1;
}

int32_t func_96 (int32_t p_97);
int32_t func_96 (int32_t p_97)
{
if ((g_45 > 1) > 1 > g_83)
{
func_100 (g_208);
return 1;
}
func_119 (g_124);
return 1;
}

void func_90 (int16_t p_92);
void func_90 (int16_t p_92)
{
for (g_83 = 0; g_83 <= 0; g_83++)
func_96 (1);
}

int main (void)
{
func_90 (1);
printf ("checksum = 0\n");
return 0;
}

Metadata

Metadata

Assignees

Labels

bugzillaIssues migrated from bugzillaworksformeResolved as "works for me"

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions