================ @@ -84,31 +84,27 @@ OffloadTargetInfo::OffloadTargetInfo(const StringRef Target, : BundlerConfig(BC) { // TODO: Add error checking from ClangOffloadBundler.cpp - auto TargetFeatures = Target.split(':'); - auto TripleOrGPU = TargetFeatures.first.rsplit('-'); - - if (clang::StringToOffloadArch(TripleOrGPU.second) != - clang::OffloadArch::UNKNOWN) { - auto KindTriple = TripleOrGPU.first.split('-'); - this->OffloadKind = KindTriple.first; - - // Enforce optional env field to standardize bundles - llvm::Triple t = llvm::Triple(KindTriple.second); - this->Triple = llvm::Triple(t.getArchName(), t.getVendorName(), - t.getOSName(), t.getEnvironmentName()); - - this->TargetID = Target.substr(Target.find(TripleOrGPU.second)); - } else { - auto KindTriple = TargetFeatures.first.split('-'); - this->OffloadKind = KindTriple.first; - - // Enforce optional env field to standardize bundles - llvm::Triple t = llvm::Triple(KindTriple.second); - this->Triple = llvm::Triple(t.getArchName(), t.getVendorName(), - t.getOSName(), t.getEnvironmentName()); - + // <kind>-<triple>[-<target id>[:target features]] + // <triple> := <arch>-<vendor>-<os>-<env> + SmallVector<StringRef, 6> Components; + Target.split(Components, '-', /*MaxSplit=*/5); + assert((Components.size() == 5 || Components.size() == 6) && ---------------- yxsamliu wrote:
We have users who executes clang-offload-bundler directly. What if they use `<arch>-<vendor>-<os>` as triple? Should we emit an error message instead of assert? https://github.com/llvm/llvm-project/pull/122629 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits