Skip to content
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
0aebcd7
Adding diagnostics for unsupported option
ShashwathiNavada Feb 4, 2025
f791b1d
minor changes
ShashwathiNavada Feb 4, 2025
689dc3a
minor changes
ShashwathiNavada Feb 4, 2025
28fcb0e
minor changes
ShashwathiNavada Feb 4, 2025
ba6c662
Merge branch 'main' into mcmodel_crash
ShashwathiNavada Feb 4, 2025
843d4cc
Addressed build fail
ShashwathiNavada Feb 4, 2025
adf4236
Merge branch 'llvm:main' into mcmodel_crash
ShashwathiNavada Feb 4, 2025
cb512f3
Added tests and releasenotes entry
ShashwathiNavada Feb 11, 2025
b2724ba
Merge branch 'main' into mcmodel_crash
ShashwathiNavada Feb 11, 2025
ad5c8ca
Merge branch 'main' into mcmodel_crash
ShashwathiNavada Feb 19, 2025
5b9ff44
Merge branch 'main' into mcmodel_crash
ShashwathiNavada Feb 21, 2025
0fa223c
Added testcase in mcmodel.c file
Mar 26, 2025
d85fad3
Merge branch 'main' into mcmodel_crash
ShashwathiNavada Mar 26, 2025
ca4d129
Merge branch 'main' into mcmodel_crash
ShashwathiNavada Apr 15, 2025
fcbc340
Merge branch 'main' into mcmodel_crash
ShashwathiNavada Apr 15, 2025
d2cf187
Merge branch 'llvm:main' into mcmodel_crash
ShashwathiNavada Apr 15, 2025
8e2b440
Suggested changes completed
Apr 15, 2025
12e4423
Merge branch 'main' into mcmodel_crash
ShashwathiNavada Apr 15, 2025
215aa42
Update Driver.cpp
ShashwathiNavada Apr 15, 2025
39e7667
Merge branch 'llvm:main' into mcmodel_crash
ShashwathiNavada Apr 22, 2025
2024997
Merge branch 'llvm:main' into mcmodel_crash
ShashwathiNavada Apr 27, 2025
075a921
Removed check from driver.cpp and corrected existing one in CommonArg…
Apr 29, 2025
742ea57
removed unnecessary test
Apr 29, 2025
59985ea
minor change
Apr 29, 2025
0c14a0c
Update ReleaseNotes.rst
ShashwathiNavada May 6, 2025
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
1 change: 1 addition & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ Improvements to Clang's diagnostics


- An error is now emitted when a ``musttail`` call is made to a function marked with the ``not_tail_called`` attribute. (#GH133509).
- The ``-mcmodel=tiny`` option will now be diagnosed on all targets other than ARM or AArch64.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The commit message/description and the note should be changed. Only X86 is affected. This change is pretty niche and does not deserve a release note.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MaskRay, Thank you for the response. I have removed the release note entry and updated the commit message as well.


Improvements to Clang's time-trace
----------------------------------
Expand Down
12 changes: 12 additions & 0 deletions clang/lib/Driver/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1755,6 +1755,18 @@ Compilation *Driver::BuildCompilation(ArrayRef<const char *> ArgList) {
<< TC.getTriple().str();
}

// Throw diagnosis if mcmodel=tiny option is passed for targets other than ARM
// or AArch64.
if (Arg *A = UArgs->getLastArg(options::OPT_mcmodel_EQ)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move to clang/lib/Driver/ToolChains/CommonArgs.cpp addMCModel. You might delete add an early return to that function and run check-clang-driver to find relevant tests. Then follow that style and add one for Arm.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tiny is expected to work with AArch64.

Copy link
Contributor Author

@ShashwathiNavada ShashwathiNavada Apr 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MaskRay Thank you for your response!
I noticed that in the function you mentioned, there’s a check like this:

else if (Triple.getArch() == llvm::Triple::x86_64) {
    Ok = llvm::is_contained({"small", "kernel", "medium", "large", "tiny"}, CM);
}

I found that removing the tiny option here gives the desired result.
Would you mind confirming if this approach looks good?

StringRef ModelName = A->getValue();
if (ModelName == "tiny" &&
!(TC.getTriple().getArch() == llvm::Triple::aarch64 ||
TC.getTriple().getArch() == llvm::Triple::arm)) {
Diag(diag::err_drv_unsupported_option_argument_for_target)
<< A->getSpelling() << ModelName << TC.getTriple().str();
}
}

// A common user mistake is specifying a target of aarch64-none-eabi or
// arm-none-elf whereas the correct names are aarch64-none-elf &
// arm-none-eabi. Detect these cases and issue a warning.
Expand Down
4 changes: 3 additions & 1 deletion clang/test/Driver/mcmodel.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// RUN: not %clang -### -c --target=i686 -mcmodel=medium %s 2>&1 | FileCheck --check-prefix=ERR-MEDIUM %s
// RUN: %clang --target=x86_64 -### -c -mcmodel=tiny %s 2>&1 | FileCheck --check-prefix=TINY %s
// RUN: not %clang --target=x86_64 -### -c -mcmodel=tiny %s 2>&1 | FileCheck --check-prefix=TINY %s
// RUN: %clang --target=x86_64 -### -c -mcmodel=small %s 2>&1 | FileCheck --check-prefix=SMALL %s
// RUN: %clang --target=x86_64 -### -S -mcmodel=kernel %s 2>&1 | FileCheck --check-prefix=KERNEL %s
// RUN: %clang --target=x86_64 -### -c -mcmodel=medium %s 2>&1 | FileCheck --check-prefix=MEDIUM %s
Expand Down Expand Up @@ -44,3 +44,5 @@
// ERR-AARCH64_32: error: unsupported argument 'small' to option '-mcmodel=' for target 'aarch64_32-unknown-linux'

// ERR-LOONGARCH64-PLT-EXTREME: error: invalid argument '-mcmodel=extreme' not allowed with '-fplt'

// CHECK: error: unsupported argument 'tiny' to option '-mcmodel=' for target '{{.*}}'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have nothing with a check prefix of just CHECK so this will never actually be tested. Also, this is the same message as ERR-TINY so we wouldn't need this line anyway.

Loading