Skip to content

Commit 7884962

Browse files
committed
Adjust logic for adding options to the -cc1 step
1 parent 8c29ad5 commit 7884962

File tree

1 file changed

+22
-23
lines changed

1 file changed

+22
-23
lines changed

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5125,37 +5125,36 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
51255125

51265126
Arg *SYCLStdArg = Args.getLastArg(options::OPT_sycl_std_EQ);
51275127

5128-
if (IsSYCLDevice) {
5129-
// Host triple is needed when doing SYCL device compilations.
5130-
llvm::Triple AuxT = C.getDefaultToolChain().getTriple();
5131-
std::string NormalizedTriple = AuxT.normalize();
5132-
CmdArgs.push_back("-aux-triple");
5133-
CmdArgs.push_back(Args.MakeArgString(NormalizedTriple));
5134-
5135-
// We want to compile sycl kernels.
5136-
CmdArgs.push_back("-fsycl-is-device");
5128+
if (IsSYCL) {
5129+
if (IsSYCLDevice) {
5130+
// Host triple is needed when doing SYCL device compilations.
5131+
llvm::Triple AuxT = C.getDefaultToolChain().getTriple();
5132+
std::string NormalizedTriple = AuxT.normalize();
5133+
CmdArgs.push_back("-aux-triple");
5134+
CmdArgs.push_back(Args.MakeArgString(NormalizedTriple));
5135+
5136+
// We want to compile sycl kernels.
5137+
CmdArgs.push_back("-fsycl-is-device");
5138+
5139+
// Set O2 optimization level by default
5140+
if (!Args.getLastArg(options::OPT_O_Group))
5141+
CmdArgs.push_back("-O2");
5142+
} else {
5143+
// Add any options that are needed specific to SYCL offload while
5144+
// performing the host side compilation.
51375145

5138-
// Set O2 optimization level by default
5139-
if (!Args.getLastArg(options::OPT_O_Group))
5140-
CmdArgs.push_back("-O2");
5141-
}
5146+
// Let the front-end host compilation flow know about SYCL offload
5147+
// compilation.
5148+
CmdArgs.push_back("-fsycl-is-host");
5149+
}
51425150

5143-
if (IsSYCL) {
5144-
// Set options for both host and device
5151+
// Set options for both host and device.
51455152
if (SYCLStdArg) {
51465153
SYCLStdArg->render(Args, CmdArgs);
51475154
} else {
51485155
// Ensure the default version in SYCL mode is 2020.
51495156
CmdArgs.push_back("-sycl-std=2020");
51505157
}
5151-
5152-
// Add any options that are needed specific to SYCL offload while
5153-
// performing the host side compilation.
5154-
if (!IsSYCLDevice) {
5155-
// Let the front-end host compilation flow know about SYCL offload
5156-
// compilation.
5157-
CmdArgs.push_back("-fsycl-is-host");
5158-
}
51595158
}
51605159

51615160
if (IsOpenMPDevice) {

0 commit comments

Comments
 (0)