1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-15 10:17:20 +00:00

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.
This commit is contained in:
Dimitry Andric 2014-12-28 02:30:03 +00:00
parent 8007ee2b0c
commit c1ddc1e628
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/projects/clang350-import/; revision=276324

View File

@ -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;