Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translate nonsemantic attribute and metadata of GlobalVariable #2944

Merged
merged 4 commits into from
Jan 8, 2025

Conversation

wenju-he
Copy link
Contributor

@wenju-he wenju-he commented Dec 24, 2024

Motivations is similar as f729c49. This PR addresses SYCL device global which may have attributes "sycl-device-image-scope", "sycl-host-access" and "sycl-unique-id". Failure to preserve "sycl-unique-id" after llvm-spirv translation triggers assert at
https://github.com/intel/llvm/blob/2824f61dd36790448a224cd596985bd01cbcd0f3/llvm/lib/SYCLLowerIR/DeviceGlobals.cpp#L85

Also preserve GlobalVariable metadata as an improvement, though there is no test to show this is really needed.

Motivations is similar as f729c49. This PR addresses SYCL device global
which may have attributes "sycl-device-image-scope", "sycl-host-access"
and "sycl-unique-id". Failure to preserve "sycl-unique-id" after
llvm-spirv translation triggers assert error at
https://github.com/intel/llvm/blob/2824f61dd36790448a224cd596985bd01cbcd0f3/llvm/lib/SYCLLowerIR/DeviceGlobals.cpp#L85

Also preserve GlobalVariable metadata as an improvement, though there is
no test to show this is really needed.
Copy link
Contributor

@MrSidims MrSidims left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just have one nit/clarification question.

Comment on lines 5146 to 5148
auto *GO = cast<GlobalObject>(getTranslatedValue(Arg0));
auto *F = dyn_cast_or_null<Function>(GO);
auto *GV = dyn_cast_or_null<GlobalVariable>(GO);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes me a little bit suspicious, why do we need dyn_cast**_or_null** here when GO is a result of a cast? May be it's leftover from a previous patch iteration, where some test was failing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, yet it is a misuse.

auto *BM = BF->getModule();
void LLVMToSPIRVBase::transAuxDataInst(SPIRVValue *BV, Value *V) {
auto *GO = cast<GlobalObject>(V);
auto *F = dyn_cast_or_null<Function>(GO);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question about _or_null

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@wenju-he wenju-he requested a review from MrSidims January 8, 2025 00:44
PreserveCount = 2
GlobalVariableMetadata = 2,
GlobalVariableAttribute = 3,
PreserveCount = 4
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If PreserveCount is (and has been previously) unused it should be probably deleted entirely. Otherwise, this line introduces a concern about binary incompatibility due to changing PreserveCount's value.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deleted. It is unused.

@MrSidims MrSidims merged commit f2d913c into KhronosGroup:main Jan 8, 2025
9 checks passed
@wenju-he wenju-he deleted the transAuxData-GV branch January 9, 2025 02:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants