[PATCH] D103048: [IR] make -stack-alignment= into a module attr

2023-08-22 Thread Ben Gamari via Phabricator via cfe-commits
bgamari added a comment.
Herald added a project: All.

@nickdesaulniers, this appears to be missing the corresponding documentation in 
the LLVM language reference. As someone who maintains GHC 
's LLVM backend, this documentation is invaluable.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103048/new/

https://reviews.llvm.org/D103048

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D103048: [IR] make -stack-alignment= into a module attr

2022-01-25 Thread Rainer Orth via Phabricator via cfe-commits
ro added a comment.

One test `FAILs` on Solaris/sparcv9:

  LLVM :: CodeGen/Generic/ForceStackAlign.ll

with

  LLVM ERROR: Function "g" required stack re-alignment, but LLVM couldn't 
handle it (probably because it has a dynamic alloca).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103048/new/

https://reviews.llvm.org/D103048

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D103048: [IR] make -stack-alignment= into a module attr

2021-06-08 Thread Nick Desaulniers via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3787ee457173: reland [IR] make -stack-alignment= into a 
module attr (authored by nickdesaulniers).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103048/new/

https://reviews.llvm.org/D103048

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGen/stackrealign-main.c
  llvm/include/llvm/IR/Module.h
  llvm/include/llvm/Target/TargetOptions.h
  llvm/lib/CodeGen/CommandFlags.cpp
  llvm/lib/IR/Module.cpp
  llvm/lib/Target/Mips/MipsCallLowering.cpp
  llvm/lib/Target/Mips/MipsTargetMachine.cpp
  llvm/lib/Target/X86/X86TargetMachine.cpp
  llvm/test/CodeGen/Generic/ForceStackAlign.ll
  llvm/test/CodeGen/Mips/stack-alignment.ll
  llvm/test/CodeGen/X86/base-pointer-and-cmpxchg.ll
  llvm/test/CodeGen/X86/base-pointer-and-mwaitx.ll
  llvm/test/CodeGen/X86/dynamic-allocas-VLAs-stack-align.ll
  llvm/test/CodeGen/X86/dynamic-allocas-VLAs.ll
  llvm/test/CodeGen/X86/force-align-stack-alloca.ll
  llvm/test/CodeGen/X86/hipe-cc.ll
  llvm/test/CodeGen/X86/hipe-cc64.ll
  llvm/test/CodeGen/X86/movtopush-stack-align.ll
  llvm/test/CodeGen/X86/movtopush.ll
  llvm/test/CodeGen/X86/pr11468.ll
  llvm/test/CodeGen/X86/unaligned-spill-folding.ll
  llvm/test/CodeGen/X86/x86-64-baseptr.ll
  llvm/test/CodeGen/X86/x86-64-xmm-spill-unaligned.ll
  llvm/test/Linker/stack-alignment.ll

Index: llvm/test/Linker/stack-alignment.ll
===
--- /dev/null
+++ llvm/test/Linker/stack-alignment.ll
@@ -0,0 +1,15 @@
+; RUN: split-file %s %t
+; RUN: llvm-link %t/main.ll %t/8.ll
+; RUN: not llvm-link %t/main.ll %t/16.ll 2>&1 | FileCheck --check-prefix=CHECK-16 %s
+
+;--- main.ll
+; NONE: error: linking module flags 'override-stack-alignment': IDs have conflicting values
+; CHECK-16: error: linking module flags 'override-stack-alignment': IDs have conflicting values
+!llvm.module.flags = !{!0}
+!0 = !{i32 1, !"override-stack-alignment", i32 8}
+;--- 8.ll
+!llvm.module.flags = !{!0}
+!0 = !{i32 1, !"override-stack-alignment", i32 8}
+;--- 16.ll
+!llvm.module.flags = !{!0}
+!0 = !{i32 1, !"override-stack-alignment", i32 16}
Index: llvm/test/CodeGen/X86/x86-64-xmm-spill-unaligned.ll
===
--- llvm/test/CodeGen/X86/x86-64-xmm-spill-unaligned.ll
+++ llvm/test/CodeGen/X86/x86-64-xmm-spill-unaligned.ll
@@ -2,7 +2,7 @@
 ; elements (here: XMM spills) are accessed using instructions that tolerate
 ; unaligned access.
 ;
-; RUN: llc -mtriple=x86_64-unknown-linux-gnu -mcpu=x86-64 -mattr=+sse,+sse-unaligned-mem -stack-alignment=8 --frame-pointer=all < %s | FileCheck %s
+; RUN: llc -mtriple=x86_64-unknown-linux-gnu -mcpu=x86-64 -mattr=+sse,+sse-unaligned-mem --frame-pointer=all < %s | FileCheck %s
 
 define dso_local preserve_allcc void @func() #0 {
 ; CHECK-LABEL: func:
@@ -13,3 +13,5 @@
 }
 
 attributes #0 = { nounwind }
