This is an archive of the discontinued LLVM Phabricator instance.

[clang][clangd] Avoid inconsistent target creation
ClosedPublic

Authored by oToToT on Mar 6 2021, 1:26 PM.

Details

Summary

As proposed in D97109, I tried to make target creation consistent in clang and clangd by replacing the original procedure with a single function introduced in D97493.

This also helps clangd works with CUDA, OpenMP, etc.

Diff Detail

Event Timeline

oToToT created this revision.Mar 6 2021, 1:26 PM
oToToT requested review of this revision.Mar 6 2021, 1:26 PM
oToToT updated this revision to Diff 328814.Mar 6 2021, 1:33 PM

Kindly ping.

Maybe I should add a test?

ping.

After some investigation, I think it is quite hard to add tests to avoid inconsistency between clang and clangd. Maybe I could add some tests for CUDA, OpenMP if needed.

WDYT

kadircet accepted this revision.Apr 6 2021, 1:56 AM

sorry for the delay here. thanks, this LGTM!

i've got a single concern in CompilerInstance::createTarget though. it will overwrite aux target for cuda, openmp and sycl (as it unconditionally sets auxtarget even if it exists).
it doesn't cause any problems today, because CompilerInstance::setAuxTarget is (AFAICT) only called within createTarget, but it might be nice to (on a separate patch) either:

  • leave a comment explaining why we overwrite if there's a reason or,
  • put it behind the condition of auxtarget being missing

so that future travellers do know what to do.

This revision is now accepted and ready to land.Apr 6 2021, 1:56 AM
This revision was automatically updated to reflect the committed changes.