On Wed, 2006-09-06 at 10:22 -0700, Chris Lattner wrote:> Okay. Question: does GCC 4.1.2 (if it exists) or GCC mainline fix the > problem? If so, we should document 4.1.1 as being buggy.FWIW, I returned to 3.4.6 when 4.1.1 didn't work out for me. I haven't tried 4.1.2. I'm waiting for the dust to settle on 4.2 Reid
On Wed, 6 Sep 2006, Reid Spencer wrote:> On Wed, 2006-09-06 at 10:22 -0700, Chris Lattner wrote: >> Okay. Question: does GCC 4.1.2 (if it exists) or GCC mainline fix the >> problem? If so, we should document 4.1.1 as being buggy. > > FWIW, I returned to 3.4.6 when 4.1.1 didn't work out for me. I haven't > tried 4.1.2. I'm waiting for the dust to settle on 4.2Do you recall what didn't work? Does 4.1.0 work? Documenting this in the GSG is really important for new users. Thx, -Chris -- http://nondot.org/sabre/ http://llvm.org/
Zhongxing Xu
2006-Sep-07 02:58 UTC
[LLVMdev] Can a name in LLVM assembly language hold two types of value at the same time
I am trying to symbolically execute LLVM assembly language. I found a
possible
semantic inconsistancy of the LLVM assembly language, or maybe my
understanding
is wrong.
The C code is:
#include <stdlib.h>
1 int f(void)
2 {
3 int a;
4 int *b = (int *) malloc(3*sizeof(int));
5 a = 3;
6 return 0;
7 }
I compile it with llvm-gcc 4 front end. The generated LLVM assembly code
is:
1 target endian = little
2 target pointersize = 32
3 target triple = "i686-pc-linux-gnu"
4 implementation ; Functions:
5 int %f() {
6 entry:
7 %retval = alloca int, align 4 ; <int*> [#uses=2]
8 %tmp = alloca int, align 4 ; <int*> [#uses=2]
9 %a = alloca int, align 4 ; <int*> [#uses=1]
10 %b = alloca int*, align 4 ; <int**> [#uses=1]
11 "alloca point" = cast int 0 to int ;
<int> [#uses=0]
12 %tmp = call sbyte* %malloc( uint 12 ) ; <sbyte*>
[#uses=1]
13 %tmp1 = cast sbyte* %tmp to int* ; <int*>
[#uses=1]
14 store int* %tmp1, int** %b
15 store int 3, int* %a
16 store int 0, int* %tmp
17 %tmp = load int* %tmp ; <int> [#uses=1]
18 store int %tmp, int* %retval
19 br label %return
20 return: ; preds = %entry
21 %retval = load int* %retval ; <int> [#uses=1]
22 ret int %retval
23 }
declare sbyte* %malloc(uint)
After line 8, %tmp holds a pointer to stack, whose type is int*
After line 12, %tmp holds a pointer to heap, whose type is sbyte*
At line 16, value 0 is to be stored to a memory location of type int
pointed to by %tmp. But at this time %tmp is holding a pointer to
heap of type sbyte. And the heap should not be written to. (There is
no assignment to b[0] in the C code.)
So I guess that %;tmp also holds its original value, which is a pointer
to stack of type int. And we can decide which location to store according
to the type.
Could someone explain this for me? Thanks.
-- Zhongxing Xu