+!llvm.module.flags = !{!0}
+!0 = !{i32 2, !"override-stack-alignment", i32 8}
Index: llvm/test/CodeGen/X86/x86-64-baseptr.ll
===
--- llvm/test/CodeGen/X86/x86-64-baseptr.ll
+++ llvm/test/CodeGen/X86/x86-64-baseptr.ll
@@ -1,6 +1,6 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
-; RUN: llc -mtriple=x86_64-pc-linux -stackrealign -stack-alignment=32 < %s | FileCheck %s
-; RUN: llc -mtriple=x86_64-pc-linux-gnux32 -stackrealign -stack-alignment=32 < %s | FileCheck -check-prefix=X32ABI %s
+; RUN: llc -mtriple=x86_64-pc-linux -stackrealign < %s | FileCheck %s
+; RUN: llc -mtriple=x86_64-pc-linux-gnux32 -stackrealign < %s | FileCheck -check-prefix=X32ABI %s
 
 ; This should run with NaCl as well ( -mtriple=x86_64-pc-nacl ) but currently doesn't due to PR22655
 
@@ -65,3 +65,5 @@
 }
 
 attributes #0 = { nounwind "frame-pointer"="all"}
+!llvm.module.flags = !{!0}
+!0 = !{i32 2, !"override-stack-alignment", i32 32}
Index: llvm/test/CodeGen/X86/unaligned-spill-folding.ll
===
--- llvm/test/CodeGen/X86/unaligned-spill-folding.ll
+++ llvm/test/CodeGen/X86/unaligned-spill-folding.ll
@@ -1,7 +1,11 @@
-; RUN: llc -mtriple=i386-unknown-freebsd -mcpu=core2 -stack-alignment=4 -relocation-model=pic < %s | FileCheck %s -check-prefix=UNALIGNED
-; RUN: llc -mtriple=i386-unknown-freebsd -mcpu=core2 -stack-alignment=16 -relocation-model=pic < %s | FileCheck %s -check-prefix=ALIGNED
-; RUN: llc -mtriple=i386-unknown-freebsd -mcpu=core2 -stack-alignment=4 -stackrealign -relocation-model=pic < %s | FileCheck %s -check-prefix=FORCEALIGNED
+; RUN: split-file %s %t
+; RUN: cat %t/main.ll %t/align4.ll > %t/a2.ll
+; RUN: cat %t/main.ll %t/align16.ll > %t/b2.ll
+; RUN: llc -mtriple=i386-unknown-freebsd -mcpu=core2 -relocation-model=pic < %t/a2.ll | FileCheck %s 

[PATCH] D103048: [IR] make -stack-alignment= into a module attr

2021-06-08 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

I've retested with all backends enabled; all green now. Changes added to:

- llvm/lib/Target/Mips/MipsCallLowering.cpp
- llvm/lib/Target/Mips/MipsTargetMachine.cpp
- llvm/test/CodeGen/Mips/stack-alignment.ll

Planning to recommit now.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103048/new/

https://reviews.llvm.org/D103048

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D103048: [IR] make -stack-alignment= into a module attr

2021-06-08 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 350660.
nickdesaulniers added a comment.
This revision is now accepted and ready to land.
Herald added subscribers: atanasyan, sdardis.

- fixes for MIPS


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103048/new/

https://reviews.llvm.org/D103048

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGen/stackrealign-main.c
  llvm/include/llvm/IR/Module.h
  llvm/include/llvm/Target/TargetOptions.h
  llvm/lib/CodeGen/CommandFlags.cpp
  llvm/lib/IR/Module.cpp
  llvm/lib/Target/Mips/MipsCallLowering.cpp
  llvm/lib/Target/Mips/MipsTargetMachine.cpp
  llvm/lib/Target/X86/X86TargetMachine.cpp
  llvm/test/CodeGen/Generic/ForceStackAlign.ll
  llvm/test/CodeGen/Mips/stack-alignment.ll
  llvm/test/CodeGen/X86/base-pointer-and-cmpxchg.ll
  llvm/test/CodeGen/X86/base-pointer-and-mwaitx.ll
  llvm/test/CodeGen/X86/dynamic-allocas-VLAs-stack-align.ll
  llvm/test/CodeGen/X86/dynamic-allocas-VLAs.ll
  llvm/test/CodeGen/X86/force-align-stack-alloca.ll
  llvm/test/CodeGen/X86/hipe-cc.ll
  llvm/test/CodeGen/X86/hipe-cc64.ll
  llvm/test/CodeGen/X86/movtopush-stack-align.ll
  llvm/test/CodeGen/X86/movtopush.ll
  llvm/test/CodeGen/X86/pr11468.ll
  llvm/test/CodeGen/X86/unaligned-spill-folding.ll
  llvm/test/CodeGen/X86/x86-64-baseptr.ll
  llvm/test/CodeGen/X86/x86-64-xmm-spill-unaligned.ll
  llvm/test/Linker/stack-alignment.ll

Index: llvm/test/Linker/stack-alignment.ll
===
--- /dev/null
+++ llvm/test/Linker/stack-alignment.ll
@@ -0,0 +1,15 @@
+; RUN: split-file %s %t
+; RUN: llvm-link %t/main.ll %t/8.ll
+; RUN: not llvm-link %t/main.ll %t/16.ll 2>&1 | FileCheck --check-prefix=CHECK-16 %s
+
+;--- main.ll
+; NONE: error: linking module flags 'override-stack-alignment': IDs have conflicting values
+; CHECK-16: error: linking module flags 'override-stack-alignment': IDs have conflicting values
+!llvm.module.flags = !{!0}
+!0 = !{i32 1, !"override-stack-alignment", i32 8}
+;--- 8.ll
+!llvm.module.flags = !{!0}
+!0 = !{i32 1, !"override-stack-alignment", i32 8}
+;--- 16.ll
+!llvm.module.flags = !{!0}
+!0 = !{i32 1, !"override-stack-alignment", i32 16}
Index: llvm/test/CodeGen/X86/x86-64-xmm-spill-unaligned.ll
===
--- llvm/test/CodeGen/X86/x86-64-xmm-spill-unaligned.ll
+++ llvm/test/CodeGen/X86/x86-64-xmm-spill-unaligned.ll
@@ -2,7 +2,7 @@
 ; elements (here: XMM spills) are accessed using instructions that tolerate
 ; unaligned access.
 ;
-; RUN: llc -mtriple=x86_64-unknown-linux-gnu -mcpu=x86-64 -mattr=+sse,+sse-unaligned-mem -stack-alignment=8 --frame-pointer=all < %s | FileCheck %s
+; RUN: llc -mtriple=x86_64-unknown-linux-gnu -mcpu=x86-64 -mattr=+sse,+sse-unaligned-mem --frame-pointer=all < %s | FileCheck %s
 
 define dso_local preserve_allcc void @func() #0 {
 ; CHECK-LABEL: func:
@@ -13,3 +13,5 @@
 }
 
 attributes #0 = { nounwind }
+!llvm.module.flags = !{!0}
+!0 = !{i32 2, !"override-stack-alignment", i32 8}
Index: llvm/test/CodeGen/X86/x86-64-baseptr.ll
===
--- llvm/test/CodeGen/X86/x86-64-baseptr.ll
+++ llvm/test/CodeGen/X86/x86-64-baseptr.ll
@@ -1,6 +1,6 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
-; RUN: llc -mtriple=x86_64-pc-linux -stackrealign -stack-alignment=32 < %s | FileCheck %s
-; RUN: llc -mtriple=x86_64-pc-linux-gnux32 -stackrealign -stack-alignment=32 < %s | FileCheck -check-prefix=X32ABI %s
+; RUN: llc -mtriple=x86_64-pc-linux -stackrealign < %s | FileCheck %s
+; RUN: llc -mtriple=x86_64-pc-linux-gnux32 -stackrealign < %s | FileCheck -check-prefix=X32ABI %s
 
 ; This should run with NaCl as well ( -mtriple=x86_64-pc-nacl ) but currently doesn't due to PR22655
 
@@ -65,3 +65,5 @@
 }
 
 attributes #0 = { nounwind "frame-pointer"="all"}
+!llvm.module.flags = !{!0}
+!0 = !{i32 2, !"override-stack-alignment", i32 32}
Index: llvm/test/CodeGen/X86/unaligned-spill-folding.ll
===
--- llvm/test/CodeGen/X86/unaligned-spill-folding.ll
+++ llvm/test/CodeGen/X86/unaligned-spill-folding.ll
@@ -1,7 +1,11 @@
-; RUN: llc -mtriple=i386-unknown-freebsd -mcpu=core2 -stack-alignment=4 -relocation-model=pic < %s | FileCheck %s -check-prefix=UNALIGNED
-; RUN: llc -mtriple=i386-unknown-freebsd -mcpu=core2 -stack-alignment=16 -relocation-model=pic < %s | FileCheck %s -check-prefix=ALIGNED
-; RUN: llc -mtriple=i386-unknown-freebsd -mcpu=core2 -stack-alignment=4 -stackrealign -relocation-model=pic < %s | FileCheck %s -check-prefix=FORCEALIGNED
+; RUN: split-file %s %t
+; RUN: cat %t/main.ll %t/align4.ll > %t/a2.ll
+; RUN: cat %t/main.ll %t/align16.ll > %t/b2.ll
+; RUN: llc -mtriple=i386-unknown-freebsd -mcpu=core2 -relocation-model=pic < %t/a2.ll | FileCheck %s -check-prefix=UNALIGNED
+; RUN: llc 

[PATCH] D103048: [IR] make -stack-alignment= into a module attr

2021-06-08 Thread Nick Desaulniers via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG433c8d950cb3: [IR] make -stack-alignment= into a module attr 
(authored by nickdesaulniers).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103048/new/

https://reviews.llvm.org/D103048

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGen/stackrealign-main.c
  llvm/include/llvm/IR/Module.h
  llvm/include/llvm/Target/TargetOptions.h
  llvm/lib/CodeGen/CommandFlags.cpp
  llvm/lib/IR/Module.cpp
  llvm/lib/Target/X86/X86TargetMachine.cpp
  llvm/test/CodeGen/Generic/ForceStackAlign.ll
  llvm/test/CodeGen/X86/base-pointer-and-cmpxchg.ll
  llvm/test/CodeGen/X86/base-pointer-and-mwaitx.ll
  llvm/test/CodeGen/X86/dynamic-allocas-VLAs-stack-align.ll
  llvm/test/CodeGen/X86/dynamic-allocas-VLAs.ll
  llvm/test/CodeGen/X86/force-align-stack-alloca.ll
  llvm/test/CodeGen/X86/hipe-cc.ll
  llvm/test/CodeGen/X86/hipe-cc64.ll
  llvm/test/CodeGen/X86/movtopush-stack-align.ll
  llvm/test/CodeGen/X86/movtopush.ll
  llvm/test/CodeGen/X86/pr11468.ll
  llvm/test/CodeGen/X86/unaligned-spill-folding.ll
  llvm/test/CodeGen/X86/x86-64-baseptr.ll
  llvm/test/CodeGen/X86/x86-64-xmm-spill-unaligned.ll
  llvm/test/Linker/stack-alignment.ll

Index: llvm/test/Linker/stack-alignment.ll
===
--- /dev/null
+++ llvm/test/Linker/stack-alignment.ll
@@ -0,0 +1,15 @@
+; RUN: split-file %s %t
+; RUN: llvm-link %t/main.ll %t/8.ll
+; RUN: not llvm-link %t/main.ll %t/16.ll 2>&1 | FileCheck --check-prefix=CHECK-16 %s
+
+;--- main.ll
+; NONE: error: linking module flags 'override-stack-alignment': IDs have conflicting values
+; CHECK-16: error: linking module flags 'override-stack-alignment': IDs have conflicting values
+!llvm.module.flags = !{!0}
+!0 = !{i32 1, !"override-stack-alignment", i32 8}
+;--- 8.ll
+!llvm.module.flags = !{!0}
+!0 = !{i32 1, !"override-stack-alignment", i32 8}
+;--- 16.ll
+!llvm.module.flags = !{!0}
+!0 = !{i32 1, !"override-stack-alignment", i32 16}
Index: llvm/test/CodeGen/X86/x86-64-xmm-spill-unaligned.ll
===
--- llvm/test/CodeGen/X86/x86-64-xmm-spill-unaligned.ll
+++ llvm/test/CodeGen/X86/x86-64-xmm-spill-unaligned.ll
@@ -2,7 +2,7 @@
 ; elements (here: XMM spills) are accessed using instructions that tolerate
 ; unaligned access.
 ;
-; RUN: llc -mtriple=x86_64-unknown-linux-gnu -mcpu=x86-64 -mattr=+sse,+sse-unaligned-mem -stack-alignment=8 --frame-pointer=all < %s | FileCheck %s
+; RUN: llc -mtriple=x86_64-unknown-linux-gnu -mcpu=x86-64 -mattr=+sse,+sse-unaligned-mem --frame-pointer=all < %s | FileCheck %s
 
 define dso_local preserve_allcc void @func() #0 {
 ; CHECK-LABEL: func:
@@ -13,3 +13,5 @@
 }
 
 attributes #0 = { nounwind }
+!llvm.module.flags = !{!0}
+!0 = !{i32 2, !"override-stack-alignment", i32 8}
Index: llvm/test/CodeGen/X86/x86-64-baseptr.ll
===
--- llvm/test/CodeGen/X86/x86-64-baseptr.ll
+++ llvm/test/CodeGen/X86/x86-64-baseptr.ll
@@ -1,6 +1,6 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
-; RUN: llc -mtriple=x86_64-pc-linux -stackrealign -stack-alignment=32 < %s | FileCheck %s
-; RUN: llc -mtriple=x86_64-pc-linux-gnux32 -stackrealign -stack-alignment=32 < %s | FileCheck -check-prefix=X32ABI %s
+; RUN: llc -mtriple=x86_64-pc-linux -stackrealign < %s | FileCheck %s
+; RUN: llc -mtriple=x86_64-pc-linux-gnux32 -stackrealign < %s | FileCheck -check-prefix=X32ABI %s
 
 ; This should run with NaCl as well ( -mtriple=x86_64-pc-nacl ) but currently doesn't due to PR22655
 
@@ -65,3 +65,5 @@
 }
 
 attributes #0 = { nounwind "frame-pointer"="all"}
