Skip to content

Commit 96e96c4

Browse files
committed
Revert "[clang-offload-bundler] Standardize TargetID field for bundler"
This reverts commit e48ae0d.
1 parent 853f680 commit 96e96c4

File tree

6 files changed

+14
-80
lines changed

6 files changed

+14
-80
lines changed

clang/docs/ClangOffloadBundler.rst

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -174,20 +174,7 @@ Where:
174174
============= ==============================================================
175175

176176
**target-triple**
177-
The target triple of the code object. See `Target Triple
178-
<https://clang.llvm.org/docs/CrossCompilation.html#target-triple>`_.
179-
180-
The bundler accepts target triples with or without the optional environment
181-
field:
182-
183-
``<arch><sub>-<vendor>-<sys>``, or
184-
``<arch><sub>-<vendor>-<sys>-<env>``
185-
186-
However, in order to standardize outputs for tools that consume bitcode
187-
bundles, bundles written by the bundler internally use only the 4-field
188-
target triple:
189-
190-
``<arch><sub>-<vendor>-<sys>-<env>``
177+
The target triple of the code object.
191178

192179
**target-id**
193180
The canonical target ID of the code object. Present only if the target

clang/lib/Driver/OffloadBundler.cpp

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -82,22 +82,12 @@ OffloadTargetInfo::OffloadTargetInfo(const StringRef Target,
8282
if (clang::StringToCudaArch(TripleOrGPU.second) != clang::CudaArch::UNKNOWN) {
8383
auto KindTriple = TripleOrGPU.first.split('-');
8484
this->OffloadKind = KindTriple.first;
85-
86-
// Enforce optional env field to standardize bundles
87-
llvm::Triple t = llvm::Triple(KindTriple.second);
88-
this->Triple = llvm::Triple(t.getArchName(), t.getVendorName(),
89-
t.getOSName(), t.getEnvironmentName());
90-
85+
this->Triple = llvm::Triple(KindTriple.second);
9186
this->TargetID = Target.substr(Target.find(TripleOrGPU.second));
9287
} else {
9388
auto KindTriple = TargetFeatures.first.split('-');
9489
this->OffloadKind = KindTriple.first;
95-
96-
// Enforce optional env field to standardize bundles
97-
llvm::Triple t = llvm::Triple(KindTriple.second);
98-
this->Triple = llvm::Triple(t.getArchName(), t.getVendorName(),
99-
t.getOSName(), t.getEnvironmentName());
100-
90+
this->Triple = llvm::Triple(KindTriple.second);
10191
this->TargetID = "";
10292
}
10393
}

clang/test/Driver/clang-offload-bundler-asserts-on.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121

2222
// Tests to check compatibility between Bundle Entry ID formats i.e. between presence/absence of extra hyphen in case of missing environment field
2323
// RUN: clang-offload-bundler -unbundle -type=a -targets=openmp-amdgcn-amd-amdhsa--gfx906,openmp-amdgcn-amd-amdhsa-gfx908 -input=%t.input-archive.a -output=%t-archive-gfx906-simple.a -output=%t-archive-gfx908-simple.a -debug-only=CodeObjectCompatibility 2>&1 | FileCheck %s -check-prefix=BUNDLECOMPATIBILITY
24-
// BUNDLECOMPATIBILITY: Compatible: Exact match: [CodeObject: openmp-amdgcn-amd-amdhsa--gfx906] : [Target: openmp-amdgcn-amd-amdhsa--gfx906]
25-
// BUNDLECOMPATIBILITY: Compatible: Exact match: [CodeObject: openmp-amdgcn-amd-amdhsa--gfx908] : [Target: openmp-amdgcn-amd-amdhsa--gfx908]
24+
// BUNDLECOMPATIBILITY: Compatible: Exact match: [CodeObject: openmp-amdgcn-amd-amdhsa-gfx906] : [Target: openmp-amdgcn-amd-amdhsa--gfx906]
25+
// BUNDLECOMPATIBILITY: Compatible: Exact match: [CodeObject: openmp-amdgcn-amd-amdhsa--gfx908] : [Target: openmp-amdgcn-amd-amdhsa-gfx908]
2626

