[PATCH] D69490: [LoopIdiomRecognize] Avoid trying to create a pattern from the address of a thread local.
Ben via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Nov 3 09:49:22 PST 2019
bobsayshilol added a reviewer: hans.
bobsayshilol added a subscriber: hans.
bobsayshilol added inline comments.
================
Comment at: lib/Transforms/Scalar/LoopIdiomRecognize.cpp:444-449
+ // While technically constant, the address of a thread_local GlobalVariable
+ // isn't known until runtime and would require additional tls init code to
+ // handle correctly.
+ if (GlobalVariable *GV = dyn_cast<GlobalVariable>(C))
+ if (GV->isThreadDependent())
+ return nullptr;
----------------
lebedev.ri wrote:
> bobsayshilol wrote:
> > lebedev.ri wrote:
> > > What about `GlobalVariable`'s that aren't global constants?
> > >
> > Can you give an example? `GlobalVariable` inherits from `Constant` since their address is constant, so my understanding was that all `GlobalVariable`s are therefore (global) `Constant`s.
> I mean, is there any other `Constant` (other than this `GlobalVariable->isThreadDependent()`)
> that could lead to similar miscompiles?
Good question! Looking at other uses of `isThreadDependent()` brought me to `ValidLookupTableConstant()` in `SimplifyCFG.cpp` which looks like the thing we should be doing here rather than just checking for TLS. The TLS part of the check was added in D4220 for a similar reason to this patch, so I'll add @hans in case they have any words of wisdom. Assuming that is the correct approach, where should `ValidLookupTableConstant()` be moved to so that it can be used here? ie is it OK to simply remove the `static` and declare it in the header?
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D69490/new/
https://reviews.llvm.org/D69490
More information about the llvm-commits
mailing list