<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body text="#000000" bgcolor="#ffffff">
I need to figure out all LLVM Instructions that may write to memory.<br>
<br>
In <a href="http://llvm.org/docs/tutorial/OCamlLangImpl7.html">http://llvm.org/docs/tutorial/OCamlLangImpl7.html</a>,
it mentions that<br>
"<span class="Apple-style-span" style="border-collapse: separate;
color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-style:
normal; font-variant: normal; font-weight: normal; letter-spacing:
normal; line-height: normal; orphans: 2; text-indent: 0px;
text-transform: none; white-space: normal; widows: 2;
word-spacing: 0px; font-size: medium;"><span
class="Apple-style-span" style="text-align: left;">In LLVM, all
memory accesses are explicit with load/store instructions, and
it is carefully designed not to have (or need) an "address-of"
operator.</span></span>"<br>
<br>
I take this as "StoreInst is the only one that writes to memory". <br>
<br>
However, this doesn't seem to be enough.<br>
<br>
Consider: <br>
...<br>
int a, b, d;<br>
d = a + b;<br>
...<br>
<br>
The above code is turned into LLVM IR:<br>
<pre wrap=""> %0 = load i32* @a, align 4
%1 = load i32* @b, align 4
%2 = add nsw i32 %1, %0
store i32 %2, i32* @d, align 4
Is it possible that temps such as %0, %1 and/or %2 will NOT being register allocated later in the compilation stage, and thus left in memory?
The above code, when converted back to C level, looks like this:
...
unsigned int llvm_cbe_tmp__6;
unsigned int llvm_cbe_tmp__7;
unsigned int llvm_cbe_tmp__8;
unsigned int llvm_cbe_tmp__9;
llvm_cbe_tmp__6 = *(&a);
llvm_cbe_tmp__7 = *(&b);
llvm_cbe_tmp__8 = ((unsigned int )(((unsigned int )llvm_cbe_tmp__7) + ((unsigned int )llvm_cbe_tmp__6)));
*(&d) = llvm_cbe_tmp__8;
llvm_cbe_tmp__9 = /<b class="moz-txt-star"><span class="moz-txt-tag">*</span>tail<span class="moz-txt-tag">*</span></b>/ printf(((&_OC_str.array[((signed int )0u)])), llvm_cbe_tmp__8);
...
It seems the compiler-generated temps are _actually_ left on stack, and writes to them are actually writes to stack memory (via load, add, ...).
I am confused here.
Could somebody help to clarify it?
Thank you
Chuck
<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"><span class="Apple-style-span" style="font-family: Fixed,monospace; font-size: 14px;"></span></span>
</pre>
</body>
</html>