Skip to content

Commit c6ed5a6

Browse files
committed
Revert "[HIP] Support compressing device binary (llvm#67162)"
This reverts commit a1e81d2. Revert "Fix test hip-offload-compress-zlib.hip" This reverts commit ba01ce6. Revert due to sanity fail at https://lab.llvm.org/buildbot/#/builders/5/builds/37188 https://lab.llvm.org/buildbot/#/builders/238/builds/5955 /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/clang/lib/Driver/OffloadBundler.cpp:1012:25: runtime error: load of misaligned address 0xaaaae2d90e7c for type 'const uint64_t' (aka 'const unsigned long'), which requires 8 byte alignment 0xaaaae2d90e7c: note: pointer points here bc 00 00 00 94 dc 29 9a 89 fb ca 2b 78 9c 8b 8f 77 f6 71 f4 73 8f f7 77 73 f3 f1 77 74 89 77 0a ^ #0 0xaaaaba125f70 in clang::CompressedOffloadBundle::decompress(llvm::MemoryBuffer const&, bool) /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/clang/lib/Driver/OffloadBundler.cpp:1012:25 #1 0xaaaaba126150 in clang::OffloadBundler::ListBundleIDsInFile(llvm::StringRef, clang::OffloadBundlerConfig const&) /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/clang/lib/Driver/OffloadBundler.cpp:1089:7 Will reland after fixing it.
1 parent f28f09d commit c6ed5a6

File tree

16 files changed

+60
-652
lines changed

16 files changed

+60
-652
lines changed

clang/docs/ClangOffloadBundler.rst

-27
Original file line numberDiff line numberDiff line change
@@ -309,30 +309,3 @@ target by comparing bundle ID's. Two bundle ID's are considered compatible if:
309309
* Their offload kind are the same
310310
* Their target triple are the same
311311
* Their GPUArch are the same
312-
313-
Compression and Decompression
314-
=============================
315-
316-
``clang-offload-bundler`` provides features to compress and decompress the full
317-
bundle, leveraging inherent redundancies within the bundle entries. Use the
318-
`-compress` command-line option to enable this compression capability.
319-
320-
The compressed offload bundle begins with a header followed by the compressed binary data:
321-
322-
- **Magic Number (4 bytes)**:
323-
This is a unique identifier to distinguish compressed offload bundles. The value is the string 'CCOB' (Compressed Clang Offload Bundle).
324-
325-
- **Version Number (16-bit unsigned int)**:
326-
This denotes the version of the compressed offload bundle format. The current version is `1`.
327-
328-
- **Compression Method (16-bit unsigned int)**:
329-
This field indicates the compression method used. The value corresponds to either `zlib` or `zstd`, represented as a 16-bit unsigned integer cast from the LLVM compression enumeration.
330-
331-
- **Uncompressed Binary Size (32-bit unsigned int)**:
332-
This is the size (in bytes) of the binary data before it was compressed.
333-
334-
- **Hash (64-bit unsigned int)**:
335-
This is a 64-bit truncated MD5 hash of the uncompressed binary data. It serves for verification and caching purposes.
336-
337-
- **Compressed Data**:
338-
The actual compressed binary data follows the header. Its size can be inferred from the total size of the file minus the header size.

clang/include/clang/Driver/OffloadBundler.h

-37
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,18 @@
1919

2020
#include "llvm/Support/Error.h"
2121
#include "llvm/TargetParser/Triple.h"
22-
#include <llvm/Support/MemoryBuffer.h>
2322
#include <string>
2423
#include <vector>
2524

2625
namespace clang {
2726

2827
class OffloadBundlerConfig {
2928
public:
30-
OffloadBundlerConfig();
31-
3229
bool AllowNoHost = false;
3330
bool AllowMissingBundles = false;
3431
bool CheckInputArchive = false;
3532
bool PrintExternalCommands = false;
3633
bool HipOpenmpCompatible = false;
37-
bool Compress = false;
38-
bool Verbose = false;
3934

4035
unsigned BundleAlignment = 1;
4136
unsigned HostInputIndex = ~0u;
@@ -89,38 +84,6 @@ struct OffloadTargetInfo {
8984
std::string str() const;
9085
};
9186

92-
// CompressedOffloadBundle represents the format for the compressed offload
93-
// bundles.
94-
//
95-
// The format is as follows:
96-
// - Magic Number (4 bytes) - A constant "CCOB".
97-
// - Version (2 bytes)
98-
// - Compression Method (2 bytes) - Uses the values from
99-
// llvm::compression::Format.
100-
// - Uncompressed Size (4 bytes).
101-
// - Truncated MD5 Hash (8 bytes).
102-
// - Compressed Data (variable length).
103-
104-
class CompressedOffloadBundle {
105-
private:
106-
static inline const size_t MagicSize = 4;
107-
static inline const size_t VersionFieldSize = sizeof(uint16_t);
108-
static inline const size_t MethodFieldSize = sizeof(uint16_t);
109-
static inline const size_t SizeFieldSize = sizeof(uint32_t);
110-
static inline const size_t HashFieldSize = 8;
111-
static inline const size_t HeaderSize = MagicSize + VersionFieldSize +
112-
MethodFieldSize + SizeFieldSize +
113-
HashFieldSize;
114-
static inline const llvm::StringRef MagicNumber = "CCOB";
115-
static inline const uint16_t Version = 1;
116-
117-
public:
118-
static llvm::Expected<std::unique_ptr<llvm::MemoryBuffer>>
119-
compress(const llvm::MemoryBuffer &Input, bool Verbose = false);
120-
static llvm::Expected<std::unique_ptr<llvm::MemoryBuffer>>
121-
decompress(const llvm::MemoryBuffer &Input, bool Verbose = false);
122-
};
123-
12487
} // namespace clang
12588

12689
#endif // LLVM_CLANG_DRIVER_OFFLOADBUNDLER_H

clang/include/clang/Driver/Options.td

-4
Original file line numberDiff line numberDiff line change
@@ -1183,10 +1183,6 @@ def fgpu_inline_threshold_EQ : Joined<["-"], "fgpu-inline-threshold=">,
11831183
def fgpu_sanitize : Flag<["-"], "fgpu-sanitize">, Group<f_Group>,
11841184
HelpText<"Enable sanitizer for supported offloading devices">;
11851185
def fno_gpu_sanitize : Flag<["-"], "fno-gpu-sanitize">, Group<f_Group>;
1186-
1187-
def offload_compress : Flag<["--"], "offload-compress">,
1188-
HelpText<"Compress offload device binaries (HIP only)">;
1189-
def no_offload_compress : Flag<["--"], "no-offload-compress">;
11901186
}
11911187

11921188
// CUDA options

0 commit comments

Comments
 (0)