<div dir="ltr">Anna,<div><br></div><div>It looks like this change breaks the build:</div><div><br></div><div>(first build with problem)</div><div><br></div><div><a href="http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux/builds/24502">http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux/builds/24502</a><br></div><div><br></div><div><div>[100/338] Building Intrinsics.gen...</div><div>FAILED: /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm_build64/bin/clang++   -DGTEST_HAS_RTTI=0 -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Ilib/Support -I/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/lib/Support -Iinclude -I/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/include --target=i686-linux-android --sysroot=/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/../../../android-ndk/standalone-x86/sysroot -B/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/../../../android-ndk/standalone-x86 -fPIC -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wcovered-switch-default -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Werror=date-time -std=c++11 -fcolor-diagnostics -ffunction-sections -fdata-sections -O3    -UNDEBUG  -fno-exceptions -fno-rtti -MMD -MT lib/Support/CMakeFiles/LLVMSupport.dir/Triple.cpp.o -MF lib/Support/CMakeFiles/LLVMSupport.dir/Triple.cpp.o.d -o lib/Support/CMakeFiles/LLVMSupport.dir/Triple.cpp.o -c /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/lib/Support/Triple.cpp</div><div>clang-3.9: /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/lib/IR/Value.cpp:375: void llvm::Value::replaceAllUsesWith(llvm::Value *): Assertion `New->getType() == getType() && "replaceAllUses of value with new value of different type!"' failed.</div><div>#0 0x00000000018969e8 llvm::sys::PrintStackTrace(llvm::raw_ostream&) /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/lib/Support/Unix/Signals.inc:402:13</div><div>#1 0x0000000001894ba6 operator!=<std::pair<void (*)(void *), void *> *, std::vector<std::pair<void (*)(void *), void *>, std::allocator<std::pair<void (*)(void *), void *> > > > /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/stl_iterator.h:825:27</div><div>#2 0x0000000001894ba6 llvm::sys::RunSignalHandlers() /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/lib/Support/Signals.cpp:44:0</div><div>#3 0x00000000018970be SignalHandler(int) /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/lib/Support/Unix/Signals.inc:256:1</div><div>#4 0x00007fc3c40a60a0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0xf0a0)</div><div>#5 0x00007fc3c3196165 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x32165)</div><div>#6 0x00007fc3c31993e0 abort (/lib/x86_64-linux-gnu/libc.so.6+0x353e0)</div><div>#7 0x00007fc3c318f311 __assert_fail (/lib/x86_64-linux-gnu/libc.so.6+0x2b311)</div><div>#8 0x000000000151f76d cast<llvm::BasicBlock, llvm::Value> /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/include/llvm/Support/Casting.h:237:3</div><div>#9 0x000000000151f76d llvm::Value::replaceAllUsesWith(llvm::Value*) /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/lib/IR/Value.cpp:398:0</div><div>#10 0x000000000159bc7c llvm::InstCombiner::replaceInstUsesWith(llvm::Instruction&, llvm::Value*) /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/lib/Transforms/InstCombine/InstCombineInternal.h:442:7</div><div>#11 0x00000000015db186 llvm::InstCombiner::visitTrunc(llvm::TruncInst&) /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp:513:12</div><div>#12 0x00000000015a697b llvm::InstCombiner::run() /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp:2872:31</div><div>#13 0x00000000015a8370 combineInstructionsOverFunction(llvm::Function&, llvm::InstCombineWorklist&, llvm::AAResults*, llvm::AssumptionCache&, llvm::TargetLibraryInfo&, llvm::DominatorTree&, bool, llvm::LoopInfo*) /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp:3100:19</div><div>#14 0x00000000015a89ea llvm::InstructionCombiningPass::runOnFunction(llvm::Function&) /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp:3156:10</div><div>#15 0x00000000014e8c1f llvm::FPPassManager::runOnFunction(llvm::Function&) /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/lib/IR/LegacyPassManager.cpp:1526:27</div><div>#16 0x000000000218c6e7 RunPassOnSCC /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/lib/Analysis/CallGraphSCCPass.cpp:151:25</div><div>#17 0x000000000218c6e7 RunAllPassesOnSCC /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/lib/Analysis/CallGraphSCCPass.cpp:419:0</div><div>#18 0x000000000218c6e7 (anonymous namespace)::CGPassManager::runOnModule(llvm::Module&) /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/lib/Analysis/CallGraphSCCPass.cpp:475:0</div><div>#19 0x00000000014e9355 runOnModule /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/lib/IR/LegacyPassManager.cpp:1603:27</div><div>#20 0x00000000014e9355 llvm::legacy::PassManagerImpl::run(llvm::Module&) /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/lib/IR/LegacyPassManager.cpp:1706:0</div><div>#21 0x00000000019e6967 EmitAssembly /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/tools/clang/lib/CodeGen/BackendUtil.cpp:763:3</div><div>#22 0x00000000019e6967 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::DataLayout const&, llvm::Module*, clang::BackendAction, llvm::raw_pwrite_stream*) /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/tools/clang/lib/CodeGen/BackendUtil.cpp:779:0</div><div>#23 0x0000000002075473 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/tools/clang/lib/CodeGen/CodeGenAction.cpp:178:7</div><div>#24 0x000000000241d606 swap<bool> /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/move.h:177:11</div><div>#25 0x000000000241d606 clang::ParseAST(clang::Sema&, bool, bool) /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/tools/clang/lib/Parse/ParseAST.cpp:169:0</div><div>#26 0x0000000001d6d8f5 clang::FrontendAction::Execute() /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/tools/clang/lib/Frontend/FrontendAction.cpp:461:10</div><div>#27 0x0000000001d37951 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/tools/clang/lib/Frontend/CompilerInstance.cpp:877:11</div><div>#28 0x0000000001dfb24f clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/tools/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:241:25</div><div>#29 0x000000000079f398 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/tools/clang/tools/driver/cc1_main.cpp:116:13</div><div>#30 0x000000000079d833 ExecuteCC1Tool /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/tools/clang/tools/driver/driver.cpp:301:12</div><div>#31 0x000000000079d833 main /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/tools/clang/tools/driver/driver.cpp:382:0</div><div>#32 0x00007fc3c3182ead __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x1eead)</div><div>#33 0x000000000079ae15 _start (/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm_build64/bin/clang-3.9+0x79ae15)</div><div>Stack dump:</div><div>0.<span class="Apple-tab-span" style="white-space:pre">    </span>Program arguments: /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm_build64/bin/clang-3.9 -cc1 -triple i686--linux-android -emit-obj -disable-free -main-file-name Triple.cpp -mrelocation-model pic -pic-level 2 -mthread-model posix -fmath-errno -masm-verbose -mconstructor-aliases -fuse-init-array -target-cpu i686 -target-feature +ssse3 -momit-leaf-frame-pointer -dwarf-column-info -debugger-tuning=gdb -ffunction-sections -fdata-sections -coverage-file /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm_build_android_x86/lib/Support/CMakeFiles/LLVMSupport.dir/Triple.cpp.o -resource-dir /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm_build64/bin/../lib/clang/3.9.0 -dependency-file lib/Support/CMakeFiles/LLVMSupport.dir/Triple.cpp.o.d -MT lib/Support/CMakeFiles/LLVMSupport.dir/Triple.cpp.o -D GTEST_HAS_RTTI=0 -D _DEBUG -D __STDC_CONSTANT_MACROS -D __STDC_FORMAT_MACROS -D __STDC_LIMIT_MACROS -I lib/Support -I /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/lib/Support -I include -I /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/include -U NDEBUG -isysroot /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/../../../android-ndk/standalone-x86/sysroot -internal-isystem /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/../../../android-ndk/standalone-x86/lib/gcc/i686-linux-android/4.8/../../../../include/c++/4.8 -internal-isystem /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/../../../android-ndk/standalone-x86/lib/gcc/i686-linux-android/4.8/../../../../include/c++/4.8/i686-linux-android -internal-isystem /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/../../../android-ndk/standalone-x86/lib/gcc/i686-linux-android/4.8/../../../../include/c++/4.8/backward -internal-isystem /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/../../../android-ndk/standalone-x86/sysroot/usr/local/include -internal-isystem /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm_build64/bin/../lib/clang/3.9.0/include -internal-externc-isystem /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/../../../android-ndk/standalone-x86/sysroot/include -internal-externc-isystem /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/../../../android-ndk/standalone-x86/sysroot/usr/include -O3 -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wno-long-long -Wcovered-switch-default -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Werror=date-time -pedantic -std=c++11 -fdeprecated-macro -fdebug-compilation-dir /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm_build_android_x86 -ferror-limit 19 -fmessage-length 0 -fvisibility-inlines-hidden -femulated-tls -fno-rtti -fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics -vectorize-loops -vectorize-slp -o lib/Support/CMakeFiles/LLVMSupport.dir/Triple.cpp.o -x c++ /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/lib/Support/Triple.cpp </div><div>1.<span class="Apple-tab-span" style="white-space:pre">    </span><eof> parser at end of file</div><div>2.<span class="Apple-tab-span" style="white-space:pre">  </span>Per-module optimization passes</div><div>3.<span class="Apple-tab-span" style="white-space:pre">     </span>Running pass 'CallGraph Pass Manager' on module '/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/lib/Support/Triple.cpp'.</div><div>4.<span class="Apple-tab-span" style="white-space:pre">     </span>Running pass 'Combine redundant instructions' on function '@_ZN4llvm6Triple22getArchTypeForLLVMNameENS_9StringRefE'</div><div>clang-3.9: error: unable to execute command: Aborted</div><div>clang-3.9: error: clang frontend command failed due to signal (use -v to see invocation)</div><div>clang version 3.9.0 (trunk 273608)</div><div>Target: i686--linux-android</div><div>Thread model: posix</div><div>InstalledDir: /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm_build64/bin</div><div>clang-3.9: note: diagnostic msg: PLEASE submit a bug report to <a href="http://llvm.org/bugs/">http://llvm.org/bugs/</a> and include the crash backtrace, preprocessed source, and associated run script.</div><div>clang-3.9: note: diagnostic msg: </div><div>********************</div><div><br></div><div>PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:</div><div>Preprocessed source(s) and associated run script(s) are located at:</div><div>clang-3.9: note: diagnostic msg: /tmp/Triple-241584.cpp</div><div>clang-3.9: note: diagnostic msg: /tmp/Triple-241584.sh</div><div>clang-3.9: note: diagnostic msg: </div><div><br></div><div>********************</div><div>FAILED: /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm_build64/bin/clang++   -DGTEST_HAS_RTTI=0 -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Ilib/Support -I/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/lib/Support -Iinclude -I/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/include --target=i686-linux-android --sysroot=/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/../../../android-ndk/standalone-x86/sysroot -B/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/../../../android-ndk/standalone-x86 -fPIC -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wcovered-switch-default -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Werror=date-time -std=c++11 -fcolor-diagnostics -ffunction-sections -fdata-sections -O3    -UNDEBUG  -fno-exceptions -fno-rtti -MMD -MT lib/Support/CMakeFiles/LLVMSupport.dir/YAMLTraits.cpp.o -MF lib/Support/CMakeFiles/LLVMSupport.dir/YAMLTraits.cpp.o.d -o lib/Support/CMakeFiles/LLVMSupport.dir/YAMLTraits.cpp.o -c /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/lib/Support/YAMLTraits.cpp</div><div>clang-3.9: /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/lib/IR/Value.cpp:375: void llvm::Value::replaceAllUsesWith(llvm::Value *): Assertion `New->getType() == getType() && "replaceAllUses of value with new value of different type!"' failed.</div><div>#0 0x00000000018969e8 llvm::sys::PrintStackTrace(llvm::raw_ostream&) /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/lib/Support/Unix/Signals.inc:402:13</div><div>#1 0x0000000001894ba6 operator!=<std::pair<void (*)(void *), void *> *, std::vector<std::pair<void (*)(void *), void *>, std::allocator<std::pair<void (*)(void *), void *> > > > /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/stl_iterator.h:825:27</div><div>#2 0x0000000001894ba6 llvm::sys::RunSignalHandlers() /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/lib/Support/Signals.cpp:44:0</div><div>#3 0x00000000018970be SignalHandler(int) /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/lib/Support/Unix/Signals.inc:256:1</div><div>#4 0x00007f64cd0910a0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0xf0a0)</div><div>#5 0x00007f64cc181165 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x32165)</div><div>#6 0x00007f64cc1843e0 abort (/lib/x86_64-linux-gnu/libc.so.6+0x353e0)</div><div>#7 0x00007f64cc17a311 __assert_fail (/lib/x86_64-linux-gnu/libc.so.6+0x2b311)</div><div>#8 0x000000000151f76d cast<llvm::BasicBlock, llvm::Value> /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/include/llvm/Support/Casting.h:237:3</div><div>#9 0x000000000151f76d llvm::Value::replaceAllUsesWith(llvm::Value*) /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/lib/IR/Value.cpp:398:0</div><div>#10 0x000000000159bc7c llvm::InstCombiner::replaceInstUsesWith(llvm::Instruction&, llvm::Value*) /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/lib/Transforms/InstCombine/InstCombineInternal.h:442:7</div><div>#11 0x00000000015db186 llvm::InstCombiner::visitTrunc(llvm::TruncInst&) /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp:513:12</div><div>#12 0x00000000015a697b llvm::InstCombiner::run() /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp:2872:31</div><div>#13 0x00000000015a8370 combineInstructionsOverFunction(llvm::Function&, llvm::InstCombineWorklist&, llvm::AAResults*, llvm::AssumptionCache&, llvm::TargetLibraryInfo&, llvm::DominatorTree&, bool, llvm::LoopInfo*) /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp:3100:19</div><div>#14 0x00000000015a89ea llvm::InstructionCombiningPass::runOnFunction(llvm::Function&) /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp:3156:10</div><div>#15 0x00000000014e8c1f llvm::FPPassManager::runOnFunction(llvm::Function&) /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/lib/IR/LegacyPassManager.cpp:1526:27</div><div>#16 0x000000000218c6e7 RunPassOnSCC /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/lib/Analysis/CallGraphSCCPass.cpp:151:25</div><div>#17 0x000000000218c6e7 RunAllPassesOnSCC /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/lib/Analysis/CallGraphSCCPass.cpp:419:0</div><div>#18 0x000000000218c6e7 (anonymous namespace)::CGPassManager::runOnModule(llvm::Module&) /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/lib/Analysis/CallGraphSCCPass.cpp:475:0</div><div>#19 0x00000000014e9355 runOnModule /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/lib/IR/LegacyPassManager.cpp:1603:27</div><div>#20 0x00000000014e9355 llvm::legacy::PassManagerImpl::run(llvm::Module&) /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/lib/IR/LegacyPassManager.cpp:1706:0</div><div>#21 0x00000000019e6967 EmitAssembly /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/tools/clang/lib/CodeGen/BackendUtil.cpp:763:3</div><div>#22 0x00000000019e6967 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::DataLayout const&, llvm::Module*, clang::BackendAction, llvm::raw_pwrite_stream*) /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/tools/clang/lib/CodeGen/BackendUtil.cpp:779:0</div><div>#23 0x0000000002075473 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/tools/clang/lib/CodeGen/CodeGenAction.cpp:178:7</div><div>#24 0x000000000241d606 swap<bool> /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/move.h:177:11</div><div>#25 0x000000000241d606 clang::ParseAST(clang::Sema&, bool, bool) /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/tools/clang/lib/Parse/ParseAST.cpp:169:0</div><div>#26 0x0000000001d6d8f5 clang::FrontendAction::Execute() /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/tools/clang/lib/Frontend/FrontendAction.cpp:461:10</div><div>#27 0x0000000001d37951 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/tools/clang/lib/Frontend/CompilerInstance.cpp:877:11</div><div>#28 0x0000000001dfb24f clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/tools/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:241:25</div><div>#29 0x000000000079f398 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/tools/clang/tools/driver/cc1_main.cpp:116:13</div><div>#30 0x000000000079d833 ExecuteCC1Tool /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/tools/clang/tools/driver/driver.cpp:301:12</div><div>#31 0x000000000079d833 main /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/tools/clang/tools/driver/driver.cpp:382:0</div><div>#32 0x00007f64cc16dead __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x1eead)</div><div>#33 0x000000000079ae15 _start (/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm_build64/bin/clang-3.9+0x79ae15)</div><div>Stack dump:</div><div>0.<span class="Apple-tab-span" style="white-space:pre">     </span>Program arguments: /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm_build64/bin/clang-3.9 -cc1 -triple i686--linux-android -emit-obj -disable-free -main-file-name YAMLTraits.cpp -mrelocation-model pic -pic-level 2 -mthread-model posix -fmath-errno -masm-verbose -mconstructor-aliases -fuse-init-array -target-cpu i686 -target-feature +ssse3 -momit-leaf-frame-pointer -dwarf-column-info -debugger-tuning=gdb -ffunction-sections -fdata-sections -coverage-file /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm_build_android_x86/lib/Support/CMakeFiles/LLVMSupport.dir/YAMLTraits.cpp.o -resource-dir /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm_build64/bin/../lib/clang/3.9.0 -dependency-file lib/Support/CMakeFiles/LLVMSupport.dir/YAMLTraits.cpp.o.d -MT lib/Support/CMakeFiles/LLVMSupport.dir/YAMLTraits.cpp.o -D GTEST_HAS_RTTI=0 -D _DEBUG -D __STDC_CONSTANT_MACROS -D __STDC_FORMAT_MACROS -D __STDC_LIMIT_MACROS -I lib/Support -I /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/lib/Support -I include -I /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/include -U NDEBUG -isysroot /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/../../../android-ndk/standalone-x86/sysroot -internal-isystem /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/../../../android-ndk/standalone-x86/lib/gcc/i686-linux-android/4.8/../../../../include/c++/4.8 -internal-isystem /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/../../../android-ndk/standalone-x86/lib/gcc/i686-linux-android/4.8/../../../../include/c++/4.8/i686-linux-android -internal-isystem /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/../../../android-ndk/standalone-x86/lib/gcc/i686-linux-android/4.8/../../../../include/c++/4.8/backward -internal-isystem /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/../../../android-ndk/standalone-x86/sysroot/usr/local/include -internal-isystem /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm_build64/bin/../lib/clang/3.9.0/include -internal-externc-isystem /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/../../../android-ndk/standalone-x86/sysroot/include -internal-externc-isystem /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/../../../android-ndk/standalone-x86/sysroot/usr/include -O3 -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wno-long-long -Wcovered-switch-default -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Werror=date-time -pedantic -std=c++11 -fdeprecated-macro -fdebug-compilation-dir /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm_build_android_x86 -ferror-limit 19 -fmessage-length 0 -fvisibility-inlines-hidden -femulated-tls -fno-rtti -fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics -vectorize-loops -vectorize-slp -o lib/Support/CMakeFiles/LLVMSupport.dir/YAMLTraits.cpp.o -x c++ /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/lib/Support/YAMLTraits.cpp </div><div>1.<span class="Apple-tab-span" style="white-space:pre">    </span><eof> parser at end of file</div><div>2.<span class="Apple-tab-span" style="white-space:pre">  </span>Per-module optimization passes</div><div>3.<span class="Apple-tab-span" style="white-space:pre">     </span>Running pass 'CallGraph Pass Manager' on module '/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/lib/Support/YAMLTraits.cpp'.</div><div>4.<span class="Apple-tab-span" style="white-space:pre"> </span>Running pass 'Combine redundant instructions' on function '@_ZSt4fillSt13_Bit_iteratorS_RKb'</div><div>clang-3.9: error: unable to execute command: Aborted</div><div>clang-3.9: error: clang frontend command failed due to signal (use -v to see invocation)</div><div>clang version 3.9.0 (trunk 273608)</div><div>Target: i686--linux-android</div><div>Thread model: posix</div><div>InstalledDir: /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm_build64/bin</div><div>clang-3.9: note: diagnostic msg: PLEASE submit a bug report to <a href="http://llvm.org/bugs/">http://llvm.org/bugs/</a> and include the crash backtrace, preprocessed source, and associated run script.</div><div>clang-3.9: note: diagnostic msg: </div><div>********************</div><div><br></div><div>PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:</div><div>Preprocessed source(s) and associated run script(s) are located at:</div><div>clang-3.9: note: diagnostic msg: /tmp/YAMLTraits-b688c4.cpp</div><div>clang-3.9: note: diagnostic msg: /tmp/YAMLTraits-b688c4.sh</div><div>clang-3.9: note: diagnostic msg: </div><div><br></div><div>********************</div><div>ninja: build stopped: subcommand failed.</div><div>@@@STEP_FAILURE@@@</div><div>+ echo @@@STEP_FAILURE@@@</div><div>+ cd ..</div><div>+ echo @@@BUILD_STEP build compiler-rt android/aarch64@@@</div></div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Jun 23, 2016 at 1:29 PM Anna Thomas via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: annat<br>
Date: Thu Jun 23 15:22:22 2016<br>
New Revision: 273608<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=273608&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=273608&view=rev</a><br>
Log:<br>
InstCombine rule to fold trunc when value available<br>
<br>
Summary:<br>
This instcombine rule folds away trunc operations that have value available from a prior load or store.<br>
This kind of code can be generated as a result of GVN widening the load or from source code as well.<br>
<br>
Reviewers: reames, majnemer, sanjoy<br>
<br>
Subscribers: llvm-commits<br>
<br>
Differential Revision: <a href="http://reviews.llvm.org/D21246" rel="noreferrer" target="_blank">http://reviews.llvm.org/D21246</a><br>
<br>
Modified:<br>
    llvm/trunk/include/llvm/Analysis/Loads.h<br>
    llvm/trunk/lib/Analysis/Loads.cpp<br>
    llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp<br>
    llvm/trunk/test/Transforms/InstCombine/trunc.ll<br>
