-
Notifications
You must be signed in to change notification settings - Fork 787
Turn new address space rules by default #242
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
Changes from all commits
9be9768
0dc80bd
6ea08ec
02774e1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3630,6 +3630,14 @@ LangAS CodeGenModule::GetGlobalVarAddressSpace(const VarDecl *D) { | |
return AddrSpace; | ||
} | ||
|
||
if (LangOpts.SYCLIsDevice) { | ||
if (!getenv("DISABLE_INFER_AS")) { | ||
if (!D || D->getType().getAddressSpace() == LangAS::Default) { | ||
romanovvlad marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return LangAS::opencl_global; | ||
} | ||
} | ||
} | ||
|
||
if (LangOpts.CUDA && LangOpts.CUDAIsDevice) { | ||
if (D && D->hasAttr<CUDAConstantAttr>()) | ||
return LangAS::cuda_constant; | ||
|
@@ -3655,6 +3663,14 @@ LangAS CodeGenModule::getStringLiteralAddressSpace() const { | |
// OpenCL v1.2 s6.5.3: a string literal is in the constant address space. | ||
if (LangOpts.OpenCL) | ||
return LangAS::opencl_constant; | ||
if (LangOpts.SYCLIsDevice && !getenv("DISABLE_INFER_AS")) | ||
// If we keep a literal string in constant address space, the following code | ||
// becomes illegal: | ||
// | ||
// const char *getLiteral() n{ | ||
// return "AB"; | ||
// } | ||
return LangAS::opencl_private; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Why not global then? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a good question - I don't know what is the best address space for this. |
||
if (auto AS = getTarget().getConstantAddressSpace()) | ||
return AS.getValue(); | ||
return LangAS::Default; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1063,6 +1063,8 @@ static void InitializePredefinedMacros(const TargetInfo &TI, | |
// SYCL device compiler which doesn't produce host binary. | ||
if (LangOpts.SYCLIsDevice) { | ||
Builder.defineMacro("__SYCL_DEVICE_ONLY__", "1"); | ||
if (!getenv("DISABLE_INFER_AS")) | ||
Builder.defineMacro("__SYCL_ENABLE_INFER_AS__", "1"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably this name should serve as a starting point for the environment variable. |
||
} | ||
|
||
// OpenCL definitions. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even if it is a temporary solution, naming the environment variable such as
SYCL_CLANG_DISABLE_INFER_AS
or whatever so we can understand among the crowded output of aprintenv
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll change the variable name in a follow-up commit.