Skip to content

[Driver][SYCL] Fixup arguments to llc call for PIC and code-model #4614

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions clang/lib/Driver/ToolChains/Clang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8544,9 +8544,10 @@ void OffloadWrapper::ConstructJob(Compilation &C, const JobAction &JA,
if (PICLevel > 0 || TCArgs.hasArg(options::OPT_shared)) {
LlcArgs.push_back("-relocation-model=pic");
}
if (IsPIE) {
LlcArgs.push_back("-enable-pie");
}
if (Arg *A = C.getArgs().getLastArg(options::OPT_mcmodel_EQ))
LlcArgs.push_back(
TCArgs.MakeArgString(Twine("--code-model=") + A->getValue()));

SmallString<128> LlcPath(C.getDriver().Dir);
llvm::sys::path::append(LlcPath, "llc");
const char *Llc = C.getArgs().MakeArgString(LlcPath);
Expand Down
9 changes: 9 additions & 0 deletions clang/test/Driver/sycl-offload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,17 @@
// RUN: | FileCheck -check-prefix=CHECK_SHARED %s
// RUN: %clangxx -### -fsycl -target x86_64-unknown-linux-gnu -fPIC %s 2>&1 \
// RUN: | FileCheck -check-prefix=CHECK_SHARED %s
// RUN: %clangxx -### -fsycl -target x86_64-unknown-linux-gnu -fPIE %s 2>&1 \
// RUN: | FileCheck -check-prefix=CHECK_SHARED %s
// CHECK_SHARED: llc{{.*}} "-relocation-model=pic"

/// check for code-model settings for llc device wrap compilation
// RUN: %clangxx -### -fsycl -target x86_64-unknown-linux-gnu -mcmodel=large %s 2>&1 \
// RUN: | FileCheck -check-prefix=CHECK_CODE_MODEL -DARG=large %s
// RUN: %clangxx -### -fsycl -target x86_64-unknown-linux-gnu -mcmodel=medium %s 2>&1 \
// RUN: | FileCheck -check-prefix=CHECK_CODE_MODEL -DARG=medium %s
// CHECK_CODE_MODEL: llc{{.*}} "--code-model=[[ARG]]"

/// -S -emit-llvm should generate textual IR for device.
// RUN: %clangxx -### -fsycl -S -emit-llvm %s 2>&1 \
// RUN: | FileCheck -check-prefix=CHECK_S_LLVM %s
Expand Down