diff options
author | Matthias Braun <matze@braunis.de> | 2024-04-19 10:01:42 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-19 10:01:42 -0700 |
commit | 6bbccd2516c3a843809a8303da48abce58a88855 (patch) | |
tree | fb5c5666a20155ecc03c688671f02609a73225a7 /llvm/lib/Analysis/GlobalsModRef.cpp | |
parent | 41e696291c64fe19629e14887ed1ed9b9c2271f0 (diff) | |
download | llvm-6bbccd2516c3a843809a8303da48abce58a88855.zip llvm-6bbccd2516c3a843809a8303da48abce58a88855.tar.gz llvm-6bbccd2516c3a843809a8303da48abce58a88855.tar.bz2 |
GlobalsModRef, ValueTracking: Look through threadlocal.address intrinsic (#88418)
This improves handling of `threadlocal.address` intrinsic in analyses:
The thread-id cannot change within a function with the exception of
suspend points of pre-split coroutines. This changes
`llvm::getUnderlyingObject` to look through `threadlocal.address` in
these cases.
`GlobalsAAResult::AnalyzeUsesOfPointer` checks whether an address can be
traced to simple loads/stores or escapes to other places. Starting the
analysis from a thread-local `GlobalValue` the `threadlocal.address`
intrinsic is safe to skip here.
This improves issue #87437
Diffstat (limited to 'llvm/lib/Analysis/GlobalsModRef.cpp')
-rw-r--r-- | llvm/lib/Analysis/GlobalsModRef.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/GlobalsModRef.cpp b/llvm/lib/Analysis/GlobalsModRef.cpp index 527f19b..1ceb1b2 100644 --- a/llvm/lib/Analysis/GlobalsModRef.cpp +++ b/llvm/lib/Analysis/GlobalsModRef.cpp @@ -344,6 +344,14 @@ bool GlobalsAAResult::AnalyzeUsesOfPointer(Value *V, if (AnalyzeUsesOfPointer(I, Readers, Writers, OkayStoreDest)) return true; } else if (auto *Call = dyn_cast<CallBase>(I)) { + if (IntrinsicInst *II = dyn_cast<IntrinsicInst>(I)) { + if (II->getIntrinsicID() == Intrinsic::threadlocal_address && + V == II->getArgOperand(0)) { + if (AnalyzeUsesOfPointer(II, Readers, Writers)) + return true; + continue; + } + } // Make sure that this is just the function being called, not that it is // passing into the function. if (Call->isDataOperand(&U)) { |