Skip to content

Commit 5b11caa

Browse files
author
raghavmedicherla
committed
[NFC][Offload Bundler] Formatting clang offloadbundler source file.
Differential Revision: https://reviews.llvm.org/D136715
1 parent fb1e90e commit 5b11caa

File tree

1 file changed

+25
-30
lines changed

1 file changed

+25
-30
lines changed

clang/lib/Driver/OffloadBundler.cpp

Lines changed: 25 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
///
1515
//===----------------------------------------------------------------------===//
1616

17+
#include "clang/Driver/OffloadBundler.h"
1718
#include "clang/Basic/Cuda.h"
1819
#include "clang/Basic/TargetID.h"
1920
#include "clang/Basic/Version.h"
20-
#include "clang/Driver/OffloadBundler.h"
2121
#include "llvm/ADT/ArrayRef.h"
2222
#include "llvm/ADT/SmallString.h"
2323
#include "llvm/ADT/SmallVector.h"
@@ -63,14 +63,13 @@ using namespace clang;
6363

6464
OffloadTargetInfo::OffloadTargetInfo(const StringRef Target,
6565
const OffloadBundlerConfig &BC)
66-
: BundlerConfig(BC) {
66+
: BundlerConfig(BC) {
6767

6868
// TODO: Add error checking from ClangOffloadBundler.cpp
6969
auto TargetFeatures = Target.split(':');
7070
auto TripleOrGPU = TargetFeatures.first.rsplit('-');
7171

72-
if (clang::StringToCudaArch(TripleOrGPU.second) !=
73-
clang::CudaArch::UNKNOWN) {
72+
if (clang::StringToCudaArch(TripleOrGPU.second) != clang::CudaArch::UNKNOWN) {
7473
auto KindTriple = TripleOrGPU.first.split('-');
7574
this->OffloadKind = KindTriple.first;
7675
this->Triple = llvm::Triple(KindTriple.second);
@@ -89,20 +88,19 @@ bool OffloadTargetInfo::hasHostKind() const {
8988

9089
bool OffloadTargetInfo::isOffloadKindValid() const {
9190
return OffloadKind == "host" || OffloadKind == "openmp" ||
92-
OffloadKind == "hip" || OffloadKind == "hipv4";
91+
OffloadKind == "hip" || OffloadKind == "hipv4";
9392
}
9493

9594
bool OffloadTargetInfo::isOffloadKindCompatible(
96-
const StringRef TargetOffloadKind) const {
95+
const StringRef TargetOffloadKind) const {
9796
if (OffloadKind == TargetOffloadKind)
9897
return true;
9998
if (BundlerConfig.HipOpenmpCompatible) {
100-
bool HIPCompatibleWithOpenMP =
101-
OffloadKind.startswith_insensitive("hip") &&
102-
TargetOffloadKind == "openmp";
99+
bool HIPCompatibleWithOpenMP = OffloadKind.startswith_insensitive("hip") &&
100+
TargetOffloadKind == "openmp";
103101
bool OpenMPCompatibleWithHIP =
104-
OffloadKind == "openmp" &&
105-
TargetOffloadKind.startswith_insensitive("hip");
102+
OffloadKind == "openmp" &&
103+
TargetOffloadKind.startswith_insensitive("hip");
106104
return HIPCompatibleWithOpenMP || OpenMPCompatibleWithHIP;
107105
}
108106
return false;
@@ -670,18 +668,16 @@ class ObjectFileHandler final : public FileHandler {
670668
InputFile = *TempFileOrErr;
671669
}
672670

673-
ObjcopyArgs.push_back(SS.save(Twine("--add-section=") +
674-
OFFLOAD_BUNDLER_MAGIC_STR +
675-
BundlerConfig.TargetNames[I] +
676-
"=" + InputFile));
677-
ObjcopyArgs.push_back(SS.save(Twine("--set-section-flags=") +
678-
OFFLOAD_BUNDLER_MAGIC_STR +
679-
BundlerConfig.TargetNames[I] +
680-
"=readonly,exclude"));
671+
ObjcopyArgs.push_back(
672+
SS.save(Twine("--add-section=") + OFFLOAD_BUNDLER_MAGIC_STR +
673+
BundlerConfig.TargetNames[I] + "=" + InputFile));
674+
ObjcopyArgs.push_back(
675+
SS.save(Twine("--set-section-flags=") + OFFLOAD_BUNDLER_MAGIC_STR +
676+
BundlerConfig.TargetNames[I] + "=readonly,exclude"));
681677
}
682678
ObjcopyArgs.push_back("--");
683679
ObjcopyArgs.push_back(
684-
BundlerConfig.InputFileNames[BundlerConfig.HostInputIndex]);
680+
BundlerConfig.InputFileNames[BundlerConfig.HostInputIndex]);
685681
ObjcopyArgs.push_back(BundlerConfig.OutputFileNames.front());
686682

687683
if (Error Err = executeObjcopy(BundlerConfig.ObjcopyPath, ObjcopyArgs))
@@ -884,8 +880,8 @@ CreateFileHandler(MemoryBuffer &FirstInput,
884880
}
885881

886882
// List bundle IDs. Return true if an error was found.
887-
Error OffloadBundler::ListBundleIDsInFile(StringRef InputFileName,
888-
const OffloadBundlerConfig &BundlerConfig) {
883+
Error OffloadBundler::ListBundleIDsInFile(
884+
StringRef InputFileName, const OffloadBundlerConfig &BundlerConfig) {
889885
// Open Input file.
890886
ErrorOr<std::unique_ptr<MemoryBuffer>> CodeOrErr =
891887
MemoryBuffer::getFileOrSTDIN(InputFileName);
@@ -910,8 +906,8 @@ Error OffloadBundler::BundleFiles() {
910906
std::error_code EC;
911907

912908
// Create output file.
913-
raw_fd_ostream OutputFile(BundlerConfig.OutputFileNames.front(),
914-
EC, sys::fs::OF_None);
909+
raw_fd_ostream OutputFile(BundlerConfig.OutputFileNames.front(), EC,
910+
sys::fs::OF_None);
915911
if (EC)
916912
return createFileError(BundlerConfig.OutputFileNames.front(), EC);
917913

@@ -929,10 +925,10 @@ Error OffloadBundler::BundleFiles() {
929925
// Get the file handler. We use the host buffer as reference.
930926
assert((BundlerConfig.HostInputIndex != ~0u || BundlerConfig.AllowNoHost) &&
931927
"Host input index undefined??");
932-
Expected<std::unique_ptr<FileHandler>> FileHandlerOrErr =
933-
CreateFileHandler(*InputBuffers[BundlerConfig.AllowNoHost ? 0
934-
: BundlerConfig.HostInputIndex],
935-
BundlerConfig);
928+
Expected<std::unique_ptr<FileHandler>> FileHandlerOrErr = CreateFileHandler(
929+
*InputBuffers[BundlerConfig.AllowNoHost ? 0
930+
: BundlerConfig.HostInputIndex],
931+
BundlerConfig);
936932
if (!FileHandlerOrErr)
937933
return FileHandlerOrErr.takeError();
938934

@@ -1202,8 +1198,7 @@ Error OffloadBundler::UnbundleArchive() {
12021198
auto CodeObjectInfo = OffloadTargetInfo(CodeObject, BundlerConfig);
12031199
if (CodeObjectInfo.hasHostKind()) {
12041200
// Do nothing, we don't extract host code yet.
1205-
} else if (getCompatibleOffloadTargets(CodeObjectInfo,
1206-
CompatibleTargets,
1201+
} else if (getCompatibleOffloadTargets(CodeObjectInfo, CompatibleTargets,
12071202
BundlerConfig)) {
12081203
std::string BundleData;
12091204
raw_string_ostream DataStream(BundleData);

0 commit comments

Comments
 (0)