New issue
Advanced search Search tips

Issue 744754 link

Starred by 1 user

Issue metadata

Status: Verified
Owner:
Closed: Sep 2017
EstimatedDays: ----
NextAction: ----
OS: Chrome
Pri: 2
Type: Bug



Sign in to add a comment

clang r307457 crashes when building opencv 2.3 for ARM32 (Thumb2)

Project Member Reported by manojgupta@chromium.org, Jul 17 2017

Issue description

The crash starts at r305938 upstream. The commit itself is not reposponsible for the crash but it exposes a bug in LoopVectorizer.

commit 52ebe03cb0a728134e66d04f85281bc5a60d7091
Author:     Michael Kruse <llvm@meinersbur.de>
AuthorDate: Wed Jun 21 18:25:37 2017 +0000
Commit:     Michael Kruse <llvm@meinersbur.de>
CommitDate: Wed Jun 21 18:25:37 2017 +0000

    [BasicAA] Use MayAlias instead of PartialAlias for fallback.

Repro: Use the attached preprocessed file.

$ clang++ -Qunused-arguments -grecord-gcc-switches -fstack-protector-strong -pie -fno-omit-frame-pointer -D_FORTIFY_SOURCE=2 -mthumb  -O2 -pipe -march=armv8-a+crc -mtune=cortex-a57.cortex-a53 -mfpu=crypto-neon-fp-armv8 -mfloat-abi=hard -g -O3 -DNDEBUG -fPIC -c emd.ii -o emd.o -target armv7a-cros-linux-gnueabihf -Wno-parentheses-equality

clang-5.0: clang_src/llvm/lib/IR/Constants.cpp:1424: static llvm::Constant* llvm::ConstantExpr::getCast(unsigned int, llvm::Constant*, llvm::Type*, bool): Assertion `CastInst::castIsValid(opc, C, Ty) && "Invalid constantexpr cast!"' failed.
#0 0x0000000003e84a0f llvm::sys::PrintStackTrace(llvm::raw_ostream&) clang_src/llvm/lib/Support/Unix/Signals.inc:398:0
#1 0x0000000003e84aa0 PrintStackTraceSignalHandler(void*) clang_src/llvm/lib/Support/Unix/Signals.inc:462:0
#2 0x0000000003e82ee6 llvm::sys::RunSignalHandlers() clang_src/llvm/lib/Support/Signals.cpp:49:0
#3 0x0000000003e843a7 SignalHandler(int) clang_src/llvm/lib/Support/Unix/Signals.inc:252:0
#4 0x00007fc17322b330 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x10330)
#5 0x00007fc172022c37 gsignal /build/eglibc-SvCtMH/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0
#6 0x00007fc172026028 abort /build/eglibc-SvCtMH/eglibc-2.19/stdlib/abort.c:91:0
#7 0x00007fc17201bbf6 __assert_fail_base /build/eglibc-SvCtMH/eglibc-2.19/assert/assert.c:92:0
#8 0x00007fc17201bca2 (/lib/x86_64-linux-gnu/libc.so.6+0x2fca2)
#9 0x00000000036ff088 llvm::ConstantExpr::getCast(unsigned int, llvm::Constant*, llvm::Type*, bool) clang_src/llvm/lib/IR/Constants.cpp:1426:0
#10 0x000000000208ace4 llvm::ConstantFolder::CreateCast(llvm::Instruction::CastOps, llvm::Constant*, llvm::Type*) const clang_src/llvm/include/llvm/IR/ConstantFolder.h:184:0
#11 0x000000000209371c llvm::IRBuilder<llvm::ConstantFolder, llvm::IRBuilderDefaultInserter>::CreateCast(llvm::Instruction::CastOps, llvm::Value*, llvm::Type*, llvm::Twine const&) clang_src/llvm/include/llvm/IR/IRBuilder.h:1481:0
#12 0x0000000002090f92 llvm::IRBuilder<llvm::ConstantFolder, llvm::IRBuilderDefaultInserter>::CreateBitCast(llvm::Value*, llvm::Type*, llvm::Twine const&) clang_src/llvm/include/llvm/IR/IRBuilder.h:1447:0
#13 0x00000000032ce6c2 llvm::IRBuilder<llvm::ConstantFolder, llvm::IRBuilderDefaultInserter>::CreateBitOrPointerCast(llvm::Value*, llvm::Type*, llvm::Twine const&) clang_src/llvm/include/llvm/IR/IRBuilder.h:1526:0
#14 0x0000000003face2a (anonymous namespace)::InnerLoopVectorizer::vectorizeInterleaveGroup(llvm::Instruction*) clang_src/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:2953:0
#15 0x0000000003fad17c (anonymous namespace)::InnerLoopVectorizer::vectorizeMemoryInstruction(llvm::Instruction*) clang_src/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:2984:0
#16 0x0000000003fb7720 (anonymous namespace)::InnerLoopVectorizer::vectorizeInstruction(llvm::Instruction&) clang_src/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:4904:0
#17 0x0000000003fc5c32 (anonymous namespace)::LoopVectorizationPlanner::executePlan((anonymous namespace)::InnerLoopVectorizer&) clang_src/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:7692:0
#18 0x0000000003fc7eca llvm::LoopVectorizePass::processLoop(llvm::Loop*) clang_src/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:8010:0
#19 0x0000000003fc86ce llvm::LoopVectorizePass::runImpl(llvm::Function&, llvm::ScalarEvolution&, llvm::LoopInfo&, llvm::TargetTransformInfo&, llvm::DominatorTree&, llvm::BlockFrequencyInfo&, llvm::TargetLibraryInfo*, llvm::DemandedBits&, llvm::AAResults&, llvm::AssumptionCache&, std::function<llvm::LoopAccessInfo const& (llvm::Loop&)>&, llvm::OptimizationRemarkEmitter&) clang_src/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:8090:0
#20 0x0000000003faa379 (anonymous namespace)::LoopVectorize::runOnFunction(llvm::Function&) clang_src/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:2358:0
#21 0x00000000037dd9a2 llvm::FPPassManager::runOnFunction(llvm::Function&) clang_src/llvm/lib/IR/LegacyPassManager.cpp:1514:0
 
emd.ii
1.3 MB Download
The root cause is LoopVectorize is try to do the following cast:

<4 x float> <float 0xC415AF1D80000000, float 0xC415AF1D80000000, float 0xC415AF1D80000000, float 0xC415AF1D80000000> to <4 x %struct.CvNode1D*

llvm does not allow a direct cast from float to pointer type. If I force a two step cast: a) bitcast from float to int and b) int to pointer, then the crash is fixed.


Upstream llvm bug at https://bugs.llvm.org/show_bug.cgi?id=33804
Owner: manojgupta@chromium.org
Status: Verified (was: Untriaged)
Upstream CL: https://reviews.llvm.org/rL312331

Sign in to add a comment