<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:Helvetica;
        panose-1:2 11 6 4 2 2 2 2 2 4;}
@font-face
        {font-family:SimSun;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:SimSun;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:"\@SimSun";
        panose-1:2 1 6 0 3 1 1 1 1 1;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
        {mso-style-priority:99;
        mso-style-link:"Balloon Text Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:8.0pt;
        font-family:"Tahoma","sans-serif";}
span.apple-converted-space
        {mso-style-name:apple-converted-space;}
span.apple-tab-span
        {mso-style-name:apple-tab-span;}
span.BalloonTextChar
        {mso-style-name:"Balloon Text Char";
        mso-style-priority:99;
        mso-style-link:"Balloon Text";
        font-family:"Tahoma","sans-serif";}
span.EmailStyle21
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Hi Manman,<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>I tried your steps on the same revision as yours: </span><span style='color:#1F497D'>r222239@trunk. But failed to reproduce it. Is it related to libc++ version? If so, what revision is used in your test.<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>I tired libc++ reversion of r222425 and r222425 and followed your steps.<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>But it had build failures on 1<sup>st</sup> step:<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>llvm[2]: Linking Release+Asserts executable FileCheck (without symbols)<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>build/utils/FileCheck/Release+Asserts/FileCheck.o:llvm/utils/FileCheck/FileCheck.cpp:function llvm::cl::list<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, llvm::cl::parser<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >::~list(): error: undefined reference to 'operator delete(void*)'<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>…<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>Also I tried to configure without “--enable-libcpp”,  both steps were finished. But can not reproduce the failures on fixxfti.c and fixunsxfti.c. So I think libc++ is necessary.<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>Thanks,<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>-Hao<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><div style='border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt'><div><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> llvm-commits-bounces@cs.uiuc.edu [mailto:llvm-commits-bounces@cs.uiuc.edu] <b>On Behalf Of </b>Manman Ren<br><b>Sent:</b> Thursday, November 20, 2014 8:29 AM<br><b>To:</b> Balaram Makam<br><b>Cc:</b> llvm-commits@cs.uiuc.edu<br><b>Subject:</b> Re: [llvm] r222039 - Reapply r221924: "[GVN] Perform Scalar PRE on gep indices that feed loads before<o:p></o:p></span></p></div></div><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><o:p> </o:p></p><div><blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><div><p class=MsoNormal>On Nov 19, 2014, at 3:46 PM, Balaram Makam <<a href="mailto:bmakam@codeaurora.org">bmakam@codeaurora.org</a>> wrote:<o:p></o:p></p></div><p class=MsoNormal><o:p> </o:p></p><div><p class=MsoNormal><span style='font-size:9.0pt;font-family:"Helvetica","sans-serif"'>Hi Manman,<br><br>I have a patch with a potential fix to the problem, but I cannot reproduce the original failure with the preprocessed source files you provided.</span><o:p></o:p></p></div></blockquote><div><p class=MsoNormal><o:p> </o:p></p></div><p class=MsoNormal>Hi Balaram,<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>You need to build a lto selfhost to reproduce.<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><p class=MsoNormal>1> make a release+assert build with your patch (install the compiler to a directory clang-install for example).<o:p></o:p></p></blockquote></blockquote></blockquote></blockquote><div><p class=MsoNormal><o:p> </o:p></p></div><p class=MsoNormal>create directory clang-build and clang-install under llvm<o:p></o:p></p></div><div><p class=MsoNormal>under clang-build, do:<br>  ./llvm/configure --enable-assertions --enable-optimized --disable-bindings --enable-targets=x86,x86_64 --enable-libcpp --prefix=Users/manmanren/llvm/clang-install<o:p></o:p></p></div><div><p class=MsoNormal>  make -j 12 VERBOSE=1 CLANG_REPOSITORY_STRING=clang-stage1-configure-RA_build SVN_REVISION=222059<br>  make install-clang -j 4<o:p></o:p></p></div><div><p class=MsoNormal><br><br><o:p></o:p></p><blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><p class=MsoNormal>2> use clang-install binary and library to build the same repo with lto.<o:p></o:p></p></blockquote></blockquote></blockquote><p class=MsoNormal><br>create directory selfhost, under selfhost, do:<o:p></o:p></p><div><p class=MsoNormal>../llvm/configure --disable-assertions --with-extra-options="-flto -gline-tables-only” --enable-optimized --disable-bindings --enable-targets=x86,x86_64 --enable-libcpp CC=/Users/manmanren/llvm/clang-install/bin/clang CXX=/Users/manmanren/gmail/clang-install/llvm/clang++<o:p></o:p></p></div></div><div><p class=MsoNormal><br><br><o:p></o:p></p><blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><p class=MsoNormal>   make -j 4 VERBOSE=1 CLANG_REPOSITORY_STRING=clang-Rlto_master_build SVN_REVISION=222059 DYLD_LIBRARY_PATH=/Users/manmanren/llvm_gmail/clang-install/lib/<o:p></o:p></p></blockquote></blockquote></blockquote><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>The whole process takes a few hours to run.You can also commit the patch if you are confident enough and then watch the bot (phase 2 lto).<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>Manman<o:p></o:p></p></div><p class=MsoNormal><br><br><o:p></o:p></p><div><p class=MsoNormal><span style='font-size:9.0pt;font-family:"Helvetica","sans-serif"'>Could you please test this patch (attached) and let me know if it works?<br><br>Thanks,<br>Balaram<br><br><br>-----Original Message-----<br>From: Chad Rosier [</span><a href="mailto:mcrosier@codeaurora.org"><span style='font-size:9.0pt;font-family:"Helvetica","sans-serif"'>mailto:mcrosier@codeaurora.org</span></a><span style='font-size:9.0pt;font-family:"Helvetica","sans-serif"'>]<span class=apple-converted-space> </span><br>Sent: Tuesday, November 18, 2014 9:09 PM<br>To: Manman Ren<br>Cc:<span class=apple-converted-space> </span></span><a href="mailto:mcrosier@codeaurora.org"><span style='font-size:9.0pt;font-family:"Helvetica","sans-serif"'>mcrosier@codeaurora.org</span></a><span style='font-size:9.0pt;font-family:"Helvetica","sans-serif"'>;<span class=apple-converted-space> </span></span><a href="mailto:llvm-commits@cs.uiuc.edu"><span style='font-size:9.0pt;font-family:"Helvetica","sans-serif"'>llvm-commits@cs.uiuc.edu</span></a><span style='font-size:9.0pt;font-family:"Helvetica","sans-serif"'>; Balaram Makam; James Molloy<br>Subject: Re: [llvm] r222039 - Reapply r221924: "[GVN] Perform Scalar PRE on gep indices that feed loads before<br><br>Thanks, Manman.  Balaram or another one of our team members will investigate.<br><br>Chad<br><br><br style='orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:0px'><br></span><o:p></o:p></p><p class=MsoNormal><span style='font-size:9.0pt;font-family:"Helvetica","sans-serif"'><br>Hi Chad,<br><br>I reverted the commit in r222287.<br><br>The lto self host of r222239 without this commit succeeded.<br>And I have finished the lto self host of r222239 including this<span class=apple-converted-space> </span><br>commit, it failed. If you need any more files, let me know.<br><br>Thanks,<br>Manman<br><br>clang(59539,0x7fff7c035300) malloc: *** error for object 0x7fa438648450:<br>pointer being freed was not allocated<br>*** set a breakpoint in malloc_error_break to debug<br> COMPILE:   clang_darwin/cc_kext/x86_64:<br>/Users/manmanren/gmail/llvm/projects/compiler-rt/lib/builtins/fixxfti.c<br> COMPILE:   clang_darwin/cc_kext/x86_64:<br>/Users/manmanren/gmail/llvm/projects/compiler-rt/lib/builtins/x86_64/f<br>loatdidf.c /Users/manmanren/gmail/selfhost/Release/bin/clang -fPIC<span class=apple-converted-space> </span><br>-I/Users/manmanren/gmail/llvm/projects/compiler-rt/lib<br>-I/Users/manmanren/gmail/llvm/projects/compiler-rt/include -arch<span class=apple-converted-space> </span><br>x86_64 -fvisibility=hidden -DVISIBILITY_HIDDEN -mkernel -DKERNEL_USE<span class=apple-converted-space> </span><br>-Wall -Werror -O3 -fomit-frame-pointer -mmacosx-version-min=10.4<span class=apple-converted-space> </span><br>-isysroot<span class=apple-converted-space> </span><br>/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/D<br>eveloper/SDKs/MacOSX10.10.sdk<br>-c -o<br>/Users/manmanren/gmail/selfhost/tools/clang/runtime/compiler-rt/clang_<br>darwin/cc_kext/x86_64/SubDir.lib__builtins/fixxfti.o<br>/Users/manmanren/gmail/llvm/projects/compiler-rt/lib/builtins/fixxfti.c<br> COMPILE:   clang_darwin/cc_kext/x86_64:<br>/Users/manmanren/gmail/llvm/projects/compiler-rt/lib/builtins/x86_64/f<br>loatdisf.c /Users/manmanren/gmail/selfhost/Release/bin/clang -fPIC<span class=apple-converted-space> </span><br>-I/Users/manmanren/gmail/llvm/projects/compiler-rt/lib<br>-I/Users/manmanren/gmail/llvm/projects/compiler-rt/include -arch<span class=apple-converted-space> </span><br>x86_64 -fvisibility=hidden -DVISIBILITY_HIDDEN -mkernel -DKERNEL_USE<span class=apple-converted-space> </span><br>-Wall -Werror -O3 -fomit-frame-pointer -mmacosx-version-min=10.4<span class=apple-converted-space> </span><br>-isysroot<span class=apple-converted-space> </span><br>/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/D<br>eveloper/SDKs/MacOSX10.10.sdk<br>-c -o<br>/Users/manmanren/gmail/selfhost/tools/clang/runtime/compiler-rt/clang_<br>darwin/cc_kext/x86_64/SubDir.lib__builtins__x86_64/floatdisf.o<br>/Users/manmanren/gmail/llvm/projects/compiler-rt/lib/builtins/x86_64/f<br>loatdisf.c /Users/manmanren/gmail/selfhost/Release/bin/clang -fPIC<span class=apple-converted-space> </span><br>-I/Users/manmanren/gmail/llvm/projects/compiler-rt/lib<br>-I/Users/manmanren/gmail/llvm/projects/compiler-rt/include -arch<span class=apple-converted-space> </span><br>x86_64 -fvisibility=hidden -DVISIBILITY_HIDDEN -mkernel -DKERNEL_USE<span class=apple-converted-space> </span><br>-Wall -Werror -O3 -fomit-frame-pointer -mmacosx-version-min=10.4<span class=apple-converted-space> </span><br>-isysroot<span class=apple-converted-space> </span><br>/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/D<br>eveloper/SDKs/MacOSX10.10.sdk<br>-c -o<br>/Users/manmanren/gmail/selfhost/tools/clang/runtime/compiler-rt/clang_<br>darwin/cc_kext/x86_64/SubDir.lib__builtins__x86_64/floatdidf.o<br>/Users/manmanren/gmail/llvm/projects/compiler-rt/lib/builtins/x86_64/f<br>loatdidf.c<br>clang(59547,0x7fff7c035300) malloc: *** error for object 0x7f9410f1c0d0:<br>pointer being freed was not allocated<br>*** set a breakpoint in malloc_error_break to debug<br>0  clang                    0x000000010c15d259<br>llvm::sys::PrintStackTrace(__sFILE*) + 57<br>1  clang                    0x000000010c15ddab SignalHandler(int) + 347<br>2  libsystem_platform.dylib 0x00007fff980faf1a _sigtramp + 26<br>3  libsystem_platform.dylib 0xffffffffffffffff _sigtramp + 1743802623<br>4  libsystem_c.dylib        0x00007fff982ccb73 abort + 129<br>5  libsystem_malloc.dylib   0x00007fff98e7b937 nano_size + 0<br>6  clang                    0x000000010b7b77b9 (anonymous<br>namespace)::X86TTI::getIntImmCost(llvm::APInt const&, llvm::Type*)<span class=apple-converted-space> </span><br>const +<br>601<br>7  clang                    0x000000010b7b6cd8 non-virtual thunk to<br>(anonymous namespace)::X86TTI::getIntImmCost(unsigned int, unsigned<span class=apple-converted-space> </span><br>int, llvm::APInt const&, llvm::Type*) const + 216<br>8  clang                    0x000000010bb73333 (anonymous<br>namespace)::ConstantHoisting::collectConstantCandidates(llvm::DenseMap<br><llvm::ConstantInt*, unsigned int,<span class=apple-converted-space> </span><br>llvm::DenseMapInfo<llvm::ConstantInt*> >&, llvm::Instruction*,<span class=apple-converted-space> </span><br>unsigned int, llvm::ConstantInt*) + 211<br> COMPILE:   clang_darwin/cc_kext/x86_64:<br>/Users/manmanren/gmail/llvm/projects/compiler-rt/lib/builtins/x86_64/floatdixf.c<br>9  clang                    0x000000010bb6ecf4 (anonymous<br>namespace)::ConstantHoisting::runOnFunction(llvm::Function&) + 516<br> COMPILE:   clang_darwin/cc_kext/x86_64:<br>/Users/manmanren/gmail/llvm/projects/compiler-rt/lib/builtins/floattid<br>f.c /Users/manmanren/gmail/selfhost/Release/bin/clang -fPIC<span class=apple-converted-space> </span><br>-I/Users/manmanren/gmail/llvm/projects/compiler-rt/lib<br>-I/Users/manmanren/gmail/llvm/projects/compiler-rt/include -arch<span class=apple-converted-space> </span><br>x86_64 -fvisibility=hidden -DVISIBILITY_HIDDEN -mkernel -DKERNEL_USE<span class=apple-converted-space> </span><br>-Wall -Werror -O3 -fomit-frame-pointer -mmacosx-version-min=10.4<span class=apple-converted-space> </span><br>-isysroot<span class=apple-converted-space> </span><br>/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/D<br>eveloper/SDKs/MacOSX10.10.sdk<br>-c -o<br>/Users/manmanren/gmail/selfhost/tools/clang/runtime/compiler-rt/clang_<br>darwin/cc_kext/x86_64/SubDir.lib__builtins__x86_64/floatdixf.o<br>/Users/manmanren/gmail/llvm/projects/compiler-rt/lib/builtins/x86_64/floatdixf.c<br>10 clang                    0x000000010c0e3a25<br>llvm::FPPassManager::runOnFunction(llvm::Function&) + 549<br>11 clang                    0x000000010c0e3c9b<br>llvm::FPPassManager::runOnModule(llvm::Module&) + 43<br>12 clang                    0x000000010c0e412a<br>llvm::legacy::PassManagerImpl::run(llvm::Module&) + 922<br>13 clang                    0x000000010a445430<br>clang::EmitBackendOutput(clang::DiagnosticsEngine&,<span class=apple-converted-space> </span><br>clang::CodeGenOptions const&, clang::TargetOptions const&,<span class=apple-converted-space> </span><br>clang::LangOptions const&, llvm::StringRef, llvm::Module*,<span class=apple-converted-space> </span><br>clang::BackendAction, llvm::raw_ostream*)<br>+ 12208<br>0  clang                    0x00000001059d5259<br>llvm::sys::PrintStackTrace(__sFILE*) + 57<br>14 clang                    0x000000010a5cda44<br>clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) +<span class=apple-converted-space> </span><br>516 /Users/manmanren/gmail/selfhost/Release/bin/clang -fPIC<span class=apple-converted-space> </span><br>-I/Users/manmanren/gmail/llvm/projects/compiler-rt/lib<br>-I/Users/manmanren/gmail/llvm/projects/compiler-rt/include -arch<span class=apple-converted-space> </span><br>x86_64 -fvisibility=hidden -DVISIBILITY_HIDDEN -mkernel -DKERNEL_USE<span class=apple-converted-space> </span><br>-Wall -Werror -O3 -fomit-frame-pointer -mmacosx-version-min=10.4<span class=apple-converted-space> </span><br>-isysroot<span class=apple-converted-space> </span><br>/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/D<br>eveloper/SDKs/MacOSX10.10.sdk<br>-c -o<br>/Users/manmanren/gmail/selfhost/tools/clang/runtime/compiler-rt/clang_<br>darwin/cc_kext/x86_64/SubDir.lib__builtins/floattidf.o<br>/Users/manmanren/gmail/llvm/projects/compiler-rt/lib/builtins/floattidf.c<br>1  clang                    0x00000001059d5dab SignalHandler(int) + 347<br>2  libsystem_platform.dylib 0x00007fff980faf1a _sigtramp + 26<br>3  libsystem_platform.dylib 0xffffffffffffffff _sigtramp + 1743802623<br>15 clang                    0x000000010a6864c5 4  libsystem_c.dylib<br>0x00007fff982ccb73 clang::ParseAST(clang::Sema&, bool, bool)abort +<span class=apple-converted-space> </span><br>661 +<br>129<br><br>5  libsystem_malloc.dylib   0x00007fff98e7b937 nano_size + 0<br>16 clang                    0x000000010a1f2b7e<br>clang::FrontendAction::Execute() + 62<br>6  clang                    0x000000010502f7b9 (anonymous<br>namespace)::X86TTI::getIntImmCost(llvm::APInt const&, llvm::Type*)<span class=apple-converted-space> </span><br>const +<br>601<br>17 clang                    0x000000010a1ba8d3<br>clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 915<br>7  clang                    0x000000010502ecd8 non-virtual thunk to<br>(anonymous namespace)::X86TTI::getIntImmCost(unsigned int, unsigned<span class=apple-converted-space> </span><br>int, llvm::APInt const&, llvm::Type*) const + 216<br>18 clang                    0x000000010a16a3fa<br>clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 2890<br>8  clang                    0x00000001053eb333 (anonymous<br>namespace)::ConstantHoisting::collectConstantCandidates(llvm::DenseMap<br><llvm::ConstantInt*, unsigned int,<span class=apple-converted-space> </span><br>llvm::DenseMapInfo<llvm::ConstantInt*> >&, llvm::Instruction*,<span class=apple-converted-space> </span><br>unsigned int, llvm::ConstantInt*) + 211<br>19 clang                    0x000000010a16000c<br>cc1_main(llvm::ArrayRef<char const*>, char const*, void*) + 1836<br>9  clang                    0x00000001053e6cf4 (anonymous<br>namespace)::ConstantHoisting::runOnFunction(llvm::Function&) + 516<br>20 clang                    0x000000010a168b21 main + 13745<br>21 libdyld.dylib            0x00007fff8b4215c9 start + 1<br>22 libdyld.dylib            0x0000000000000045 start + 1958603389<br>10 clang                    0x000000010595ba25<br>llvm::FPPassManager::runOnFunction(llvm::Function&) + 549 Stack dump:<br>0.<span class=apple-tab-span>          </span>Program arguments: /Users/manmanren/gmail/selfhost/Release/bin/clang<br>-cc1 -triple x86_64-apple-macosx10.4.0 -emit-obj -disable-free<span class=apple-converted-space> </span><br>-disable-llvm-verifier -main-file-name fixunsxfti.c -static-define<span class=apple-converted-space> </span><br>-mrelocation-model static -mthread-model posix -masm-verbose<span class=apple-converted-space> </span><br>-fforbid-guard-variables -target-cpu core2 -disable-red-zone<span class=apple-converted-space> </span><br>-no-implicit-float -target-linker-version 242 -dwarf-column-info<span class=apple-converted-space> </span><br>-coverage-file<span class=apple-converted-space> </span><br>/Users/manmanren/gmail/selfhost/tools/clang/runtime/compiler-rt/clang_<br>darwin/cc_kext/x86_64/SubDir.lib__builtins/fixunsxfti.o<br>-resource-dir<br>/Users/manmanren/gmail/selfhost/Release/bin/../lib/clang/3.6.0<span class=apple-converted-space> </span><br>-isysroot<span class=apple-converted-space> </span><br>/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/D<br>eveloper/SDKs/MacOSX10.10.sdk<br>-D VISIBILITY_HIDDEN -D KERNEL_USE -I<br>/Users/manmanren/gmail/llvm/projects/compiler-rt/lib -I<span class=apple-converted-space> </span><br>/Users/manmanren/gmail/llvm/projects/compiler-rt/include -O3 -Wall<span class=apple-converted-space> </span><br>-Werror -fdebug-compilation-dir<span class=apple-converted-space> </span><br>/Users/manmanren/gmail/llvm/projects/compiler-rt<br>-ferror-limit 19 -fmessage-length 164 -fvisibility hidden<span class=apple-converted-space> </span><br>-ffreestanding -mstackrealign -fno-builtin -fblocks<span class=apple-converted-space> </span><br>-fblocks-runtime-optional -fno-rtti -fno-use-cxa-atexit<span class=apple-converted-space> </span><br>-fobjc-runtime=macosx-10.4.0 -fobjc-dispatch-method=non-legacy<span class=apple-converted-space> </span><br>-fencode-extended-block-signature<br>-fmax-type-align=16 -fno-common -fdiagnostics-show-option<span class=apple-converted-space> </span><br>-fcolor-diagnostics -vectorize-loops -vectorize-slp -o<span class=apple-converted-space> </span><br>/Users/manmanren/gmail/selfhost/tools/clang/runtime/compiler-rt/clang_<br>darwin/cc_kext/x86_64/SubDir.lib__builtins/fixunsxfti.o<br>-x c<br>/Users/manmanren/gmail/llvm/projects/compiler-rt/lib/builtins/fixunsxfti.c<br>1.<span class=apple-tab-span>          </span><eof> parser at end of file<br>2.<span class=apple-tab-span>          </span>Code generation<br>3.<span class=apple-tab-span>          </span>Running pass 'Function Pass Manager' on module<br>'/Users/manmanren/gmail/llvm/projects/compiler-rt/lib/builtins/fixunsxfti.c'.<br>4.<span class=apple-tab-span>          </span>Running pass 'Constant Hoisting' on function '@__fixunsxfti'<br>11 clang                    0x000000010595bc9b<br>llvm::FPPassManager::runOnModule(llvm::Module&) + 43<br>12 clang                    0x000000010595c12a<br>llvm::legacy::PassManagerImpl::run(llvm::Module&) + 922<br>13 clang                    0x0000000103cbd430<br>clang::EmitBackendOutput(clang::DiagnosticsEngine&,<span class=apple-converted-space> </span><br>clang::CodeGenOptions const&, clang::TargetOptions const&,<span class=apple-converted-space> </span><br>clang::LangOptions const&, llvm::StringRef, llvm::Module*,<span class=apple-converted-space> </span><br>clang::BackendAction, llvm::raw_ostream*)<br>+ 12208<br>14 clang                    0x0000000103e45a44<br>clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) + 516<br>15 clang                    0x0000000103efe4c5<br>clang::ParseAST(clang::Sema&, bool, bool) + 661<br>16 clang                    0x0000000103a6ab7e<br>clang::FrontendAction::Execute() + 62<br>17 clang                    0x0000000103a328d3<br>clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 915<br>18 clang                    0x00000001039e23fa<br>clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 2890<br>19 clang                    0x00000001039d800c<br>cc1_main(llvm::ArrayRef<char const*>, char const*, void*) + 1836<br>20 clang                    0x00000001039e0b21 main + 13745<br>21 libdyld.dylib            0x00007fff8b4215c9 start + 1<br>22 libdyld.dylib            0x0000000000000045 start + 1958603389<br>Stack dump:<br>0.<span class=apple-tab-span>          </span>Program arguments: /Users/manmanren/gmail/selfhost/Release/bin/clang<br>-cc1 -triple x86_64-apple-macosx10.4.0 -emit-obj -disable-free<span class=apple-converted-space> </span><br>-disable-llvm-verifier -main-file-name fixxfti.c -static-define<span class=apple-converted-space> </span><br>-mrelocation-model static -mthread-model posix -masm-verbose<span class=apple-converted-space> </span><br>-fforbid-guard-variables -target-cpu core2 -disable-red-zone<span class=apple-converted-space> </span><br>-no-implicit-float -target-linker-version 242 -dwarf-column-info<span class=apple-converted-space> </span><br>-coverage-file<span class=apple-converted-space> </span><br>/Users/manmanren/gmail/selfhost/tools/clang/runtime/compiler-rt/clang_<br>darwin/cc_kext/x86_64/SubDir.lib__builtins/fixxfti.o<br>-resource-dir<br>/Users/manmanren/gmail/selfhost/Release/bin/../lib/clang/3.6.0<span class=apple-converted-space> </span><br>-isysroot<span class=apple-converted-space> </span><br>/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/D<br>eveloper/SDKs/MacOSX10.10.sdk<br>-D VISIBILITY_HIDDEN -D KERNEL_USE -I<br>/Users/manmanren/gmail/llvm/projects/compiler-rt/lib -I<span class=apple-converted-space> </span><br>/Users/manmanren/gmail/llvm/projects/compiler-rt/include -O3 -Wall<span class=apple-converted-space> </span><br>-Werror -fdebug-compilation-dir<span class=apple-converted-space> </span><br>/Users/manmanren/gmail/llvm/projects/compiler-rt<br>-ferror-limit 19 -fmessage-length 164 -fvisibility hidden<span class=apple-converted-space> </span><br>-ffreestanding -mstackrealign -fno-builtin -fblocks<span class=apple-converted-space> </span><br>-fblocks-runtime-optional -fno-rtti -fno-use-cxa-atexit<span class=apple-converted-space> </span><br>-fobjc-runtime=macosx-10.4.0 -fobjc-dispatch-method=non-legacy<span class=apple-converted-space> </span><br>-fencode-extended-block-signature<br>-fmax-type-align=16 -fno-common -fdiagnostics-show-option<span class=apple-converted-space> </span><br>-fcolor-diagnostics -vectorize-loops -vectorize-slp -o<span class=apple-converted-space> </span><br>/Users/manmanren/gmail/selfhost/tools/clang/runtime/compiler-rt/clang_<br>darwin/cc_kext/x86_64/SubDir.lib__builtins/fixxfti.o<br>-x c<br>/Users/manmanren/gmail/llvm/projects/compiler-rt/lib/builtins/fixxfti.c<br>1.<span class=apple-tab-span>          </span><eof> parser at end of file<br>2.<span class=apple-tab-span>          </span>Code generation<br>3.<span class=apple-tab-span>          </span>Running pass 'Function Pass Manager' on module<br>'/Users/manmanren/gmail/llvm/projects/compiler-rt/lib/builtins/fixxfti.c'.<br>4.<span class=apple-tab-span>          </span>Running pass 'Constant Hoisting' on function '@__fixxfti'<br> COMPILE:   clang_darwin/cc_kext/x86_64:<br>/Users/manmanren/gmail/llvm/projects/compiler-rt/lib/builtins/floattis<br>f.c /Users/manmanren/gmail/selfhost/Release/bin/clang -fPIC<span class=apple-converted-space> </span><br>-I/Users/manmanren/gmail/llvm/projects/compiler-rt/lib<br>-I/Users/manmanren/gmail/llvm/projects/compiler-rt/include -arch<span class=apple-converted-space> </span><br>x86_64 -fvisibility=hidden -DVISIBILITY_HIDDEN -mkernel -DKERNEL_USE<span class=apple-converted-space> </span><br>-Wall -Werror -O3 -fomit-frame-pointer -mmacosx-version-min=10.4<span class=apple-converted-space> </span><br>-isysroot<span class=apple-converted-space> </span><br>/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/D<br>eveloper/SDKs/MacOSX10.10.sdk<br>-c -o<br>/Users/manmanren/gmail/selfhost/tools/clang/runtime/compiler-rt/clang_<br>darwin/cc_kext/x86_64/SubDir.lib__builtins/floattisf.o<br>/Users/manmanren/gmail/llvm/projects/compiler-rt/lib/builtins/floattis<br>f.c<br><br> COMPILE:   clang_darwin/cc_kext/x86_64:<br>/Users/manmanren/gmail/llvm/projects/compiler-rt/lib/builtins/powidf2.<br>c /Users/manmanren/gmail/selfhost/Release/bin/clang -fPIC<span class=apple-converted-space> </span><br>-I/Users/manmanren/gmail/llvm/projects/compiler-rt/lib<br>-I/Users/manmanren/gmail/llvm/projects/compiler-rt/include -arch<span class=apple-converted-space> </span><br>x86_64 -fvisibility=hidden -DVISIBILITY_HIDDEN -mkernel -DKERNEL_USE<span class=apple-converted-space> </span><br>-Wall -Werror -O3 -fomit-frame-pointer -mmacosx-version-min=10.4<span class=apple-converted-space> </span><br>-isysroot<span class=apple-converted-space> </span><br>/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/D<br>eveloper/SDKs/MacOSX10.10.sdk<br>-c -o<br>/Users/manmanren/gmail/selfhost/tools/clang/runtime/compiler-rt/clang_<br>darwin/cc_kext/x86_64/SubDir.lib__builtins/popcountti2.o<br>/Users/manmanren/gmail/llvm/projects/compiler-rt/lib/builtins/popcount<br>ti2.c /Users/manmanren/gmail/selfhost/Release/bin/clang -fPIC<span class=apple-converted-space> </span><br>-I/Users/manmanren/gmail/llvm/projects/compiler-rt/lib<br>-I/Users/manmanren/gmail/llvm/projects/compiler-rt/include -arch<span class=apple-converted-space> </span><br>x86_64 -fvisibility=hidden -DVISIBILITY_HIDDEN -mkernel -DKERNEL_USE<span class=apple-converted-space> </span><br>-Wall -Werror -O3 -fomit-frame-pointer -mmacosx-version-min=10.4<span class=apple-converted-space> </span><br>-isysroot<span class=apple-converted-space> </span><br>/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/D<br>eveloper/SDKs/MacOSX10.10.sdk<br>-c -o<br>/Users/manmanren/gmail/selfhost/tools/clang/runtime/compiler-rt/clang_<br>darwin/cc_kext/x86_64/SubDir.lib__builtins/powidf2.o<br>/Users/manmanren/gmail/llvm/projects/compiler-rt/lib/builtins/powidf2.<br>c<br>clang: error: unable to execute command: Abort trap: 6<br>clang: error: clang frontend command failed due to signal (use -v to<span class=apple-converted-space> </span><br>see<br>invocation)<br>clang version 3.6.0 (clang-Rlto_master_build 222059) (llvm/trunk<span class=apple-converted-space> </span><br>222239)<br>Target: x86_64-apple-darwin14.0.0<br>Thread model: posix<br>clang: note: diagnostic msg: PLEASE submit a bug report to<span class=apple-converted-space> </span><br><a href="http://llvm.org/bugs/">http://llvm.org/bugs/</a> and include the crash backtrace, preprocessed<span class=apple-converted-space> </span><br>source, and associated run script.<br> COMPILE:   clang_darwin/cc_kext/x86_64:<br>/Users/manmanren/gmail/llvm/projects/compiler-rt/lib/builtins/powisf2.<br>c /Users/manmanren/gmail/selfhost/Release/bin/clang -fPIC<span class=apple-converted-space> </span><br>-I/Users/manmanren/gmail/llvm/projects/compiler-rt/lib<br>-I/Users/manmanren/gmail/llvm/projects/compiler-rt/include -arch<span class=apple-converted-space> </span><br>x86_64 -fvisibility=hidden -DVISIBILITY_HIDDEN -mkernel -DKERNEL_USE<span class=apple-converted-space> </span><br>-Wall -Werror -O3 -fomit-frame-pointer -mmacosx-version-min=10.4<span class=apple-converted-space> </span><br>-isysroot<span class=apple-converted-space> </span><br>/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/D<br>eveloper/SDKs/MacOSX10.10.sdk<br>-c -o<br>/Users/manmanren/gmail/selfhost/tools/clang/runtime/compiler-rt/clang_<br>darwin/cc_kext/x86_64/SubDir.lib__builtins/powisf2.o<br>/Users/manmanren/gmail/llvm/projects/compiler-rt/lib/builtins/powisf2.<br>c<br>clang: note: diagnostic msg:<br>********************<br><br>PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:<br>Preprocessed source(s) and associated run script(s) are located at:<br>clang: note: diagnostic msg:<br>/var/folders/8d/mksp0c9x6yngd578zj_s72ym0000gn/T/fixxfti-868934.c<br>clang: note: diagnostic msg:<br>/var/folders/8d/mksp0c9x6yngd578zj_s72ym0000gn/T/fixxfti-868934.sh<br>clang: note: diagnostic msg:<br><br>********************<br> COMPILE:   clang_darwin/cc_kext/x86_64:<br>/Users/manmanren/gmail/llvm/projects/compiler-rt/lib/builtins/powixf2.<br>c<br>make[5]: ***<br>[/Users/manmanren/gmail/selfhost/tools/clang/runtime/compiler-rt/clang<br>_darwin/cc_kext/x86_64/SubDir.lib__builtins/fixxfti.o]<br>Error 254<br>make[5]: *** Waiting for unfinished jobs....<br>/Users/manmanren/gmail/selfhost/Release/bin/clang -fPIC<span class=apple-converted-space> </span><br>-I/Users/manmanren/gmail/llvm/projects/compiler-rt/lib<br>-I/Users/manmanren/gmail/llvm/projects/compiler-rt/include -arch<span class=apple-converted-space> </span><br>x86_64 -fvisibility=hidden -DVISIBILITY_HIDDEN -mkernel -DKERNEL_USE<span class=apple-converted-space> </span><br>-Wall -Werror -O3 -fomit-frame-pointer -mmacosx-version-min=10.4<span class=apple-converted-space> </span><br>-isysroot<span class=apple-converted-space> </span><br>/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/D<br>eveloper/SDKs/MacOSX10.10.sdk<br>-c -o<br>/Users/manmanren/gmail/selfhost/tools/clang/runtime/compiler-rt/clang_<br>darwin/cc_kext/x86_64/SubDir.lib__builtins/powixf2.o<br>/Users/manmanren/gmail/llvm/projects/compiler-rt/lib/builtins/powixf2.<br>c<br>clang: error: unable to execute command: Abort trap: 6<br>clang: error: clang frontend command failed due to signal (use -v to<span class=apple-converted-space> </span><br>see<br>invocation)<br>clang version 3.6.0 (clang-Rlto_master_build 222059) (llvm/trunk<span class=apple-converted-space> </span><br>222239)<br>Target: x86_64-apple-darwin14.0.0<br>Thread model: posix<br>clang: note: diagnostic msg: PLEASE submit a bug report to<span class=apple-converted-space> </span><br><a href="http://llvm.org/bugs/">http://llvm.org/bugs/</a> and include the crash backtrace, preprocessed<span class=apple-converted-space> </span><br>source, and associated run script.<br>clang: note: diagnostic msg:<br>********************<br><br>PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:<br>Preprocessed source(s) and associated run script(s) are located at:<br>clang: note: diagnostic msg:<br>/var/folders/8d/mksp0c9x6yngd578zj_s72ym0000gn/T/fixunsxfti-33f776.c<br>clang: note: diagnostic msg:<br>/var/folders/8d/mksp0c9x6yngd578zj_s72ym0000gn/T/fixunsxfti-33f776.sh<br>clang: note: diagnostic msg:<br><br>********************<br><br><br><br><o:p></o:p></span></p><p class=MsoNormal><span style='font-size:9.0pt;font-family:"Helvetica","sans-serif"'>On Nov 18, 2014, at 2:53 PM, Chad Rosier <<a href="mailto:mcrosier@codeaurora.org">mcrosier@codeaurora.org</a>><br>wrote:<br><br>Hi Manman,<br>Feel free to revert the patch if you're convinced this is the problem.<br>Please keep Balaram, James, and I updated on the progress.  This is a<span class=apple-converted-space> </span><br>performance critical fix, so we need to make sure it doesn't get lost<span class=apple-converted-space> </span><br>in the mix.<br><br>Chad<br><br><br><o:p></o:p></span></p><p class=MsoNormal><span style='font-size:9.0pt;font-family:"Helvetica","sans-serif"'>Hi Chad,<br><br>About the buildbot phase 2 failure, I now think this commit is the<span class=apple-converted-space> </span><br>root cause.<br><br>What I did was:<br>1> update the repo to r222239, then "svn merge -c -r222039 .”,<span class=apple-converted-space> </span><br>1> made a<br>release+assert build (installed to clang-install).<br>2> use clang-install binary and library to build the same repo with<br>lto.<br>   make -j 4 VERBOSE=1<span class=apple-converted-space> </span><br>CLANG_REPOSITORY_STRING=clang-Rlto_master_build<br>SVN_REVISION=222059<br>DYLD_LIBRARY_PATH=/Users/manmanren/llvm_gmail/clang-install/lib/<br>3> the build completed<br>make[1]: Nothing to be done for `all'.<br>make[1]: Nothing to be done for `all'.<br>llvm[0]: ***** Completed Release Build<br><br>Is it okay for us to revert this commit and watch the bot? If the<span class=apple-converted-space> </span><br>bot is still red, we can re-submit it.<br><br>If you want me to do more testing (maybe a lto self host with<span class=apple-converted-space> </span><br>r22239), let me know,<br><br>Thanks,<br>Manman (The build czar)<br><br><br><o:p></o:p></span></p><p class=MsoNormal><span style='font-size:9.0pt;font-family:"Helvetica","sans-serif"'>On Nov 14, 2014, at 1:09 PM, Chad Rosier <<a href="mailto:mcrosier@codeaurora.org">mcrosier@codeaurora.org</a>><br>wrote:<br><br>Author: mcrosier<br>Date: Fri Nov 14 15:09:13 2014<br>New Revision: 222039<br><br>URL: <a href="http://llvm.org/viewvc/llvm-project?rev=222039&view=rev">http://llvm.org/viewvc/llvm-project?rev=222039&view=rev</a><br>Log:<br>Reapply r221924: "[GVN] Perform Scalar PRE on gep indices that feed<span class=apple-converted-space> </span><br>loads before doing Load PRE"<br><br>This commit updates the failing test in<span class=apple-converted-space> </span><br>Analysis/TypeBasedAliasAnalysis/gvn-nonlocal-type-mismatch.ll<br><br>The failing test is sensitive to the order in which we process loads.<br>This<br>version turns on the RPO traversal instead of the while DT<span class=apple-converted-space> </span><br>traversal in GVN.<br>The new test code is functionally same just the order of loads that<span class=apple-converted-space> </span><br>are eliminated is swapped.<br><br>This new version also fixes an issue where GVN splits a critical<span class=apple-converted-space> </span><br>edge and potentially invalidate the RPO/DT iterator.<br><br>Added:<br> llvm/trunk/test/Transforms/GVN/pre-gep-load.ll<br>Modified:<br> llvm/trunk/lib/Transforms/Scalar/GVN.cpp<br><br>llvm/trunk/test/Analysis/TypeBasedAliasAnalysis/gvn-nonlocal-type-m<br>ismatch.ll<br><br>Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp<br>URL:<br><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scala">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scala</a><br>r/GVN.cpp?rev=222039&r1=222038&r2=222039&view=diff<br>===================================================================<br>===========<br>--- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original)<br>+++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Fri Nov 14 15:09:13<span class=apple-converted-space> </span><br>+++ 2014<br>@@ -20,6 +20,7 @@<br>#include "llvm/ADT/DepthFirstIterator.h"<br>#include "llvm/ADT/Hashing.h"<br>#include "llvm/ADT/MapVector.h"<br>+#include "llvm/ADT/PostOrderIterator.h"<br>#include "llvm/ADT/SetVector.h"<br>#include "llvm/ADT/SmallPtrSet.h"<br>#include "llvm/ADT/Statistic.h"<br>@@ -709,6 +710,7 @@ namespace {<br>  void dump(DenseMap<uint32_t, Value*> &d);<br>  bool iterateOnFunction(Function &F);<br>  bool performPRE(Function &F);<br>+    bool performScalarPRE(Instruction *I);<br>  Value *findLeader(const BasicBlock *BB, uint32_t num);<br>  void cleanupGlobalSets();<br>  void verifyRemoved(const Instruction *I) const; @@ -1729,6<span class=apple-converted-space> </span><br>+1731,15 @@ bool GVN::processNonLocalLoad(LoadInst *<br>  return false;<br>}<br><br>+  // If this load follows a GEP, see if we can PRE the indices<span class=apple-converted-space> </span><br>+ before<br>analyzing.<br>+  if (GetElementPtrInst *GEP =<br>dyn_cast<GetElementPtrInst>(LI->getOperand(0))) {<br>+    for (GetElementPtrInst::op_iterator OI = GEP->idx_begin(),<br>+                                        OE = GEP->idx_end();<br>+         OI != OE; ++OI)<br>+      if (Instruction *I = dyn_cast<Instruction>(OI->get()))<br>+        performScalarPRE(I);<br>+  }<br>+<br>// Step 2: Analyze the availability of the load  AvailValInBlkVect<span class=apple-converted-space> </span><br>ValuesPerBlock;  UnavailBlkVect UnavailableBlocks; @@ -2431,175<span class=apple-converted-space> </span><br>+2442,182 @@ bool GVN::processBlock(BasicBlock *BB) {  return<span class=apple-converted-space> </span><br>ChangedFunction; }<br><br>-/// performPRE - Perform a purely local form of PRE that looks for<span class=apple-converted-space> </span><br>diamond -/// control flow patterns and attempts to perform simple<span class=apple-converted-space> </span><br>PRE at the join point.<br>-bool GVN::performPRE(Function &F) {<br>-  bool Changed = false;<br>+bool GVN::performScalarPRE(Instruction *CurInst) {<br>SmallVector<std::pair<Value*, BasicBlock*>, 8> predMap;<br>-  for (BasicBlock *CurrentBlock : depth_first(&F.getEntryBlock())) {<br>-    // Nothing to PRE in the entry block.<br>-    if (CurrentBlock == &F.getEntryBlock()) continue;<br><br>-    // Don't perform PRE on a landing pad.<br>-    if (CurrentBlock->isLandingPad()) continue;<br>+  if (isa<AllocaInst>(CurInst) || isa<TerminatorInst>(CurInst) ||<br>+      isa<PHINode>(CurInst) || CurInst->getType()->isVoidTy() ||<br>+      CurInst->mayReadFromMemory() ||<span class=apple-converted-space> </span><br>+ CurInst->mayHaveSideEffects()<br>||<br>+      isa<DbgInfoIntrinsic>(CurInst))<br>+    return false;<br><br>-    for (BasicBlock::iterator BI = CurrentBlock->begin(),<br>-         BE = CurrentBlock->end(); BI != BE; ) {<br>-      Instruction *CurInst = BI++;<br>+  // Don't do PRE on compares. The PHI would prevent<span class=apple-converted-space> </span><br>+ CodeGenPrepare<br>from<br>+  // sinking the compare again, and it would force the code<span class=apple-converted-space> </span><br>+ generator<br>to<br>+  // move the i1 from processor flags or predicate registers into<span class=apple-converted-space> </span><br>+ a<br>general<br>+  // purpose register.<br>+  if (isa<CmpInst>(CurInst))<br>+    return false;<br><br>-      if (isa<AllocaInst>(CurInst) ||<br>-          isa<TerminatorInst>(CurInst) || isa<PHINode>(CurInst) ||<br>-          CurInst->getType()->isVoidTy() ||<br>-          CurInst->mayReadFromMemory() ||<br>CurInst->mayHaveSideEffects()<br>||<br>-          isa<DbgInfoIntrinsic>(CurInst))<br>-        continue;<br>+  // We don't currently value number ANY inline asm calls.<br>+  if (CallInst *CallI = dyn_cast<CallInst>(CurInst))<br>+    if (CallI->isInlineAsm())<br>+      return false;<br><br>-      // Don't do PRE on compares. The PHI would prevent<br>CodeGenPrepare<br>from<br>-      // sinking the compare again, and it would force the code<br>generator to<br>-      // move the i1 from processor flags or predicate registers into<br>a<br>general<br>-      // purpose register.<br>-      if (isa<CmpInst>(CurInst))<br>-        continue;<br>+  uint32_t ValNo = VN.lookup(CurInst);<br><br>-      // We don't currently value number ANY inline asm calls.<br>-      if (CallInst *CallI = dyn_cast<CallInst>(CurInst))<br>-        if (CallI->isInlineAsm())<br>-          continue;<br>+  // Look for the predecessors for PRE opportunities.  We're  //<span class=apple-converted-space> </span><br>+ only trying to solve the basic diamond case, where  // a value is<span class=apple-converted-space> </span><br>+ computed in the successor and one predecessor,  // but not the<span class=apple-converted-space> </span><br>+ other.  We also explicitly disallow cases  // where the successor<span class=apple-converted-space> </span><br>+ is its own predecessor, because they're  // more complicated to<span class=apple-converted-space> </span><br>+ get right.<br>+  unsigned NumWith = 0;<br>+  unsigned NumWithout = 0;<br>+  BasicBlock *PREPred = nullptr;<br>+  BasicBlock *CurrentBlock = CurInst->getParent();  <br>+ predMap.clear();<br>+<br>+  for (pred_iterator PI = pred_begin(CurrentBlock), PE =<br>pred_end(CurrentBlock);<br>+       PI != PE; ++PI) {<br>+    BasicBlock *P = *PI;<br>+    // We're not interested in PRE where the block is its<br>+    // own predecessor, or in blocks with predecessors<br>+    // that are not reachable.<br>+    if (P == CurrentBlock) {<br>+      NumWithout = 2;<br>+      break;<br>+    } else if (!DT->isReachableFromEntry(P)) {<br>+      NumWithout = 2;<br>+      break;<br>+    }<br><br>-      uint32_t ValNo = VN.lookup(CurInst);<br>+    Value *predV = findLeader(P, ValNo);<br>+    if (!predV) {<br>+      predMap.push_back(std::make_pair(static_cast<Value<span class=apple-converted-space> </span><br>+ *>(nullptr),<br>P));<br>+      PREPred = P;<br>+      ++NumWithout;<br>+    } else if (predV == CurInst) {<br>+      /* CurInst dominates this predecessor. */<br>+      NumWithout = 2;<br>+      break;<br>+    } else {<br>+      predMap.push_back(std::make_pair(predV, P));<br>+      ++NumWith;<br>+    }<br>+  }<br><br>-      // Look for the predecessors for PRE opportunities.  We're<br>-      // only trying to solve the basic diamond case, where<br>-      // a value is computed in the successor and one predecessor,<br>-      // but not the other.  We also explicitly disallow cases<br>-      // where the successor is its own predecessor, because they're<br>-      // more complicated to get right.<br>-      unsigned NumWith = 0;<br>-      unsigned NumWithout = 0;<br>-      BasicBlock *PREPred = nullptr;<br>-      predMap.clear();<br>-<br>-      for (pred_iterator PI = pred_begin(CurrentBlock),<br>-           PE = pred_end(CurrentBlock); PI != PE; ++PI) {<br>-        BasicBlock *P = *PI;<br>-        // We're not interested in PRE where the block is its<br>-        // own predecessor, or in blocks with predecessors<br>-        // that are not reachable.<br>-        if (P == CurrentBlock) {<br>-          NumWithout = 2;<br>-          break;<br>-        } else if (!DT->isReachableFromEntry(P))  {<br>-          NumWithout = 2;<br>-          break;<br>-        }<br>+  // Don't do PRE when it might increase code size, i.e. when  //<span class=apple-converted-space> </span><br>+ we would need to insert instructions in more than one pred.<br>+  if (NumWithout != 1 || NumWith == 0)<br>+    return false;<br><br>-        Value* predV = findLeader(P, ValNo);<br>-        if (!predV) {<br>-          predMap.push_back(std::make_pair(static_cast<Value<br>*>(nullptr), P));<br>-          PREPred = P;<br>-          ++NumWithout;<br>-        } else if (predV == CurInst) {<br>-          /* CurInst dominates this predecessor. */<br>-          NumWithout = 2;<br>-          break;<br>-        } else {<br>-          predMap.push_back(std::make_pair(predV, P));<br>-          ++NumWith;<br>-        }<br>-      }<br>+  // Don't do PRE across indirect branch.<br>+  if (isa<IndirectBrInst>(PREPred->getTerminator()))<br>+    return false;<br><br>-      // Don't do PRE when it might increase code size, i.e. when<br>-      // we would need to insert instructions in more than one pred.<br>-      if (NumWithout != 1 || NumWith == 0)<br>-        continue;<br>+  // We can't do PRE safely on a critical edge, so instead we<br>schedule<br>+  // the edge to be split and perform the PRE the next time we<br>iterate<br>+  // on the function.<br>+  unsigned SuccNum = GetSuccessorNumber(PREPred, CurrentBlock);  <br>+ if (isCriticalEdge(PREPred->getTerminator(), SuccNum)) {<br>+    toSplit.push_back(std::make_pair(PREPred->getTerminator(),<br>SuccNum));<br>+    return false;<br>+  }<br><br>-      // Don't do PRE across indirect branch.<br>-      if (isa<IndirectBrInst>(PREPred->getTerminator()))<br>-        continue;<br>+  // Instantiate the expression in the predecessor that lacked it.<br>+  // Because we are going top-down through the block, all value<br>numbers<br>+  // will be available in the predecessor by the time we need them.<br>Any<br>+  // that weren't originally present will have been instantiated<br>earlier<br>+  // in this loop.<br>+  Instruction *PREInstr = CurInst->clone();  bool success = true;  <br>+ for (unsigned i = 0, e = CurInst->getNumOperands(); i != e; ++i) {<br>+    Value *Op = PREInstr->getOperand(i);<br>+    if (isa<Argument>(Op) || isa<Constant>(Op) ||<br>isa<GlobalValue>(Op))<br>+      continue;<br><br>-      // We can't do PRE safely on a critical edge, so instead we<br>schedule<br>-      // the edge to be split and perform the PRE the next time we<br>iterate<br>-      // on the function.<br>-      unsigned SuccNum = GetSuccessorNumber(PREPred, CurrentBlock);<br>-      if (isCriticalEdge(PREPred->getTerminator(), SuccNum)) {<br>-        toSplit.push_back(std::make_pair(PREPred->getTerminator(),<br>SuccNum));<br>-        continue;<br>-      }<br>+    if (Value *V = findLeader(PREPred, VN.lookup(Op))) {<br>+      PREInstr->setOperand(i, V);<br>+    } else {<br>+      success = false;<br>+      break;<br>+    }<br>+  }<br><br>-      // Instantiate the expression in the predecessor that lacked<br>it.<br>-      // Because we are going top-down through the block, all value<br>numbers<br>-      // will be available in the predecessor by the time we need<br>them.<br>Any<br>-      // that weren't originally present will have been instantiated<br>earlier<br>-      // in this loop.<br>-      Instruction *PREInstr = CurInst->clone();<br>-      bool success = true;<br>-      for (unsigned i = 0, e = CurInst->getNumOperands(); i != e;<br>++i)<br>{<br>-        Value *Op = PREInstr->getOperand(i);<br>-        if (isa<Argument>(Op) || isa<Constant>(Op) ||<br>isa<GlobalValue>(Op))<br>-          continue;<br>+  // Fail out if we encounter an operand that is not available in  <br>+ // the PRE predecessor.  This is typically because of loads which  <br>+ // are not value numbered precisely.<br>+  if (!success) {<br>+    DEBUG(verifyRemoved(PREInstr));<br>+    delete PREInstr;<br>+    return false;<br>+  }<br><br>-        if (Value *V = findLeader(PREPred, VN.lookup(Op))) {<br>-          PREInstr->setOperand(i, V);<br>-        } else {<br>-          success = false;<br>-          break;<br>-        }<br>-      }<br>+  PREInstr->insertBefore(PREPred->getTerminator());<br>+  PREInstr->setName(CurInst->getName() + ".pre");  <br>+ PREInstr->setDebugLoc(CurInst->getDebugLoc());<br>+  VN.add(PREInstr, ValNo);<br>+  ++NumGVNPRE;<br>+<br>+  // Update the availability map to include the new instruction.<br>+  addToLeaderTable(ValNo, PREInstr, PREPred);<br>+<br>+  // Create a PHI to make the value available in this block.<br>+  PHINode *Phi =<br>+      PHINode::Create(CurInst->getType(), predMap.size(),<br>+                      CurInst->getName() + ".pre-phi",<br>CurrentBlock->begin());<br>+  for (unsigned i = 0, e = predMap.size(); i != e; ++i) {<br>+    if (Value *V = predMap[i].first)<br>+      Phi->addIncoming(V, predMap[i].second);<br>+    else<br>+      Phi->addIncoming(PREInstr, PREPred);  }<br><br>-      // Fail out if we encounter an operand that is not available in<br>-      // the PRE predecessor.  This is typically because of loads<br>which<br>-      // are not value numbered precisely.<br>-      if (!success) {<br>-        DEBUG(verifyRemoved(PREInstr));<br>-        delete PREInstr;<br>-        continue;<br>-      }<br>+  VN.add(Phi, ValNo);<br>+  addToLeaderTable(ValNo, Phi, CurrentBlock);  <br>+ Phi->setDebugLoc(CurInst->getDebugLoc());<br>+  CurInst->replaceAllUsesWith(Phi);  if<span class=apple-converted-space> </span><br>+ (Phi->getType()->getScalarType()->isPointerTy()) {<br>+    // Because we have added a PHI-use of the pointer value, it<span class=apple-converted-space> </span><br>+ has<br>now<br>+    // "escaped" from alias analysis' perspective.  We need to inform<br>+    // AA of this.<br>+    for (unsigned ii = 0, ee = Phi->getNumIncomingValues(); ii !=<span class=apple-converted-space> </span><br>+ ee;<br>++ii) {<br>+      unsigned jj = PHINode::getOperandNumForIncomingValue(ii);<br>+      VN.getAliasAnalysis()->addEscapingUse(Phi->getOperandUse(jj));<br>+    }<br><br>-      PREInstr->insertBefore(PREPred->getTerminator());<br>-      PREInstr->setName(CurInst->getName() + ".pre");<br>-      PREInstr->setDebugLoc(CurInst->getDebugLoc());<br>-      VN.add(PREInstr, ValNo);<br>-      ++NumGVNPRE;<br>-<br>-      // Update the availability map to include the new instruction.<br>-      addToLeaderTable(ValNo, PREInstr, PREPred);<br>-<br>-      // Create a PHI to make the value available in this block.<br>-      PHINode* Phi = PHINode::Create(CurInst->getType(),<br>predMap.size(),<br>-                                     CurInst->getName() + ".pre-phi",<br>-                                     CurrentBlock->begin());<br>-      for (unsigned i = 0, e = predMap.size(); i != e; ++i) {<br>-        if (Value *V = predMap[i].first)<br>-          Phi->addIncoming(V, predMap[i].second);<br>-        else<br>-          Phi->addIncoming(PREInstr, PREPred);<br>-      }<br>-<br>-      VN.add(Phi, ValNo);<br>-      addToLeaderTable(ValNo, Phi, CurrentBlock);<br>-      Phi->setDebugLoc(CurInst->getDebugLoc());<br>-      CurInst->replaceAllUsesWith(Phi);<br>-      if (Phi->getType()->getScalarType()->isPointerTy()) {<br>-        // Because we have added a PHI-use of the pointer value, it<br>has<br>now<br>-        // "escaped" from alias analysis' perspective.  We need to<br>inform<br>-        // AA of this.<br>-        for (unsigned ii = 0, ee = Phi->getNumIncomingValues(); ii !=<br>ee;<br>-             ++ii) {<br>-          unsigned jj = PHINode::getOperandNumForIncomingValue(ii);<br>-<br>VN.getAliasAnalysis()->addEscapingUse(Phi->getOperandUse(jj));<br>-        }<br>+    if (MD)<br>+      MD->invalidateCachedPointerInfo(Phi);<br>+  }<br>+  VN.erase(CurInst);<br>+  removeFromLeaderTable(ValNo, CurInst, CurrentBlock);<br><br>-        if (MD)<br>-          MD->invalidateCachedPointerInfo(Phi);<br>-      }<br>-      VN.erase(CurInst);<br>-      removeFromLeaderTable(ValNo, CurInst, CurrentBlock);<br>+  DEBUG(dbgs() << "GVN PRE removed: " << *CurInst << '\n');<br>+  if (MD)<br>+    MD->removeInstruction(CurInst);<br>+  DEBUG(verifyRemoved(CurInst));<br>+  CurInst->eraseFromParent();<br>+  return true;<br>+}<br>+<br>+/// performPRE - Perform a purely local form of PRE that looks for<br>diamond<br>+/// control flow patterns and attempts to perform simple PRE at<span class=apple-converted-space> </span><br>+the<br>join point.<br>+bool GVN::performPRE(Function &F) {<br>+  bool Changed = false;<br>+  for (BasicBlock *CurrentBlock : depth_first(&F.getEntryBlock())) {<br>+    // Nothing to PRE in the entry block.<br>+    if (CurrentBlock == &F.getEntryBlock())<br>+      continue;<br><br>-      DEBUG(dbgs() << "GVN PRE removed: " << *CurInst << '\n');<br>-      if (MD) MD->removeInstruction(CurInst);<br>-      DEBUG(verifyRemoved(CurInst));<br>-      CurInst->eraseFromParent();<br>-      Changed = true;<br>+    // Don't perform PRE on a landing pad.<br>+    if (CurrentBlock->isLandingPad())<br>+      continue;<br>+<br>+    for (BasicBlock::iterator BI = CurrentBlock->begin(),<br>+                              BE = CurrentBlock->end();<br>+         BI != BE;) {<br>+      Instruction *CurInst = BI++;<br>+      Changed = performScalarPRE(CurInst);<br>  }<br>}<br><br>@@ -2637,25 +2655,21 @@ bool GVN::iterateOnFunction(Function &F)<br><br>// Top-down walk of the dominator tree  bool Changed = false; -#if<span class=apple-converted-space> </span><br>0<br>-  // Needed for value numbering with phi construction to work.<br>-  ReversePostOrderTraversal<Function*> RPOT(&F);<br>-  for (ReversePostOrderTraversal<Function*>::rpo_iterator RI =<span class=apple-converted-space> </span><br>RPOT.begin(),<br>-       RE = RPOT.end(); RI != RE; ++RI)<br>-    Changed |= processBlock(*RI);<br>-#else<br>// Save the blocks this function have before transformation begins.<br>GVN may<br>// split critical edge, and hence may invalidate the RPO/DT iterator.<br>//<br>std::vector<BasicBlock *> BBVect;<br>BBVect.reserve(256);<br>-  for (DomTreeNode *X : depth_first(DT->getRootNode()))<br>-    BBVect.push_back(X->getBlock());<br>+  // Needed for value numbering with phi construction to work.<br>+  ReversePostOrderTraversal<Function *> RPOT(&F);  for<span class=apple-converted-space> </span><br>+ (ReversePostOrderTraversal<Function *>::rpo_iterator RI =<br>RPOT.begin(),<br>+                                                           RE =<br>RPOT.end();<br>+       RI != RE; ++RI)<br>+    BBVect.push_back(*RI);<br><br>for (std::vector<BasicBlock *>::iterator I = BBVect.begin(), E =<span class=apple-converted-space> </span><br>BBVect.end();<br>     I != E; I++)<br>  Changed |= processBlock(*I);<br>-#endif<br><br>return Changed;<br>}<br><br>Modified:<br>llvm/trunk/test/Analysis/TypeBasedAliasAnalysis/gvn-nonlocal-type-m<br>ismatch.ll<br>URL:<br><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/TypeBa">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/TypeBa</a><br>sedAliasAnalysis/gvn-nonlocal-type-mismatch.ll?rev=222039&r1=222038<br>&r2=222039&view=diff<span class=apple-converted-space> </span><br>===================================================================<br>===========<br>---<br>llvm/trunk/test/Analysis/TypeBasedAliasAnalysis/gvn-nonlocal-type-m<br>ismatch.ll<br>(original)<br>+++<br>llvm/trunk/test/Analysis/TypeBasedAliasAnalysis/gvn-nonlocal-type-m<br>ismatch.ll<br>Fri Nov 14 15:09:13 2014<br>@@ -46,12 +46,12 @@ entry:<br>br i1 %c, label %if.else, label %if.then<br><br>if.then:<br>-  %t = load i32* %p, !tbaa !4<br>+  %t = load i32* %p, !tbaa !3<br>store i32 %t, i32* %q<br>ret void<br><br>if.else:<br>-  %u = load i32* %p, !tbaa !3<br>+  %u = load i32* %p, !tbaa !4<br>store i32 %u, i32* %q<br>ret void<br>}<br>@@ -61,11 +61,11 @@ if.else:<br><br>; CHECK: @watch_out_for_another_type_change<br>; CHECK: if.then:<br>-; CHECK:   %t = load i32* %p<br>-; CHECK:   store i32 %t, i32* %q<br>+; CHECK:   store i32 0, i32* %q<br>; CHECK:   ret void<br>; CHECK: if.else:<br>-; CHECK:   store i32 0, i32* %q<br>+; CHECK:   %u = load i32* %p<br>+; CHECK:   store i32 %u, i32* %q<br><br>define void @watch_out_for_another_type_change(i1 %c, i32* %p, i32*<span class=apple-converted-space> </span><br>%p1,<br>i32* %q) nounwind {<br>entry:<br>@@ -74,12 +74,12 @@ entry:<br>br i1 %c, label %if.else, label %if.then<br><br>if.then:<br>-  %t = load i32* %p, !tbaa !3<br>+  %t = load i32* %p, !tbaa !4<br>store i32 %t, i32* %q<br>ret void<br><br>if.else:<br>-  %u = load i32* %p, !tbaa !4<br>+  %u = load i32* %p, !tbaa !3<br>store i32 %u, i32* %q<br>ret void<br>}<br><br>Added: llvm/trunk/test/Transforms/GVN/pre-gep-load.ll<br>URL:<br><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GVN/">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GVN/</a><br>pre-gep-load.ll?rev=222039&view=auto<br>===================================================================<br>===========<br>--- llvm/trunk/test/Transforms/GVN/pre-gep-load.ll (added)<br>+++ llvm/trunk/test/Transforms/GVN/pre-gep-load.ll Fri Nov 14<span class=apple-converted-space> </span><br>+++ 15:09:13<br>2014<br>@@ -0,0 +1,49 @@<br>+; RUN: opt < %s -basicaa -gvn -enable-load-pre -S | FileCheck %s<span class=apple-converted-space> </span><br>+target datalayout = "e-m:e-i64:64-i128:128-n32:64-S128"<br>+target triple = "aarch64--linux-gnu"<br>+<br>+define double @foo(i32 %stat, i32 %i, double** %p) { ;<span class=apple-converted-space> </span><br>+CHECK-LABEL: @foo(<br>+entry:<br>+  switch i32 %stat, label %sw.default [<br>+    i32 0, label %sw.bb<br>+    i32 1, label %sw.bb<br>+    i32 2, label %sw.bb2<br>+  ]<br>+<br>+sw.bb:                                            ; preds = %entry,<br>%entry<br>+  %idxprom = sext i32 %i to i64<br>+  %arrayidx = getelementptr inbounds double** %p, i64 0<br>+  %0 = load double** %arrayidx, align 8<br>+  %arrayidx1 = getelementptr inbounds double* %0, i64 %idxprom<br>+  %1 = load double* %arrayidx1, align 8  %sub = fsub double %1,<span class=apple-converted-space> </span><br>+ 1.000000e+00  %cmp = fcmp olt double %sub, 0.000000e+00  br i1<span class=apple-converted-space> </span><br>+ %cmp, label %if.then, label %if.end<br>+<br>+if.then:                                          ; preds = %sw.bb<br>+  br label %return<br>+<br>+if.end:                                           ; preds = %sw.bb<br>+  br label %sw.bb2<br>+<br>+sw.bb2:                                           ; preds = %if.end,<br>%entry<br>+  %idxprom3 = sext i32 %i to i64<br>+  %arrayidx4 = getelementptr inbounds double** %p, i64 0<br>+  %2 = load double** %arrayidx4, align 8<br>+  %arrayidx5 = getelementptr inbounds double* %2, i64 %idxprom3<br>+  %3 = load double* %arrayidx5, align 8 ; CHECK: sw.bb2:<br>+; CHECK-NEXT-NOT: sext<br>+; CHECK-NEXT: phi double [<br>+; CHECK-NOT: load<br>+  %sub6 = fsub double 3.000000e+00, %3<br>+  br label %return<br>+<br>+sw.default:                                       ; preds = %entry<br>+  br label %return<br>+<br>+return:                                           ; preds =<br>%sw.default, %sw.bb2, %if.then<br>+  %retval.0 = phi double [ 0.000000e+00, %sw.default ], [ %sub6,<br>%sw.bb2 ], [ %sub, %if.then ]<br>+  ret double %retval.0<br>+}<br><br><br>_______________________________________________<br>llvm-commits mailing list<br><a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><o:p></o:p></span></p><p class=MsoNormal style='margin-bottom:12.0pt'><span style='font-size:9.0pt;font-family:"Helvetica","sans-serif"'><o:p> </o:p></span></p><p class=MsoNormal style='margin-bottom:12.0pt'><span style='font-size:9.0pt;font-family:"Helvetica","sans-serif"'><o:p> </o:p></span></p><p class=MsoNormal style='margin-bottom:12.0pt'><span style='font-size:9.0pt;font-family:"Helvetica","sans-serif"'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:9.0pt;font-family:"Helvetica","sans-serif"'><br><br></span><0001-Reapply-r221924-GVN-Perform-Scalar-PRE-on-gep-indice.patch><o:p></o:p></p></div></div><p class=MsoNormal><o:p> </o:p></p></div></div></body></html>