Skip to content

Commit 27f3283

Browse files
authored
[lanai] Add back the ability to set the memory model with --mcmodel. (#150575)
This ability got removed at some point but is still needed to select specific modes for Lanai backend. Add back with simple frontend smoke test.
1 parent e4334af commit 27f3283

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,10 @@ New Compiler Flags
147147
------------------
148148
- New option ``-fno-sanitize-annotate-debug-info-traps`` added to disable emitting trap reasons into the debug info when compiling with trapping UBSan (e.g. ``-fsanitize-trap=undefined``).
149149

150+
Lanai Support
151+
^^^^^^^^^^^^^^
152+
- The option ``-mcmodel={small,medium,large}`` is supported again.
153+
150154
Deprecated Compiler Flags
151155
-------------------------
152156

clang/lib/Driver/ToolChains/CommonArgs.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3125,6 +3125,8 @@ void tools::addMCModel(const Driver &D, const llvm::opt::ArgList &Args,
31253125
else if (CM == "medany")
31263126
CM = "large";
31273127
Ok = CM == "small" || CM == "medium" || CM == "large";
3128+
} else if (Triple.getArch() == llvm::Triple::lanai) {
3129+
Ok = llvm::is_contained({"small", "medium", "large"}, CM);
31283130
}
31293131
if (Ok) {
31303132
CmdArgs.push_back(Args.MakeArgString("-mcmodel=" + CM));

clang/test/Driver/lanai-mcmodel.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// RUN: %clang --target=lanai -### -c -mcmodel=small %s 2>&1 | FileCheck --check-prefix=SMALL %s
2+
// RUN: %clang --target=lanai -### -c -mcmodel=medium %s 2>&1 | FileCheck --check-prefix=MEDIUM %s
3+
// RUN: %clang --target=lanai -### -c -mcmodel=large %s 2>&1 | FileCheck --check-prefix=LARGE %s
4+
// RUN: not %clang --target=lanai -### -c -mcmodel=something %s 2>&1 | FileCheck --check-prefix=ERR-MCMODEL %s
5+
6+
// SMALL: "-mcmodel=small"
7+
// MEDIUM: "-mcmodel=medium"
8+
// LARGE: "-mcmodel=large"
9+
10+
// ERR-MCMODEL: error: unsupported argument 'something' to option '-mcmodel=' for target 'lanai'

0 commit comments

Comments
 (0)