2727
// RUN: clang-offload-bundler -unbundle -type=a -targets=hip-amdgcn-amd-amdhsa--gfx906,hipv4-amdgcn-amd-amdhsa-gfx908 -input=%t.input-archive.a -output=%t-hip-archive-gfx906-simple.a -output=%t-hipv4-archive-gfx908-simple.a -hip-openmp-compatible -debug-only=CodeObjectCompatibility 2>&1 | FileCheck %s -check-prefix=HIPOpenMPCOMPATIBILITY
28-
// HIPOpenMPCOMPATIBILITY: Compatible: Code Objects are compatible [CodeObject: openmp-amdgcn-amd-amdhsa--gfx906] : [Target: hip-amdgcn-amd-amdhsa--gfx906]
29-
// HIPOpenMPCOMPATIBILITY: Compatible: Code Objects are compatible [CodeObject: openmp-amdgcn-amd-amdhsa--gfx908] : [Target: hipv4-amdgcn-amd-amdhsa--gfx908]
28+
// HIPOpenMPCOMPATIBILITY: Compatible: Code Objects are compatible [CodeObject: openmp-amdgcn-amd-amdhsa-gfx906] : [Target: hip-amdgcn-amd-amdhsa--gfx906]
29+
// HIPOpenMPCOMPATIBILITY: Compatible: Code Objects are compatible [CodeObject: openmp-amdgcn-amd-amdhsa--gfx908] : [Target: hipv4-amdgcn-amd-amdhsa-gfx908]
3030

3131
// Some code so that we can create a binary out of this file.
3232
int A = 0;

clang/test/Driver/clang-offload-bundler-standardize.c

Lines changed: 0 additions & 37 deletions
This file was deleted.

clang/test/Driver/clang-offload-bundler.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// REQUIRES: x86-registered-target
2+
// REQUIRES: powerpc-registered-target
23
// UNSUPPORTED: target={{.*}}-darwin{{.*}}, target={{.*}}-aix{{.*}}
34

45
//
@@ -310,11 +311,11 @@
310311

311312
// RUN: clang-offload-bundler -type=o -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -input=%t.o -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle3.o -### 2>&1 \
312313
// RUN: | FileCheck %s -DHOST=%itanium_abi_triple -DINOBJ1=%t.o -DINOBJ2=%t.tgt1 -DINOBJ3=%t.tgt2 -DOUTOBJ=%t.bundle3.o --check-prefix CK-OBJ-CMD
313-
// CK-OBJ-CMD: llvm-objcopy{{(.exe)?}}" "--add-section=__CLANG_OFFLOAD_BUNDLE__host-[[HOST:.+]]={{.*}}" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu-=[[INOBJ2]]" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu-=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu-=[[INOBJ3]]" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu-=readonly,exclude" "--" "[[INOBJ1]]" "[[OUTOBJ]]"
314+
// CK-OBJ-CMD: llvm-objcopy{{(.exe)?}}" "--add-section=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]={{.*}}" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu=[[INOBJ2]]" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu=[[INOBJ3]]" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu=readonly,exclude" "--" "[[INOBJ1]]" "[[OUTOBJ]]"
314315

315316
// RUN: clang-offload-bundler -type=o -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -input=%t.o -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle3.o -### 2>&1 \
316317
// RUN: | FileCheck %s -DHOST=%itanium_abi_triple -DINOBJ1=%t.o -DINOBJ2=%t.tgt1 -DINOBJ3=%t.tgt2 -DOUTOBJ=%t.bundle3.o --check-prefix CK-OBJ-CMD-INPUTS
317-
// CK-OBJ-CMD-INPUTS: llvm-objcopy{{(.exe)?}}" "--add-section=__CLANG_OFFLOAD_BUNDLE__host-[[HOST:.+]]={{.*}}" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu-=[[INOBJ2]]" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu-=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu-=[[INOBJ3]]" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu-=readonly,exclude" "--" "[[INOBJ1]]" "[[OUTOBJ]]"
318+
// CK-OBJ-CMD-INPUTS: llvm-objcopy{{(.exe)?}}" "--add-section=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]={{.*}}" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu=[[INOBJ2]]" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu=[[INOBJ3]]" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu=readonly,exclude" "--" "[[INOBJ1]]" "[[OUTOBJ]]"
318319

319320
// RUN: clang-offload-bundler -type=o -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -input=%t.o -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle3.o
320321
// RUN: clang-offload-bundler -type=o -input=%t.bundle3.o -list | FileCheck -check-prefix=CKLST %s
@@ -546,15 +547,15 @@
546547
// RUN: llvm-ar t %t-archive-gfx906-simple.a | FileCheck %s -check-prefix=GFX906
547548
// RUN: clang-offload-bundler -unbundle -type=a -targets=openmp-amdgcn-amd-amdhsa-gfx906:xnack+ -input=%t.input-archive.a -output=%t-archive-gfx906-simple.a
548549
// RUN: llvm-ar t %t-archive-gfx906-simple.a | FileCheck %s -check-prefix=GFX906
549-
// GFX906: simple-openmp-amdgcn-amd-amdhsa--gfx906
550+
// GFX906: simple-openmp-amdgcn-amd-amdhsa-gfx906
550551
// RUN: llvm-ar t %t-archive-gfx908-simple.a | FileCheck %s -check-prefix=GFX908
551552
// GFX908-NOT: {{gfx906}}
552553
// RUN: not clang-offload-bundler -type=o -targets=host-%itanium_abi_triple,openmp-amdgcn-amd-amdhsa-gfx906,openmp-amdgcn-amd-amdhsa-gfx906:sramecc+ -input=%t.o -input=%t.tgt1 -input=%t.tgt2 -output=%t.bad.bundle 2>&1 | FileCheck %s -check-prefix=BADTARGETS
553-
// BADTARGETS: error: Cannot bundle inputs with conflicting targets: 'openmp-amdgcn-amd-amdhsa--gfx906' and 'openmp-amdgcn-amd-amdhsa--gfx906:sramecc+'
554+
// BADTARGETS: error: Cannot bundle inputs with conflicting targets: 'openmp-amdgcn-amd-amdhsa-gfx906' and 'openmp-amdgcn-amd-amdhsa-gfx906:sramecc+'
554555

