<div dir="ltr">Hi Hao,<div><br></div><div>Sorry about missing the step of acquiring source. What I did was trying to replicate what the build bot is doing.</div><div><br></div><div>Yes, libcxx is part of the source acquiring. See </div><div><br></div><a href="http://lab.llvm.org:8080/green/job/clang-Rlto_master_acquire/514/console">http://lab.llvm.org:8080/green/job/clang-Rlto_master_acquire/514/console</a><div><br></div><div>for a list of projects.</div><div><br><div><div>If you still have problem reproducing, let me know.</div><div><br></div><div>Manman</div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Nov 20, 2014 at 2:49 AM, Hao Liu <span dir="ltr"><<a href="mailto:Hao.Liu@arm.com" target="_blank">Hao.Liu@arm.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="EN-US" link="blue" vlink="purple"><div><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Hi Manman,<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></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.<u></u><u></u></span></p><p class="MsoNormal"><span style="color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="color:#1f497d">I tired libc++ reversion of r222425 and r222425 and followed your steps.<u></u><u></u></span></p><p class="MsoNormal"><span style="color:#1f497d">But it had build failures on 1<sup>st</sup> step:<u></u><u></u></span></p><p class="MsoNormal"><span style="color:#1f497d">llvm[2]: Linking Release+Asserts executable FileCheck (without symbols)<u></u><u></u></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*)'<u></u><u></u></span></p><p class="MsoNormal"><span style="color:#1f497d">…<u></u><u></u></span></p><p class="MsoNormal"><span style="color:#1f497d"><u></u> <u></u></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.<u></u><u></u></span></p><p class="MsoNormal"><span style="color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="color:#1f497d">Thanks,<u></u><u></u></span></p><p class="MsoNormal"><span style="color:#1f497d">-Hao<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></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""> <a href="mailto:llvm-commits-bounces@cs.uiuc.edu" target="_blank">llvm-commits-bounces@cs.uiuc.edu</a> [mailto:<a href="mailto:llvm-commits-bounces@cs.uiuc.edu" target="_blank">llvm-commits-bounces@cs.uiuc.edu</a>] <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> <a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a></span></p><div><div class="h5"><br><b>Subject:</b> Re: [llvm] r222039 - Reapply r221924: "[GVN] Perform Scalar PRE on gep indices that feed loads before<u></u><u></u></div></div><p></p></div></div><div><div class="h5"><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal"><u></u> <u></u></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" target="_blank">bmakam@codeaurora.org</a>> wrote:<u></u><u></u></p></div><p class="MsoNormal"><u></u> <u></u></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><u></u><u></u></p></div></blockquote><div><p class="MsoNormal"><u></u> <u></u></p></div><p class="MsoNormal">Hi Balaram,<u></u><u></u></p></div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">You need to build a lto selfhost to reproduce.<u></u><u></u></p></div><div><p class="MsoNormal"><u></u> <u></u></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).<u></u><u></u></p></blockquote></blockquote></blockquote></blockquote><div><p class="MsoNormal"><u></u> <u></u></p></div><p class="MsoNormal">create directory clang-build and clang-install under llvm<u></u><u></u></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<u></u><u></u></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<u></u><u></u></p></div><div><p class="MsoNormal"><br><br><u></u><u></u></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.<u></u><u></u></p></blockquote></blockquote></blockquote><p class="MsoNormal"><br>create directory selfhost, under selfhost, do:<u></u><u></u></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++<u></u><u></u></p></div></div><div><p class="MsoNormal"><br><br><u></u><u></u></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/<u></u><u></u></p></blockquote></blockquote></blockquote><div><p class="MsoNormal"><u></u> <u></u></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).<u></u><u></u></p></div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">Manman<u></u><u></u></p></div><p class="MsoNormal"><br><br><u></u><u></u></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" target="_blank"><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> </span><br>Sent: Tuesday, November 18, 2014 9:09 PM<br>To: Manman Ren<br>Cc:<span> </span></span><a href="mailto:mcrosier@codeaurora.org" target="_blank"><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> </span></span><a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank"><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="text-align:start;word-spacing:0px"><br></span><u></u><u></u></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> </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> </span><br>-I/Users/manmanren/gmail/llvm/projects/compiler-rt/lib<br>-I/Users/manmanren/gmail/llvm/projects/compiler-rt/include -arch<span> </span><br>x86_64 -fvisibility=hidden -DVISIBILITY_HIDDEN -mkernel -DKERNEL_USE<span> </span><br>-Wall -Werror -O3 -fomit-frame-pointer -mmacosx-version-min=10.4<span> </span><br>-isysroot<span> </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> </span><br>-I/Users/manmanren/gmail/llvm/projects/compiler-rt/lib<br>-I/Users/manmanren/gmail/llvm/projects/compiler-rt/include -arch<span> </span><br>x86_64 -fvisibility=hidden -DVISIBILITY_HIDDEN -mkernel -DKERNEL_USE<span> </span><br>-Wall -Werror -O3 -fomit-frame-pointer -mmacosx-version-min=10.4<span> </span><br>-isysroot<span> </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> </span><br>-I/Users/manmanren/gmail/llvm/projects/compiler-rt/lib<br>-I/Users/manmanren/gmail/llvm/projects/compiler-rt/include -arch<span> </span><br>x86_64 -fvisibility=hidden -DVISIBILITY_HIDDEN -mkernel -DKERNEL_USE<span> </span><br>-Wall -Werror -O3 -fomit-frame-pointer -mmacosx-version-min=10.4<span> </span><br>-isysroot<span> </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> </span><br>const +<br>601<br>7 clang 0x000000010b7b6cd8 non-virtual thunk to<br>(anonymous namespace)::X86TTI::getIntImmCost(unsigned int, unsigned<span> </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> </span><br>llvm::DenseMapInfo<llvm::ConstantInt*> >&, llvm::Instruction*,<span> </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> </span><br>-I/Users/manmanren/gmail/llvm/projects/compiler-rt/lib<br>-I/Users/manmanren/gmail/llvm/projects/compiler-rt/include -arch<span> </span><br>x86_64 -fvisibility=hidden -DVISIBILITY_HIDDEN -mkernel -DKERNEL_USE<span> </span><br>-Wall -Werror -O3 -fomit-frame-pointer -mmacosx-version-min=10.4<span> </span><br>-isysroot<span> </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> </span><br>clang::CodeGenOptions const&, clang::TargetOptions const&,<span> </span><br>clang::LangOptions const&, llvm::StringRef, llvm::Module*,<span> </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> </span><br>516 /Users/manmanren/gmail/selfhost/Release/bin/clang -fPIC<span> </span><br>-I/Users/manmanren/gmail/llvm/projects/compiler-rt/lib<br>-I/Users/manmanren/gmail/llvm/projects/compiler-rt/include -arch<span> </span><br>x86_64 -fvisibility=hidden -DVISIBILITY_HIDDEN -mkernel -DKERNEL_USE<span> </span><br>-Wall -Werror -O3 -fomit-frame-pointer -mmacosx-version-min=10.4<span> </span><br>-isysroot<span> </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> </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> </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> </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> </span><br>llvm::DenseMapInfo<llvm::ConstantInt*> >&, llvm::Instruction*,<span> </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> </span>Program arguments: /Users/manmanren/gmail/selfhost/Release/bin/clang<br>-cc1 -triple x86_64-apple-macosx10.4.0 -emit-obj -disable-free<span> </span><br>-disable-llvm-verifier -main-file-name fixunsxfti.c -static-define<span> </span><br>-mrelocation-model static -mthread-model posix -masm-verbose<span> </span><br>-fforbid-guard-variables -target-cpu core2 -disable-red-zone<span> </span><br>-no-implicit-float -target-linker-version 242 -dwarf-column-info<span> </span><br>-coverage-file<span> </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> </span><br>-isysroot<span> </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> </span><br>/Users/manmanren/gmail/llvm/projects/compiler-rt/include -O3 -Wall<span> </span><br>-Werror -fdebug-compilation-dir<span> </span><br>/Users/manmanren/gmail/llvm/projects/compiler-rt<br>-ferror-limit 19 -fmessage-length 164 -fvisibility hidden<span> </span><br>-ffreestanding -mstackrealign -fno-builtin -fblocks<span> </span><br>-fblocks-runtime-optional -fno-rtti -fno-use-cxa-atexit<span> </span><br>-fobjc-runtime=macosx-10.4.0 -fobjc-dispatch-method=non-legacy<span> </span><br>-fencode-extended-block-signature<br>-fmax-type-align=16 -fno-common -fdiagnostics-show-option<span> </span><br>-fcolor-diagnostics -vectorize-loops -vectorize-slp -o<span> </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> </span><eof> parser at end of file<br>2.<span> </span>Code generation<br>3.<span> </span>Running pass 'Function Pass Manager' on module<br>'/Users/manmanren/gmail/llvm/projects/compiler-rt/lib/builtins/fixunsxfti.c'.<br>4.<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> </span><br>clang::CodeGenOptions const&, clang::TargetOptions const&,<span> </span><br>clang::LangOptions const&, llvm::StringRef, llvm::Module*,<span> </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> </span>Program arguments: /Users/manmanren/gmail/selfhost/Release/bin/clang<br>-cc1 -triple x86_64-apple-macosx10.4.0 -emit-obj -disable-free<span> </span><br>-disable-llvm-verifier -main-file-name fixxfti.c -static-define<span> </span><br>-mrelocation-model static -mthread-model posix -masm-verbose<span> </span><br>-fforbid-guard-variables -target-cpu core2 -disable-red-zone<span> </span><br>-no-implicit-float -target-linker-version 242 -dwarf-column-info<span> </span><br>-coverage-file<span> </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> </span><br>-isysroot<span> </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> </span><br>/Users/manmanren/gmail/llvm/projects/compiler-rt/include -O3 -Wall<span> </span><br>-Werror -fdebug-compilation-dir<span> </span><br>/Users/manmanren/gmail/llvm/projects/compiler-rt<br>-ferror-limit 19 -fmessage-length 164 -fvisibility hidden<span> </span><br>-ffreestanding -mstackrealign -fno-builtin -fblocks<span> </span><br>-fblocks-runtime-optional -fno-rtti -fno-use-cxa-atexit<span> </span><br>-fobjc-runtime=macosx-10.4.0 -fobjc-dispatch-method=non-legacy<span> </span><br>-fencode-extended-block-signature<br>-fmax-type-align=16 -fno-common -fdiagnostics-show-option<span> </span><br>-fcolor-diagnostics -vectorize-loops -vectorize-slp -o<span> </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> </span><eof> parser at end of file<br>2.<span> </span>Code generation<br>3.<span> </span>Running pass 'Function Pass Manager' on module<br>'/Users/manmanren/gmail/llvm/projects/compiler-rt/lib/builtins/fixxfti.c'.<br>4.<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> </span><br>-I/Users/manmanren/gmail/llvm/projects/compiler-rt/lib<br>-I/Users/manmanren/gmail/llvm/projects/compiler-rt/include -arch<span> </span><br>x86_64 -fvisibility=hidden -DVISIBILITY_HIDDEN -mkernel -DKERNEL_USE<span> </span><br>-Wall -Werror -O3 -fomit-frame-pointer -mmacosx-version-min=10.4<span> </span><br>-isysroot<span> </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> </span><br>-I/Users/manmanren/gmail/llvm/projects/compiler-rt/lib<br>-I/Users/manmanren/gmail/llvm/projects/compiler-rt/include -arch<span> </span><br>x86_64 -fvisibility=hidden -DVISIBILITY_HIDDEN -mkernel -DKERNEL_USE<span> </span><br>-Wall -Werror -O3 -fomit-frame-pointer -mmacosx-version-min=10.4<span> </span><br>-isysroot<span> </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> </span><br>-I/Users/manmanren/gmail/llvm/projects/compiler-rt/lib<br>-I/Users/manmanren/gmail/llvm/projects/compiler-rt/include -arch<span> </span><br>x86_64 -fvisibility=hidden -DVISIBILITY_HIDDEN -mkernel -DKERNEL_USE<span> </span><br>-Wall -Werror -O3 -fomit-frame-pointer -mmacosx-version-min=10.4<span> </span><br>-isysroot<span> </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> </span><br>see<br>invocation)<br>clang version 3.6.0 (clang-Rlto_master_build 222059) (llvm/trunk<span> </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> </span><br><a href="http://llvm.org/bugs/" target="_blank">http://llvm.org/bugs/</a> and include the crash backtrace, preprocessed<span> </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> </span><br>-I/Users/manmanren/gmail/llvm/projects/compiler-rt/lib<br>-I/Users/manmanren/gmail/llvm/projects/compiler-rt/include -arch<span> </span><br>x86_64 -fvisibility=hidden -DVISIBILITY_HIDDEN -mkernel -DKERNEL_USE<span> </span><br>-Wall -Werror -O3 -fomit-frame-pointer -mmacosx-version-min=10.4<span> </span><br>-isysroot<span> </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> </span><br>-I/Users/manmanren/gmail/llvm/projects/compiler-rt/lib<br>-I/Users/manmanren/gmail/llvm/projects/compiler-rt/include -arch<span> </span><br>x86_64 -fvisibility=hidden -DVISIBILITY_HIDDEN -mkernel -DKERNEL_USE<span> </span><br>-Wall -Werror -O3 -fomit-frame-pointer -mmacosx-version-min=10.4<span> </span><br>-isysroot<span> </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> </span><br>see<br>invocation)<br>clang version 3.6.0 (clang-Rlto_master_build 222059) (llvm/trunk<span> </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> </span><br><a href="http://llvm.org/bugs/" target="_blank">http://llvm.org/bugs/</a> and include the crash backtrace, preprocessed<span> </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><u></u><u></u></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" target="_blank">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> </span><br>performance critical fix, so we need to make sure it doesn't get lost<span> </span><br>in the mix.<br><br>Chad<br><br><br><u></u><u></u></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> </span><br>root cause.<br><br>What I did was:<br>1> update the repo to r222239, then "svn merge -c -r222039 .†,<span> </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> </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> </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> </span><br>r22239), let me know,<br><br>Thanks,<br>Manman (The build czar)<br><br><br><u></u><u></u></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" target="_blank">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" target="_blank">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> </span><br>loads before doing Load PRE"<br><br>This commit updates the failing test in<span> </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> </span><br>traversal in GVN.<br>The new test code is functionally same just the order of loads that<span> </span><br>are eliminated is swapped.<br><br>This new version also fixes an issue where GVN splits a critical<span> </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" target="_blank">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> </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> </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> </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> </span><br>ValuesPerBlock; UnavailBlkVect UnavailableBlocks; @@ -2431,175<span> </span><br>+2442,182 @@ bool GVN::processBlock(BasicBlock *BB) { return<span> </span><br>ChangedFunction; }<br><br>-/// performPRE - Perform a purely local form of PRE that looks for<span> </span><br>diamond -/// control flow patterns and attempts to perform simple<span> </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> </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> </span><br>+ CodeGenPrepare<br>from<br>+ // sinking the compare again, and it would force the code<span> </span><br>+ generator<br>to<br>+ // move the i1 from processor flags or predicate registers into<span> </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> </span><br>+ only trying to solve the basic diamond case, where // a value is<span> </span><br>+ computed in the successor and one predecessor, // but not the<span> </span><br>+ other. We also explicitly disallow cases // where the successor<span> </span><br>+ is its own predecessor, because they're // more complicated to<span> </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> </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> </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> </span><br>+ (Phi->getType()->getScalarType()->isPointerTy()) {<br>+ // Because we have added a PHI-use of the pointer value, it<span> </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> </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> </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> </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> </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> </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> </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" target="_blank">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> </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> </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/" target="_blank">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> </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> </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> </span><br>+CHECK-LABEL: @foo(<br>+entry:<br>+ switch i32 %stat, label %sw.default [<br>+ i32 0, label %<a href="http://sw.bb" target="_blank">sw.bb</a><br>+ i32 1, label %<a href="http://sw.bb" target="_blank">sw.bb</a><br>+ i32 2, label %sw.bb2<br>+ ]<br>+<br>+<a href="http://sw.bb" target="_blank">sw.bb</a>: ; 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> </span><br>+ 1.000000e+00 %cmp = fcmp olt double %sub, 0.000000e+00 br i1<span> </span><br>+ %cmp, label %if.then, label %if.end<br>+<br>+if.then: ; preds = %<a href="http://sw.bb" target="_blank">sw.bb</a><br>+ br label %return<br>+<br>+if.end: ; preds = %<a href="http://sw.bb" target="_blank">sw.bb</a><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" target="_blank">llvm-commits@cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><u></u><u></u></span></p><p class="MsoNormal" style="margin-bottom:12.0pt"><span style="font-size:9.0pt;font-family:"Helvetica","sans-serif""><u></u> <u></u></span></p><p class="MsoNormal" style="margin-bottom:12.0pt"><span style="font-size:9.0pt;font-family:"Helvetica","sans-serif""><u></u> <u></u></span></p><p class="MsoNormal" style="margin-bottom:12.0pt"><span style="font-size:9.0pt;font-family:"Helvetica","sans-serif""><u></u> <u></u></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><u></u><u></u></p></div></div><p class="MsoNormal"><u></u> <u></u></p></div></div></div></div></div><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" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
<br></blockquote></div><br></div>