<br>
Modified: llvm/trunk/include/llvm/Analysis/Loads.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/Loads.h?rev=273608&r1=273607&r2=273608&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/Loads.h?rev=273608&r1=273607&r2=273608&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/Analysis/Loads.h (original)<br>
+++ llvm/trunk/include/llvm/Analysis/Loads.h Thu Jun 23 15:22:22 2016<br>
@@ -61,6 +61,38 @@ bool isSafeToLoadUnconditionally(Value *<br>
 /// to scan in the block, used by FindAvailableLoadedValue().<br>
 extern cl::opt<unsigned> DefMaxInstsToScan;<br>
<br>
+/// Scan the ScanBB block backwards checking to see if we have the value at<br>
+/// the memory address \p Ptr of type \p AccessTy locally available within a<br>
+/// small number of instructions. If the value is available, return it.<br>
+///<br>
+/// If not, return the iterator for the last validated instruction that the<br>
+/// value would be live through.  If we scanned the entire block and didn't<br>
+/// find something that invalidates *Ptr or provides it, ScanFrom would be<br>
+/// left at begin() and this returns null.  ScanFrom could also be left<br>
+///<br>
+/// MaxInstsToScan specifies the maximum instructions to scan in the block.<br>
+/// If it is set to 0, it will scan the whole block. You can also optionally<br>
+/// specify an alias analysis implementation, which makes this more precise.<br>
+///<br>
+/// If AATags is non-null and a load or store is found, the AA tags from the<br>
+/// load or store are recorded there.  If there are no AA tags or if no access<br>
+/// is found, it is left unmodified.<br>
+///<br>
+/// IsAtomicMemOp specifies the atomicity of the memory operation that accesses<br>
+/// \p *Ptr. We verify atomicity constraints are satisfied when value forwarding<br>
+/// from another memory operation that has value \p *Ptr available.<br>
+///<br>
+/// Note that we assume the \p *Ptr is accessed through a non-volatile but<br>
+/// potentially atomic load. Any other constraints should be verified at the<br>
+/// caller.<br>
+Value *FindAvailableLoadedValue(Value *Ptr, Type *AccessTy, bool IsAtomicMemOp,<br>
+                                BasicBlock *ScanBB,<br>
+                                BasicBlock::iterator &ScanFrom,<br>
+                                unsigned MaxInstsToScan,<br>
+                                AliasAnalysis *AA = nullptr,<br>
+                                AAMDNodes *AATags = nullptr,<br>
+                                bool *IsLoadCSE = nullptr);<br>
+<br>
 /// FindAvailableLoadedValue - Scan the ScanBB block backwards (starting at<br>
 /// the instruction before ScanFrom) checking to see if we have the value at<br>
 /// the memory address *Ptr locally available within a small number of<br>
<br>
Modified: llvm/trunk/lib/Analysis/Loads.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/Loads.cpp?rev=273608&r1=273607&r2=273608&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/Loads.cpp?rev=273608&r1=273607&r2=273608&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Analysis/Loads.cpp (original)<br>
+++ llvm/trunk/lib/Analysis/Loads.cpp Thu Jun 23 15:22:22 2016<br>
@@ -300,8 +300,9 @@ llvm::DefMaxInstsToScan("available-load-<br>
            "to scan backward from a given instruction, when searching for "<br>
            "available loaded value"));<br>
