This is an archive of the discontinued LLVM Phabricator instance.

[clang][RISCV][NFC] Prevent data race in RVVType::computeType
ClosedPublic

Authored by kito-cheng on Nov 21 2022, 6:42 AM.

Details

Summary

Introduce a RVVTypeCache to hold the cache instead of using a local
static variable to maintain a cache.

Also made construct of RVVType to private, make sure that could be only
created by a cache manager.

Diff Detail

Event Timeline

kito-cheng created this revision.Nov 21 2022, 6:42 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 21 2022, 6:42 AM
kito-cheng requested review of this revision.Nov 21 2022, 6:42 AM
sammccall accepted this revision.Nov 21 2022, 6:53 AM

LG from a thread-safety perspective, thanks!

Approving because it looks mechanically "obviously correct", but you may want to wait for another reviewer to confirm the API changes are sane (I don't really know what this code does or how it's used).

This revision is now accepted and ready to land.Nov 21 2022, 6:53 AM

thanks! +1 from my side as well for thread-safety purposes (and I hope having 2 separate caches for tablegen and sema doesn't have unexpected effects).

khchen added inline comments.Nov 21 2022, 5:43 PM
clang/include/clang/Support/RISCVVIntrinsicUtils.h
284

nit: maybe we could add some comments to said the motivation for RVVTypeCache.

289

static could be eliminated now.

kadircet added inline comments.Nov 21 2022, 11:14 PM
clang/include/clang/Support/RISCVVIntrinsicUtils.h
289

nit: i'd actually drop it from the header completely

Changes:

  • Add comment for RVVTypeCache
  • computeRVVTypeHashValue become a local function rather than static function of RVVTypeCache.
kito-cheng marked 3 inline comments as done.Nov 23 2022, 12:59 AM
kito-cheng added inline comments.
clang/include/clang/Support/RISCVVIntrinsicUtils.h
284

good suggestion, thanks :)

289

I just move that to a local static function.

This revision was landed with ongoing or failed builds.Nov 23 2022, 12:59 AM
This revision was automatically updated to reflect the committed changes.
kito-cheng marked 2 inline comments as done.