This is an archive of the discontinued LLVM Phabricator instance.

[HLSL][clang][Driver] Parse target profile early to update Driver::TargetTriple.
ClosedPublic

Authored by python3kgae on May 13 2022, 2:38 PM.

Details

Summary

This is to avoid err_target_unknown_abi which is caused by use default TargetTriple instead of shader model target triple.

Diff Detail

Event Timeline

python3kgae created this revision.May 13 2022, 2:38 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 13 2022, 2:38 PM
Herald added a subscriber: Anastasia. · View Herald Transcript
python3kgae requested review of this revision.May 13 2022, 2:38 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 13 2022, 2:38 PM
beanz added inline comments.May 17 2022, 3:54 PM
clang/lib/Driver/ToolChains/HLSL.h
32–33

I don't like using an empty string as a sentinel for an error. Since this is no longer overriding an existing method, we should change it. Probably the easiest change is to llvm::Optional. Then you can return None in the failure cases.

Use llvm::Optional.

beanz added inline comments.May 31 2022, 9:30 AM
clang/lib/Driver/Driver.cpp
1242

The -T flag is required for DXCMode, so the else of this should emit an error. That also means the code above that explicitly sets the OS to ShaderModel can be removed too.

Add check for no -T option.

beanz accepted this revision.May 31 2022, 11:14 AM

LGTM.

This revision is now accepted and ready to land.May 31 2022, 11:14 AM

@python3kgae
0fbafb5a1c4381ded4bc7f59a5a6091c229faed7 is fixing leaks in this tests.

Note, the leak was missed because of unrelated issues in gtest and lsan setup which we fixed recently.

I incorrectly blamed the leak on D122865, but in fact it was D125585. I see that before this patch we have one Driver, one Compilation and both deleted correctly. Leaks are obvious, after this patch we don't delete Compilation.

I fixed the leak, but I had to remove shared driver. My concern is that maybe shared driver is important use-case. If it's so, would you like to take a look, and find how to avoid a leak with shared driver?

@python3kgae
0fbafb5a1c4381ded4bc7f59a5a6091c229faed7 is fixing leaks in this tests.

Note, the leak was missed because of unrelated issues in gtest and lsan setup which we fixed recently.

I incorrectly blamed the leak on D122865, but in fact it was D125585. I see that before this patch we have one Driver, one Compilation and both deleted correctly. Leaks are obvious, after this patch we don't delete Compilation.

I fixed the leak, but I had to remove shared driver. My concern is that maybe shared driver is important use-case. If it's so, would you like to take a look, and find how to avoid a leak with shared driver?

Hi Vitaly,
Thanks for fixing the leak. Shared driver is not important use-case.