[cfe-dev] volatile store/load

Cédric Venet cedric.venet at laposte.net
Sat Jun 7 09:04:09 PDT 2008


	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
}

)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: first_try_volatile.patch
Type: application/octet-stream
Size: 2018 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20080607/d6bb11d3/attachment.obj>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: echo.c
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20080607/d6bb11d3/attachment.c>


More information about the cfe-dev mailing list