+!llvm.module.flags = !{!0}
+!0 = !{i32 2, !"override-stack-alignment", i32 32}
Index: llvm/test/CodeGen/X86/unaligned-spill-folding.ll
===
--- llvm/test/CodeGen/X86/unaligned-spill-folding.ll
+++ llvm/test/CodeGen/X86/unaligned-spill-folding.ll
@@ -1,7 +1,11 @@
-; RUN: llc -mtriple=i386-unknown-freebsd -mcpu=core2 -stack-alignment=4 -relocation-model=pic < %s | FileCheck %s -check-prefix=UNALIGNED
-; RUN: llc -mtriple=i386-unknown-freebsd -mcpu=core2 -stack-alignment=16 -relocation-model=pic < %s | FileCheck %s -check-prefix=ALIGNED
-; RUN: llc -mtriple=i386-unknown-freebsd -mcpu=core2 -stack-alignment=4 -stackrealign -relocation-model=pic < %s | FileCheck %s -check-prefix=FORCEALIGNED
+; RUN: split-file %s %t
+; RUN: cat %t/main.ll %t/align4.ll > %t/a2.ll
+; RUN: cat %t/main.ll %t/align16.ll > %t/b2.ll
+; RUN: llc -mtriple=i386-unknown-freebsd -mcpu=core2 -relocation-model=pic < %t/a2.ll | FileCheck %s -check-prefix=UNALIGNED
+; RUN: llc -mtriple=i386-unknown-freebsd -mcpu=core2 -relocation-model=pic < %t/b2.ll | FileCheck %s 

[PATCH] D103048: [IR] make -stack-alignment= into a module attr

2021-06-08 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

Thanks for the review!

Notified downstream dependents:

- https://github.com/llvm-hs/llvm-hs/issues/345
- https://github.com/halide/Halide/issues/6079


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103048/new/

https://reviews.llvm.org/D103048

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D103048: [IR] make -stack-alignment= into a module attr

2021-06-08 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson accepted this revision.
tejohnson added a comment.
This revision is now accepted and ready to land.

lgtm




Comment at: llvm/test/Linker/stack-alignment.ll:11
+;--- main.ll
+; NONE: error: linking module flags 'override-stack-alignment': IDs have 
conflicting values
+; CHECK-16: error: linking module flags 'override-stack-alignment': IDs have 
conflicting values

nickdesaulniers wrote:
> tejohnson wrote:
> > Will you get this error currently? I thought per comment and behavior of 
> > Error that it shouldn't give an error.
> the `RUN` line for that check is missing the `:`, so it's not actually run.  
> I think I'll create the new `ModFlagBehavior` as a child revision to this 
> commit, in which I add the new behavior and upgrade this attribute to use it, 
> adding in this unit test.
> 
> ---
> 
> Now that I've had time to play with implementing such a `ModFlagBehavior`; it 
> looks like it's not possible to create a module with such semantics then test 
> it properly with `llvm-link`.  The reason is that `llvm-link` is structured 
> to start with an empty module ("Composite"), then link in the first module 
> specified on the command line, then link in the rest of the modules 
> specified.  So we can't disambiguate between the initial empty module being 
> linked against the initial source file with the MDNode vs 2 full modules 
> where 1 is missing the MD node.  (ie. for two input source files, the main 
> module linking logic is run twice, not once).
> 
> See: https://reviews.llvm.org/D103851
> 
> ---
> 
> In that case, I just plan to remove this test case then, since it wasn't 
> being `RUN` anyways.
Ah ok, that makes sense. For regular LTO via the linker we also start with an 
empty module and link into it, so it would have the same issue.

Presumably we could detect and handle the case of linking into a completely 
empty module? But that can be revisited later.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103048/new/

https://reviews.llvm.org/D103048

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D103048: [IR] make -stack-alignment= into a module attr

2021-06-07 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 350443.
nickdesaulniers added a comment.

- remove test for module without module attr


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103048/new/

https://reviews.llvm.org/D103048

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGen/stackrealign-main.c
  llvm/include/llvm/IR/Module.h
  llvm/include/llvm/Target/TargetOptions.h
  llvm/lib/CodeGen/CommandFlags.cpp
  llvm/lib/IR/Module.cpp
  llvm/lib/Target/X86/X86TargetMachine.cpp
  llvm/test/CodeGen/Generic/ForceStackAlign.ll
  llvm/test/CodeGen/X86/base-pointer-and-cmpxchg.ll
  llvm/test/CodeGen/X86/base-pointer-and-mwaitx.ll
  llvm/test/CodeGen/X86/dynamic-allocas-VLAs-stack-align.ll
  llvm/test/CodeGen/X86/dynamic-allocas-VLAs.ll
  llvm/test/CodeGen/X86/force-align-stack-alloca.ll
  llvm/test/CodeGen/X86/hipe-cc.ll
  llvm/test/CodeGen/X86/hipe-cc64.ll
  llvm/test/CodeGen/X86/movtopush-stack-align.ll
  llvm/test/CodeGen/X86/movtopush.ll
  llvm/test/CodeGen/X86/pr11468.ll
  llvm/test/CodeGen/X86/unaligned-spill-folding.ll
  llvm/test/CodeGen/X86/x86-64-baseptr.ll
  llvm/test/CodeGen/X86/x86-64-xmm-spill-unaligned.ll
  llvm/test/Linker/stack-alignment.ll

