forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[RISCV][LTO] enable LTO/ThinLTO on RISCV (D78035)
- Loading branch information
Showing
9 changed files
with
132 additions
and
0 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
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,14 @@ | ||
target datalayout = "e-m:e-p:32:32-i64:64-n32-S128" | ||
target triple = "riscv32-unknown-linux-gnu" | ||
|
||
define float @foo(float %x) #0 { | ||
%conv = fpext float %x to double | ||
%add = fadd double %conv, 0x400921FD80C9BEFB | ||
%conv1 = fptrunc double %add to float | ||
ret float %conv1 | ||
} | ||
|
||
attributes #0 = { nounwind "target-features"="+a,+c,+f,+m,+relax" } | ||
|
||
!llvm.module.flags = !{!0} | ||
!0 = !{i32 1, !"target-abi", !"ilp32"} |
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,14 @@ | ||
target datalayout = "e-m:e-p:32:32-i64:64-n32-S128" | ||
target triple = "riscv32-unknown-linux-gnu" | ||
|
||
define float @foo(float %x) #0 { | ||
%conv = fpext float %x to double | ||
%add = fadd double %conv, 0x400921FD80C9BEFB | ||
%conv1 = fptrunc double %add to float | ||
ret float %conv1 | ||
} | ||
|
||
attributes #0 = { nounwind "target-features"="+a,+c,+f,+m,+relax" } | ||
|
||
!llvm.module.flags = !{!0} | ||
!0 = !{i32 1, !"target-abi", !"ilp32f"} |
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,2 @@ | ||
if not 'RISCV' in config.root.targets: | ||
config.unsupported = True |
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,35 @@ | ||
; Check with regular LTO | ||
; RUN: rm -f %t* | ||
; RUN: llvm-as < %s >%t1 | ||
; RUN: llvm-as < %p/Inputs/mabi-invalid.ll >%t2 | ||
; Check old API | ||
; RUN: not llvm-lto -exported-symbol=main -o %t3 %t1 %t2 2>&1 | FileCheck %s | ||
; Check new API | ||
; RUN: not llvm-lto2 run -r %t1,foo, -r %t1,main,plx -r %t2,foo,plx -o %t3.o %t1 %t2 2>&1 | FileCheck %s | ||
|
||
; Check with ThinLTO. | ||
; RUN: rm -f %t* | ||
; RUN: opt -module-summary -o %t1 %s | ||
; RUN: opt -module-summary -o %t2 %p/Inputs/mabi-invalid.ll | ||
; Check old API | ||
; RUN: not --crash llvm-lto -thinlto -thinlto-action=run %t1 %t2 -exported-symbol=main 2>&1 | FileCheck %s | ||
; Check new API | ||
; RUN: not --crash llvm-lto2 run -r %t1,foo, -r %t1,main,plx -r %t2,foo,plx -o %t3.o %t1 %t2 2>&1 | FileCheck %s | ||
|
||
; CHECK: 'target-abi': IDs have conflicting values | ||
|
||
target datalayout = "e-m:e-p:32:32-i64:64-n32-S128" | ||
target triple = "riscv32-unknown-linux-gnu" | ||
|
||
declare float @foo(float) #1 | ||
|
||
define float @main(float %x) #0 { | ||
%retval = call float @foo(float 10.0) | ||
ret float %retval | ||
} | ||
|
||
attributes #0 = { nounwind "target-features"="+a,+c,+f,+m,+relax" } | ||
attributes #1 = { nounwind "target-features"="+a,+c,+f,+m,+relax" } | ||
|
||
!llvm.module.flags = !{!0} | ||
!0 = !{i32 1, !"target-abi", !"ilp32f"} |
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,44 @@ | ||
; Test target-abi module flag generate correct elf flags. | ||
|
||
; Check with regular LTO | ||
; RUN: rm -f %t* | ||
; RUN: llvm-as < %s >%t1 | ||
; RUN: llvm-as < %p/Inputs/mabi.ll >%t2 | ||
; Check old API | ||
; RUN: llvm-lto -exported-symbol=main -o %t3 %t1 %t2 | ||
; RUN: llvm-readelf -h %t3 | FileCheck %s | ||
; Check new API | ||
; RUN: llvm-lto2 run -r %t1,foo, -r %t1,main,plx -r %t2,foo,plx -o %t3.o %t1 %t2 | ||
; RUN: llvm-readelf -h %t3.o.0 | FileCheck %s | ||
|
||
; Check with ThinLTO. | ||
; RUN: rm -f %t* | ||
; RUN: opt -module-summary -o %t1 %s | ||
; RUN: opt -module-summary -o %t2 %p/Inputs/mabi.ll | ||
; Check old API | ||
; RUN: llvm-lto -thinlto -thinlto-action=run %t1 %t2 -exported-symbol=main | ||
; RUN: llvm-readelf -h %t1.thinlto.o | FileCheck %s | ||
; RUN: llvm-readelf -h %t2.thinlto.o | FileCheck %s | ||
; Check new API | ||
; RUN: llvm-lto2 run -r %t1,foo, -r %t1,main,plx -r %t2,foo,plx -o %t3.o %t1 %t2 | ||
; RUN: llvm-readelf -h %t3.o.1 | FileCheck %s | ||
; RUN: llvm-readelf -h %t3.o.2 | FileCheck %s | ||
|
||
; CHECK: Flags: 0x2, single-float ABI | ||
|
||
target datalayout = "e-m:e-p:32:32-i64:64-n32-S128" | ||
target triple = "riscv32-unknown-linux-gnu" | ||
|
||
declare float @foo(float) #1 | ||
|
||
define float @main(float %x) #0 { | ||
%retval = call float @foo(float 10.0) | ||
ret float %retval | ||
} | ||
|
||
attributes #0 = { nounwind "target-features"="+a,+c,+f,+m,+relax" } | ||
attributes #1 = { nounwind "target-features"="+a,+c,+f,+m,+relax" } | ||
|
||
!llvm.module.flags = !{!0} | ||
!0 = !{i32 1, !"target-abi", !"ilp32f"} | ||
|