This is an archive of the discontinued LLVM Phabricator instance.

[HIP] Support device sanitizer
ClosedPublic

Authored by yaxunl on Feb 16 2021, 9:13 PM.

Details

Summary

Add option -fgpu-sanitize to enable sanitizer for AMDGPU target.

Since it is experimental, it is off by default.

Diff Detail

Event Timeline

yaxunl created this revision.Feb 16 2021, 9:13 PM
yaxunl requested review of this revision.Feb 16 2021, 9:13 PM
tra added inline comments.Feb 17 2021, 10:36 AM
clang/include/clang/Driver/Options.td
933

We do have BoolFOption for -fsomething/-fno-something options.

clang/lib/Driver/ToolChains/HIP.cpp
85

I'd pass the library prefix argument as a string, instead of a boolean flag. Makes it easier to tell what's going on without having to annotate it as a comment.

Also, maybe consider separating "get the list of bitcode files" from "construct aguments for tool X for the given list of bitcode files". Right now addHIPDeviceLibArgs does both and has to plumb the UseMLinkOptthrough multiple function calls. Adding the prefix argument can be done at the constructLldCommand/addClangTargetOptions.

yaxunl marked 2 inline comments as done.Feb 17 2021, 8:22 PM
yaxunl added inline comments.
clang/include/clang/Driver/Options.td
933

done

clang/lib/Driver/ToolChains/HIP.cpp
85

Will refactor to get the list of bitcode files.

yaxunl updated this revision to Diff 324510.Feb 17 2021, 8:29 PM
yaxunl marked 2 inline comments as done.

revised by Artem's comments

tra accepted this revision.Feb 18 2021, 10:10 AM

Nice. LGTM with few minor nits.

clang/lib/Driver/ToolChain.cpp
1132

Nit: It could be just return {};

clang/lib/Driver/ToolChains/HIP.cpp
358

I'd explicitly return {} to make it obvious that it's an empty list and move BClibs down to where we use it first.

clang/test/Driver/hip-sanitize-options.hip
25

I'd add a comment describing what exactly is invalid about rocm-invalid. Maybe add it to a README in the directory.

Or, If the purpose is very specific, rename the directory to reflect it. E.g. if it just to test handling of installations w/o asan bitcode, call it rocm-noasan.

This revision is now accepted and ready to land.Feb 18 2021, 10:10 AM
yaxunl marked 3 inline comments as done.Feb 18 2021, 10:28 AM
yaxunl added inline comments.
clang/lib/Driver/ToolChain.cpp
1132

will do

clang/lib/Driver/ToolChains/HIP.cpp
358

will do

clang/test/Driver/hip-sanitize-options.hip
25

I will add a README to the directory explaining what is invalid, since we may reuse this directory for other invalid usages later.

This revision was automatically updated to reflect the committed changes.
yaxunl marked 3 inline comments as done.
Herald added a project: Restricted Project. · View Herald TranscriptFeb 18 2021, 8:33 PM
Conanap added a subscriber: Conanap.

Hello,

One of our PowerPC buildbots is failing because it is named lld-multistage, which matches with this CHECK-NOT in clang/test/Driver/hip-sanitize-options.hip: ;CHECK-NOT: {{"[^"]*lld[^"]*".* ".*hip.bc"}}.
I've created a patch and if you could review it that'd be great!

https://reviews.llvm.org/D97423

Thank you!