diff options
author | Hal Finkel <hfinkel@anl.gov> | 2015-10-28 23:43:00 +0000 |
---|---|---|
committer | Hal Finkel <hfinkel@anl.gov> | 2015-10-28 23:43:00 +0000 |
commit | 7d0e34eb33d2cfa44e393feb3bc387e004306919 (patch) | |
tree | 278ecd2d06e4422bc8f9e8729bd315cac5d988a3 /llvm/lib/Target/PowerPC/PPCCTRLoops.cpp | |
parent | 22f637a30b035e67078d93aee2cc0a33b5b8d355 (diff) | |
download | llvm-7d0e34eb33d2cfa44e393feb3bc387e004306919.zip llvm-7d0e34eb33d2cfa44e393feb3bc387e004306919.tar.gz llvm-7d0e34eb33d2cfa44e393feb3bc387e004306919.tar.bz2 |
[PowerPC] Recurse through constants when looking for TLS globals
We cannot form ctr-based loops around function calls, including calls to
__tls_get_addr used for PIC TLS variables. References to such TLS variables,
however, might be buried within constant expressions, and so we need to search
the entire constant expression to be sure that no references to such TLS
variables exist.
Fixes PR25256, reported by Eric Schweitz. This is a slightly-modified version
of the patch suggested by Eric in the bug report, and a test case I created.
llvm-svn: 251582
Diffstat (limited to 'llvm/lib/Target/PowerPC/PPCCTRLoops.cpp')
-rw-r--r-- | llvm/lib/Target/PowerPC/PPCCTRLoops.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/llvm/lib/Target/PowerPC/PPCCTRLoops.cpp b/llvm/lib/Target/PowerPC/PPCCTRLoops.cpp index a9687ad..58ccb4a 100644 --- a/llvm/lib/Target/PowerPC/PPCCTRLoops.cpp +++ b/llvm/lib/Target/PowerPC/PPCCTRLoops.cpp @@ -197,10 +197,18 @@ static bool isLargeIntegerTy(bool Is32Bit, Type *Ty) { // 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 Value *MemAddr) { const auto *GV = dyn_cast<GlobalValue>(MemAddr); - if (!GV) + if (!GV) { + // Recurse to check for constants that refer to TLS global variables. + if (const auto *CV = dyn_cast<Constant>(MemAddr)) + for (const auto &CO : CV->operands()) + if (memAddrUsesCTR(TM, CO)) + return true; + return false; + } + if (!GV->isThreadLocal()) return false; if (!TM) |