Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,15 @@ attributes #6 = { "sycl-unique-id"="6da74a122db9f35d____ZL7no_dg_int1" "device_i
; 1. 8 bytes denoting the bit-size of the byte array, here 64 bits or 8 bytes.
; 2. 4 bytes with the value of the 32-bit uint32_t integer with the size of the
; underlying type of the device global variable. Its value being 1.
; 3. 1 byte with the value of the 8-bit uint8_t integer with the flag that
; 3. 4 byte with the value of the 32-bit uint32_t integer with the flag that
; the device global variable has the 'device_image_scope' property.
; Its value being 1, property is present.
; 4. Any 3 bytes used as padding to align the structure to 8 bytes.
;
; CHECK-PROP: [SYCL/device globals]
; CHECK-PROP-NEXT: 6da74a122db9f35d____ZL7dg_int1=2|ABAAAAAAAAABAAAAA
; CHECK-PROP-NEXT: 7da74a1187b9f35d____ZL7dg_int2=2|ABAAAAAAAAABAAAAA
; CHECK-PROP-NEXT: 9d329ad59055e972____ZL8dg_bool3=2|ABAAAAAAAAQAAAAAB
; CHECK-PROP-NEXT: dda2bad52c45c432____ZL8dg_bool4=2|ABAAAAAAAAQAAAAAB
; CHECK-PROP-NEXT: 6da74a122db9f35d____ZL7dg_int1=2|ABAAAAAAAAABAAAAAAAAAA
; CHECK-PROP-NEXT: 7da74a1187b9f35d____ZL7dg_int2=2|ABAAAAAAAAABAAAAAAAAAA
; CHECK-PROP-NEXT: 9d329ad59055e972____ZL8dg_bool3=2|ABAAAAAAAAQAAAAABAAAAA
; CHECK-PROP-NEXT: dda2bad52c45c432____ZL8dg_bool4=2|ABAAAAAAAAQAAAAABAAAAA
;
; The variable is not a device global one and must be ignored
; CHECK-PROP-NOT: 6da74a122db9f35d____ZL7no_dg_int1
4 changes: 3 additions & 1 deletion llvm/tools/sycl-post-link/DeviceGlobals.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ struct DeviceGlobalProperty {

// Either 1 (true) or 0 (false), telling whether the device global variable
// was declared with the device_image_scope property.
uint8_t DeviceImageScope;
// We use uint32_t for a boolean value to eliminate padding after the field
// and suppress false positive reports from MemorySanitizer.
uint32_t DeviceImageScope;
};

using DeviceGlobalPropertyMapTy =
Expand Down
8 changes: 4 additions & 4 deletions sycl/source/detail/program_manager/program_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1217,13 +1217,13 @@ void ProgramManager::addImages(pi_device_binaries DeviceBinary) {
// The supplied device_global info property is expected to contain:
// * 8 bytes - Size of the property.
// * 4 bytes - Size of the underlying type in the device_global.
// * 1 byte - 0 if device_global has device_image_scope and any value
// * 4 bytes - 0 if device_global has device_image_scope and any value
// otherwise.
// Note: Property may be padded.
assert(DeviceGlobalInfo.size() >= 13 && "Unexpected property size");
assert(DeviceGlobalInfo.size() == 16 && "Unexpected property size");
const std::uint32_t TypeSize =
*reinterpret_cast<const std::uint32_t *>(&DeviceGlobalInfo[8]);
const std::uint32_t DeviceImageScopeDecorated = DeviceGlobalInfo[12];
const std::uint32_t DeviceImageScopeDecorated =
*reinterpret_cast<const std::uint32_t *>(&DeviceGlobalInfo[12]);
Entry->second.initialize(TypeSize, DeviceImageScopeDecorated);
}
}
Expand Down