volatile store/load

Hi,

In order to compile this small program (echo.c), I did a very basic
implementation of volatile. For the moment, I only modified store/load of
simple scalar value type. Afterward, I saw that there was a fixme in LValue.
Would it be best to add a volatility flag to LValue, or is my way of doing
it okay?

Regards,

Cédric

(result of compiling and optimizing echo with the patch:

@serial_data = global i8 addrspace(1)* inttoptr (i32 1 to i8 addrspace(1)*),
align 4 ; <i8 addrspace(1)**> [#uses=1]
@serial_ctrl = global i8 addrspace(1)* inttoptr (i32 2 to i8 addrspace(1)*),
align 4 ; <i8 addrspace(1)**> [#uses=1]

define void @main(...) noreturn nounwind {
entry:
  br label %whilecond1

whilecond1: ; preds = %whileexit, %whilecond1, %entry
  %tmp = load i8 addrspace(1)** @serial_ctrl ; <i8
addrspace(1)*> [#uses=1]
  %tmp2 = volatile load i8 addrspace(1)* %tmp ; <i8>
[#uses=1]
  %cmp = icmp eq i8 %tmp2, 0 ; <i1> [#uses=1]
  br i1 %cmp, label %whilecond1, label %whileexit

whileexit: ; preds = %whilecond1
  %tmp4 = load i8 addrspace(1)** @serial_data ; <i8
addrspace(1)*> [#uses=2]
  %tmp5 = volatile load i8 addrspace(1)* %tmp4 ; <i8>
[#uses=1]
  volatile store i8 %tmp5, i8 addrspace(1)* %tmp4
  br label %whilecond1
}

)

first_try_volatile.patch (1.98 KB)

echo.c (586 Bytes)