Index: llvm/test/Linker/stack-alignment.ll
===
--- /dev/null
+++ llvm/test/Linker/stack-alignment.ll
@@ -0,0 +1,15 @@
+; RUN: split-file %s %t
+; RUN: llvm-link %t/main.ll %t/8.ll
+; RUN: not llvm-link %t/main.ll %t/16.ll 2>&1 | FileCheck --check-prefix=CHECK-16 %s
+
+;--- main.ll
+; NONE: error: linking module flags 'override-stack-alignment': IDs have conflicting values
+; CHECK-16: error: linking module flags 'override-stack-alignment': IDs have conflicting values
+!llvm.module.flags = !{!0}
+!0 = !{i32 1, !"override-stack-alignment", i32 8}
+;--- 8.ll
+!llvm.module.flags = !{!0}
+!0 = !{i32 1, !"override-stack-alignment", i32 8}
+;--- 16.ll
+!llvm.module.flags = !{!0}
+!0 = !{i32 1, !"override-stack-alignment", i32 16}
Index: llvm/test/CodeGen/X86/x86-64-xmm-spill-unaligned.ll
===
--- llvm/test/CodeGen/X86/x86-64-xmm-spill-unaligned.ll
+++ llvm/test/CodeGen/X86/x86-64-xmm-spill-unaligned.ll
@@ -2,7 +2,7 @@
 ; elements (here: XMM spills) are accessed using instructions that tolerate
 ; unaligned access.
 ;
-; RUN: llc -mtriple=x86_64-unknown-linux-gnu -mcpu=x86-64 -mattr=+sse,+sse-unaligned-mem -stack-alignment=8 --frame-pointer=all < %s | FileCheck %s
+; RUN: llc -mtriple=x86_64-unknown-linux-gnu -mcpu=x86-64 -mattr=+sse,+sse-unaligned-mem --frame-pointer=all < %s | FileCheck %s
 
 define dso_local preserve_allcc void @func() #0 {
 ; CHECK-LABEL: func:
@@ -13,3 +13,5 @@
 }
 
 attributes #0 = { nounwind }
+!llvm.module.flags = !{!0}
+!0 = !{i32 2, !"override-stack-alignment", i32 8}
Index: llvm/test/CodeGen/X86/x86-64-baseptr.ll
===
--- llvm/test/CodeGen/X86/x86-64-baseptr.ll
+++ llvm/test/CodeGen/X86/x86-64-baseptr.ll
@@ -1,6 +1,6 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
-; RUN: llc -mtriple=x86_64-pc-linux -stackrealign -stack-alignment=32 < %s | FileCheck %s
-; RUN: llc -mtriple=x86_64-pc-linux-gnux32 -stackrealign -stack-alignment=32 < %s | FileCheck -check-prefix=X32ABI %s
+; RUN: llc -mtriple=x86_64-pc-linux -stackrealign < %s | FileCheck %s
+; RUN: llc -mtriple=x86_64-pc-linux-gnux32 -stackrealign < %s | FileCheck -check-prefix=X32ABI %s
 
 ; This should run with NaCl as well ( -mtriple=x86_64-pc-nacl ) but currently doesn't due to PR22655
 
@@ -65,3 +65,5 @@
 }
 
 attributes #0 = { nounwind "frame-pointer"="all"}
+!llvm.module.flags = !{!0}
+!0 = !{i32 2, !"override-stack-alignment", i32 32}
Index: llvm/test/CodeGen/X86/unaligned-spill-folding.ll
===
--- llvm/test/CodeGen/X86/unaligned-spill-folding.ll
+++ llvm/test/CodeGen/X86/unaligned-spill-folding.ll
@@ -1,7 +1,11 @@
-; RUN: llc -mtriple=i386-unknown-freebsd -mcpu=core2 -stack-alignment=4 -relocation-model=pic < %s | FileCheck %s -check-prefix=UNALIGNED
-; RUN: llc -mtriple=i386-unknown-freebsd -mcpu=core2 -stack-alignment=16 -relocation-model=pic < %s | FileCheck %s -check-prefix=ALIGNED
-; RUN: llc -mtriple=i386-unknown-freebsd -mcpu=core2 -stack-alignment=4 -stackrealign -relocation-model=pic < %s | FileCheck %s -check-prefix=FORCEALIGNED
+; RUN: split-file %s %t
+; RUN: cat %t/main.ll %t/align4.ll > %t/a2.ll
+; RUN: cat %t/main.ll %t/align16.ll > %t/b2.ll
+; RUN: llc -mtriple=i386-unknown-freebsd -mcpu=core2 -relocation-model=pic < %t/a2.ll | FileCheck %s -check-prefix=UNALIGNED
+; RUN: llc -mtriple=i386-unknown-freebsd -mcpu=core2 -relocation-model=pic < %t/b2.ll | FileCheck %s -check-prefix=ALIGNED
+; RUN: llc -mtriple=i386-unknown-freebsd -mcpu=core2 -stackrealign -relocation-model=pic < %t/a2.ll | 

[PATCH] D103048: [IR] make -stack-alignment= into a module attr

2021-06-07 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: llvm/test/Linker/stack-alignment.ll:11
+;--- main.ll
+; NONE: error: linking module flags 'override-stack-alignment': IDs have 
conflicting values
+; CHECK-16: error: linking module flags 'override-stack-alignment': IDs have 
conflicting values

tejohnson wrote:
> Will you get this error currently? I thought per comment and behavior of 
> Error that it shouldn't give an error.
the `RUN` line for that check is missing the `:`, so it's not actually run.  I 
think I'll create the new `ModFlagBehavior` as a child revision to this commit, 
in which I add the new behavior and upgrade this attribute to use it, adding in 
this unit test.

---

Now that I've had time to play with implementing such a `ModFlagBehavior`; it 
looks like it's not possible to create a module with such semantics then test 
it properly with `llvm-link`.  The reason is that `llvm-link` is structured to 
start with an empty module ("Composite"), then link in the first module 
specified on the command line, then link in the rest of the modules specified.  
So we can't disambiguate between the initial empty module being linked against 
the initial source file with the MDNode vs 2 full modules where 1 is missing 
the MD node.  (ie. for two input source files, the main module linking logic is 
run twice, not once).

See: https://reviews.llvm.org/D103851

---

In that case, I just plan to remove this test case then, since it wasn't being 
`RUN` anyways.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103048/new/

https://reviews.llvm.org/D103048

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D103048: [IR] make -stack-alignment= into a module attr

2021-06-07 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

In D103048#2795456 , @tejohnson wrote:

>> Curiously, using ModFlagBehavior::Error doesn't error if one of two modules 
>> being linked together doesn't have such a module level attribute.
>
> Yeah, there's a Require behavior, but that only allows you to specify what 
> the value should be after linking modules. Barring changing the behavior of 
> Error, which I'm guessing is relied upon too many places, the main thing I 
> can think of is to add a new module flag behavior with tbd name that is 
> essentially like Error but treats a module without the module flag as having 
> a conflicting value and issues an error for that as well.

I agree, that's what I was thinking we'd need to do, so I'm glad you came to a 
similar conclusion.  I'll work on implementing a new `ModFlagBehavior` in this 
patch implementing such semantics that then this module level IR node can use.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103048/new/

https://reviews.llvm.org/D103048

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D103048: [IR] make -stack-alignment= into a module attr

2021-06-02 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.
Herald added a subscriber: ormris.

> Curiously, using ModFlagBehavior::Error doesn't error if one of two modules 
> being linked together doesn't have such a module level attribute.

Yeah, there's a Require behavior, but that only allows you to specify what the 
value should be after linking modules. Barring changing the behavior of Error, 
which I'm guessing is relied upon too many places, the main thing I can think 
of is to add a new module flag behavior with tbd name that is essentially like 
Error but treats a module without the module flag as having a conflicting value 
and issues an error for that as well.




Comment at: llvm/test/Linker/stack-alignment.ll:11
+;--- main.ll
+; NONE: error: linking module flags 'override-stack-alignment': IDs have 
conflicting values
+; CHECK-16: error: linking module flags 'override-stack-alignment': IDs have 
conflicting values

Will you get this error currently? I thought per comment and behavior of Error 
that it shouldn't give an error.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103048/new/

https://reviews.llvm.org/D103048

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D103048: [IR] make -stack-alignment= into a module attr

2021-06-01 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

bumping for review (or suggestions of additional reviewers)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103048/new/

https://reviews.llvm.org/D103048

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D103048: [IR] make -stack-alignment= into a module attr

2021-05-24 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers created this revision.
nickdesaulniers added reviewers: tejohnson, craig.topper, RKSimon.
Herald added subscribers: dexonsmith, pengfei, hiraditya, qcolombet.
nickdesaulniers requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Similar to D102742 , specifying the stack 
alignment via CodegenOpts means
that this flag gets dropped during LTO, unless the command line is
respecified 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.

Curiously, using ModFlagBehavior::Error doesn't error if one of two
modules being linked together doesn't have such a module level
attribute.

Looks like external dependencies might need a fix:

- https://github.com/llvm-hs/llvm-hs
- https://github.com/halide/Halide

