forked from intel/llvm
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IR] make -stack-alignment= into a module attr
Similar to D102742, specifying the stack alignment via CodegenOpts means that this flag gets dropped during LTO, unless the command line is re-specified as a plugin opt. Instead, encode this information as a module level attribute so that we don't have to expose this llvm internal flag when linking the Linux kernel with LTO. Looks like external dependencies might need a fix: * llvm-hs/llvm-hs#345 * halide/Halide#6079 Link: ClangBuiltLinux/linux#1377 Reviewed By: tejohnson Differential Revision: https://reviews.llvm.org/D103048
- Loading branch information
1 parent
c5d56fe
commit 433c8d9
Showing
23 changed files
with
189 additions
and
120 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
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
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,46 @@ | ||
; RUN: llc < %s -stack-symbol-ordering=0 -mcpu=generic -stackrealign -mattr=+avx -mtriple=x86_64-apple-darwin10 | FileCheck %s | ||
; rdar://11496434 | ||
declare void @t1_helper(i32*) | ||
declare void @t3_helper(i32*, i32*) | ||
|
||
; Test when forcing stack alignment | ||
define i32 @t8() nounwind uwtable { | ||
entry: | ||
%a = alloca i32, align 4 | ||
call void @t1_helper(i32* %a) nounwind | ||
%0 = load i32, i32* %a, align 4 | ||
%add = add nsw i32 %0, 13 | ||
ret i32 %add | ||
|
||
; CHECK: _t8 | ||
; CHECK: movq %rsp, %rbp | ||
; CHECK: andq $-32, %rsp | ||
; CHECK-NEXT: subq $32, %rsp | ||
; CHECK: movq %rbp, %rsp | ||
; CHECK: popq %rbp | ||
} | ||
|
||
; VLAs | ||
define i32 @t9(i64 %sz) nounwind uwtable { | ||
entry: | ||
%a = alloca i32, align 4 | ||
%vla = alloca i32, i64 %sz, align 16 | ||
call void @t3_helper(i32* %a, i32* %vla) nounwind | ||
%0 = load i32, i32* %a, align 4 | ||
%add = add nsw i32 %0, 13 | ||
ret i32 %add | ||
|
||
; CHECK: _t9 | ||
; CHECK: pushq %rbp | ||
; CHECK: movq %rsp, %rbp | ||
; CHECK: pushq %rbx | ||
; CHECK: andq $-32, %rsp | ||
; CHECK: subq $32, %rsp | ||
; CHECK: movq %rsp, %rbx | ||
|
||
; CHECK: leaq -8(%rbp), %rsp | ||
; CHECK: popq %rbx | ||
; CHECK: popq %rbp | ||
} | ||
!llvm.module.flags = !{!0} | ||
!0 = !{i32 2, !"override-stack-alignment", i32 32} |
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,52 @@ | ||
; RUN: llc < %s -mtriple=i686-windows -stackrealign | FileCheck %s | ||
|
||
declare void @good(i32 %a, i32 %b, i32 %c, i32 %d) | ||
declare void @oneparam(i32 %a) | ||
declare void @eightparams(i32 %a, i32 %b, i32 %c, i32 %d, i32 %e, i32 %f, i32 %g, i32 %h) | ||
|
||
; When there is no reserved call frame, check that additional alignment | ||
; is added when the pushes don't add up to the required alignment. | ||
; CHECK-LABEL: test5: | ||
; CHECK: subl $16, %esp | ||
; CHECK-NEXT: pushl $4 | ||
; CHECK-NEXT: pushl $3 | ||
; CHECK-NEXT: pushl $2 | ||
; CHECK-NEXT: pushl $1 | ||
; CHECK-NEXT: call | ||
define void @test5(i32 %k) { | ||
entry: | ||
%a = alloca i32, i32 %k | ||
call void @good(i32 1, i32 2, i32 3, i32 4) | ||
ret void | ||
} | ||
|
||
; When the alignment adds up, do the transformation | ||
; CHECK-LABEL: test5b: | ||
; CHECK: pushl $8 | ||
; CHECK-NEXT: pushl $7 | ||
; CHECK-NEXT: pushl $6 | ||
; CHECK-NEXT: pushl $5 | ||
; CHECK-NEXT: pushl $4 | ||
; CHECK-NEXT: pushl $3 | ||
; CHECK-NEXT: pushl $2 | ||
; CHECK-NEXT: pushl $1 | ||
; CHECK-NEXT: call | ||
define void @test5b() optsize { | ||
entry: | ||
call void @eightparams(i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8) | ||
ret void | ||
} | ||
|
||
; When having to compensate for the alignment isn't worth it, | ||
; don't use pushes. | ||
; CHECK-LABEL: test5c: | ||
; CHECK: movl $1, (%esp) | ||
; CHECK-NEXT: call | ||
define void @test5c() optsize { | ||
entry: | ||
call void @oneparam(i32 1) | ||
ret void | ||
} | ||
|
||
!llvm.module.flags = !{!0} | ||
!0 = !{i32 2, !"override-stack-alignment", i32 32} |
Oops, something went wrong.