Skip to content

Commit 442ed9f

Browse files
committed
improve lit test, apply code-style feedback
Signed-off-by: Sarnie, Nick <[email protected]>
1 parent d4b3358 commit 442ed9f

File tree

5 files changed

+47
-44
lines changed

5 files changed

+47
-44
lines changed
-1.31 KB
Binary file not shown.

clang/test/Tooling/clang-linker-wrapper-spirv-elf.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
// REQUIRES: spirv-tools
44
// RUN: mkdir -p %t_tmp
55
// RUN: cd %t_tmp
6-
// RUN: not clang-linker-wrapper -o a.out %S/Inputs/clang-linker-wrapper-spirv-elf.o --save-temps --linker-path=ld
6+
// RUN: %clangxx -fopenmp -fopenmp-targets=spirv64-intel -nogpulib -c -o %t_clang-linker-wrapper-spirv-elf.o %s
7+
// RUN: not clang-linker-wrapper -o a.out %t_clang-linker-wrapper-spirv-elf.o --save-temps --linker-path=ld
78
// RUN: clang-offload-packager --image=triple=spirv64-intel,kind=openmp,file=%t.elf %t_tmp/a.out.openmp.image.wrapper.o
89
// RUN: llvm-readelf -t %t.elf | FileCheck -check-prefix=CHECK-SECTION %s
910
// RUN: llvm-readelf -n %t.elf | FileCheck -check-prefix=CHECK-NOTES %s
@@ -12,3 +13,6 @@
1213
// CHECK-SECTION: __openmp_offload_spirv_0
1314

1415
// CHECK-NOTES-COUNT-3: INTELONEOMPOFFLOAD
16+
int main(int argc, char** argv) {
17+
return 0;
18+
}

clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -611,9 +611,7 @@ Error containerizeRawImage(std::unique_ptr<MemoryBuffer> &Img, OffloadKind Kind,
611611
if (Kind != OFK_OpenMP || !Triple.isSPIRV() ||
612612
Triple.getVendor() != llvm::Triple::Intel)
613613
return Error::success();
614-
if (Error E = offloading::intel::containerizeOpenMPSPIRVImage(Img))
615-
return E;
616-
return Error::success();
614+
return offloading::intel::containerizeOpenMPSPIRVImage(Img);
617615
}
618616

619617
Expected<StringRef> writeOffloadFile(const OffloadFile &File) {

llvm/include/llvm/Frontend/Offloading/Utility.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ Error getAMDGPUMetaDataFromImage(MemoryBufferRef MemBuffer,
153153
StringMap<AMDGPUKernelMetaData> &KernelInfoMap,
154154
uint16_t &ELFABIVersion);
155155
} // namespace amdgpu
156+
156157
namespace intel {
157158
/// Containerizes an offloading binary into the ELF binary format expected by
158159
/// the Intel runtime offload plugin.

llvm/lib/Frontend/Offloading/Utility.cpp

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -415,46 +415,46 @@ Error offloading::intel::containerizeOpenMPSPIRVImage(
415415
std::string YamlFile;
416416
llvm::raw_string_ostream YamlFileStream(YamlFile);
417417

418-
// Write YAML template file.
419-
{
420-
// We use 64-bit little-endian ELF currently.
421-
ELFYAML::FileHeader Header{};
422-
Header.Class = ELF::ELFCLASS64;
423-
Header.Data = ELF::ELFDATA2LSB;
424-
Header.Type = ELF::ET_DYN;
425-
// Use an existing Intel machine type as there is not one specifically for
426-
// Intel GPUs.
427-
Header.Machine = ELF::EM_IA_64;
428-
429-
// Create a section with notes.
430-
ELFYAML::NoteSection Section{};
431-
Section.Type = ELF::SHT_NOTE;
432-
Section.AddressAlign = 0;
433-
Section.Name = ".note.inteloneompoffload";
434-
Section.Notes.emplace(std::move(Notes));
435-
436-
ELFYAML::Object Object{};
437-
Object.Header = Header;
438-
Object.Chunks.push_back(
439-
std::make_unique<ELFYAML::NoteSection>(std::move(Section)));
440-
441-
// Create the section that will hold the image
442-
ELFYAML::RawContentSection ImageSection{};
443-
ImageSection.Type = ELF::SHT_PROGBITS;
444-
ImageSection.AddressAlign = 0;
445-
std::string Name = "__openmp_offload_spirv_0";
446-
ImageSection.Name = Name;
447-
ImageSection.Content =
448-
llvm::yaml::BinaryRef(arrayRefFromStringRef(Img->getBuffer()));
449-
Object.Chunks.push_back(
450-
std::make_unique<ELFYAML::RawContentSection>(std::move(ImageSection)));
451-
Error Err = Error::success();
452-
llvm::yaml::yaml2elf(
453-
Object, YamlFileStream,
454-
[&Err](const Twine &Msg) { Err = createStringError(Msg); }, UINT64_MAX);
455-
if (Err)
456-
return Err;
457-
}
418+
// Write the YAML template file.
419+
420+
// We use 64-bit little-endian ELF currently.
421+
ELFYAML::FileHeader Header{};
422+
Header.Class = ELF::ELFCLASS64;
423+
Header.Data = ELF::ELFDATA2LSB;
424+
Header.Type = ELF::ET_DYN;
425+
// Use an existing Intel machine type as there is not one specifically for
426+
// Intel GPUs.
427+
Header.Machine = ELF::EM_IA_64;
428+
429+
// Create a section with notes.
430+
ELFYAML::NoteSection Section{};
431+
Section.Type = ELF::SHT_NOTE;
432+
Section.AddressAlign = 0;
433+
Section.Name = ".note.inteloneompoffload";
434+
Section.Notes.emplace(std::move(Notes));
435+
436+
ELFYAML::Object Object{};
437+
Object.Header = Header;
438+
Object.Chunks.push_back(
439+
std::make_unique<ELFYAML::NoteSection>(std::move(Section)));
440+
441+
// Create the section that will hold the image
442+
ELFYAML::RawContentSection ImageSection{};
443+
ImageSection.Type = ELF::SHT_PROGBITS;
444+
ImageSection.AddressAlign = 0;
445+
std::string Name = "__openmp_offload_spirv_0";
446+
ImageSection.Name = Name;
447+
ImageSection.Content =
448+
llvm::yaml::BinaryRef(arrayRefFromStringRef(Img->getBuffer()));
449+
Object.Chunks.push_back(
450+
std::make_unique<ELFYAML::RawContentSection>(std::move(ImageSection)));
451+
Error Err = Error::success();
452+
llvm::yaml::yaml2elf(
453+
Object, YamlFileStream,
454+
[&Err](const Twine &Msg) { Err = createStringError(Msg); }, UINT64_MAX);
455+
if (Err)
456+
return Err;
457+
458458
Img = MemoryBuffer::getMemBufferCopy(YamlFile);
459459
return Error::success();
460460
}

0 commit comments

Comments
 (0)