-
Notifications
You must be signed in to change notification settings - Fork 11.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[clang][Arm] Fix handling of -Wa,-march=
This fixes Bugzilla #48894 for Arm, where it was reported that -Wa,-march was not being handled by the integrated assembler. This was previously fixed for -Wa,-mthumb by parsing the argument in ToolChain::ComputeLLVMTriple instead of CollectArgsForIntegratedAssembler. It has to be done in the former because the Triple is read only by the time we get to the latter. Previously only mcpu would work via -Wa but only because "-target-cpu" is it's own option to cc1, which we were able to modify. Target architecture is part of "-target-triple". This change applies the same workaround to -march and cleans up handling of -Wa,-mcpu at the same time. There were some places where we were not using the last instance of an argument. The existing -Wa,-mthumb code was doing this correctly, so I've just added tests to confirm that. Now the same rules will apply to -Wa,-march/-mcpu as would if you just passed them to the compiler: * -Wa/-Xassembler options only apply to assembly files. * Architecture derived from mcpu beats any march options. * When there are multiple mcpu or multiple march, the last one wins. * If there is a compiler option and an assembler option of the same type, we prefer the one that fits the input type. * If there is an applicable mcpu option but it is overruled by an march, the cpu value is still used for the "-target-cpu" cc1 option. Reviewed By: nickdesaulniers Differential Revision: https://reviews.llvm.org/D95872
- Loading branch information
1 parent
985a42f
commit 1d51c69
Showing
4 changed files
with
156 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
/// These tests make sure that options passed to the assembler | ||
/// via -Wa or -Xassembler are applied correctly to assembler inputs. | ||
/// Also we check that the same priority rules apply to compiler and | ||
/// assembler options. | ||
/// | ||
/// Note that the cortex-a8 is armv7-a, the cortex-a32 is armv8-a | ||
/// and clang's default Arm architecture is armv4t. | ||
|
||
/// Sanity check how the options behave when passed to the compiler | ||
// RUN: %clang -target arm-linux-gnueabi -### -c -march=armv7-a %s 2>&1 | \ | ||
// RUN: FileCheck --check-prefix=TRIPLE-ARMV7 %s | ||
// RUN: %clang -target arm-linux-gnueabi -### -c -march=armv7-a+crc %s 2>&1 | \ | ||
// RUN: FileCheck --check-prefixes=TRIPLE-ARMV7,EXT-CRC %s | ||
|
||
/// -Wa/-Xassembler doesn't apply to non assembly files | ||
// RUN: %clang -target arm-linux-gnueabi -### -c -Wa,-march=armv7-a \ | ||
// RUN: %S/Inputs/wildcard1.c 2>&1 | FileCheck --check-prefix=TRIPLE-ARMV4 %s | ||
// RUN: %clang -target arm-linux-gnueabi -### -c -Xassembler -march=armv7-a \ | ||
// RUN: %S/Inputs/wildcard1.c 2>&1 | FileCheck --check-prefix=TRIPLE-ARMV4 %s | ||
|
||
/// -Wa/-Xassembler does apply to assembler input | ||
// RUN: %clang -target arm-linux-gnueabi -### -c -Wa,-march=armv7-a %s 2>&1 | \ | ||
// RUN: FileCheck --check-prefix=TRIPLE-ARMV7 %s | ||
// RUN: %clang -target arm-linux-gnueabi -### -c -Wa,-march=armv7-a+crc %s 2>&1 | \ | ||
// RUN: FileCheck --check-prefixes=TRIPLE-ARMV7,EXT-CRC %s | ||
// RUN: %clang -target arm-linux-gnueabi -### -c -Xassembler -march=armv7-a %s 2>&1 | \ | ||
// RUN: FileCheck --check-prefix=TRIPLE-ARMV7 %s | ||
// RUN: %clang -target arm-linux-gnueabi -### -c -Xassembler -march=armv7-a+crc %s 2>&1 | \ | ||
// RUN: FileCheck --check-prefixes=TRIPLE-ARMV7,EXT-CRC %s | ||
|
||
/// Check that arch name is still canonicalised | ||
// RUN: %clang -target arm-linux-gnueabi -### -c -Wa,-march=armv7a %s 2>&1 | \ | ||
// RUN: FileCheck --check-prefix=TRIPLE-ARMV7 %s | ||
// RUN: %clang -target arm-linux-gnueabi -### -c -Xassembler -march=armv7 %s 2>&1 | \ | ||
// RUN: FileCheck --check-prefix=TRIPLE-ARMV7 %s | ||
|
||
/// march to compiler and assembler, we choose the one suited to the input file type | ||
// RUN: %clang -target arm-linux-gnueabi -### -c -march=armv8-a -Wa,-march=armv7a %s 2>&1 | \ | ||
// RUN: FileCheck --check-prefix=TRIPLE-ARMV7 %s | ||
// RUN: %clang -target arm-linux-gnueabi -### -c -march=armv7-a -Wa,-march=armv8-a \ | ||
// RUN: %S/Inputs/wildcard1.c 2>&1 | FileCheck --check-prefix=TRIPLE-ARMV7 %s | ||
|
||
/// mcpu to compiler and march to assembler, we use the assembler's architecture for assembly files. | ||
/// We use the target CPU for both. | ||
// RUN: %clang -target arm-linux-gnueabi -### -c -mcpu=cortex-a8 -Wa,-march=armv8a %s 2>&1 | \ | ||
// RUN: FileCheck --check-prefixes=TRIPLE-ARMV8,CPU-A8 %s | ||
// RUN: %clang -target arm-linux-gnueabi -### -c -mcpu=cortex-a8 -Wa,-march=armv8-a \ | ||
// RUN: %S/Inputs/wildcard1.c 2>&1 | FileCheck --check-prefixes=TRIPLE-ARMV7,CPU-A8 %s | ||
|
||
/// march to compiler and mcpu to assembler, we use the one that matches the file type | ||
/// (again both get the target-cpu option either way) | ||
// RUN: %clang -target arm-linux-gnueabi -### -c -march=armv8a -Wa,-mcpu=cortex-a8 %s 2>&1 | \ | ||
// RUN: FileCheck --check-prefixes=TRIPLE-ARMV7,CPU-A8 %s | ||
// RUN: %clang -target arm-linux-gnueabi -### -c -march=armv8a -Wa,-mcpu=cortex-a8 \ | ||
// RUN: %S/Inputs/wildcard1.c 2>&1 | FileCheck --check-prefix=TRIPLE-ARMV8 %s | ||
|
||
/// march and mcpu to the compiler, mcpu wins | ||
// RUN: %clang -target arm-linux-gnueabi -### -c -mcpu=cortex-a8 -march=armv8-a %s 2>&1 | \ | ||
// RUN: FileCheck --check-prefixes=TRIPLE-ARMV7,CPU-A8 %s | ||
/// not dependent on order | ||
// RUN: %clang -target arm-linux-gnueabi -### -c -march=armv8-a -mcpu=cortex-a8 %s 2>&1 | \ | ||
// RUN: FileCheck --check-prefixes=TRIPLE-ARMV7,CPU-A8 %s | ||
/// or file type | ||
// RUN: %clang -target arm-linux-gnueabi -### -c -march=armv8a -mcpu=cortex-a8 \ | ||
// RUN: %S/Inputs/wildcard1.c 2>&1 | FileCheck --check-prefixes=TRIPLE-ARMV7,CPU-A8 %s | ||
|
||
/// If we pass mcpu and march to the assembler then mcpu's arch wins | ||
/// (matches the compiler behaviour) | ||
// RUN: %clang -target arm-linux-gnueabi -### -c -Wa,-mcpu=cortex-a8 -Wa,-march=armv8-a %s 2>&1 | \ | ||
// RUN: FileCheck --check-prefixes=TRIPLE-ARMV7,CPU-A8 %s | ||
// RUN: %clang -target arm-linux-gnueabi -### -c -Wa,-mcpu=cortex-a8,-march=armv8-a %s 2>&1 | \ | ||
// RUN: FileCheck --check-prefixes=TRIPLE-ARMV7,CPU-A8 %s | ||
// RUN: %clang -target arm-linux-gnueabi -### -c -Xassembler -march=armv8-a -Xassembler -mcpu=cortex-a8 \ | ||
// RUN: %s 2>&1 | FileCheck --check-prefixes=TRIPLE-ARMV7,CPU-A8 %s | ||
|
||
/// Last mcpu to assembler wins | ||
// RUN: %clang -target arm-linux-gnueabi -### -c -Wa,-mcpu=cortex-a32,-mcpu=cortex-a8 %s 2>&1 | \ | ||
// RUN: FileCheck --check-prefixes=TRIPLE-ARMV7,CPU-A8 %s | ||
// RUN: %clang -target arm-linux-gnueabi -### -c -Wa,-mcpu=cortex-a32 -Wa,-mcpu=cortex-a8 %s 2>&1 | \ | ||
// RUN: FileCheck --check-prefix=TRIPLE-ARMV7 --check-prefix=CPU-A8 %s | ||
// RUN: %clang -target arm-linux-gnueabi -### -c -Xassembler -mcpu=cortex-a32 -Xassembler -mcpu=cortex-a8 \ | ||
// RUN: %s 2>&1 | FileCheck --check-prefixes=TRIPLE-ARMV7,CPU-A8 %s | ||
|
||
/// Last mcpu to compiler wins | ||
// RUN: %clang -target arm-linux-gnueabi -### -c -mcpu=cortex-a32 -mcpu=cortex-a8 %s 2>&1 | \ | ||
// RUN: FileCheck --check-prefixes=TRIPLE-ARMV7,CPU-A8 %s | ||
|
||
/// Last march to assembler wins | ||
// RUN: %clang -target arm-linux-gnueabi -### -c -Wa,-march=armv8-a,-march=armv7-a %s 2>&1 | \ | ||
// RUN: FileCheck --check-prefix=TRIPLE-ARMV7 %s | ||
// RUN: %clang -target arm-linux-gnueabi -### -c -Wa,-march=armv8-a -Wa,-march=armv7-a %s 2>&1 | \ | ||
// RUN: FileCheck --check-prefix=TRIPLE-ARMV7 %s | ||
// RUN: %clang -target arm-linux-gnueabi -### -c -Xassembler -march=armv8-a -Xassembler -march=armv7-a \ | ||
// RUN: %s 2>&1 | FileCheck --check-prefix=TRIPLE-ARMV7 %s | ||
|
||
/// Last march to compiler wins | ||
// RUN: %clang -target arm-linux-gnueabi -### -c -march=armv8-a -march=armv7-a %s 2>&1 | \ | ||
// RUN: FileCheck --check-prefix=TRIPLE-ARMV7 %s | ||
|
||
// TRIPLE-ARMV4: "-triple" "armv4t-unknown-linux-gnueabi" | ||
// TRIPLE-ARMV7: "-triple" "armv7-unknown-linux-gnueabi" | ||
// TRIPLE-ARMV8: "-triple" "armv8-unknown-linux-gnueabi" | ||
// CPU-A8: "-target-cpu" "cortex-a8" | ||
// EXT-CRC: "-target-feature" "+crc" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters