Date: Sun, 28 Dec 2014 02:30:04 +0000 (UTC) From: Dimitry Andric <dim@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r276324 - projects/clang350-import/contrib/llvm/lib/Target/PowerPC Message-ID: <201412280230.sBS2U4M2051346@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: dim Date: Sun Dec 28 02:30:03 2014 New Revision: 276324 URL: https://svnweb.freebsd.org/changeset/base/276324 Log: Pull in r224890 from upstream llvm trunk (by David Majnemer): PowerPC: CTR shouldn't fire if a TLS call is in the loop Determining the address of a TLS variable results in a function call in certain TLS models. This means that a simple ICmpInst might actually result in invalidating the CTR register. In such cases, do not attempt to rely on the CTR register for loop optimization purposes. This fixes PR22034. Differential Revision: http://reviews.llvm.org/D6786 This fixes a "Invalid PPC CTR loop" error when compiling parts of libc for PowerPC-32. Modified: projects/clang350-import/contrib/llvm/lib/Target/PowerPC/PPCCTRLoops.cpp Modified: projects/clang350-import/contrib/llvm/lib/Target/PowerPC/PPCCTRLoops.cpp ============================================================================== --- projects/clang350-import/contrib/llvm/lib/Target/PowerPC/PPCCTRLoops.cpp Sun Dec 28 00:53:52 2014 (r276323) +++ projects/clang350-import/contrib/llvm/lib/Target/PowerPC/PPCCTRLoops.cpp Sun Dec 28 02:30:03 2014 (r276324) @@ -194,6 +194,21 @@ static bool isLargeIntegerTy(bool Is32Bi return false; } +// Determining the address of a TLS variable results in a function call in +// certain TLS models. +static bool memAddrUsesCTR(const PPCTargetMachine *TM, + const llvm::Value *MemAddr) { + const auto *GV = dyn_cast<GlobalValue>(MemAddr); + if (!GV) + return false; + if (!GV->isThreadLocal()) + return false; + if (!TM) + return true; + TLSModel::Model Model = TM->getTLSModel(GV); + return Model == TLSModel::GeneralDynamic || Model == TLSModel::LocalDynamic; +} + bool PPCCTRLoops::mightUseCTR(const Triple &TT, BasicBlock *BB) { for (BasicBlock::iterator J = BB->begin(), JE = BB->end(); J != JE; ++J) { @@ -390,6 +405,9 @@ bool PPCCTRLoops::mightUseCTR(const Trip SI->getNumCases()+1 >= (unsigned) TLI->getMinimumJumpTableEntries()) return true; } + for (Value *Operand : J->operands()) + if (memAddrUsesCTR(TM, Operand)) + return true; } return false;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201412280230.sBS2U4M2051346>