Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clang crashes when building opencv 2.3 for ARM32 (Thumb2) #33151

Closed
m-gupta opened this issue Jul 15, 2017 · 8 comments
Closed

clang crashes when building opencv 2.3 for ARM32 (Thumb2) #33151

m-gupta opened this issue Jul 15, 2017 · 8 comments
Labels
bugzilla Issues migrated from bugzilla clang Clang issues not falling into any other category

Comments

@m-gupta
Copy link
Contributor

m-gupta commented Jul 15, 2017

Bugzilla Link 33804
Resolution FIXED
Resolved on Sep 12, 2017 23:22
Version trunk
OS Linux
CC @lalozano,@Meinersbur,@m-gupta,@pirama-arumuga-nainar,@stephenhines

Extended Description

The crash starts at r305938.

commit 52ebe03
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

The crash is blocking ChromeOS to upgrade to a newer llvm version.

@m-gupta
Copy link
Contributor Author

m-gupta commented Jul 15, 2017

@Meinersbur
Copy link
Member

r305938 removes a workaround that stopped other alias analysis results from returning more precise results. If another alias analysis finds that there is no aliasing, LoopVectorizer might run into a bug that was hidden before. Even if the alias result is incorrect, LoopVectorizer should not crash ('just' miscompile).

Please upload the file to Bugzilla so it is available for reference even after the external location is cleaned-up.

@m-gupta
Copy link
Contributor Author

m-gupta commented Jul 16, 2017

The preprocessed file is slightly bigger than bugzilla limit of 1024KB :(. So can't attach it here.

@m-gupta
Copy link
Contributor Author

m-gupta commented Jul 16, 2017

Test case (tgz)
Preprocessed file

@Meinersbur
Copy link
Member

emd.ll
Bugpoint reduced testcase

@Meinersbur
Copy link
Member

Thank you.

Reduced reproducer:

$ opt emd.ll -loop-vectorize

Looks like the vectorizer emits code that wants to cast a float-vector into a vector of pointers.

Adding Hao Liu to CC as he wrote the code that does the cast.

void InnerLoopVectorizer::vectorizeInterleaveGroup(Instruction *Instr) {
...
// If this member has different type, cast it to an unified type.
if (StoredVec->getType() != SubVT)
StoredVec = Builder.CreateBitOrPointerCast(StoredVec, SubVT);

StoredVec:
<4 x float> <float 0xC415AF1D80000000, float 0xC415AF1D80000000, float 0xC415AF1D80000000, float 0xC415AF1D80000000>

SubVT:
<4 x %struct.CvNode1D*>

Revision r239291
Author: Hao Liu Hao.Liu@arm.com
Date: Mon Jun 8 06:39:56 2015 +0000

[LoopVectorize] Teach Loop Vectorizor about interleaved memory accesses.

@m-gupta
Copy link
Contributor Author

m-gupta commented Jul 18, 2017

I am trying a fix at https://reviews.llvm.org/D35498

@m-gupta
Copy link
Contributor Author

m-gupta commented Sep 13, 2017

Fixed in https://reviews.llvm.org/rL312331

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla clang Clang issues not falling into any other category
Projects
None yet
Development

No branches or pull requests

2 participants