llvm.org GIT mirror llvm / 4d6ca73
[Linker] Remove warning when linking ARM and Thumb IR modules. Summary: This patch updates Triple::isCompatibleWith to make armxx and thumbxx triples compatible, as long as the subarch, vendor, os, envorionment and object format match. Thumb/ARM code generation should be controlled using the thumb-mode per-function target feature rather than by the triple to allow mixing Thumb and ARM functions. D33448 updates Clang's codegen to add thumb-mode for all functions with armxx or thumbxx triples. Reviewers: echristo, t.p.northover, rafael, kristof.beyls, rengolin, tejohnson Reviewed By: tejohnson Subscribers: rinon, eugenis, pcc, srhines, aemerson, mehdi_amini, javed.absar, llvm-commits Differential Revision: https://reviews.llvm.org/D33287 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@304884 91177308-0d34-0410-b5e6-96231b3b80d8 Florian Hahn 2 years ago
5 changed file(s) with 104 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
14871487 }
14881488
14891489 bool Triple::isCompatibleWith(const Triple &Other) const {
1490 // ARM and Thumb triples are compatible, if subarch, vendor and OS match.
1491 if ((getArch() == Triple::thumb && Other.getArch() == Triple::arm) ||
1492 (getArch() == Triple::arm && Other.getArch() == Triple::thumb) ||
1493 (getArch() == Triple::thumbeb && Other.getArch() == Triple::armeb) ||
1494 (getArch() == Triple::armeb && Other.getArch() == Triple::thumbeb)) {
1495 if (getVendor() == Triple::Apple)
1496 return getSubArch() == Other.getSubArch() &&
1497 getVendor() == Other.getVendor() && getOS() == Other.getOS();
1498 else
1499 return getSubArch() == Other.getSubArch() &&
1500 getVendor() == Other.getVendor() && getOS() == Other.getOS() &&
1501 getEnvironment() == Other.getEnvironment() &&
1502 getObjectFormat() == Other.getObjectFormat();
1503 }
1504
14901505 // If vendor is apple, ignore the version number.
14911506 if (getVendor() == Triple::Apple)
14921507 return getArch() == Other.getArch() && getSubArch() == Other.getSubArch() &&
0 target triple = "thumbv7-linux-gnueabihf"
1
2 define i32 @foo(i32 %a, i32 %b) #0 {
3 entry:
4 %add = add i32 %a, %b
5 ret i32 %add
6 }
7
8 define i32 @bar(i32 %a, i32 %b) #0 {
9 entry:
10 %add = add i32 %a, %b
11 ret i32 %add
12 }
13
14 attributes #0 = { "target-features"="+thumb-mode" }
0 ; Testcase to check that functions from a Thumb module can be inlined in an
1 ; ARM function.
2 ;
3 ; RUN: llvm-as %s -o %t1.bc
4 ; RUN: llvm-as %p/Inputs/thumb.ll -o %t2.bc
5 ; RUN: llvm-lto -exported-symbol main \
6 ; RUN: -exported-symbol bar \
7 ; RUN: -filetype=asm \
8 ; RUN: -o - \
9 ; RUN: %t1.bc %t2.bc 2> %t3.out| FileCheck %s
10 ; RUN: FileCheck --allow-empty --input-file %t3.out --check-prefix STDERR %s
11
12 target triple = "armv7-linux-gnueabihf"
13
14 ; CHECK: .code 32
15 ; CHECK-NEXT: main
16 ; CHECK-NEXT: .fnstart
17 ; CHECK-NEXT: mov r0, #30
18
19 ; CHECK: .code 16
20 ; CHECK-NEXT: .thumb_func
21 ; CHECK-NEXT: bar
22
23 declare i32 @foo(i32 %a, i32 %b);
24
25 define i32 @main() {
26 entry:
27 %add = call i32 @foo(i32 10, i32 20)
28 ret i32 %add
29 }
30
31 ; STDERR-NOT: warning: Linking two modules of different target triples:
0 target triple = "thumbv7-linux-gnueabihf"
1
2 define i32 @foo(i32 %a, i32 %b) #0 {
3 entry:
4 %add = add i32 %a, %b
5 ret i32 %add
6 }
7
8 define i32 @bar(i32 %a, i32 %b) #1 {
9 entry:
10 %add = add i32 %a, %b
11 ret i32 %add
12 }
13
14 attributes #0 = { "target-features"="-thumb-mode" }
15 attributes #1 = { "target-features"="+thumb-mode" }
0 ; RUN: llvm-as %s -o %t1.bc
1 ; RUN: llvm-as %p/Inputs/thumb.ll -o %t2.bc
2 ; RUN: llvm-link %t1.bc %t2.bc -S 2> %t3.out | llc | FileCheck %s
3 ; RUN: FileCheck --allow-empty --input-file %t3.out --check-prefix STDERR %s
4
5 target triple = "armv7-linux-gnueabihf"
6
7 declare i32 @foo(i32 %a, i32 %b);
8
9 define i32 @main() {
10 entry:
11 %add = call i32 @foo(i32 10, i32 20)
12 ret i32 %add
13 }
14
15 ; CHECK: .code 32 @ @main
16 ; CHECK-NEXT: main
17
18 ; CHECK: .code 32 @ @foo
19 ; CHECK-NEXT: foo
20
21 ; CHECK: .code 16 @ @bar
22 ; CHECK-NEXT: .thumb_func
23 ; CHECK-NEXT: bar
24
25 ; STDERR-NOT: warning: Linking two modules of different target triples: