Skip to content

Commit 831834c

Browse files
authored
[Driver][SYCL] Fixup arguments to llc call for PIC and code-model (#4614)
When calling 'llc' for wrapping the device binaries, fix a problem with -fPIE and also enable -mcmodel=arg hooks
1 parent e3c9c92 commit 831834c

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8544,9 +8544,10 @@ void OffloadWrapper::ConstructJob(Compilation &C, const JobAction &JA,
85448544
if (PICLevel > 0 || TCArgs.hasArg(options::OPT_shared)) {
85458545
LlcArgs.push_back("-relocation-model=pic");
85468546
}
8547-
if (IsPIE) {
8548-
LlcArgs.push_back("-enable-pie");
8549-
}
8547+
if (Arg *A = C.getArgs().getLastArg(options::OPT_mcmodel_EQ))
8548+
LlcArgs.push_back(
8549+
TCArgs.MakeArgString(Twine("--code-model=") + A->getValue()));
8550+
85508551
SmallString<128> LlcPath(C.getDriver().Dir);
85518552
llvm::sys::path::append(LlcPath, "llc");
85528553
const char *Llc = C.getArgs().MakeArgString(LlcPath);

clang/test/Driver/sycl-offload.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,17 @@
3939
// RUN: | FileCheck -check-prefix=CHECK_SHARED %s
4040
// RUN: %clangxx -### -fsycl -target x86_64-unknown-linux-gnu -fPIC %s 2>&1 \
4141
// RUN: | FileCheck -check-prefix=CHECK_SHARED %s
42+
// RUN: %clangxx -### -fsycl -target x86_64-unknown-linux-gnu -fPIE %s 2>&1 \
43+
// RUN: | FileCheck -check-prefix=CHECK_SHARED %s
4244
// CHECK_SHARED: llc{{.*}} "-relocation-model=pic"
4345

46+
/// check for code-model settings for llc device wrap compilation
47+
// RUN: %clangxx -### -fsycl -target x86_64-unknown-linux-gnu -mcmodel=large %s 2>&1 \
48+
// RUN: | FileCheck -check-prefix=CHECK_CODE_MODEL -DARG=large %s
49+
// RUN: %clangxx -### -fsycl -target x86_64-unknown-linux-gnu -mcmodel=medium %s 2>&1 \
50+
// RUN: | FileCheck -check-prefix=CHECK_CODE_MODEL -DARG=medium %s
51+
// CHECK_CODE_MODEL: llc{{.*}} "--code-model=[[ARG]]"
52+
4453
/// -S -emit-llvm should generate textual IR for device.
4554
// RUN: %clangxx -### -fsycl -S -emit-llvm %s 2>&1 \
4655
// RUN: | FileCheck -check-prefix=CHECK_S_LLVM %s

0 commit comments

Comments
 (0)