Skip to content

Commit c4941ea

Browse files
committed
opencl_constant only for ocl
Signed-off-by: Sarnie, Nick <[email protected]>
1 parent 06bfbba commit c4941ea

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

clang/lib/Basic/Targets/SPIR.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,9 +376,18 @@ class LLVM_LIBRARY_VISIBILITY SPIRV64TargetInfo : public BaseSPIRVTargetInfo {
376376
}
377377

378378
std::optional<LangAS> getConstantAddressSpace() const override {
379+
return ConstantAS;
380+
}
381+
void adjust(DiagnosticsEngine &Diags, LangOptions &Opts) override {
382+
BaseSPIRVTargetInfo::adjust(Diags, Opts);
379383
// opencl_constant will map to UniformConstant in SPIR-V
380-
return LangAS::opencl_constant;
384+
if (Opts.OpenCL)
385+
ConstantAS = LangAS::opencl_constant;
381386
}
387+
388+
private:
389+
// opencl_global will map to CrossWorkgroup in SPIR-V
390+
LangAS ConstantAS = LangAS::opencl_global;
382391
};
383392

384393
class LLVM_LIBRARY_VISIBILITY SPIRV64AMDGCNTargetInfo final

clang/test/OpenMP/spirv_target_addrspace.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ extern int printf(char[]);
55

66
#pragma omp declare target
77
// CHECK: @global = addrspace(1) global i32 0, align 4
8-
// CHECK: @.str = private unnamed_addr addrspace(2) constant [4 x i8] c"foo\00", align 1f
8+
// CHECK: @.str = private unnamed_addr addrspace(1) constant [4 x i8] c"foo\00", align 1
99
int global = 0;
1010
#pragma omp end declare target
1111
int main() {

0 commit comments

Comments
 (0)