<br>
-/// \brief Scan the ScanBB block backwards to see if we have the value at the<br>
-/// memory address *Ptr locally available within a small number of instructions.<br>
+/// Scan the ScanBB block backwards checking to see if we have the value at<br>
+/// the memory address \p Ptr of type \p AccessTy locally available within a<br>
+/// small number of instructions. If the value is available, return it.<br>
 ///<br>
 /// The scan starts from \c ScanFrom. \c MaxInstsToScan specifies the maximum<br>
 /// instructions to scan in the block. If it is set to \c 0, it will scan the whole<br>
@@ -318,26 +319,25 @@ llvm::DefMaxInstsToScan("available-load-<br>
 ///<br>
 /// If \c AATags is non-null and a load or store is found, the AA tags from the<br>
 /// load or store are recorded there. If there are no AA tags or if no access is<br>
-/// found, it is left unmodified.<br>
-Value *llvm::FindAvailableLoadedValue(LoadInst *Load, BasicBlock *ScanBB,<br>
+/// is found, it is left unmodified.<br>
+///<br>
+/// IsAtomicMemOp specifies the atomicity of the memory operation that accesses<br>
+/// \p *Ptr. We verify atomicity constraints are satisfied when value forwarding<br>
+/// from another memory operation that has value \p *Ptr available.<br>
+///<br>
+/// Note that we assume the \p *Ptr is accessed through a non-volatile but<br>
+/// potentially atomic load. Any other constraints should be verified at the<br>
+/// caller.<br>
+Value *llvm::FindAvailableLoadedValue(Value *Ptr, Type *AccessTy, bool IsAtomicMemOp,<br>
+                                      BasicBlock *ScanBB,<br>
                                       BasicBlock::iterator &ScanFrom,<br>
                                       unsigned MaxInstsToScan,<br>
                                       AliasAnalysis *AA, AAMDNodes *AATags,<br>
                                       bool *IsLoadCSE) {<br>
+<br>
   if (MaxInstsToScan == 0)<br>
     MaxInstsToScan = ~0U;<br>
<br>
-  Value *Ptr = Load->getPointerOperand();<br>
-  Type *AccessTy = Load->getType();<br>
-<br>
-  // We can never remove a volatile load<br>
-  if (Load->isVolatile())<br>
-    return nullptr;<br>
-<br>
-  // Anything stronger than unordered is currently unimplemented.<br>
-  if (!Load->isUnordered())<br>
-    return nullptr;<br>
-<br>
   const DataLayout &DL = ScanBB->getModule()->getDataLayout();<br>
<br>
   // Try to get the store size for the type.<br>
@@ -363,14 +363,14 @@ Value *llvm::FindAvailableLoadedValue(Lo<br>
     // If this is a load of Ptr, the loaded value is available.<br>
     // (This is true even if the load is volatile or atomic, although<br>
     // those cases are unlikely.)<br>
-    if (LoadInst *LI = dyn_cast<LoadInst>(Inst))<br>
-      if (AreEquivalentAddressValues(<br>
-              LI->getPointerOperand()->stripPointerCasts(), StrippedPtr) &&<br>
+    if (LoadInst *LI = dyn_cast<LoadInst>(Inst)) {<br>
+      Value *LoadPtr = LI->getPointerOperand()->stripPointerCasts();<br>
+      if (AreEquivalentAddressValues(LoadPtr, StrippedPtr) &&<br>
           CastInst::isBitOrNoopPointerCastable(LI->getType(), AccessTy, DL)) {<br>
<br>
         // We can value forward from an atomic to a non-atomic, but not the<br>
         // other way around.<br>
-        if (LI->isAtomic() < Load->isAtomic())<br>
+        if (LI->isAtomic() < IsAtomicMemOp)<br>
           return nullptr;<br>
<br>
         if (AATags)<br>
@@ -380,6 +380,8 @@ Value *llvm::FindAvailableLoadedValue(Lo<br>
         return LI;<br>
       }<br>
<br>
+    }<br>
+<br>
     if (StoreInst *SI = dyn_cast<StoreInst>(Inst)) {<br>
       Value *StorePtr = SI->getPointerOperand()->stripPointerCasts();<br>
       // If this is a store through Ptr, the value is available!<br>
@@ -391,7 +393,7 @@ Value *llvm::FindAvailableLoadedValue(Lo<br>
<br>
         // We can value forward from an atomic to a non-atomic, but not the<br>
         // other way around.<br>
-        if (SI->isAtomic() < Load->isAtomic())<br>
+        if (SI->isAtomic() < IsAtomicMemOp)<br>
           return nullptr;<br>
<br>
         if (AATags)<br>
@@ -434,4 +436,44 @@ Value *llvm::FindAvailableLoadedValue(Lo<br>
   // Got to the start of the block, we didn't find it, but are done for this<br>
   // block.<br>
   return nullptr;<br>
+<br>
+}<br>
+<br>
+/// \brief Scan the ScanBB block backwards to see if we have the value at the<br>
+/// memory address *Ptr locally available within a small number of instructions.<br>
+///<br>
+/// The scan starts from \c ScanFrom. \c MaxInstsToScan specifies the maximum<br>
+/// instructions to scan in the block. If it is set to \c 0, it will scan the whole<br>
+/// block.<br>
+///<br>
+/// If the value is available, this function returns it. If not, it returns the<br>
+/// iterator for the last validated instruction that the value would be live<br>
+/// through. If we scanned the entire block and didn't find something that<br>
+/// invalidates \c *Ptr or provides it, \c ScanFrom is left at the last<br>
+/// instruction processed and this returns null.<br>
+///<br>
+/// You can also optionally specify an alias analysis implementation, which<br>
+/// makes this more precise.<br>
+///<br>
+/// If \c AATags is non-null and a load or store is found, the AA tags from the<br>
+/// load or store are recorded there. If there are no AA tags or if no access is<br>
+/// is found, it is left unmodified.<br>
+Value *llvm::FindAvailableLoadedValue(LoadInst *Load, BasicBlock *ScanBB,<br>
+                                      BasicBlock::iterator &ScanFrom,<br>
+                                      unsigned MaxInstsToScan,<br>
+                                      AliasAnalysis *AA, AAMDNodes *AATags,<br>
+                                      bool *IsLoadCSE) {<br>
+<br>
+  // We can never remove a volatile load<br>
+  if (Load->isVolatile())<br>
+    return nullptr;<br>
+<br>
+  // Anything stronger than unordered is currently unimplemented.<br>
+  if (!Load->isUnordered())<br>
+    return nullptr;<br>
+<br>
+  // Return the full value of the load if available.<br>
+  return FindAvailableLoadedValue(Load->getPointerOperand(), Load->getType(),<br>
+                                  Load->isAtomic(), ScanBB, ScanFrom,<br>
+                                  MaxInstsToScan, AA, AATags, IsLoadCSE);<br>
 }<br>
<br>
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp?rev=273608&r1=273607&r2=273608&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp?rev=273608&r1=273607&r2=273608&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp (original)<br>
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp Thu Jun 23 15:22:22 2016<br>
@@ -14,9 +14,10 @@<br>
 #include "InstCombineInternal.h"<br>
 #include "llvm/ADT/SetVector.h"<br>
 #include "llvm/Analysis/ConstantFolding.h"<br>
+#include "llvm/Analysis/Loads.h"<br>
+#include "llvm/Analysis/TargetLibraryInfo.h"<br>
 #include "llvm/IR/DataLayout.h"<br>
 #include "llvm/IR/PatternMatch.h"<br>
-#include "llvm/Analysis/TargetLibraryInfo.h"<br>
 using namespace llvm;<br>
 using namespace PatternMatch;<br>
<br>
@@ -576,6 +577,24 @@ Instruction *InstCombiner::visitTrunc(Tr<br>
   if (Instruction *I = foldVecTruncToExtElt(CI, *this, DL))<br>
     return I;<br>
<br>
+  // When trunc operand is a widened load, see if we can get the value from a<br>
+  // previous store/load<br>
+  if (auto *LI = dyn_cast<LoadInst>(Src)) {<br>
+    BasicBlock::iterator BBI(*LI);<br>
+<br>
+    // Scan a few instructions up from LI and if we find a partial load/store<br>
+    // of Type DestTy that feeds into LI, we can replace all uses of the trunc<br>
+    // with the load/store value.<br>
+    // This replacement can be done only in the case of non-volatile loads. If<br>
+    // the load is atomic, its only use should be the trunc instruction. We<br>
+    // don't want to allow other users of LI to see a value that is out of sync<br>
+    // with the value we're folding the trunc to (in case of a race).<br>
+    if (!LI->isVolatile() && (!LI->isAtomic() || LI->hasOneUse()))<br>
+      if (Value *AvailableVal = FindAvailableLoadedValue(<br>
+              LI->getPointerOperand(), DestTy, LI->isAtomic(), LI->getParent(),<br>
+              BBI, DefMaxInstsToScan))<br>
+        return replaceInstUsesWith(CI, AvailableVal);<br>
+  }<br>
   return nullptr;<br>
 }<br>
<br>
<br>
Modified: llvm/trunk/test/Transforms/InstCombine/trunc.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/trunc.ll?rev=273608&r1=273607&r2=273608&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/trunc.ll?rev=273608&r1=273607&r2=273608&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/Transforms/InstCombine/trunc.ll (original)<br>
+++ llvm/trunk/test/Transforms/InstCombine/trunc.ll Thu Jun 23 15:22:22 2016<br>
@@ -181,3 +181,60 @@ bb1:<br>
 bb2:<br>
   unreachable<br>
 }<br>
+<br>
+declare void @consume(i8) readonly<br>
+define i1 @trunc_load_store(i8* align 2 %a) {<br>
+  store i8 0, i8 *%a, align 2<br>
+  %bca  = bitcast i8* %a to i16*<br>
+  %wide.load = load i16, i16* %bca, align 2<br>
+  %lowhalf.1 = trunc i16 %wide.load to i8<br>
+  call void @consume(i8 %lowhalf.1)<br>
+  %cmp.2 = icmp ult i16 %wide.load, 256<br>
+  ret i1 %cmp.2<br>
+; CHECK-LABEL: @trunc_load_store<br>
+; CHECK-NOT: trunc<br>
+; CHECK: call void @consume(i8 0)<br>
+}<br>
+<br>
+<br>
+; The trunc can be replaced with the load value.<br>
+define i1 @trunc_load_load(i8* align 2 %a) {<br>
+  %pload = load i8, i8* %a, align 2<br>
+  %bca  = bitcast i8* %a to i16*<br>
+  %wide.load = load i16, i16* %bca, align 2<br>
+  %lowhalf = trunc i16 %wide.load to i8<br>
+  call void @consume(i8 %lowhalf)<br>
+  call void @consume(i8 %pload)<br>
+  %cmp.2 = icmp ult i16 %wide.load, 256<br>
+  ret i1 %cmp.2<br>
+; CHECK-LABEL: @trunc_load_load<br>
+; CHECK-NOT: trunc<br>
+}<br>
+<br>
+; trunc should not be replaced since atomic load %wide.load has more than one use.<br>
+; different values can be seen by the uses of %wide.load in case of race.<br>
+define i1 @trunc_atomic_loads(i8* align 2 %a) {<br>
+  %pload = load atomic i8, i8* %a unordered, align 2<br>
+  %bca  = bitcast i8* %a to i16*<br>
+  %wide.load = load atomic i16, i16* %bca unordered, align 2<br>
+  %lowhalf = trunc i16 %wide.load to i8<br>
+  call void @consume(i8 %lowhalf)<br>
+  call void @consume(i8 %pload)<br>
+  %cmp.2 = icmp ult i16 %wide.load, 256<br>
+  ret i1 %cmp.2<br>
+; CHECK-LABEL: @trunc_atomic_loads<br>
+; CHECK: trunc<br>
+}<br>
+<br>
+; trunc cannot be replaced since store size is not trunc result size<br>
+define i1 @trunc_different_size_load(i16 * align 2 %a) {<br>
+  store i16 0, i16 *%a, align 2<br>
+  %bca  = bitcast i16* %a to i32*<br>
+  %wide.load = load i32, i32* %bca, align 2<br>
+  %lowhalf = trunc i32 %wide.load to i8<br>
+  call void @consume(i8 %lowhalf)<br>
+  %cmp.2 = icmp ult i32 %wide.load, 256<br>
+  ret i1 %cmp.2<br>
+; CHECK-LABEL: @trunc_different_size_load<br>
+; CHECK: %lowhalf = trunc i32 %wide.load to i8<br>
+}<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><div dir="ltr">-- <br></div><div data-smartmail="gmail_signature">Mike<br>Sent from phone</div>