555556
// Check for error if no compatible code object is found in the heterogeneous archive library
556557
// RUN: not clang-offload-bundler -unbundle -type=a -targets=openmp-amdgcn-amd-amdhsa-gfx803 -input=%t.input-archive.a -output=%t-archive-gfx803-incompatible.a 2>&1 | FileCheck %s -check-prefix=INCOMPATIBLEARCHIVE
557-
// INCOMPATIBLEARCHIVE: error: no compatible code object found for the target 'openmp-amdgcn-amd-amdhsa--gfx803' in heterogeneous archive library
558+
// INCOMPATIBLEARCHIVE: error: no compatible code object found for the target 'openmp-amdgcn-amd-amdhsa-gfx803' in heterogeneous archive library
558559

559560
// Check creation of empty archive if allow-missing-bundles is present and no compatible code object is found in the heterogeneous archive library
560561
// RUN: clang-offload-bundler -unbundle -type=a -targets=openmp-amdgcn-amd-amdhsa-gfx803 -input=%t.input-archive.a -output=%t-archive-gfx803-empty.a -allow-missing-bundles
@@ -564,7 +565,7 @@
564565
// Check compatibility of OpenMP code objects found in the heterogeneous archive library with HIP code objects of the target
565566
// RUN: clang-offload-bundler -unbundle -type=a -targets=hip-amdgcn-amd-amdhsa-gfx906,hipv4-amdgcn-amd-amdhsa-gfx908 -input=%t.input-archive.a -output=%t-hip-archive-gfx906-simple.a -output=%t-hipv4-archive-gfx908-simple.a -hip-openmp-compatible
566567
// RUN: llvm-ar t %t-hip-archive-gfx906-simple.a | FileCheck %s -check-prefix=HIPOPENMPCOMPAT
567-
// HIPOPENMPCOMPAT: simple-openmp-amdgcn-amd-amdhsa--gfx906
568+
// HIPOPENMPCOMPAT: simple-openmp-amdgcn-amd-amdhsa-gfx906
568569
// RUN: llvm-ar t %t-hipv4-archive-gfx908-simple.a | FileCheck %s -check-prefix=HIPv4OPENMPCOMPAT
569570
// HIPv4OPENMPCOMPAT: simple-openmp-amdgcn-amd-amdhsa--gfx908
570571

clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -377,8 +377,6 @@ int main(int argc, const char **argv) {
377377
llvm::DenseSet<StringRef> ParsedTargets;
378378
// Map {offload-kind}-{triple} to target IDs.
379379
std::map<std::string, std::set<StringRef>> TargetIDs;
380-
// Standardize target names to include env field
381-
std::vector<std::string> StandardizedTargetNames;
382380
for (StringRef Target : TargetNames) {
383381
if (ParsedTargets.contains(Target)) {
384382
reportError(createStringError(errc::invalid_argument,
@@ -390,8 +388,6 @@ int main(int argc, const char **argv) {
390388
bool KindIsValid = OffloadInfo.isOffloadKindValid();
391389
bool TripleIsValid = OffloadInfo.isTripleValid();
392390

393-
StandardizedTargetNames.push_back(OffloadInfo.str());
394-
395391
if (!KindIsValid || !TripleIsValid) {
396392
SmallVector<char, 128u> Buf;
397393
raw_svector_ostream Msg(Buf);
@@ -416,9 +412,6 @@ int main(int argc, const char **argv) {
416412

417413
++Index;
418414
}
419-
420-
BundlerConfig.TargetNames = StandardizedTargetNames;
421-
422415
for (const auto &TargetID : TargetIDs) {
423416
if (auto ConflictingTID =
424417
clang::getConflictTargetIDCombination(TargetID.second)) {

0 commit comments

Comments
 (0)