diff options
author | dim <dim@FreeBSD.org> | 2014-12-28 02:30:03 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2014-12-28 02:30:03 +0000 |
commit | 1e759913cd74f815b264461062da7e1a33b11d5f (patch) | |
tree | 868ba2d4a9c3f1e09418090740acaf240495fbf6 /contrib/llvm/lib/Target/PowerPC | |
parent | 1848cf1db38654a8dfebddc939ea4560806c375f (diff) | |
download | FreeBSD-src-1e759913cd74f815b264461062da7e1a33b11d5f.zip FreeBSD-src-1e759913cd74f815b264461062da7e1a33b11d5f.tar.gz |
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.
Diffstat (limited to 'contrib/llvm/lib/Target/PowerPC')
-rw-r--r-- | contrib/llvm/lib/Target/PowerPC/PPCCTRLoops.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/contrib/llvm/lib/Target/PowerPC/PPCCTRLoops.cpp b/contrib/llvm/lib/Target/PowerPC/PPCCTRLoops.cpp index ec1e34d..2adde22 100644 --- a/contrib/llvm/lib/Target/PowerPC/PPCCTRLoops.cpp +++ b/contrib/llvm/lib/Target/PowerPC/PPCCTRLoops.cpp @@ -194,6 +194,21 @@ static bool isLargeIntegerTy(bool Is32Bit, Type *Ty) { 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 Triple &TT, BasicBlock *BB) { SI->getNumCases()+1 >= (unsigned) TLI->getMinimumJumpTableEntries()) return true; } + for (Value *Operand : J->operands()) + if (memAddrUsesCTR(TM, Operand)) + return true; } return false; |