<div dir="ltr">Hi,<div><br></div><div>I'm developing a compiler based on LLVM. It was first based on LLVM 3.2 and</div><div>I have rebased it on every release since. I also have unit tests that check generated</div><div>IR code. I am testing my software on Linux (Ubuntu 14.04) and on Mac OS X.</div><div>Until now, the generated IR code was identical, but in 3.7 this has changed.</div><div>I'm wondering why this is..<br></div><div><br></div><div><div>Both versions have been build with the same version of LLVM/Clang, but there are</div><div>differences in the way I had to build them. So the real question is, whether the differences</div></div><div>in building (see below) cause this, or the different platform...</div><div><br></div><div>--- Linux Build ---</div><div>../llvm/configure --enable-optimized --prefix=$HOME/llvm-c2/ --with-python=/usr/bin/python2<br></div><div><br></div><div>--- OS X Build ---</div><div><div>cmake -G "Unix Makefiles" \</div><div> -DCMAKE_BUILD_TYPE="RelWithDebInfo" \</div><div> -DCMAKE_ENABLE_ASSERTIONS=ON \</div><div> -DCMAKE_INSTALL_PREFIX=$HOME/llvm-c2 \</div><div> ../llvm</div></div><div><br></div><div>I have also tried build type "Release" but then you get a warning that the ASSERTIONS flag is unused.</div><div><br></div><div>The smallest example I could find it hello world. On Linux this generates:</div><div>(only relevant part shown)</div><div><br></div><div>--- Linux IR ---</div><div><div>; Function Attrs: nounwind uwtable</div><div>define i32 @main(i32 %argc, i8** %argv) #0 {</div><div>entry:</div><div> %retval = alloca i32, align 4</div><div> %argc.addr = alloca i32, align 4</div><div> %argv.addr = alloca i8**, align 8</div><div> store i32 0, i32* %retval</div><div> store i32 %argc, i32* %argc.addr, align 4</div><div> store i8** %argv, i8*** %argv.addr, align 8</div><div> %call = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i32 0, i32 0))</div><div> ret i32 0</div><div>}</div></div><div><br></div><div><p style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;color:rgb(245,245,245);background-color:rgb(0,0,0)">define i32 @main(i32 %argc, i8** %argv) #0 {</p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;color:rgb(245,245,245);background-color:rgb(0,0,0)">entry:</p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;color:rgb(245,245,245);background-color:rgb(0,0,0)"> entry:</p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;color:rgb(245,245,245);background-color:rgb(0,0,0)"> %retval = alloca i32, align 4</p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;color:rgb(245,245,245);background-color:rgb(0,0,0)"> %argc.addr = alloca i32, align 4</p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;color:rgb(245,245,245);background-color:rgb(0,0,0)"> %argv.addr = alloca i8**, align 8</p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;color:rgb(245,245,245);background-color:rgb(0,0,0)"> store i32 0, i32* %retval</p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;color:rgb(245,245,245);background-color:rgb(0,0,0)"> store i32 %argc, i32* %argc.addr, align 4</p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;color:rgb(245,245,245);background-color:rgb(0,0,0)"> store i8** %argv, i8*** %argv.addr, align 8</p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;color:rgb(245,245,245);background-color:rgb(0,0,0)"> %call = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i32 0, i32 0))</p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;color:rgb(245,245,245);background-color:rgb(0,0,0)"> ret i32 0</p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;color:rgb(245,245,245);background-color:rgb(0,0,0)">}</p></div><div><br></div><div><br></div><div>--- OS X IR ---</div><div><p style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;color:rgb(245,245,245);background-color:rgb(0,0,0)">define i32 @main(i32 %argc, i8** %argv) {</p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;color:rgb(245,245,245);background-color:rgb(0,0,0)"> <---- NOTE missing 'entry:' here</p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;color:rgb(245,245,245);background-color:rgb(0,0,0)"> %argc.addr = alloca i32</p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;color:rgb(245,245,245);background-color:rgb(0,0,0)"> %argv.addr = alloca i8**</p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;color:rgb(245,245,245);background-color:rgb(0,0,0)"> store i32 %argc, i32* %argc.addr</p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;color:rgb(245,245,245);background-color:rgb(0,0,0)"> store i8** %argv, i8*** %argv.addr</p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;color:rgb(245,245,245);background-color:rgb(0,0,0)"> %1 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @0, i32 0, i32 0))</p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;color:rgb(245,245,245);background-color:rgb(0,0,0)"> ret i32 0</p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;color:rgb(245,245,245);background-color:rgb(0,0,0)">}</p></div><div><br></div><div>Any hints are welcome...</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div></div>