Link: https://github.com/ClangBuiltLinux/linux/issues/1377


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D103048

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGen/stackrealign-main.c
  llvm/include/llvm/IR/Module.h
  llvm/include/llvm/Target/TargetOptions.h
  llvm/lib/CodeGen/CommandFlags.cpp
  llvm/lib/IR/Module.cpp
  llvm/lib/Target/X86/X86TargetMachine.cpp
  llvm/test/CodeGen/Generic/ForceStackAlign.ll
  llvm/test/CodeGen/X86/base-pointer-and-cmpxchg.ll
  llvm/test/CodeGen/X86/base-pointer-and-mwaitx.ll
  llvm/test/CodeGen/X86/dynamic-allocas-VLAs-stack-align.ll
  llvm/test/CodeGen/X86/dynamic-allocas-VLAs.ll
  llvm/test/CodeGen/X86/force-align-stack-alloca.ll
  llvm/test/CodeGen/X86/hipe-cc.ll
  llvm/test/CodeGen/X86/hipe-cc64.ll
  llvm/test/CodeGen/X86/movtopush-stack-align.ll
  llvm/test/CodeGen/X86/movtopush.ll
  llvm/test/CodeGen/X86/pr11468.ll
  llvm/test/CodeGen/X86/unaligned-spill-folding.ll
  llvm/test/CodeGen/X86/x86-64-baseptr.ll
  llvm/test/CodeGen/X86/x86-64-xmm-spill-unaligned.ll
  llvm/test/Linker/stack-alignment.ll

Index: llvm/test/Linker/stack-alignment.ll
===
--- /dev/null
+++ llvm/test/Linker/stack-alignment.ll
@@ -0,0 +1,22 @@
+; RUN: split-file %s %t
+; TODO: it seems that ModFlagBehavior::Error doesn't error when a module is
+;   missing a module level attribute. IRLinker::linkModuleFlagsMetadata
+;   seems to think this is ok. Debugging stack mismatch errors is not a fun
+;   time.
+; RUN not llvm-link %t/main.ll %t/none.ll 2>&1 | FileCheck --check-prefix=NONE %s
+; RUN: llvm-link %t/main.ll %t/8.ll
+; RUN: not llvm-link %t/main.ll %t/16.ll 2>&1 | FileCheck --check-prefix=CHECK-16 %s
+
+;--- main.ll
+; NONE: error: linking module flags 'override-stack-alignment': IDs have conflicting values
+; CHECK-16: error: linking module flags 'override-stack-alignment': IDs have conflicting values
+!llvm.module.flags = !{!0}
+!0 = !{i32 1, !"override-stack-alignment", i32 8}
+
+;--- none.ll
+;--- 8.ll
+!llvm.module.flags = !{!0}
+!0 = !{i32 1, !"override-stack-alignment", i32 8}
+;--- 16.ll
+!llvm.module.flags = !{!0}
+!0 = !{i32 1, !"override-stack-alignment", i32 16}
Index: llvm/test/CodeGen/X86/x86-64-xmm-spill-unaligned.ll
===
--- llvm/test/CodeGen/X86/x86-64-xmm-spill-unaligned.ll
+++ llvm/test/CodeGen/X86/x86-64-xmm-spill-unaligned.ll
@@ -2,7 +2,7 @@
 ; elements (here: XMM spills) are accessed using instructions that tolerate
 ; unaligned access.
 ;
-; RUN: llc -mtriple=x86_64-unknown-linux-gnu -mcpu=x86-64 -mattr=+sse,+sse-unaligned-mem -stack-alignment=8 --frame-pointer=all < %s | FileCheck %s
+; RUN: llc -mtriple=x86_64-unknown-linux-gnu -mcpu=x86-64 -mattr=+sse,+sse-unaligned-mem --frame-pointer=all < %s | FileCheck %s
 
 define dso_local preserve_allcc void @func() #0 {
 ; CHECK-LABEL: func:
@@ -13,3 +13,5 @@
 }
 
 attributes #0 = { nounwind }
+!llvm.module.flags = !{!0}
+!0 = !{i32 2, !"override-stack-alignment", i32 8}
Index: llvm/test/CodeGen/X86/x86-64-baseptr.ll
===
--- llvm/test/CodeGen/X86/x86-64-baseptr.ll
+++ llvm/test/CodeGen/X86/x86-64-baseptr.ll
@@ -1,6 +1,6 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
-; RUN: llc -mtriple=x86_64-pc-linux -stackrealign -stack-alignment=32 < %s | FileCheck %s
-; RUN: llc -mtriple=x86_64-pc-linux-gnux32 -stackrealign -stack-alignment=32 < %s | FileCheck -check-prefix=X32ABI %s
+; RUN: llc -mtriple=x86_64-pc-linux -stackrealign < %s | FileCheck %s
+; RUN: llc -mtriple=x86_64-pc-linux-gnux32 -stackrealign < %s | FileCheck -check-prefix=X32ABI %s
 
 ; This should run with NaCl as well ( -mtriple=x86_64-pc-nacl ) but currently doesn't due to PR22655
 
@@ -65,3 +65,5 @@
 }
 
 attributes #0 = { nounwind "frame-pointer"="all"}
+!llvm.module.flags = !{!0}
+!0 = !{i32 2, !"override-stack-alignment", i32 32}