Setting constant address space for global constants used for memcpy-initialization of arrays.
Details
Diff Detail
- Build Status
Buildable 195 Build 195: arc lint + arc unit
Event Timeline
lib/CodeGen/CGDecl.cpp | ||
---|---|---|
1272 | Why this change? |
lib/CodeGen/CGDecl.cpp | ||
---|---|---|
1272 | Without this change, global variables with unnamed address space are translated to SPIR-V as variables with "Function" storage class, which is wrong. |
lib/CodeGen/CGDecl.cpp | ||
---|---|---|
1272 | There is inconsistency with how Clang maps initializers to OpenCL memory model. __private int arr[] = {1, 2, 3}; This code allocates a global constant for initializer {1, 2, 3} and later copies values from this global constant to the private array using memcpy intrinsic. The global constant must be allocated in constant address space, but old code do assign any address space, which is considered to be a private memory region. |
lib/CodeGen/CGDecl.cpp | ||
---|---|---|
1272 | Yes, this is perfectly fine. I was specifically asking about setting llvm::GlobalValue::UnnamedAddr::None attribute. I can't see why this has to be done or is it because we now assign concrete address space and private was treated as no address space at all? |
lib/CodeGen/CGDecl.cpp | ||
---|---|---|
1272 | This attribute has nothing to do with address spaces. |
lib/CodeGen/CGDecl.cpp | ||
---|---|---|
1272 | llvm::GlobalValue::UnnamedAddr::None is default value of UnnamedAddr for GlobalValue. This line can be removed, but extra "if" statement must be added before GV->setUnnamedAddr(UA); |
lib/CodeGen/CGDecl.cpp | ||
---|---|---|
1272 | Yes, I also think that leaving global should be fine here. So could we just undo the change to line 1274? |
lib/CodeGen/CGDecl.cpp | ||
---|---|---|
1272 | Changed to Global |
Why this change?