[llvm-branch-commits] [llvm] release/18.x: [llvm-objdump] Add support for the PT_OPENBSD_SYSCALLS segment type. (#82121) (PR #82317)

2024-02-20 Thread via llvm-branch-commits

https://github.com/llvmbot created 
https://github.com/llvm/llvm-project/pull/82317

Backport 1b894864862d8049e4a2567a472efdc2eda1e035

Requested by: @brad0

>From 2c9dc98d2605f89d67b3ebfee63b55d7c81c5bea Mon Sep 17 00:00:00 2001
From: Frederic Cambus 
Date: Tue, 20 Feb 2024 09:11:54 +0100
Subject: [PATCH] [llvm-objdump] Add support for the PT_OPENBSD_SYSCALLS
 segment type. (#82121)

Reference: https://github.com/openbsd/src/blob/master/sys/sys/exec_elf.h
(cherry picked from commit 1b894864862d8049e4a2567a472efdc2eda1e035)
---
 llvm/test/tools/llvm-objdump/openbsd-headers.test | 3 +++
 llvm/tools/llvm-objdump/ELFDump.cpp   | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/llvm/test/tools/llvm-objdump/openbsd-headers.test 
b/llvm/test/tools/llvm-objdump/openbsd-headers.test
index f547854fdf..84fa59bdf89f5c 100644
--- a/llvm/test/tools/llvm-objdump/openbsd-headers.test
+++ b/llvm/test/tools/llvm-objdump/openbsd-headers.test
@@ -11,6 +11,8 @@
 # CHECK-NEXT:  filesz 0x memsz 0x flags ---
 # CHECK-NEXT: OPENBSD_NOBTCFI off0x vaddr 
0x paddr 0x align 2**0
 # CHECK-NEXT:  filesz 0x memsz 0x flags ---
+# CHECK-NEXT: OPENBSD_SYSCALLS off0x vaddr 
0x paddr 0x align 2**0
+# CHECK-NEXT:  filesz 0x memsz 0x flags ---
 # CHECK-NEXT: OPENBSD_BOOTDATA off0x vaddr 
0x paddr 0x align 2**0
 # CHECK-NEXT:  filesz 0x memsz 0x flags ---
 
@@ -25,4 +27,5 @@ ProgramHeaders:
   - Type: 0x65a3dbe6 ## PT_OPENBSD_RANDOMIZE
   - Type: 0x65a3dbe7 ## PT_OPENBSD_WXNEEDED
   - Type: 0x65a3dbe8 ## PT_OPENBSD_NOBTCFI
+  - Type: 0x65a3dbe9 ## PT_OPENBSD_SYSCALLS
   - Type: 0x65a41be6 ## PT_OPENBSD_BOOTDATA
diff --git a/llvm/tools/llvm-objdump/ELFDump.cpp 
b/llvm/tools/llvm-objdump/ELFDump.cpp
index 34861ee92128fd..fda99bd6d33e17 100644
--- a/llvm/tools/llvm-objdump/ELFDump.cpp
+++ b/llvm/tools/llvm-objdump/ELFDump.cpp
@@ -291,6 +291,9 @@ template  void 
ELFDumper::printProgramHeaders() {
 case ELF::PT_OPENBSD_RANDOMIZE:
   outs() << "OPENBSD_RANDOMIZE ";
   break;
+case ELF::PT_OPENBSD_SYSCALLS:
+  outs() << "OPENBSD_SYSCALLS ";
+  break;
 case ELF::PT_OPENBSD_WXNEEDED:
   outs() << "OPENBSD_WXNEEDED ";
   break;

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


[llvm-branch-commits] [llvm] release/18.x: [llvm-objdump] Add support for the PT_OPENBSD_SYSCALLS segment type. (#82121) (PR #82317)

2024-02-20 Thread via llvm-branch-commits

https://github.com/llvmbot milestoned 
https://github.com/llvm/llvm-project/pull/82317
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] release/18.x: [llvm-objdump] Add support for the PT_OPENBSD_SYSCALLS segment type. (#82121) (PR #82317)

2024-02-20 Thread via llvm-branch-commits

llvmbot wrote:

@fcambus What do you think about merging this PR to the release branch?

https://github.com/llvm/llvm-project/pull/82317
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] release/18.x: [llvm-objdump] Add support for the PT_OPENBSD_SYSCALLS segment type. (#82121) (PR #82317)

2024-02-20 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-llvm-binary-utilities

Author: None (llvmbot)


Changes

Backport 1b894864862d8049e4a2567a472efdc2eda1e035

Requested by: @brad0

---
Full diff: https://github.com/llvm/llvm-project/pull/82317.diff


2 Files Affected:

- (modified) llvm/test/tools/llvm-objdump/openbsd-headers.test (+3) 
- (modified) llvm/tools/llvm-objdump/ELFDump.cpp (+3) 


``diff
diff --git a/llvm/test/tools/llvm-objdump/openbsd-headers.test 
b/llvm/test/tools/llvm-objdump/openbsd-headers.test
index f547854fdf..84fa59bdf89f5c 100644
--- a/llvm/test/tools/llvm-objdump/openbsd-headers.test
+++ b/llvm/test/tools/llvm-objdump/openbsd-headers.test
@@ -11,6 +11,8 @@
 # CHECK-NEXT:  filesz 0x memsz 0x flags ---
 # CHECK-NEXT: OPENBSD_NOBTCFI off0x vaddr 
0x paddr 0x align 2**0
 # CHECK-NEXT:  filesz 0x memsz 0x flags ---
+# CHECK-NEXT: OPENBSD_SYSCALLS off0x vaddr 
0x paddr 0x align 2**0
+# CHECK-NEXT:  filesz 0x memsz 0x flags ---
 # CHECK-NEXT: OPENBSD_BOOTDATA off0x vaddr 
0x paddr 0x align 2**0
 # CHECK-NEXT:  filesz 0x memsz 0x flags ---
 
@@ -25,4 +27,5 @@ ProgramHeaders:
   - Type: 0x65a3dbe6 ## PT_OPENBSD_RANDOMIZE
   - Type: 0x65a3dbe7 ## PT_OPENBSD_WXNEEDED
   - Type: 0x65a3dbe8 ## PT_OPENBSD_NOBTCFI
+  - Type: 0x65a3dbe9 ## PT_OPENBSD_SYSCALLS
   - Type: 0x65a41be6 ## PT_OPENBSD_BOOTDATA
diff --git a/llvm/tools/llvm-objdump/ELFDump.cpp 
b/llvm/tools/llvm-objdump/ELFDump.cpp
index 34861ee92128fd..fda99bd6d33e17 100644
--- a/llvm/tools/llvm-objdump/ELFDump.cpp
+++ b/llvm/tools/llvm-objdump/ELFDump.cpp
@@ -291,6 +291,9 @@ template  void 
ELFDumper::printProgramHeaders() {
 case ELF::PT_OPENBSD_RANDOMIZE:
   outs() << "OPENBSD_RANDOMIZE ";
   break;
+case ELF::PT_OPENBSD_SYSCALLS:
+  outs() << "OPENBSD_SYSCALLS ";
+  break;
 case ELF::PT_OPENBSD_WXNEEDED:
   outs() << "OPENBSD_WXNEEDED ";
   break;

``




https://github.com/llvm/llvm-project/pull/82317
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] release/18.x: [llvm-readobj] Add support for the PT_OPENBSD_SYSCALLS segment type. (#82122) (PR #82318)

2024-02-20 Thread via llvm-branch-commits

https://github.com/llvmbot created 
https://github.com/llvm/llvm-project/pull/82318

Backport a8d7511811c7d7c689c3e8f858e8e00a56aba152

Requested by: @brad0

>From 88153334fe0232f51eb8ca40d93331ae603f2a85 Mon Sep 17 00:00:00 2001
From: Frederic Cambus 
Date: Tue, 20 Feb 2024 09:12:58 +0100
Subject: [PATCH] [llvm-readobj] Add support for the PT_OPENBSD_SYSCALLS
 segment type. (#82122)

Reference: https://github.com/openbsd/src/blob/master/sys/sys/exec_elf.h
(cherry picked from commit a8d7511811c7d7c689c3e8f858e8e00a56aba152)
---
 .../llvm-readobj/ELF/program-headers.test | 254 ++
 llvm/tools/llvm-readobj/ELFDumper.cpp |   1 +
 2 files changed, 138 insertions(+), 117 deletions(-)

diff --git a/llvm/test/tools/llvm-readobj/ELF/program-headers.test 
b/llvm/test/tools/llvm-readobj/ELF/program-headers.test
index 702a06b6403f0a..856cf378ddad95 100644
--- a/llvm/test/tools/llvm-readobj/ELF/program-headers.test
+++ b/llvm/test/tools/llvm-readobj/ELF/program-headers.test
@@ -29,68 +29,70 @@
 # RUN:   FileCheck %s --check-prefixes=ELF64,MAPPING --strict-whitespace 
--match-full-lines
 # RUN: llvm-readobj -l %t64.elf | FileCheck %s 
--check-prefixes=ELF-LLVM,ELF64-LLVM
 
-#   ELF32:There are 25 program headers, starting at offset 52
+#   ELF32:There are 26 program headers, starting at offset 52
 # ELF32-EMPTY:
 # ELF32-NEXT:Program Headers:
 # ELF32-NEXT:  Type   Offset   VirtAddr   PhysAddr   FileSiz MemSiz  
Flg Align
-# ELF32-NEXT:  PHDR   0x000354 0x1000 0x1000 0x3 0x3  
W  0x1
-# ELF32-NEXT:  PHDR   0x000357 0x2000 0x2000 0x7 0x7   
E 0x1
-# ELF32-NEXT:  NULL   0x000357 0x2000 0x2000 0x7 0x7   
E 0x1
-# ELF32-NEXT:  DYNAMIC0x000354 0x1000 0x1000 0x3 0x3 
RWE 0x1
-# ELF32-NEXT:  INTERP 0x00035e 0x3000 0x3000 0x4 0x4 
RW  0x1
+# ELF32-NEXT:  PHDR   0x000374 0x1000 0x1000 0x3 0x3  
W  0x1
+# ELF32-NEXT:  PHDR   0x000377 0x2000 0x2000 0x7 0x7   
E 0x1
+# ELF32-NEXT:  NULL   0x000377 0x2000 0x2000 0x7 0x7   
E 0x1
+# ELF32-NEXT:  DYNAMIC0x000374 0x1000 0x1000 0x3 0x3 
RWE 0x1
+# ELF32-NEXT:  INTERP 0x00037e 0x3000 0x3000 0x4 0x4 
RW  0x1
 # ELF32-NEXT:  [Requesting program interpreter: ABC]
-# ELF32-NEXT:  NOTE   0x000354 0x1000 0x1000 0x3 0x3   
  0x1
-# ELF32-NEXT:  SHLIB  0x000354 0x1000 0x1000 0x1 0x1   
  0x1
-# ELF32-NEXT:  TLS0x000362 0x4000 0x4000 0x1 0x1   
  0x1
-# ELF32-NEXT:  : 0x6000 0x000354 0x1000 0x1000 0x3 
0x3 0x1
-# ELF32-NEXT:  GNU_EH_FRAME   0x000354 0x1000 0x1000 0x3 0x3   
  0x1
-# ELF32-NEXT:  SUNW_UNWIND0x000354 0x1000 0x1000 0x3 0x3   
  0x1
-# ELF32-NEXT:  GNU_STACK  0x000354 0x1000 0x1000 0x3 0x3   
  0x1
-# ELF32-NEXT:  GNU_RELRO  0x000354 0x1000 0x1000 0x3 0x3   
  0x1
-# ELF32-NEXT:  GNU_PROPERTY   0x000354 0x1000 0x1000 0x3 0x3   
  0x1
-# ELF32-NEXT:  OPENBSD_MUTABLE 0x000354 0x1000 0x1000 0x3 0x3  
   0x1
-# ELF32-NEXT:  OPENBSD_RANDOMIZE 0x000354 0x1000 0x1000 0x3 
0x3 0x1
-# ELF32-NEXT:  OPENBSD_WXNEEDED 0x000354 0x1000 0x1000 0x3 0x3 
0x1
-# ELF32-NEXT:  OPENBSD_NOBTCFI 0x000354 0x1000 0x1000 0x3 0x3  
   0x1
-# ELF32-NEXT:  OPENBSD_BOOTDATA 0x000354 0x1000 0x1000 0x3 0x3 
0x1
-# ELF32-NEXT:  : 0x6fff 0x000354 0x1000 0x1000 0x3 
0x3 0x1
-# ELF32-NEXT:  : 0x7000 0x000354 0x1000 0x1000 0x3 
0x3 0x1
-# ELF32-NEXT:  : 0x7001 0x000354 0x1000 0x1000 0x3 
0x3 0x1
-# ELF32-NEXT:  : 0x7002 0x000354 0x1000 0x1000 0x3 
0x3 0x1
-# ELF32-NEXT:  : 0x7003 0x000354 0x1000 0x1000 0x3 
0x3 0x1
-# ELF32-NEXT:  : 0x7fff 0x000354 0x1000 0x1000 0x3 
0x3 0x1
+# ELF32-NEXT:  NOTE   0x000374 0x1000 0x1000 0x3 0x3   
  0x1
+# ELF32-NEXT:  SHLIB  0x000374 0x1000 0x1000 0x1 0x1   
  0x1
+# ELF32-NEXT:  TLS0x000382 0x4000 0x4000 0x1 0x1   
  0x1
+# ELF32-NEXT:  : 0x6000 0x000374 0x1000 0x1000 0x3 
0x3 0x1
+# ELF32-NEXT:  GNU_EH_FRAME   0x000374 0x1000 0x1000 0x3 0x3   
  0x1
+# ELF32-NEXT:  SUNW_UNWIND0x000374 0x1000 0x1000 0x3 0x3   
  0x1
+# ELF32-NEXT:  GNU_STACK  0x000374 0x1000 0x1000 0x3 0x3   
  0x1
+# ELF32-NEXT:  GNU_RELRO  0x000374 0x1000 0x1000 0x3 0x3   
  0x1
+# ELF32-NEXT:  GNU_PROPERTY   0x000374 0x1000 0x1000 0x3 0x3   
  0x1
+# ELF32-NEXT:  OPENBSD_MUTABLE 0x000374 0x1000 0x1000 0x3 0x3

[llvm-branch-commits] [llvm] release/18.x: [llvm-readobj] Add support for the PT_OPENBSD_SYSCALLS segment type. (#82122) (PR #82318)

2024-02-20 Thread via llvm-branch-commits

https://github.com/llvmbot milestoned 
https://github.com/llvm/llvm-project/pull/82318
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] release/18.x: [llvm-readobj] Add support for the PT_OPENBSD_SYSCALLS segment type. (#82122) (PR #82318)

2024-02-20 Thread via llvm-branch-commits

llvmbot wrote:

@brad0 What do you think about merging this PR to the release branch?

https://github.com/llvm/llvm-project/pull/82318
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] release/18.x: [llvm-readobj] Add support for the PT_OPENBSD_SYSCALLS segment type. (#82122) (PR #82318)

2024-02-20 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-llvm-binary-utilities

Author: None (llvmbot)


Changes

Backport a8d7511811c7d7c689c3e8f858e8e00a56aba152

Requested by: @brad0

---

Patch is 26.17 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/82318.diff


2 Files Affected:

- (modified) llvm/test/tools/llvm-readobj/ELF/program-headers.test (+137-117) 
- (modified) llvm/tools/llvm-readobj/ELFDumper.cpp (+1) 


``diff
diff --git a/llvm/test/tools/llvm-readobj/ELF/program-headers.test 
b/llvm/test/tools/llvm-readobj/ELF/program-headers.test
index 702a06b6403f0a..856cf378ddad95 100644
--- a/llvm/test/tools/llvm-readobj/ELF/program-headers.test
+++ b/llvm/test/tools/llvm-readobj/ELF/program-headers.test
@@ -29,68 +29,70 @@
 # RUN:   FileCheck %s --check-prefixes=ELF64,MAPPING --strict-whitespace 
--match-full-lines
 # RUN: llvm-readobj -l %t64.elf | FileCheck %s 
--check-prefixes=ELF-LLVM,ELF64-LLVM
 
-#   ELF32:There are 25 program headers, starting at offset 52
+#   ELF32:There are 26 program headers, starting at offset 52
 # ELF32-EMPTY:
 # ELF32-NEXT:Program Headers:
 # ELF32-NEXT:  Type   Offset   VirtAddr   PhysAddr   FileSiz MemSiz  
Flg Align
-# ELF32-NEXT:  PHDR   0x000354 0x1000 0x1000 0x3 0x3  
W  0x1
-# ELF32-NEXT:  PHDR   0x000357 0x2000 0x2000 0x7 0x7   
E 0x1
-# ELF32-NEXT:  NULL   0x000357 0x2000 0x2000 0x7 0x7   
E 0x1
-# ELF32-NEXT:  DYNAMIC0x000354 0x1000 0x1000 0x3 0x3 
RWE 0x1
-# ELF32-NEXT:  INTERP 0x00035e 0x3000 0x3000 0x4 0x4 
RW  0x1
+# ELF32-NEXT:  PHDR   0x000374 0x1000 0x1000 0x3 0x3  
W  0x1
+# ELF32-NEXT:  PHDR   0x000377 0x2000 0x2000 0x7 0x7   
E 0x1
+# ELF32-NEXT:  NULL   0x000377 0x2000 0x2000 0x7 0x7   
E 0x1
+# ELF32-NEXT:  DYNAMIC0x000374 0x1000 0x1000 0x3 0x3 
RWE 0x1
+# ELF32-NEXT:  INTERP 0x00037e 0x3000 0x3000 0x4 0x4 
RW  0x1
 # ELF32-NEXT:  [Requesting program interpreter: ABC]
-# ELF32-NEXT:  NOTE   0x000354 0x1000 0x1000 0x3 0x3   
  0x1
-# ELF32-NEXT:  SHLIB  0x000354 0x1000 0x1000 0x1 0x1   
  0x1
-# ELF32-NEXT:  TLS0x000362 0x4000 0x4000 0x1 0x1   
  0x1
-# ELF32-NEXT:  : 0x6000 0x000354 0x1000 0x1000 0x3 
0x3 0x1
-# ELF32-NEXT:  GNU_EH_FRAME   0x000354 0x1000 0x1000 0x3 0x3   
  0x1
-# ELF32-NEXT:  SUNW_UNWIND0x000354 0x1000 0x1000 0x3 0x3   
  0x1
-# ELF32-NEXT:  GNU_STACK  0x000354 0x1000 0x1000 0x3 0x3   
  0x1
-# ELF32-NEXT:  GNU_RELRO  0x000354 0x1000 0x1000 0x3 0x3   
  0x1
-# ELF32-NEXT:  GNU_PROPERTY   0x000354 0x1000 0x1000 0x3 0x3   
  0x1
-# ELF32-NEXT:  OPENBSD_MUTABLE 0x000354 0x1000 0x1000 0x3 0x3  
   0x1
-# ELF32-NEXT:  OPENBSD_RANDOMIZE 0x000354 0x1000 0x1000 0x3 
0x3 0x1
-# ELF32-NEXT:  OPENBSD_WXNEEDED 0x000354 0x1000 0x1000 0x3 0x3 
0x1
-# ELF32-NEXT:  OPENBSD_NOBTCFI 0x000354 0x1000 0x1000 0x3 0x3  
   0x1
-# ELF32-NEXT:  OPENBSD_BOOTDATA 0x000354 0x1000 0x1000 0x3 0x3 
0x1
-# ELF32-NEXT:  : 0x6fff 0x000354 0x1000 0x1000 0x3 
0x3 0x1
-# ELF32-NEXT:  : 0x7000 0x000354 0x1000 0x1000 0x3 
0x3 0x1
-# ELF32-NEXT:  : 0x7001 0x000354 0x1000 0x1000 0x3 
0x3 0x1
-# ELF32-NEXT:  : 0x7002 0x000354 0x1000 0x1000 0x3 
0x3 0x1
-# ELF32-NEXT:  : 0x7003 0x000354 0x1000 0x1000 0x3 
0x3 0x1
-# ELF32-NEXT:  : 0x7fff 0x000354 0x1000 0x1000 0x3 
0x3 0x1
+# ELF32-NEXT:  NOTE   0x000374 0x1000 0x1000 0x3 0x3   
  0x1
+# ELF32-NEXT:  SHLIB  0x000374 0x1000 0x1000 0x1 0x1   
  0x1
+# ELF32-NEXT:  TLS0x000382 0x4000 0x4000 0x1 0x1   
  0x1
+# ELF32-NEXT:  : 0x6000 0x000374 0x1000 0x1000 0x3 
0x3 0x1
+# ELF32-NEXT:  GNU_EH_FRAME   0x000374 0x1000 0x1000 0x3 0x3   
  0x1
+# ELF32-NEXT:  SUNW_UNWIND0x000374 0x1000 0x1000 0x3 0x3   
  0x1
+# ELF32-NEXT:  GNU_STACK  0x000374 0x1000 0x1000 0x3 0x3   
  0x1
+# ELF32-NEXT:  GNU_RELRO  0x000374 0x1000 0x1000 0x3 0x3   
  0x1
+# ELF32-NEXT:  GNU_PROPERTY   0x000374 0x1000 0x1000 0x3 0x3   
  0x1
+# ELF32-NEXT:  OPENBSD_MUTABLE 0x000374 0x1000 0x1000 0x3 0x3  
   0x1
+# ELF32-NEXT:  OPENBSD_RANDOMIZE 0x000374 0x1000 0x1000 0x3 
0x3 0x1
+# ELF32-NEXT:  OPENBSD_WXNEEDED 0x000374 0x1000 0x1000 0x3 0x3 
0x1
+# ELF32-NEXT:  OPENBSD_NOBTCFI 0x000374 0x1000 0x10

[llvm-branch-commits] [llvm] release/18.x: [llvm-readobj] Add support for the PT_OPENBSD_SYSCALLS segment type. (#82122) (PR #82318)

2024-02-20 Thread Brad Smith via llvm-branch-commits

https://github.com/brad0 approved this pull request.


https://github.com/llvm/llvm-project/pull/82318
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] release/18.x: [llvm-objdump] Add support for the PT_OPENBSD_SYSCALLS segment type. (#82121) (PR #82317)

2024-02-20 Thread Brad Smith via llvm-branch-commits

https://github.com/brad0 approved this pull request.


https://github.com/llvm/llvm-project/pull/82317
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] PR for llvm/llvm-project#79861 (PR #80832)

2024-02-20 Thread Nikita Popov via llvm-branch-commits

nikic wrote:

ping @fhahn for backport review

https://github.com/llvm/llvm-project/pull/80832
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [RISCV] Support llvm.readsteadycounter intrinsic (PR #82322)

2024-02-20 Thread Wang Pengcheng via llvm-branch-commits

https://github.com/wangpc-pp created 
https://github.com/llvm/llvm-project/pull/82322

This intrinsic was introduced by #81331, which is a lot like
`llvm.readcyclecounter`.

For the RISCV implementation, we rename `ReadCycleWide` pseudo to
`ReadCounterWide` and make it accept two operands (the low and high
parts of the counter). As for legalization and lowering parts, we
reuse the code of `ISD::READCYCLECOUNTER` (make it able to handle
both intrinsics).

Tests using Clang builtins are runned on real hardware and it works
as excepted.



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


[llvm-branch-commits] [RISCV] Support llvm.readsteadycounter intrinsic (PR #82322)

2024-02-20 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-risc-v

Author: Wang Pengcheng (wangpc-pp)


Changes

This intrinsic was introduced by #81331, which is a lot like
`llvm.readcyclecounter`.

For the RISCV implementation, we rename `ReadCycleWide` pseudo to
`ReadCounterWide` and make it accept two operands (the low and high
parts of the counter). As for legalization and lowering parts, we
reuse the code of `ISD::READCYCLECOUNTER` (make it able to handle
both intrinsics).

Tests using Clang builtins are runned on real hardware and it works
as excepted.


---
Full diff: https://github.com/llvm/llvm-project/pull/82322.diff


4 Files Affected:

- (modified) llvm/lib/Target/RISCV/RISCVISelLowering.cpp (+44-25) 
- (modified) llvm/lib/Target/RISCV/RISCVISelLowering.h (+2-2) 
- (modified) llvm/lib/Target/RISCV/RISCVInstrInfo.td (+20-13) 
- (added) llvm/test/CodeGen/RISCV/readsteadycounter.ll (+28) 


``diff
diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp 
b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index 9ab6895aed521e..32d47a669020f1 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -629,6 +629,8 @@ RISCVTargetLowering::RISCVTargetLowering(const 
TargetMachine &TM,
   // Unfortunately this can't be determined just from the ISA naming string.
   setOperationAction(ISD::READCYCLECOUNTER, MVT::i64,
  Subtarget.is64Bit() ? Legal : Custom);
+  setOperationAction(ISD::READSTEADYCOUNTER, MVT::i64,
+ Subtarget.is64Bit() ? Legal : Custom);
 
   setOperationAction({ISD::TRAP, ISD::DEBUGTRAP}, MVT::Other, Legal);
   setOperationAction(ISD::INTRINSIC_WO_CHAIN, MVT::Other, Custom);
@@ -11725,13 +11727,27 @@ void RISCVTargetLowering::ReplaceNodeResults(SDNode 
*N,
 Results.push_back(Result);
 break;
   }
-  case ISD::READCYCLECOUNTER: {
-assert(!Subtarget.is64Bit() &&
-   "READCYCLECOUNTER only has custom type legalization on riscv32");
+  case ISD::READCYCLECOUNTER:
+  case ISD::READSTEADYCOUNTER: {
+assert(!Subtarget.is64Bit() && "READCYCLECOUNTER/READSTEADYCOUNTER only "
+   "has custom type legalization on riscv32");
 
+SDValue LoCounter, HiCounter;
+MVT XLenVT = Subtarget.getXLenVT();
+if (N->getOpcode() == ISD::READCYCLECOUNTER) {
+  LoCounter = DAG.getConstant(
+  RISCVSysReg::lookupSysRegByName("CYCLE")->Encoding, DL, XLenVT);
+  HiCounter = DAG.getConstant(
+  RISCVSysReg::lookupSysRegByName("CYCLEH")->Encoding, DL, XLenVT);
+} else if (N->getOpcode() == ISD::READSTEADYCOUNTER) {
+  LoCounter = DAG.getConstant(
+  RISCVSysReg::lookupSysRegByName("TIME")->Encoding, DL, XLenVT);
+  HiCounter = DAG.getConstant(
+  RISCVSysReg::lookupSysRegByName("TIMEH")->Encoding, DL, XLenVT);
+}
 SDVTList VTs = DAG.getVTList(MVT::i32, MVT::i32, MVT::Other);
-SDValue RCW =
-DAG.getNode(RISCVISD::READ_CYCLE_WIDE, DL, VTs, N->getOperand(0));
+SDValue RCW = DAG.getNode(RISCVISD::READ_COUNTER_WIDE, DL, VTs,
+  N->getOperand(0), LoCounter, HiCounter);
 
 Results.push_back(
 DAG.getNode(ISD::BUILD_PAIR, DL, MVT::i64, RCW, RCW.getValue(1)));
@@ -16903,29 +16919,30 @@ 
RISCVTargetLowering::getTargetConstantFromLoad(LoadSDNode *Ld) const {
   return CNodeLo->getConstVal();
 }
 
-static MachineBasicBlock *emitReadCycleWidePseudo(MachineInstr &MI,
-  MachineBasicBlock *BB) {
-  assert(MI.getOpcode() == RISCV::ReadCycleWide && "Unexpected instruction");
+static MachineBasicBlock *emitReadCounterWidePseudo(MachineInstr &MI,
+MachineBasicBlock *BB) {
+  assert(MI.getOpcode() == RISCV::ReadCounterWide && "Unexpected instruction");
 
-  // To read the 64-bit cycle CSR on a 32-bit target, we read the two halves.
+  // To read a 64-bit counter CSR on a 32-bit target, we read the two halves.
   // Should the count have wrapped while it was being read, we need to try
   // again.
-  // ...
+  // For example:
+  // ```
   // read:
-  // rdcycleh x3 # load high word of cycle
-  // rdcycle  x2 # load low word of cycle
-  // rdcycleh x4 # load high word of cycle
-  // bne x3, x4, read # check if high word reads match, otherwise try again
-  // ...
+  //   csrrs x3, counter # load high word of counter
+  //   csrrs x2, counterh # load low word of counter
+  //   csrrs x4, counter # load high word of counter
+  //   bne x3, x4, read # check if high word reads match, otherwise try again
+  // ```
 
   MachineFunction &MF = *BB->getParent();
-  const BasicBlock *LLVM_BB = BB->getBasicBlock();
+  const BasicBlock *LLVMBB = BB->getBasicBlock();
   MachineFunction::iterator It = ++BB->getIterator();
 
-  MachineBasicBlock *LoopMBB = MF.CreateMachineBasicBlock(LLVM_BB);
+  MachineBasicBlock *LoopMBB = MF.CreateMachineBasicBlock(LLVMBB);
   MF.insert(It, LoopMBB);
 
-  Machin

[llvm-branch-commits] [RISCV] Support llvm.readsteadycounter intrinsic (PR #82322)

2024-02-20 Thread Wang Pengcheng via llvm-branch-commits

https://github.com/wangpc-pp edited 
https://github.com/llvm/llvm-project/pull/82322
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] release/18.x: [llvm-objcopy] Add SystemZ support (#81841) (PR #82324)

2024-02-20 Thread via llvm-branch-commits

https://github.com/llvmbot created 
https://github.com/llvm/llvm-project/pull/82324

Backport 3c02cb7492fc78fb678264cebf57ff88e478e14f

Requested by: @uweigand

>From 7ee97f1bb916424624cfd0ab961f235ed15dcc6a Mon Sep 17 00:00:00 2001
From: Ulrich Weigand 
Date: Fri, 16 Feb 2024 11:58:05 +0100
Subject: [PATCH] [llvm-objcopy] Add SystemZ support (#81841)

This is also necessary for enabling ClangBuiltLinux:
https://github.com/ClangBuiltLinux/linux/issues/1530

(cherry picked from commit 3c02cb7492fc78fb678264cebf57ff88e478e14f)
---
 llvm/test/tools/llvm-objcopy/ELF/binary-output-target.test | 6 ++
 llvm/test/tools/llvm-objcopy/ELF/cross-arch-headers.test   | 7 +++
 llvm/tools/llvm-objcopy/ObjcopyOptions.cpp | 2 ++
 3 files changed, 15 insertions(+)

diff --git a/llvm/test/tools/llvm-objcopy/ELF/binary-output-target.test 
b/llvm/test/tools/llvm-objcopy/ELF/binary-output-target.test
index fc5856691f8dca..f88b7575002a94 100644
--- a/llvm/test/tools/llvm-objcopy/ELF/binary-output-target.test
+++ b/llvm/test/tools/llvm-objcopy/ELF/binary-output-target.test
@@ -48,6 +48,9 @@
 # RUN: llvm-objcopy -I binary -O elf64-loongarch %t.txt %t.la64.o
 # RUN: llvm-readobj --file-headers %t.la64.o | FileCheck %s 
--check-prefixes=CHECK,LE,LA64,64
 
+# RUN: llvm-objcopy -I binary -O elf64-s390 %t.txt %t.s390x.o
+# RUN: llvm-readobj --file-headers %t.s390x.o | FileCheck %s 
--check-prefixes=CHECK,BE,S390X,64
+
 # CHECK: Format:
 # 32-SAME:  elf32-
 # 64-SAME:  elf64-
@@ -64,6 +67,7 @@
 # PPCLE-SAME:   powerpcle{{$}}
 # SPARC-SAME:   sparc
 # SPARCEL-SAME: sparc
+# S390X-SAME:   s390
 # X86-64-SAME:  x86-64
 
 # AARCH64-NEXT: Arch: aarch64
@@ -81,6 +85,7 @@
 # RISCV64-NEXT: Arch: riscv64
 # SPARC-NEXT:   Arch: sparc{{$}}
 # SPARCEL-NEXT: Arch: sparcel
+# S390X-NEXT:   Arch: s390x
 # X86-64-NEXT:  Arch: x86_64
 
 # 32-NEXT:  AddressSize: 32bit
@@ -116,6 +121,7 @@
 # RISCV64-NEXT:   Machine: EM_RISCV (0xF3)
 # SPARC-NEXT: Machine: EM_SPARC (0x2)
 # SPARCEL-NEXT:   Machine: EM_SPARC (0x2)
+# S390X-NEXT: Machine: EM_S390 (0x16)
 # X86-64-NEXT:Machine: EM_X86_64 (0x3E)
 
 # CHECK-NEXT: Version: 1
diff --git a/llvm/test/tools/llvm-objcopy/ELF/cross-arch-headers.test 
b/llvm/test/tools/llvm-objcopy/ELF/cross-arch-headers.test
index 882940c05e19c2..9a8128611792d5 100644
--- a/llvm/test/tools/llvm-objcopy/ELF/cross-arch-headers.test
+++ b/llvm/test/tools/llvm-objcopy/ELF/cross-arch-headers.test
@@ -117,6 +117,10 @@
 # RUN: llvm-readobj --file-headers %t.elf64_loongarch.o | FileCheck %s 
--check-prefixes=CHECK,LE,LA64,64,SYSV
 # RUN: llvm-readobj --file-headers %t.elf64_loongarch.dwo | FileCheck %s 
--check-prefixes=CHECK,LE,LA64,64,SYSV
 
+# RUN: llvm-objcopy %t.o -O elf64-s390 %t.elf64_s390.o 
--split-dwo=%t.elf64_s390.dwo
+# RUN: llvm-readobj --file-headers %t.elf64_s390.o | FileCheck %s 
--check-prefixes=CHECK,BE,S390X,64,SYSV
+# RUN: llvm-readobj --file-headers %t.elf64_s390.dwo | FileCheck %s 
--check-prefixes=CHECK,BE,S390X,64,SYSV
+
 !ELF
 FileHeader:
   Class:   ELFCLASS32
@@ -160,6 +164,7 @@ Symbols:
 # RISCV32-SAME: riscv{{$}}
 # RISCV64-SAME: riscv{{$}}
 # SPARC-SAME:   sparc
+# S390X-SAME:   s390
 # X86-64-SAME:  x86-64
 # DEFAULT-SAME: unknown
 
@@ -182,6 +187,7 @@ Symbols:
 # RISCV64-NEXT:  Arch: riscv64
 # SPARC-NEXT:Arch: sparc{{$}}
 # SPARCEL-NEXT:  Arch: sparcel
+# S390X-NEXT:Arch: s390x
 # X86-64-NEXT:   Arch: x86_64
 # DEFAULT-NEXT:  Arch: unknown
 
@@ -210,6 +216,7 @@ Symbols:
 # RISCV32: Machine: EM_RISCV (0xF3)
 # RISCV64: Machine: EM_RISCV (0xF3)
 # SPARC:   Machine: EM_SPARC (0x2)
+# S390X:   Machine: EM_S390 (0x16)
 # X86-64:  Machine: EM_X86_64 (0x3E)
 
 # 32: HeaderSize: 52
diff --git a/llvm/tools/llvm-objcopy/ObjcopyOptions.cpp 
b/llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
index f15307181fad61..f63e5c61e802c8 100644
--- a/llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
+++ b/llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
@@ -299,6 +299,8 @@ static const StringMap TargetMap{
 // LoongArch
 {"elf32-loongarch", {ELF::EM_LOONGARCH, false, true}},
 {"elf64-loongarch", {ELF::EM_LOONGARCH, true, true}},
+// SystemZ
+{"elf64-s390", {ELF::EM_S390, true, false}},
 };
 
 static Expected

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


[llvm-branch-commits] [llvm] release/18.x: [llvm-objcopy] Add SystemZ support (#81841) (PR #82324)

2024-02-20 Thread via llvm-branch-commits

https://github.com/llvmbot milestoned 
https://github.com/llvm/llvm-project/pull/82324
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] release/18.x: [llvm-objcopy] Add SystemZ support (#81841) (PR #82324)

2024-02-20 Thread via llvm-branch-commits

llvmbot wrote:

@jh7370 What do you think about merging this PR to the release branch?

https://github.com/llvm/llvm-project/pull/82324
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] release/18.x: [llvm-objcopy] Add SystemZ support (#81841) (PR #82324)

2024-02-20 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-llvm-binary-utilities

Author: None (llvmbot)


Changes

Backport 3c02cb7492fc78fb678264cebf57ff88e478e14f

Requested by: @uweigand

---
Full diff: https://github.com/llvm/llvm-project/pull/82324.diff


3 Files Affected:

- (modified) llvm/test/tools/llvm-objcopy/ELF/binary-output-target.test (+6) 
- (modified) llvm/test/tools/llvm-objcopy/ELF/cross-arch-headers.test (+7) 
- (modified) llvm/tools/llvm-objcopy/ObjcopyOptions.cpp (+2) 


``diff
diff --git a/llvm/test/tools/llvm-objcopy/ELF/binary-output-target.test 
b/llvm/test/tools/llvm-objcopy/ELF/binary-output-target.test
index fc5856691f8dca..f88b7575002a94 100644
--- a/llvm/test/tools/llvm-objcopy/ELF/binary-output-target.test
+++ b/llvm/test/tools/llvm-objcopy/ELF/binary-output-target.test
@@ -48,6 +48,9 @@
 # RUN: llvm-objcopy -I binary -O elf64-loongarch %t.txt %t.la64.o
 # RUN: llvm-readobj --file-headers %t.la64.o | FileCheck %s 
--check-prefixes=CHECK,LE,LA64,64
 
+# RUN: llvm-objcopy -I binary -O elf64-s390 %t.txt %t.s390x.o
+# RUN: llvm-readobj --file-headers %t.s390x.o | FileCheck %s 
--check-prefixes=CHECK,BE,S390X,64
+
 # CHECK: Format:
 # 32-SAME:  elf32-
 # 64-SAME:  elf64-
@@ -64,6 +67,7 @@
 # PPCLE-SAME:   powerpcle{{$}}
 # SPARC-SAME:   sparc
 # SPARCEL-SAME: sparc
+# S390X-SAME:   s390
 # X86-64-SAME:  x86-64
 
 # AARCH64-NEXT: Arch: aarch64
@@ -81,6 +85,7 @@
 # RISCV64-NEXT: Arch: riscv64
 # SPARC-NEXT:   Arch: sparc{{$}}
 # SPARCEL-NEXT: Arch: sparcel
+# S390X-NEXT:   Arch: s390x
 # X86-64-NEXT:  Arch: x86_64
 
 # 32-NEXT:  AddressSize: 32bit
@@ -116,6 +121,7 @@
 # RISCV64-NEXT:   Machine: EM_RISCV (0xF3)
 # SPARC-NEXT: Machine: EM_SPARC (0x2)
 # SPARCEL-NEXT:   Machine: EM_SPARC (0x2)
+# S390X-NEXT: Machine: EM_S390 (0x16)
 # X86-64-NEXT:Machine: EM_X86_64 (0x3E)
 
 # CHECK-NEXT: Version: 1
diff --git a/llvm/test/tools/llvm-objcopy/ELF/cross-arch-headers.test 
b/llvm/test/tools/llvm-objcopy/ELF/cross-arch-headers.test
index 882940c05e19c2..9a8128611792d5 100644
--- a/llvm/test/tools/llvm-objcopy/ELF/cross-arch-headers.test
+++ b/llvm/test/tools/llvm-objcopy/ELF/cross-arch-headers.test
@@ -117,6 +117,10 @@
 # RUN: llvm-readobj --file-headers %t.elf64_loongarch.o | FileCheck %s 
--check-prefixes=CHECK,LE,LA64,64,SYSV
 # RUN: llvm-readobj --file-headers %t.elf64_loongarch.dwo | FileCheck %s 
--check-prefixes=CHECK,LE,LA64,64,SYSV
 
+# RUN: llvm-objcopy %t.o -O elf64-s390 %t.elf64_s390.o 
--split-dwo=%t.elf64_s390.dwo
+# RUN: llvm-readobj --file-headers %t.elf64_s390.o | FileCheck %s 
--check-prefixes=CHECK,BE,S390X,64,SYSV
+# RUN: llvm-readobj --file-headers %t.elf64_s390.dwo | FileCheck %s 
--check-prefixes=CHECK,BE,S390X,64,SYSV
+
 !ELF
 FileHeader:
   Class:   ELFCLASS32
@@ -160,6 +164,7 @@ Symbols:
 # RISCV32-SAME: riscv{{$}}
 # RISCV64-SAME: riscv{{$}}
 # SPARC-SAME:   sparc
+# S390X-SAME:   s390
 # X86-64-SAME:  x86-64
 # DEFAULT-SAME: unknown
 
@@ -182,6 +187,7 @@ Symbols:
 # RISCV64-NEXT:  Arch: riscv64
 # SPARC-NEXT:Arch: sparc{{$}}
 # SPARCEL-NEXT:  Arch: sparcel
+# S390X-NEXT:Arch: s390x
 # X86-64-NEXT:   Arch: x86_64
 # DEFAULT-NEXT:  Arch: unknown
 
@@ -210,6 +216,7 @@ Symbols:
 # RISCV32: Machine: EM_RISCV (0xF3)
 # RISCV64: Machine: EM_RISCV (0xF3)
 # SPARC:   Machine: EM_SPARC (0x2)
+# S390X:   Machine: EM_S390 (0x16)
 # X86-64:  Machine: EM_X86_64 (0x3E)
 
 # 32: HeaderSize: 52
diff --git a/llvm/tools/llvm-objcopy/ObjcopyOptions.cpp 
b/llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
index f15307181fad61..f63e5c61e802c8 100644
--- a/llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
+++ b/llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
@@ -299,6 +299,8 @@ static const StringMap TargetMap{
 // LoongArch
 {"elf32-loongarch", {ELF::EM_LOONGARCH, false, true}},
 {"elf64-loongarch", {ELF::EM_LOONGARCH, true, true}},
+// SystemZ
+{"elf64-s390", {ELF::EM_S390, true, false}},
 };
 
 static Expected

``




https://github.com/llvm/llvm-project/pull/82324
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [RISCV] Support llvm.readsteadycounter intrinsic (PR #82322)

2024-02-20 Thread Yingwei Zheng via llvm-branch-commits

https://github.com/dtcxzyw edited 
https://github.com/llvm/llvm-project/pull/82322
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [RISCV] Support llvm.readsteadycounter intrinsic (PR #82322)

2024-02-20 Thread Yingwei Zheng via llvm-branch-commits


@@ -11725,13 +11727,27 @@ void RISCVTargetLowering::ReplaceNodeResults(SDNode 
*N,
 Results.push_back(Result);
 break;
   }
-  case ISD::READCYCLECOUNTER: {
-assert(!Subtarget.is64Bit() &&
-   "READCYCLECOUNTER only has custom type legalization on riscv32");
+  case ISD::READCYCLECOUNTER:
+  case ISD::READSTEADYCOUNTER: {
+assert(!Subtarget.is64Bit() && "READCYCLECOUNTER/READSTEADYCOUNTER only "
+   "has custom type legalization on riscv32");
 
+SDValue LoCounter, HiCounter;
+MVT XLenVT = Subtarget.getXLenVT();
+if (N->getOpcode() == ISD::READCYCLECOUNTER) {
+  LoCounter = DAG.getConstant(
+  RISCVSysReg::lookupSysRegByName("CYCLE")->Encoding, DL, XLenVT);
+  HiCounter = DAG.getConstant(
+  RISCVSysReg::lookupSysRegByName("CYCLEH")->Encoding, DL, XLenVT);
+} else if (N->getOpcode() == ISD::READSTEADYCOUNTER) {

dtcxzyw wrote:

```suggestion
} else {
```

https://github.com/llvm/llvm-project/pull/82322
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [RISCV] Support llvm.readsteadycounter intrinsic (PR #82322)

2024-02-20 Thread Yingwei Zheng via llvm-branch-commits

https://github.com/dtcxzyw approved this pull request.

LGTM. Thanks!

https://github.com/llvm/llvm-project/pull/82322
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] release/18.x: [llvm-objcopy] Add SystemZ support (#81841) (PR #82324)

2024-02-20 Thread James Henderson via llvm-branch-commits

jh7370 wrote:

Functionally, I'm confident this is safe, but I don't know whether it's too 
late in the cycle to be picking additional non-bug fix commits. @tstellar?

Also, as noted in the original PR, the corresponding doc change needs picking 
too.

https://github.com/llvm/llvm-project/pull/82324
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [mlir] [mlir][Transforms][NFC] Decouple `ConversionPatternRewriterImpl` from `ConversionPatternRewriter` (PR #82333)

2024-02-20 Thread Matthias Springer via llvm-branch-commits

https://github.com/matthias-springer created 
https://github.com/llvm/llvm-project/pull/82333

`ConversionPatternRewriterImpl` no longer maintains a reference to the 
respective `ConversionPatternRewriter`. An `MLIRContext` is sufficient. This 
commit simplifies the internal state of `ConversionPatternRewriterImpl`.

>From 362813d590d6b61ebc0d03db2ed56764c5332d2c Mon Sep 17 00:00:00 2001
From: Matthias Springer 
Date: Tue, 20 Feb 2024 09:48:57 +
Subject: [PATCH] [mlir][Transforms][NFC] Decouple
 `ConversionPatternRewriterImpl` from `ConversionPatternRewriter`

`ConversionPatternRewriterImpl` no longer maintains a reference to the 
respective `ConversionPatternRewriter`. An `MLIRContext` is sufficient. This 
commit simplifies the internal state of `ConversionPatternRewriterImpl`.
---
 .../Transforms/Utils/DialectConversion.cpp| 44 +--
 1 file changed, 21 insertions(+), 23 deletions(-)

diff --git a/mlir/lib/Transforms/Utils/DialectConversion.cpp 
b/mlir/lib/Transforms/Utils/DialectConversion.cpp
index 30fc2298b3deb3..ec97a4247658b8 100644
--- a/mlir/lib/Transforms/Utils/DialectConversion.cpp
+++ b/mlir/lib/Transforms/Utils/DialectConversion.cpp
@@ -725,10 +725,9 @@ static RewriteTy *findSingleRewrite(R &&rewrites, Block 
*block) {
 namespace mlir {
 namespace detail {
 struct ConversionPatternRewriterImpl : public RewriterBase::Listener {
-  explicit ConversionPatternRewriterImpl(PatternRewriter &rewriter,
+  explicit ConversionPatternRewriterImpl(MLIRContext *ctx,
  const ConversionConfig &config)
-  : rewriter(rewriter), eraseRewriter(rewriter.getContext()),
-config(config) {}
+  : eraseRewriter(ctx), config(config) {}
 
   
//======//
   // State Management
@@ -823,8 +822,8 @@ struct ConversionPatternRewriterImpl : public 
RewriterBase::Listener {
Type origOutputType,
const TypeConverter *converter);
 
-  Value buildUnresolvedArgumentMaterialization(PatternRewriter &rewriter,
-   Location loc, ValueRange inputs,
+  Value buildUnresolvedArgumentMaterialization(Block *block, Location loc,
+   ValueRange inputs,
Type origOutputType,
Type outputType,
const TypeConverter *converter);
@@ -903,8 +902,6 @@ struct ConversionPatternRewriterImpl : public 
RewriterBase::Listener {
   // State
   
//======//
 
-  PatternRewriter &rewriter;
-
   /// This rewriter must be used for erasing ops/blocks.
   SingleEraseRewriter eraseRewriter;
 
@@ -1008,8 +1005,12 @@ void BlockTypeConversionRewrite::rollback() {
 
 LogicalResult BlockTypeConversionRewrite::materializeLiveConversions(
 function_ref findLiveUser) {
+  auto builder = OpBuilder::atBlockBegin(block, /*listener=*/&rewriterImpl);
+
   // Process the remapping for each of the original arguments.
   for (unsigned i = 0, e = origBlock->getNumArguments(); i != e; ++i) {
+OpBuilder::InsertionGuard g(builder);
+
 // If the type of this argument changed and the argument is still live, we
 // need to materialize a conversion.
 BlockArgument origArg = origBlock->getArgument(i);
@@ -1021,14 +1022,12 @@ LogicalResult 
BlockTypeConversionRewrite::materializeLiveConversions(
 
 Value replacementValue = rewriterImpl.mapping.lookupOrDefault(origArg);
 bool isDroppedArg = replacementValue == origArg;
-if (isDroppedArg)
-  rewriterImpl.rewriter.setInsertionPointToStart(getBlock());
-else
-  rewriterImpl.rewriter.setInsertionPointAfterValue(replacementValue);
+if (!isDroppedArg)
+  builder.setInsertionPointAfterValue(replacementValue);
 Value newArg;
 if (converter) {
   newArg = converter->materializeSourceConversion(
-  rewriterImpl.rewriter, origArg.getLoc(), origArg.getType(),
+  builder, origArg.getLoc(), origArg.getType(),
   isDroppedArg ? ValueRange() : ValueRange(replacementValue));
   assert((!newArg || newArg.getType() == origArg.getType()) &&
  "materialization hook did not provide a value of the expected "
@@ -1293,6 +1292,8 @@ LogicalResult 
ConversionPatternRewriterImpl::convertNonEntryRegionTypes(
 Block *ConversionPatternRewriterImpl::applySignatureConversion(
 Block *block, const TypeConverter *converter,
 TypeConverter::SignatureConversion &signatureConversion) {
+  MLIRContext *ctx = block->getParentOp()->getContext();
+
   // If no arguments are being changed or added, there is nothing to do.
   unsigned origArgCount = block->getNumArguments();
   auto convertedTypes = signatureConversion.getConvertedTypes();
@@ -1309,7 +1310,7 @@ B

[llvm-branch-commits] [llvm] release/18.x: [llvm-objcopy] Add SystemZ support (#81841) (PR #82324)

2024-02-20 Thread Ulrich Weigand via llvm-branch-commits

uweigand wrote:

> Also, as noted in the original PR, the corresponding doc change needs picking 
> too.

I'll add a cherry-pick for the doc PR if and when this PR is approved.

https://github.com/llvm/llvm-project/pull/82324
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [mlir] [mlir][Transforms][NFC] Decouple `ConversionPatternRewriterImpl` from `ConversionPatternRewriter` (PR #82333)

2024-02-20 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-mlir-core

Author: Matthias Springer (matthias-springer)


Changes

`ConversionPatternRewriterImpl` no longer maintains a reference to the 
respective `ConversionPatternRewriter`. An `MLIRContext` is sufficient. This 
commit simplifies the internal state of `ConversionPatternRewriterImpl`.

---
Full diff: https://github.com/llvm/llvm-project/pull/82333.diff


1 Files Affected:

- (modified) mlir/lib/Transforms/Utils/DialectConversion.cpp (+21-23) 


``diff
diff --git a/mlir/lib/Transforms/Utils/DialectConversion.cpp 
b/mlir/lib/Transforms/Utils/DialectConversion.cpp
index 30fc2298b3deb3..ec97a4247658b8 100644
--- a/mlir/lib/Transforms/Utils/DialectConversion.cpp
+++ b/mlir/lib/Transforms/Utils/DialectConversion.cpp
@@ -725,10 +725,9 @@ static RewriteTy *findSingleRewrite(R &&rewrites, Block 
*block) {
 namespace mlir {
 namespace detail {
 struct ConversionPatternRewriterImpl : public RewriterBase::Listener {
-  explicit ConversionPatternRewriterImpl(PatternRewriter &rewriter,
+  explicit ConversionPatternRewriterImpl(MLIRContext *ctx,
  const ConversionConfig &config)
-  : rewriter(rewriter), eraseRewriter(rewriter.getContext()),
-config(config) {}
+  : eraseRewriter(ctx), config(config) {}
 
   
//======//
   // State Management
@@ -823,8 +822,8 @@ struct ConversionPatternRewriterImpl : public 
RewriterBase::Listener {
Type origOutputType,
const TypeConverter *converter);
 
-  Value buildUnresolvedArgumentMaterialization(PatternRewriter &rewriter,
-   Location loc, ValueRange inputs,
+  Value buildUnresolvedArgumentMaterialization(Block *block, Location loc,
+   ValueRange inputs,
Type origOutputType,
Type outputType,
const TypeConverter *converter);
@@ -903,8 +902,6 @@ struct ConversionPatternRewriterImpl : public 
RewriterBase::Listener {
   // State
   
//======//
 
-  PatternRewriter &rewriter;
-
   /// This rewriter must be used for erasing ops/blocks.
   SingleEraseRewriter eraseRewriter;
 
@@ -1008,8 +1005,12 @@ void BlockTypeConversionRewrite::rollback() {
 
 LogicalResult BlockTypeConversionRewrite::materializeLiveConversions(
 function_ref findLiveUser) {
+  auto builder = OpBuilder::atBlockBegin(block, /*listener=*/&rewriterImpl);
+
   // Process the remapping for each of the original arguments.
   for (unsigned i = 0, e = origBlock->getNumArguments(); i != e; ++i) {
+OpBuilder::InsertionGuard g(builder);
+
 // If the type of this argument changed and the argument is still live, we
 // need to materialize a conversion.
 BlockArgument origArg = origBlock->getArgument(i);
@@ -1021,14 +1022,12 @@ LogicalResult 
BlockTypeConversionRewrite::materializeLiveConversions(
 
 Value replacementValue = rewriterImpl.mapping.lookupOrDefault(origArg);
 bool isDroppedArg = replacementValue == origArg;
-if (isDroppedArg)
-  rewriterImpl.rewriter.setInsertionPointToStart(getBlock());
-else
-  rewriterImpl.rewriter.setInsertionPointAfterValue(replacementValue);
+if (!isDroppedArg)
+  builder.setInsertionPointAfterValue(replacementValue);
 Value newArg;
 if (converter) {
   newArg = converter->materializeSourceConversion(
-  rewriterImpl.rewriter, origArg.getLoc(), origArg.getType(),
+  builder, origArg.getLoc(), origArg.getType(),
   isDroppedArg ? ValueRange() : ValueRange(replacementValue));
   assert((!newArg || newArg.getType() == origArg.getType()) &&
  "materialization hook did not provide a value of the expected "
@@ -1293,6 +1292,8 @@ LogicalResult 
ConversionPatternRewriterImpl::convertNonEntryRegionTypes(
 Block *ConversionPatternRewriterImpl::applySignatureConversion(
 Block *block, const TypeConverter *converter,
 TypeConverter::SignatureConversion &signatureConversion) {
+  MLIRContext *ctx = block->getParentOp()->getContext();
+
   // If no arguments are being changed or added, there is nothing to do.
   unsigned origArgCount = block->getNumArguments();
   auto convertedTypes = signatureConversion.getConvertedTypes();
@@ -1309,7 +1310,7 @@ Block 
*ConversionPatternRewriterImpl::applySignatureConversion(
 
   // Map all new arguments to the location of the argument they originate from.
   SmallVector newLocs(convertedTypes.size(),
-rewriter.getUnknownLoc());
+Builder(ctx).getUnknownLoc());
   for (unsigned i = 0; i < origArgCount; ++i) {
 auto inputMap = signatureConversion.getInp

[llvm-branch-commits] [llvm] release/18.x: [llvm-objdump] Add support for the PT_OPENBSD_SYSCALLS segment type. (#82121) (PR #82317)

2024-02-20 Thread Frederic Cambus via llvm-branch-commits

https://github.com/fcambus approved this pull request.


https://github.com/llvm/llvm-project/pull/82317
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] release/18.x: [llvm-objdump] Add support for the PT_OPENBSD_SYSCALLS segment type. (#82121) (PR #82317)

2024-02-20 Thread Frederic Cambus via llvm-branch-commits

fcambus wrote:

@brad0 It would indeed be great to have this in the the 18.x release branch, 
thanks for suggesting it!

https://github.com/llvm/llvm-project/pull/82317
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] [RISCV] Support llvm.readsteadycounter intrinsic (PR #82322)

2024-02-20 Thread Wang Pengcheng via llvm-branch-commits

https://github.com/wangpc-pp updated 
https://github.com/llvm/llvm-project/pull/82322

>From f8415de83823cd5b244fcb288b29d4afc7ea10db Mon Sep 17 00:00:00 2001
From: Wang Pengcheng 
Date: Tue, 20 Feb 2024 18:20:03 +0800
Subject: [PATCH] Fix typo and address comments

Created using spr 1.3.4
---
 llvm/lib/Target/RISCV/RISCVISelLowering.cpp | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp 
b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index 32d47a669020f1..1814928c5ca159 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -625,7 +625,7 @@ RISCVTargetLowering::RISCVTargetLowering(const 
TargetMachine &TM,
   if (Subtarget.is64Bit())
 setOperationAction(ISD::Constant, MVT::i64, Custom);
 
-  // TODO: On M-mode only targets, the cycle[h] CSR may not be present.
+  // TODO: On M-mode only targets, the cycle[h]/time[h] CSR may not be present.
   // Unfortunately this can't be determined just from the ISA naming string.
   setOperationAction(ISD::READCYCLECOUNTER, MVT::i64,
  Subtarget.is64Bit() ? Legal : Custom);
@@ -11739,7 +11739,7 @@ void RISCVTargetLowering::ReplaceNodeResults(SDNode *N,
   RISCVSysReg::lookupSysRegByName("CYCLE")->Encoding, DL, XLenVT);
   HiCounter = DAG.getConstant(
   RISCVSysReg::lookupSysRegByName("CYCLEH")->Encoding, DL, XLenVT);
-} else if (N->getOpcode() == ISD::READSTEADYCOUNTER) {
+} else {
   LoCounter = DAG.getConstant(
   RISCVSysReg::lookupSysRegByName("TIME")->Encoding, DL, XLenVT);
   HiCounter = DAG.getConstant(
@@ -16929,9 +16929,9 @@ static MachineBasicBlock 
*emitReadCounterWidePseudo(MachineInstr &MI,
   // For example:
   // ```
   // read:
-  //   csrrs x3, counter # load high word of counter
-  //   csrrs x2, counterh # load low word of counter
-  //   csrrs x4, counter # load high word of counter
+  //   csrrs x3, counterh # load high word of counter
+  //   csrrs x2, counter # load low word of counter
+  //   csrrs x4, counterh # load high word of counter
   //   bne x3, x4, read # check if high word reads match, otherwise try again
   // ```
 

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


[llvm-branch-commits] [llvm] [RISCV] Support llvm.readsteadycounter intrinsic (PR #82322)

2024-02-20 Thread Wang Pengcheng via llvm-branch-commits

https://github.com/wangpc-pp edited 
https://github.com/llvm/llvm-project/pull/82322
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [llvm] release/18.x: [AArch64] Backport Ampere1B support (#81297 , #81341, and #81744) (PR #81857)

2024-02-20 Thread David Green via llvm-branch-commits

https://github.com/davemgreen approved this pull request.

I believe considering what this changes it should be OK. LGTM

https://github.com/llvm/llvm-project/pull/81857
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] release/18.x: [InstCombine] Fold gep of exact unsigned division (#82334) (PR #82347)

2024-02-20 Thread via llvm-branch-commits

https://github.com/llvmbot created 
https://github.com/llvm/llvm-project/pull/82347

Backport ec2c770b9f9a0e9eca4a893383d2b27dd4c0bfe7 
26d4afc3de86ca5416c8e38000362c526b6808cd

Requested by: @nikic

>From c74afe6f52e9db0c5acd90b78a232176ad460b5e Mon Sep 17 00:00:00 2001
From: Nikita Popov 
Date: Tue, 20 Feb 2024 11:08:01 +0100
Subject: [PATCH 1/2] [InstCombine] Add unsigned variants of gep exact div
 tests (NFC)

(cherry picked from commit ec2c770b9f9a0e9eca4a893383d2b27dd4c0bfe7)
---
 .../Transforms/InstCombine/getelementptr.ll   | 56 +++
 1 file changed, 56 insertions(+)

diff --git a/llvm/test/Transforms/InstCombine/getelementptr.ll 
b/llvm/test/Transforms/InstCombine/getelementptr.ll
index 642c3eb2a0e41b..e6a3b759cf78d6 100644
--- a/llvm/test/Transforms/InstCombine/getelementptr.ll
+++ b/llvm/test/Transforms/InstCombine/getelementptr.ll
@@ -116,6 +116,7 @@ define void @test_overaligned_vec(i8 %B) {
 ; CHECK-LABEL: @test_overaligned_vec(
 ; CHECK-NEXT:store i8 [[B:%.*]], ptr getelementptr inbounds ([10 x i8], 
ptr @Global, i64 0, i64 2), align 1
 ; CHECK-NEXT:ret void
+;
   %A = getelementptr <2 x half>, ptr @Global, i64 0, i64 1
   store i8 %B, ptr %A
   ret void
@@ -1473,6 +1474,17 @@ define ptr @gep_sdiv(ptr %p, i64 %off) {
   ret ptr %ptr
 }
 
+define ptr @gep_udiv(ptr %p, i64 %off) {
+; CHECK-LABEL: @gep_udiv(
+; CHECK-NEXT:[[INDEX:%.*]] = udiv exact i64 [[OFF:%.*]], 7
+; CHECK-NEXT:[[PTR:%.*]] = getelementptr [[STRUCT_C:%.*]], ptr [[P:%.*]], 
i64 [[INDEX]]
+; CHECK-NEXT:ret ptr [[PTR]]
+;
+  %index = udiv exact i64 %off, 7
+  %ptr = getelementptr %struct.C, ptr %p, i64 %index
+  ret ptr %ptr
+}
+
 define <2 x ptr> @gep_sdiv_vec(<2 x ptr> %p, <2 x i64> %off) {
 ; CHECK-LABEL: @gep_sdiv_vec(
 ; CHECK-NEXT:[[PTR:%.*]] = getelementptr i8, <2 x ptr> [[P:%.*]], <2 x 
i64> [[OFF:%.*]]
@@ -1503,6 +1515,17 @@ define ptr @gep_ashr(ptr %p, i64 %off) {
   ret ptr %ptr
 }
 
+define ptr @gep_lshr(ptr %p, i64 %off) {
+; CHECK-LABEL: @gep_lshr(
+; CHECK-NEXT:[[INDEX:%.*]] = lshr exact i64 [[OFF:%.*]], 2
+; CHECK-NEXT:[[PTR:%.*]] = getelementptr i32, ptr [[P:%.*]], i64 [[INDEX]]
+; CHECK-NEXT:ret ptr [[PTR]]
+;
+  %index = lshr exact i64 %off, 2
+  %ptr = getelementptr i32, ptr %p, i64 %index
+  ret ptr %ptr
+}
+
 ; Negative tests
 
 define ptr @gep_i8(ptr %p, i64 %off) {
@@ -1525,6 +1548,17 @@ define ptr @gep_sdiv_mismatched_size(ptr %p, i64 %off) {
   ret ptr %ptr
 }
 
+define ptr @gep_udiv_mismatched_size(ptr %p, i64 %off) {
+; CHECK-LABEL: @gep_udiv_mismatched_size(
+; CHECK-NEXT:[[INDEX:%.*]] = udiv exact i64 [[OFF:%.*]], 20
+; CHECK-NEXT:[[PTR:%.*]] = getelementptr [[STRUCT_C:%.*]], ptr [[P:%.*]], 
i64 [[INDEX]]
+; CHECK-NEXT:ret ptr [[PTR]]
+;
+  %index = udiv exact i64 %off, 20
+  %ptr = getelementptr %struct.C, ptr %p, i64 %index
+  ret ptr %ptr
+}
+
 define ptr @gep_sdiv_without_exact(ptr %p, i64 %off) {
 ; CHECK-LABEL: @gep_sdiv_without_exact(
 ; CHECK-NEXT:[[INDEX:%.*]] = sdiv i64 [[OFF:%.*]], 7
@@ -1536,6 +1570,17 @@ define ptr @gep_sdiv_without_exact(ptr %p, i64 %off) {
   ret ptr %ptr
 }
 
+define ptr @gep_udiv_without_exact(ptr %p, i64 %off) {
+; CHECK-LABEL: @gep_udiv_without_exact(
+; CHECK-NEXT:[[INDEX:%.*]] = udiv i64 [[OFF:%.*]], 7
+; CHECK-NEXT:[[PTR:%.*]] = getelementptr [[STRUCT_C:%.*]], ptr [[P:%.*]], 
i64 [[INDEX]]
+; CHECK-NEXT:ret ptr [[PTR]]
+;
+  %index = udiv i64 %off, 7
+  %ptr = getelementptr %struct.C, ptr %p, i64 %index
+  ret ptr %ptr
+}
+
 define ptr @gep_ashr_without_exact(ptr %p, i64 %off) {
 ; CHECK-LABEL: @gep_ashr_without_exact(
 ; CHECK-NEXT:[[INDEX:%.*]] = ashr i64 [[OFF:%.*]], 2
@@ -1547,6 +1592,17 @@ define ptr @gep_ashr_without_exact(ptr %p, i64 %off) {
   ret ptr %ptr
 }
 
+define ptr @gep_lshr_without_exact(ptr %p, i64 %off) {
+; CHECK-LABEL: @gep_lshr_without_exact(
+; CHECK-NEXT:[[INDEX:%.*]] = lshr i64 [[OFF:%.*]], 2
+; CHECK-NEXT:[[PTR:%.*]] = getelementptr i32, ptr [[P:%.*]], i64 [[INDEX]]
+; CHECK-NEXT:ret ptr [[PTR]]
+;
+  %index = lshr i64 %off, 2
+  %ptr = getelementptr i32, ptr %p, i64 %index
+  ret ptr %ptr
+}
+
 define i1 @test_only_used_by_icmp(ptr %a, ptr %b, ptr %c) {
 ; CHECK-LABEL: @test_only_used_by_icmp(
 ; CHECK-NEXT:[[CMP:%.*]] = icmp eq ptr [[B:%.*]], [[C:%.*]]

>From ebc589e44ffe7b77cc500f3d2dc1a7ba11dd82b1 Mon Sep 17 00:00:00 2001
From: Nikita Popov 
Date: Tue, 20 Feb 2024 12:48:13 +0100
Subject: [PATCH 2/2] [InstCombine] Fold gep of exact unsigned division
 (#82334)

Extend the transform added in
https://github.com/llvm/llvm-project/pull/76458 to also handle unsigned
division. X exact/ Y * Y == X holds independently of whether the
division is signed or unsigned.

Proofs: https://alive2.llvm.org/ce/z/wFd5Ec
(cherry picked from commit 26d4afc3de86ca5416c8e38000362c526b6808cd)
---
 llvm/lib/Transforms/InstCombine/InstructionCombining.cpp | 6 +++---
 llvm/test/Transforms/InstCombine/getelementptr.ll| 6 ++
 2 files changed, 5 insertio

[llvm-branch-commits] [llvm] release/18.x: [InstCombine] Fold gep of exact unsigned division (#82334) (PR #82347)

2024-02-20 Thread via llvm-branch-commits

https://github.com/llvmbot milestoned 
https://github.com/llvm/llvm-project/pull/82347
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] release/18.x: [InstCombine] Fold gep of exact unsigned division (#82334) (PR #82347)

2024-02-20 Thread via llvm-branch-commits

llvmbot wrote:

@dtcxzyw What do you think about merging this PR to the release branch?

https://github.com/llvm/llvm-project/pull/82347
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] release/18.x: [InstCombine] Fold gep of exact unsigned division (#82334) (PR #82347)

2024-02-20 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-llvm-transforms

Author: None (llvmbot)


Changes

Backport ec2c770b9f9a0e9eca4a893383d2b27dd4c0bfe7 
26d4afc3de86ca5416c8e38000362c526b6808cd

Requested by: @nikic

---
Full diff: https://github.com/llvm/llvm-project/pull/82347.diff


2 Files Affected:

- (modified) llvm/lib/Transforms/InstCombine/InstructionCombining.cpp (+3-3) 
- (modified) llvm/test/Transforms/InstCombine/getelementptr.ll (+54) 


``diff
diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp 
b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
index 249f4a7710e046..5d207dcfd18dd4 100644
--- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
@@ -2594,10 +2594,10 @@ Instruction 
*InstCombinerImpl::visitGetElementPtrInst(GetElementPtrInst &GEP) {
 Value *V;
 if ((has_single_bit(TyAllocSize) &&
  match(GEP.getOperand(1),
-   m_Exact(m_AShr(m_Value(V),
-  m_SpecificInt(countr_zero(TyAllocSize)) 
||
+   m_Exact(m_Shr(m_Value(V),
+ m_SpecificInt(countr_zero(TyAllocSize)) ||
 match(GEP.getOperand(1),
-  m_Exact(m_SDiv(m_Value(V), m_SpecificInt(TyAllocSize) {
+  m_Exact(m_IDiv(m_Value(V), m_SpecificInt(TyAllocSize) {
   GetElementPtrInst *NewGEP = GetElementPtrInst::Create(
   Builder.getInt8Ty(), GEP.getPointerOperand(), V);
   NewGEP->setIsInBounds(GEP.isInBounds());
diff --git a/llvm/test/Transforms/InstCombine/getelementptr.ll 
b/llvm/test/Transforms/InstCombine/getelementptr.ll
index 642c3eb2a0e41b..c90b6c9fb29592 100644
--- a/llvm/test/Transforms/InstCombine/getelementptr.ll
+++ b/llvm/test/Transforms/InstCombine/getelementptr.ll
@@ -116,6 +116,7 @@ define void @test_overaligned_vec(i8 %B) {
 ; CHECK-LABEL: @test_overaligned_vec(
 ; CHECK-NEXT:store i8 [[B:%.*]], ptr getelementptr inbounds ([10 x i8], 
ptr @Global, i64 0, i64 2), align 1
 ; CHECK-NEXT:ret void
+;
   %A = getelementptr <2 x half>, ptr @Global, i64 0, i64 1
   store i8 %B, ptr %A
   ret void
@@ -1473,6 +1474,16 @@ define ptr @gep_sdiv(ptr %p, i64 %off) {
   ret ptr %ptr
 }
 
+define ptr @gep_udiv(ptr %p, i64 %off) {
+; CHECK-LABEL: @gep_udiv(
+; CHECK-NEXT:[[PTR:%.*]] = getelementptr i8, ptr [[P:%.*]], i64 [[OFF:%.*]]
+; CHECK-NEXT:ret ptr [[PTR]]
+;
+  %index = udiv exact i64 %off, 7
+  %ptr = getelementptr %struct.C, ptr %p, i64 %index
+  ret ptr %ptr
+}
+
 define <2 x ptr> @gep_sdiv_vec(<2 x ptr> %p, <2 x i64> %off) {
 ; CHECK-LABEL: @gep_sdiv_vec(
 ; CHECK-NEXT:[[PTR:%.*]] = getelementptr i8, <2 x ptr> [[P:%.*]], <2 x 
i64> [[OFF:%.*]]
@@ -1503,6 +1514,16 @@ define ptr @gep_ashr(ptr %p, i64 %off) {
   ret ptr %ptr
 }
 
+define ptr @gep_lshr(ptr %p, i64 %off) {
+; CHECK-LABEL: @gep_lshr(
+; CHECK-NEXT:[[PTR:%.*]] = getelementptr i8, ptr [[P:%.*]], i64 [[OFF:%.*]]
+; CHECK-NEXT:ret ptr [[PTR]]
+;
+  %index = lshr exact i64 %off, 2
+  %ptr = getelementptr i32, ptr %p, i64 %index
+  ret ptr %ptr
+}
+
 ; Negative tests
 
 define ptr @gep_i8(ptr %p, i64 %off) {
@@ -1525,6 +1546,17 @@ define ptr @gep_sdiv_mismatched_size(ptr %p, i64 %off) {
   ret ptr %ptr
 }
 
+define ptr @gep_udiv_mismatched_size(ptr %p, i64 %off) {
+; CHECK-LABEL: @gep_udiv_mismatched_size(
+; CHECK-NEXT:[[INDEX:%.*]] = udiv exact i64 [[OFF:%.*]], 20
+; CHECK-NEXT:[[PTR:%.*]] = getelementptr [[STRUCT_C:%.*]], ptr [[P:%.*]], 
i64 [[INDEX]]
+; CHECK-NEXT:ret ptr [[PTR]]
+;
+  %index = udiv exact i64 %off, 20
+  %ptr = getelementptr %struct.C, ptr %p, i64 %index
+  ret ptr %ptr
+}
+
 define ptr @gep_sdiv_without_exact(ptr %p, i64 %off) {
 ; CHECK-LABEL: @gep_sdiv_without_exact(
 ; CHECK-NEXT:[[INDEX:%.*]] = sdiv i64 [[OFF:%.*]], 7
@@ -1536,6 +1568,17 @@ define ptr @gep_sdiv_without_exact(ptr %p, i64 %off) {
   ret ptr %ptr
 }
 
+define ptr @gep_udiv_without_exact(ptr %p, i64 %off) {
+; CHECK-LABEL: @gep_udiv_without_exact(
+; CHECK-NEXT:[[INDEX:%.*]] = udiv i64 [[OFF:%.*]], 7
+; CHECK-NEXT:[[PTR:%.*]] = getelementptr [[STRUCT_C:%.*]], ptr [[P:%.*]], 
i64 [[INDEX]]
+; CHECK-NEXT:ret ptr [[PTR]]
+;
+  %index = udiv i64 %off, 7
+  %ptr = getelementptr %struct.C, ptr %p, i64 %index
+  ret ptr %ptr
+}
+
 define ptr @gep_ashr_without_exact(ptr %p, i64 %off) {
 ; CHECK-LABEL: @gep_ashr_without_exact(
 ; CHECK-NEXT:[[INDEX:%.*]] = ashr i64 [[OFF:%.*]], 2
@@ -1547,6 +1590,17 @@ define ptr @gep_ashr_without_exact(ptr %p, i64 %off) {
   ret ptr %ptr
 }
 
+define ptr @gep_lshr_without_exact(ptr %p, i64 %off) {
+; CHECK-LABEL: @gep_lshr_without_exact(
+; CHECK-NEXT:[[INDEX:%.*]] = lshr i64 [[OFF:%.*]], 2
+; CHECK-NEXT:[[PTR:%.*]] = getelementptr i32, ptr [[P:%.*]], i64 [[INDEX]]
+; CHECK-NEXT:ret ptr [[PTR]]
+;
+  %index = lshr i64 %off, 2
+  %ptr = getelementptr i32, ptr %p, i64 %index
+  ret ptr %ptr
+}

[llvm-branch-commits] [llvm] release/18.x: [InstCombine] Fold gep of exact unsigned division (#82334) (PR #82347)

2024-02-20 Thread Nikita Popov via llvm-branch-commits

nikic wrote:

Submitting this for backport, because it mitigates an LLVM 18 optimization 
regression encountered in Rust. The regression is really in a different area, 
but I think this is the least intrusive way to mitigate it.

https://github.com/llvm/llvm-project/pull/82347
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] release/18.x: [InstCombine] Fold gep of exact unsigned division (#82334) (PR #82347)

2024-02-20 Thread Yingwei Zheng via llvm-branch-commits

https://github.com/dtcxzyw approved this pull request.

LGTM if CI is happy.


https://github.com/llvm/llvm-project/pull/82347
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [flang] [flang][OpenMP] Convert unique clauses in ClauseProcessor (PR #81622)

2024-02-20 Thread Sergio Afonso via llvm-branch-commits

https://github.com/skatrak commented:

Thanks, LGTM.

https://github.com/llvm/llvm-project/pull/81622
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [flang] [flang][OpenMP] Convert unique clauses in ClauseProcessor (PR #81622)

2024-02-20 Thread Sergio Afonso via llvm-branch-commits


@@ -2639,54 +2641,50 @@ bool 
ClauseProcessor::processFinal(Fortran::lower::StatementContext &stmtCtx,
 }
 
 bool ClauseProcessor::processHint(mlir::IntegerAttr &result) const {
-  if (auto *hintClause = findUniqueClause()) {
+  if (auto *clause = findUniqueClause()) {
 fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
-const auto *expr = Fortran::semantics::GetExpr(hintClause->v);
-int64_t hintValue = *Fortran::evaluate::ToInt64(*expr);
+int64_t hintValue = *Fortran::evaluate::ToInt64(clause->v);
 result = firOpBuilder.getI64IntegerAttr(hintValue);
 return true;
   }
   return false;
 }
 
 bool ClauseProcessor::processMergeable(mlir::UnitAttr &result) const {
-  return markClauseOccurrence(result);
+  return markClauseOccurrence(result);
 }
 
 bool ClauseProcessor::processNowait(mlir::UnitAttr &result) const {
-  return markClauseOccurrence(result);
+  return markClauseOccurrence(result);
 }
 
 bool ClauseProcessor::processNumTeams(Fortran::lower::StatementContext 
&stmtCtx,
   mlir::Value &result) const {
   // TODO Get lower and upper bounds for num_teams when parser is updated to
   // accept both.
-  if (auto *numTeamsClause = findUniqueClause()) {
-result = fir::getBase(converter.genExprValue(
-*Fortran::semantics::GetExpr(numTeamsClause->v), stmtCtx));
+  if (auto *clause = findUniqueClause()) {
+result = fir::getBase(converter.genExprValue(clause->v, stmtCtx));
 return true;
   }
   return false;
 }
 
 bool ClauseProcessor::processNumThreads(
 Fortran::lower::StatementContext &stmtCtx, mlir::Value &result) const {
-  if (auto *numThreadsClause = findUniqueClause()) {
+  if (auto *clause = findUniqueClause()) {
 // OMPIRBuilder expects `NUM_THREADS` clause as a `Value`.
-result = fir::getBase(converter.genExprValue(
-*Fortran::semantics::GetExpr(numThreadsClause->v), stmtCtx));
+result = fir::getBase(converter.genExprValue(clause->v, stmtCtx));
 return true;
   }
   return false;
 }
 
 bool ClauseProcessor::processOrdered(mlir::IntegerAttr &result) const {
-  if (auto *orderedClause = findUniqueClause()) {
+  if (auto *clause = findUniqueClause()) {
 fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
 int64_t orderedClauseValue = 0l;
-if (orderedClause->v.has_value()) {
-  const auto *expr = Fortran::semantics::GetExpr(orderedClause->v);
-  orderedClauseValue = *Fortran::evaluate::ToInt64(*expr);
+if (clause->v.has_value()) {

skatrak wrote:

Nit: Braces not necessary.

https://github.com/llvm/llvm-project/pull/81622
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [flang] [flang][OpenMP] Convert unique clauses in ClauseProcessor (PR #81622)

2024-02-20 Thread Sergio Afonso via llvm-branch-commits

https://github.com/skatrak edited 
https://github.com/llvm/llvm-project/pull/81622
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] [RISCV] Support llvm.readsteadycounter intrinsic (PR #82322)

2024-02-20 Thread Joseph Huber via llvm-branch-commits

https://github.com/jhuber6 approved this pull request.


https://github.com/llvm/llvm-project/pull/82322
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] [RISCV] Support llvm.readsteadycounter intrinsic (PR #82322)

2024-02-20 Thread Alex Bradbury via llvm-branch-commits

https://github.com/asb approved this pull request.

LGTM.

https://github.com/llvm/llvm-project/pull/82322
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [flang] [flang][OpenMP] Convert repeatable clauses (except Map) in ClauseProc… (PR #81623)

2024-02-20 Thread Sergio Afonso via llvm-branch-commits

https://github.com/skatrak commented:

This LGTM, I just have a question on a part of the patch that I wasn't able to 
fully understand.

https://github.com/llvm/llvm-project/pull/81623
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [flang] [flang][OpenMP] Convert repeatable clauses (except Map) in ClauseProc… (PR #81623)

2024-02-20 Thread Sergio Afonso via llvm-branch-commits


@@ -2865,53 +2865,45 @@ bool ClauseProcessor::processDepend(
 llvm::SmallVectorImpl &dependOperands) const {
   fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
 
-  return findRepeatableClause(
-  [&](const ClauseTy::Depend *dependClause,
+  return findRepeatableClause(
+  [&](const omp::clause::Depend &clause,
   const Fortran::parser::CharBlock &) {
-const std::list &depVal =
-std::get>(
-std::get(
-dependClause->v.u)
-.t);
+assert(std::holds_alternative(clause.u) &&
+   "Only InOut is handled at the moment");
+const auto &inOut = std::get(clause.u);
+const auto &objects = std::get(inOut.t);
+
 mlir::omp::ClauseTaskDependAttr dependTypeOperand =
-genDependKindAttr(firOpBuilder, dependClause);
-dependTypeOperands.insert(dependTypeOperands.end(), depVal.size(),
-  dependTypeOperand);
-for (const Fortran::parser::Designator &ompObject : depVal) {
-  Fortran::semantics::Symbol *sym = nullptr;
-  std::visit(
-  Fortran::common::visitors{
-  [&](const Fortran::parser::DataRef &designator) {
-if (const Fortran::parser::Name *name =
-std::get_if(&designator.u)) 
{
-  sym = name->symbol;
-} else if (std::get_if>(
-   &designator.u)) {
-  TODO(converter.getCurrentLocation(),
-   "array sections not supported for task depend");
-}
-  },
-  [&](const Fortran::parser::Substring &designator) {
-TODO(converter.getCurrentLocation(),
- "substring not supported for task depend");
-  }},
-  (ompObject).u);
+genDependKindAttr(firOpBuilder, clause);
+dependTypeOperands.append(objects.size(), dependTypeOperand);
+
+for (const omp::Object &object : objects) {
+  assert(object.dsg && "Expecting designator");
+
+  if (Fortran::evaluate::ExtractSubstring(*object.dsg)) {
+TODO(converter.getCurrentLocation(),
+ "substring not supported for task depend");
+  } else if (Fortran::evaluate::IsArrayElement(*object.dsg)) {
+TODO(converter.getCurrentLocation(),
+ "array sections not supported for task depend");
+  }
+
+  Fortran::semantics::Symbol *sym = object.sym;
   const mlir::Value variable = converter.getSymbolAddress(*sym);
   dependOperands.push_back(variable);
 }

skatrak wrote:

I can't quite understand the equivalence between this and the previous 
implementation. Could you elaborate a bit?

https://github.com/llvm/llvm-project/pull/81623
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [flang] [flang][OpenMP] Convert repeatable clauses (except Map) in ClauseProc… (PR #81623)

2024-02-20 Thread Sergio Afonso via llvm-branch-commits

https://github.com/skatrak edited 
https://github.com/llvm/llvm-project/pull/81623
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [flang] [flang][OpenMP] Convert processTODO and remove unused objects (PR #81627)

2024-02-20 Thread Sergio Afonso via llvm-branch-commits

https://github.com/skatrak commented:

LGTM.

https://github.com/llvm/llvm-project/pull/81627
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [flang] [flang][OpenMP] Convert DataSharingProcessor to omp::Clause (PR #81629)

2024-02-20 Thread Sergio Afonso via llvm-branch-commits


@@ -1278,14 +1278,15 @@ class DataSharingProcessor {
   llvm::SetVector symbolsInNestedRegions;
   llvm::SetVector symbolsInParentRegions;
   Fortran::lower::AbstractConverter &converter;
+  Fortran::semantics::SemanticsContext &semaCtx;

skatrak wrote:

Do we expect to need it stored in the class? It looks like at least currently 
the only place where it's accessed is the constructor, in order to create the 
list of clauses.

https://github.com/llvm/llvm-project/pull/81629
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [flang] [flang][OpenMP] Convert DataSharingProcessor to omp::Clause (PR #81629)

2024-02-20 Thread Sergio Afonso via llvm-branch-commits


@@ -1384,30 +1386,28 @@ void DataSharingProcessor::copyLastPrivateSymbol(
 }
 
 void DataSharingProcessor::collectOmpObjectListSymbol(
-const Fortran::parser::OmpObjectList &ompObjectList,
+const omp::ObjectList &objects,
 llvm::SetVector &symbolSet) {
-  for (const Fortran::parser::OmpObject &ompObject : ompObjectList.v) {
-Fortran::semantics::Symbol *sym = getOmpObjectSymbol(ompObject);
+  for (const omp::Object &object : objects) {
+Fortran::semantics::Symbol *sym = object.sym;

skatrak wrote:

Nit: I think `object.sym` can be passed directly to the call below now that 
this becomes a trivial statement.

https://github.com/llvm/llvm-project/pull/81629
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [flang] [flang][OpenMP] Convert DataSharingProcessor to omp::Clause (PR #81629)

2024-02-20 Thread Sergio Afonso via llvm-branch-commits

https://github.com/skatrak edited 
https://github.com/llvm/llvm-project/pull/81629
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [flang] [flang][OpenMP] Convert DataSharingProcessor to omp::Clause (PR #81629)

2024-02-20 Thread Sergio Afonso via llvm-branch-commits

https://github.com/skatrak commented:

LGTM, just small comments.

https://github.com/llvm/llvm-project/pull/81629
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [llvm] release/18.x: [AArch64] Backport Ampere1B support (#81297 , #81341, and #81744) (PR #81857)

2024-02-20 Thread Aaron Ballman via llvm-branch-commits

AaronBallman wrote:

Is this fixing a regression introduced in Clang 18? I'm wondering why the 
backport is needed in the first place, as this seems to be making potentially 
significant changes during the RC ("Make +pauth enabled in Armv8.3-a by 
default").

https://github.com/llvm/llvm-project/pull/81857
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [ARM, MC] Support FDPIC relocations (PR #82187)

2024-02-20 Thread Peter Smith via llvm-branch-commits

https://github.com/smithp35 edited 
https://github.com/llvm/llvm-project/pull/82187
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [ARM, MC] Support FDPIC relocations (PR #82187)

2024-02-20 Thread Peter Smith via llvm-branch-commits


@@ -223,6 +223,12 @@ class MCSymbolRefExpr : public MCExpr {
 VK_SECREL,
 VK_SIZE,// symbol@SIZE
 VK_WEAKREF, // The link between the symbols in .weakref foo, bar
+VK_FUNCDESC,

smithp35 wrote:

While VK_TLSGD_FDPIC are somewhat self documenting, it may be worth a comment 
for VK_FUNCDESC to VK_GOTOFFUNCDESC to state that these are for FDPIC.

https://github.com/llvm/llvm-project/pull/82187
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [ARM, MC] Support FDPIC relocations (PR #82187)

2024-02-20 Thread Peter Smith via llvm-branch-commits

https://github.com/smithp35 commented:

I've checked over the implementation with binutils. Out of interest are you 
planning on implementing all of fdpic or just enough to get assembler/linker 
support working?

If you are there are some other GNU options that may be useful to look at as 
possible intermediate steps. In particular -mno-pic-data-is-text-relative 
https://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html#index-mpic-data-is-text-relative
 this uses a single static base for the GOT which is sufficient for position 
independent executables but no shared library support.

https://github.com/llvm/llvm-project/pull/82187
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [ARM, MC] Support FDPIC relocations (PR #82187)

2024-02-20 Thread Peter Smith via llvm-branch-commits


@@ -11358,6 +11361,37 @@ bool ARMAsmParser::parseDirectiveARM(SMLoc L) {
   return false;
 }
 
+MCSymbolRefExpr::VariantKind
+ARMAsmParser::getVariantKindForName(StringRef Name) const {
+  return StringSwitch(Name.lower())
+  .Case("funcdesc", MCSymbolRefExpr::VK_FUNCDESC)
+  .Case("got", MCSymbolRefExpr::VK_GOT)
+  .Case("got_prel", MCSymbolRefExpr::VK_ARM_GOT_PREL)
+  .Case("gotfuncdesc", MCSymbolRefExpr::VK_GOTFUNCDESC)
+  .Case("gotoff", MCSymbolRefExpr::VK_GOTOFF)
+  .Case("gotofffuncdesc", MCSymbolRefExpr::VK_GOTOFFFUNCDESC)
+  .Case("gottpoff", MCSymbolRefExpr::VK_GOTTPOFF)
+  .Case("gottpoff_fdpic", MCSymbolRefExpr::VK_GOTTPOFF_FDPIC)
+  .Case("imgrel", MCSymbolRefExpr::VK_COFF_IMGREL32)
+  .Case("none", MCSymbolRefExpr::VK_ARM_NONE)
+  .Case("plt", MCSymbolRefExpr::VK_PLT)
+  .Case("prel31", MCSymbolRefExpr::VK_ARM_PREL31)
+  .Case("sbrel", MCSymbolRefExpr::VK_ARM_SBREL)
+  .Case("secrel32", MCSymbolRefExpr::VK_SECREL)
+  .Case("target1", MCSymbolRefExpr::VK_ARM_TARGET1)
+  .Case("target2", MCSymbolRefExpr::VK_ARM_TARGET2)
+  .Case("tlscall", MCSymbolRefExpr::VK_TLSCALL)
+  .Case("tlsdesc", MCSymbolRefExpr::VK_TLSDESC)
+  .Case("tlsgd", MCSymbolRefExpr::VK_TLSGD)
+  .Case("tlsgd_fdpic", MCSymbolRefExpr::VK_TLSGD_FDPIC)
+  .Case("tlsld", MCSymbolRefExpr::VK_TLSLD)
+  .Case("tlsldm", MCSymbolRefExpr::VK_TLSLDM)
+  .Case("tlsldm_fdpic", MCSymbolRefExpr::VK_TLSLDM_FDPIC)
+  .Case("tlsldo", MCSymbolRefExpr::VK_ARM_TLSLDO)
+  .Case("tpoff", MCSymbolRefExpr::VK_TPOFF)
+  .Default(MCSymbolRefExpr::VK_Invalid);

smithp35 wrote:

I think Arm supports "tlddescseq" from checking this list against binutils. I 
don't think this was in the original list though.

https://github.com/llvm/llvm-project/pull/82187
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [ARM, MC] Support FDPIC relocations (PR #82187)

2024-02-20 Thread Peter Smith via llvm-branch-commits


@@ -11358,6 +11361,37 @@ bool ARMAsmParser::parseDirectiveARM(SMLoc L) {
   return false;
 }
 
+MCSymbolRefExpr::VariantKind
+ARMAsmParser::getVariantKindForName(StringRef Name) const {

smithp35 wrote:

I can see a design trade-off here. By implementing only the expressions that 
are supported on Arm we find some problems earlier, however we may miss out on 
generic expressions added to the `MCSymbolRefExpr::getVariantKindForName` but 
not for Arm. I can see these getting out of sync.

Would it be worth calling the MCSymbolRefExpr::getVariantKindForName if the 
Name isn't found? Ideally we could refactor so that 
MCSymbolRefExpr::getVariantKindForName contains only generic and no target 
specific variant kinds.



https://github.com/llvm/llvm-project/pull/82187
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [ARM, MC] Support FDPIC relocations (PR #82187)

2024-02-20 Thread Peter Smith via llvm-branch-commits


@@ -84,6 +84,11 @@ unsigned ARMELFObjectWriter::GetRelocTypeInner(const MCValue 
&Target,
   if (Kind >= FirstLiteralRelocationKind)
 return Kind - FirstLiteralRelocationKind;
   MCSymbolRefExpr::VariantKind Modifier = Target.getAccessVariant();
+  auto CheckFDPIC = [&]() {
+if (getOSABI() != ELF::ELFOSABI_ARM_FDPIC)
+  Ctx.reportError(Fixup.getLoc(),

smithp35 wrote:

I think the error message could be improved by giving out the string 
representation of the relocation code. For example:
```relocation R_ARM_FUNCDESC only supported in FDPIC mode```. I think this 
should be relatively easy to add.

https://github.com/llvm/llvm-project/pull/82187
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [openmp] release/18.x: [OpenMP][AIX]Add assembly file containing microtasking routines and unnamed common block definitions (#81770) (PR #82391)

2024-02-20 Thread via llvm-branch-commits

https://github.com/llvmbot milestoned 
https://github.com/llvm/llvm-project/pull/82391
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [openmp] release/18.x: [OpenMP][AIX]Add assembly file containing microtasking routines and unnamed common block definitions (#81770) (PR #82391)

2024-02-20 Thread via llvm-branch-commits

https://github.com/llvmbot created 
https://github.com/llvm/llvm-project/pull/82391

Backport 94100bc2fb1a39dbeb43d18a95176097c53f1324

Requested by: @brad0

>From c30cb94d7f5b4742cdd8f13de59bb28fa6cff363 Mon Sep 17 00:00:00 2001
From: Xing Xue 
Date: Tue, 20 Feb 2024 12:08:37 -0500
Subject: [PATCH] [OpenMP][AIX]Add assembly file containing microtasking
 routines and unnamed common block definitions (#81770)

This patch adds assembly file `z_AIX_asm.S` that contains the 32- and
64-bit XCOFF version of microtasking routines and unnamed common block
definitions. This code has been run through the libomp LIT tests and a
user package successfully.

(cherry picked from commit 94100bc2fb1a39dbeb43d18a95176097c53f1324)
---
 openmp/runtime/src/z_AIX_asm.S | 410 +
 1 file changed, 410 insertions(+)
 create mode 100644 openmp/runtime/src/z_AIX_asm.S

diff --git a/openmp/runtime/src/z_AIX_asm.S b/openmp/runtime/src/z_AIX_asm.S
new file mode 100644
index 00..d711fcb7a7854f
--- /dev/null
+++ b/openmp/runtime/src/z_AIX_asm.S
@@ -0,0 +1,410 @@
+//  z_AIX_asm.S:  - microtasking routines specifically
+//  written for Power platforms running AIX OS
+
+//
+===--===//
+
+ Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+ See https://llvm.org/LICENSE.txt for license information.
+ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+===--===//
+//
+
+// ---
+// macros
+// ---
+
+#include "kmp_config.h"
+
+#if KMP_OS_AIX
+//
+// int
+// __kmp_invoke_microtask( void (*pkfn) (int *gtid, int *tid, ...),
+// int gtid, int tid,
+// int argc, void *p_argv[]
+// #if OMPT_SUPPORT
+// ,
+// void **exit_frame_ptr
+// #endif
+//   ) {
+// #if OMPT_SUPPORT
+//   *exit_frame_ptr = OMPT_GET_FRAME_ADDRESS(0);
+// #endif
+//
+//   (*pkfn)( & gtid, & tid, p_argv[0], ... );
+//
+// // FIXME: This is done at call-site and can be removed here.
+// #if OMPT_SUPPORT
+//   *exit_frame_ptr = 0;
+// #endif
+//
+//   return 1;
+// }
+//
+// parameters:
+//   r3: pkfn
+//   r4: gtid
+//   r5: tid
+//   r6: argc
+//   r7: p_argv
+//   r8: &exit_frame
+//
+// return:  r3 (always 1/TRUE)
+//
+
+#if KMP_ARCH_PPC64_XCOFF
+
+.globl  __kmp_invoke_microtask[DS]
+.globl  .__kmp_invoke_microtask
+.align  4
+.csect __kmp_invoke_microtask[DS],3
+.vbyte  8, .__kmp_invoke_microtask
+.vbyte  8, TOC[TC0]
+.vbyte  8, 0
+.csect .text[PR],2
+.machine "pwr7"
+.__kmp_invoke_microtask:
+
+
+// -- Begin __kmp_invoke_microtask
+// mark_begin;
+
+// We need to allocate a stack frame large enough to hold all of the parameters
+// on the stack for the microtask plus what this function needs. That's 48
+// bytes under the XCOFF64 ABI, plus max(64, 8*(2 + argc)) for
+// the parameters to the microtask (gtid, tid, argc elements of p_argv),
+// plus 8 bytes to store the values of r4 and r5, and 8 bytes to store r31.
+// With OMP-T support, we need an additional 8 bytes to save r30 to hold
+// a copy of r8.
+// Stack offsets relative to stack pointer:
+//   r31: -8, r30: -16, gtid: -20, tid: -24
+
+mflr 0
+std 31, -8(1)  # Save r31 to the stack
+std 0, 16(1)   # Save LR to the linkage area
+
+// This is unusual because normally we'd set r31 equal to r1 after the stack
+// frame is established. In this case, however, we need to dynamically compute
+// the stack frame size, and so we keep a direct copy of r1 to access our
+// register save areas and restore the r1 value before returning.
+mr 31, 1
+
+// Compute the size of the "argc" portion of the parameter save area.
+// The parameter save area is always at least 64 bytes long (i.e. 8 regs)
+// The microtask has (2 + argc) parameters, so if argc <= 6, we need to
+// to allocate 8*6 bytes, not 8*argc.
+li 0, 6
+cmpwi 0, 6, 6
+iselgt 0, 6, 0 # r0 = (argc > 6)? argc : 6
+sldi 0, 0, 3   # r0 = 8 * max(argc, 6)
+
+// Compute the size necessary for the local stack frame.
+// 88 = 48 + 4 (for r4) + 4 (for r5) + 8 (for r31) + 8 (for OMP-T r30) +
+//  8 (parameter gtid) + 8 (parameter tid)
+li 12, 88
+add 12, 0, 12
+neg 12, 12
+
+// We need to make sure that the stack frame stays aligned (to 16 bytes).
+li 0, -16
+and 12, 0, 12
+
+// Establish the local stack frame.
+stdux 1, 1, 12
+
+#if OMPT_SUPPORT
+std 30, -16(31)# Save r30 to the stack
+std 1, 0(8)
+mr 30, 8
+#endif
+
+// Store gtid and tid to the stack because they're passed by reference 

[llvm-branch-commits] [openmp] release/18.x: [OpenMP][AIX]Add assembly file containing microtasking routines and unnamed common block definitions (#81770) (PR #82391)

2024-02-20 Thread via llvm-branch-commits

llvmbot wrote:

@shiltian What do you think about merging this PR to the release branch?

https://github.com/llvm/llvm-project/pull/82391
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [openmp] release/18.x: [OpenMP][AIX]Add assembly file containing microtasking routines and unnamed common block definitions (#81770) (PR #82391)

2024-02-20 Thread Shilei Tian via llvm-branch-commits

https://github.com/shiltian approved this pull request.


https://github.com/llvm/llvm-project/pull/82391
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [ARM, MC] Support FDPIC relocations (PR #82187)

2024-02-20 Thread Fangrui Song via llvm-branch-commits


@@ -11358,6 +11361,37 @@ bool ARMAsmParser::parseDirectiveARM(SMLoc L) {
   return false;
 }
 
+MCSymbolRefExpr::VariantKind
+ARMAsmParser::getVariantKindForName(StringRef Name) const {
+  return StringSwitch(Name.lower())
+  .Case("funcdesc", MCSymbolRefExpr::VK_FUNCDESC)
+  .Case("got", MCSymbolRefExpr::VK_GOT)
+  .Case("got_prel", MCSymbolRefExpr::VK_ARM_GOT_PREL)
+  .Case("gotfuncdesc", MCSymbolRefExpr::VK_GOTFUNCDESC)
+  .Case("gotoff", MCSymbolRefExpr::VK_GOTOFF)
+  .Case("gotofffuncdesc", MCSymbolRefExpr::VK_GOTOFFFUNCDESC)
+  .Case("gottpoff", MCSymbolRefExpr::VK_GOTTPOFF)
+  .Case("gottpoff_fdpic", MCSymbolRefExpr::VK_GOTTPOFF_FDPIC)
+  .Case("imgrel", MCSymbolRefExpr::VK_COFF_IMGREL32)
+  .Case("none", MCSymbolRefExpr::VK_ARM_NONE)
+  .Case("plt", MCSymbolRefExpr::VK_PLT)
+  .Case("prel31", MCSymbolRefExpr::VK_ARM_PREL31)
+  .Case("sbrel", MCSymbolRefExpr::VK_ARM_SBREL)
+  .Case("secrel32", MCSymbolRefExpr::VK_SECREL)
+  .Case("target1", MCSymbolRefExpr::VK_ARM_TARGET1)
+  .Case("target2", MCSymbolRefExpr::VK_ARM_TARGET2)
+  .Case("tlscall", MCSymbolRefExpr::VK_TLSCALL)
+  .Case("tlsdesc", MCSymbolRefExpr::VK_TLSDESC)
+  .Case("tlsgd", MCSymbolRefExpr::VK_TLSGD)
+  .Case("tlsgd_fdpic", MCSymbolRefExpr::VK_TLSGD_FDPIC)
+  .Case("tlsld", MCSymbolRefExpr::VK_TLSLD)
+  .Case("tlsldm", MCSymbolRefExpr::VK_TLSLDM)
+  .Case("tlsldm_fdpic", MCSymbolRefExpr::VK_TLSLDM_FDPIC)
+  .Case("tlsldo", MCSymbolRefExpr::VK_ARM_TLSLDO)
+  .Case("tpoff", MCSymbolRefExpr::VK_TPOFF)
+  .Default(MCSymbolRefExpr::VK_Invalid);

MaskRay wrote:

Yes, the binutils contains `tlsdescseq`, but there is no `(tlsdescseq)` 
occurrence. GCC doesn't emit `(tlsdescseq)`, either.
I suspect that the entry in binutils is not used.

There is a directive named `.tlsdescseq`  
(https://www.fsfla.org/~lxoliva/writeups/TLS/RFC-TLSDESC-ARM.txt), which is for 
TLS optimization. But GCC doesn't emit this directive.

Clang doesn't support `-mtls-dialect=gnu2` for ARM.

https://github.com/llvm/llvm-project/pull/82187
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [ARM, MC] Support FDPIC relocations (PR #82187)

2024-02-20 Thread Fangrui Song via llvm-branch-commits

https://github.com/MaskRay edited 
https://github.com/llvm/llvm-project/pull/82187
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [ARM, MC] Support FDPIC relocations (PR #82187)

2024-02-20 Thread Fangrui Song via llvm-branch-commits


@@ -11358,6 +11361,37 @@ bool ARMAsmParser::parseDirectiveARM(SMLoc L) {
   return false;
 }
 
+MCSymbolRefExpr::VariantKind
+ARMAsmParser::getVariantKindForName(StringRef Name) const {

MaskRay wrote:

> Ideally we could refactor so that MCSymbolRefExpr::getVariantKindForName 
> contains only generic and no target specific variant kinds.

I agree with this. I believe that binutils doesn't have a generic operand 
modifier, so ideally `MCSymbolRefExpr::getVariantKindForName` should be a pure 
virtual function. Unfortunately, many architectures add arch-specific modifiers 
in this list. We should eventually move them to respective lib/Target/XXX files.

In this patch I am only focusing on the ARM specific operand modifiers.

https://github.com/llvm/llvm-project/pull/82187
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [ARM, MC] Support FDPIC relocations (PR #82187)

2024-02-20 Thread Fangrui Song via llvm-branch-commits

https://github.com/MaskRay edited 
https://github.com/llvm/llvm-project/pull/82187
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [ARM, MC] Support FDPIC relocations (PR #82187)

2024-02-20 Thread Fangrui Song via llvm-branch-commits

https://github.com/MaskRay edited 
https://github.com/llvm/llvm-project/pull/82187
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [ARM, MC] Support FDPIC relocations (PR #82187)

2024-02-20 Thread Fangrui Song via llvm-branch-commits

MaskRay wrote:

> I've checked over the implementation with binutils. Out of interest are you 
> planning on implementing all of fdpic or just enough to get assembler/linker 
> support working?

Yes, I plan to implement the codegen part to help me understand FDPIC better 
and the codegen part of LLVM...
(I need to study PPC ELFv1 function descriptors.)

> If you are there are some other GNU options that may be useful to look at as 
> possible intermediate steps. In particular -mno-pic-data-is-text-relative 
> [gcc.gnu.org/onlinedocs/gcc/ARM-Options.html#index-mpic-data-is-text-relative](https://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html#index-mpic-data-is-text-relative)
>  this uses a single static base for the GOT which is sufficient for position 
> independent executables but no shared library support.

Thanks for the pointers. Yes, it looks like ARM added 
`-mpic-data-is-text-relative` first then s390x ported it.
The option is similar to `-msep-data` (m68k/bfin) and probably used for 
MMU-less systems without dynamic linking support. I have work-in-progress notes 
at https://maskray.me/blog/2024-02-20-mmu-less-systems-and-fdpic

https://github.com/llvm/llvm-project/pull/82187
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [mlir] [mlir][Transforms][NFC] Simplify `ArgConverter` state (PR #81462)

2024-02-20 Thread Jacques Pienaar via llvm-branch-commits

https://github.com/jpienaar approved this pull request.

Nice, thanks!

https://github.com/llvm/llvm-project/pull/81462
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [mlir] [mlir][Transforms][NFC] Decouple `ConversionPatternRewriterImpl` from `ConversionPatternRewriter` (PR #82333)

2024-02-20 Thread Jacques Pienaar via llvm-branch-commits

https://github.com/jpienaar approved this pull request.


https://github.com/llvm/llvm-project/pull/82333
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [ARM, MC] Support FDPIC relocations (PR #82187)

2024-02-20 Thread Fangrui Song via llvm-branch-commits

https://github.com/MaskRay updated 
https://github.com/llvm/llvm-project/pull/82187


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


[llvm-branch-commits] [ARM, MC] Support FDPIC relocations (PR #82187)

2024-02-20 Thread Fangrui Song via llvm-branch-commits

https://github.com/MaskRay updated 
https://github.com/llvm/llvm-project/pull/82187


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


[llvm-branch-commits] [llvm] c74afe6 - [InstCombine] Add unsigned variants of gep exact div tests (NFC)

2024-02-20 Thread via llvm-branch-commits

Author: Nikita Popov
Date: 2024-02-20T12:02:48Z
New Revision: c74afe6f52e9db0c5acd90b78a232176ad460b5e

URL: 
https://github.com/llvm/llvm-project/commit/c74afe6f52e9db0c5acd90b78a232176ad460b5e
DIFF: 
https://github.com/llvm/llvm-project/commit/c74afe6f52e9db0c5acd90b78a232176ad460b5e.diff

LOG: [InstCombine] Add unsigned variants of gep exact div tests (NFC)

(cherry picked from commit ec2c770b9f9a0e9eca4a893383d2b27dd4c0bfe7)

Added: 


Modified: 
llvm/test/Transforms/InstCombine/getelementptr.ll

Removed: 




diff  --git a/llvm/test/Transforms/InstCombine/getelementptr.ll 
b/llvm/test/Transforms/InstCombine/getelementptr.ll
index 642c3eb2a0e41b..e6a3b759cf78d6 100644
--- a/llvm/test/Transforms/InstCombine/getelementptr.ll
+++ b/llvm/test/Transforms/InstCombine/getelementptr.ll
@@ -116,6 +116,7 @@ define void @test_overaligned_vec(i8 %B) {
 ; CHECK-LABEL: @test_overaligned_vec(
 ; CHECK-NEXT:store i8 [[B:%.*]], ptr getelementptr inbounds ([10 x i8], 
ptr @Global, i64 0, i64 2), align 1
 ; CHECK-NEXT:ret void
+;
   %A = getelementptr <2 x half>, ptr @Global, i64 0, i64 1
   store i8 %B, ptr %A
   ret void
@@ -1473,6 +1474,17 @@ define ptr @gep_sdiv(ptr %p, i64 %off) {
   ret ptr %ptr
 }
 
+define ptr @gep_udiv(ptr %p, i64 %off) {
+; CHECK-LABEL: @gep_udiv(
+; CHECK-NEXT:[[INDEX:%.*]] = udiv exact i64 [[OFF:%.*]], 7
+; CHECK-NEXT:[[PTR:%.*]] = getelementptr [[STRUCT_C:%.*]], ptr [[P:%.*]], 
i64 [[INDEX]]
+; CHECK-NEXT:ret ptr [[PTR]]
+;
+  %index = udiv exact i64 %off, 7
+  %ptr = getelementptr %struct.C, ptr %p, i64 %index
+  ret ptr %ptr
+}
+
 define <2 x ptr> @gep_sdiv_vec(<2 x ptr> %p, <2 x i64> %off) {
 ; CHECK-LABEL: @gep_sdiv_vec(
 ; CHECK-NEXT:[[PTR:%.*]] = getelementptr i8, <2 x ptr> [[P:%.*]], <2 x 
i64> [[OFF:%.*]]
@@ -1503,6 +1515,17 @@ define ptr @gep_ashr(ptr %p, i64 %off) {
   ret ptr %ptr
 }
 
+define ptr @gep_lshr(ptr %p, i64 %off) {
+; CHECK-LABEL: @gep_lshr(
+; CHECK-NEXT:[[INDEX:%.*]] = lshr exact i64 [[OFF:%.*]], 2
+; CHECK-NEXT:[[PTR:%.*]] = getelementptr i32, ptr [[P:%.*]], i64 [[INDEX]]
+; CHECK-NEXT:ret ptr [[PTR]]
+;
+  %index = lshr exact i64 %off, 2
+  %ptr = getelementptr i32, ptr %p, i64 %index
+  ret ptr %ptr
+}
+
 ; Negative tests
 
 define ptr @gep_i8(ptr %p, i64 %off) {
@@ -1525,6 +1548,17 @@ define ptr @gep_sdiv_mismatched_size(ptr %p, i64 %off) {
   ret ptr %ptr
 }
 
+define ptr @gep_udiv_mismatched_size(ptr %p, i64 %off) {
+; CHECK-LABEL: @gep_udiv_mismatched_size(
+; CHECK-NEXT:[[INDEX:%.*]] = udiv exact i64 [[OFF:%.*]], 20
+; CHECK-NEXT:[[PTR:%.*]] = getelementptr [[STRUCT_C:%.*]], ptr [[P:%.*]], 
i64 [[INDEX]]
+; CHECK-NEXT:ret ptr [[PTR]]
+;
+  %index = udiv exact i64 %off, 20
+  %ptr = getelementptr %struct.C, ptr %p, i64 %index
+  ret ptr %ptr
+}
+
 define ptr @gep_sdiv_without_exact(ptr %p, i64 %off) {
 ; CHECK-LABEL: @gep_sdiv_without_exact(
 ; CHECK-NEXT:[[INDEX:%.*]] = sdiv i64 [[OFF:%.*]], 7
@@ -1536,6 +1570,17 @@ define ptr @gep_sdiv_without_exact(ptr %p, i64 %off) {
   ret ptr %ptr
 }
 
+define ptr @gep_udiv_without_exact(ptr %p, i64 %off) {
+; CHECK-LABEL: @gep_udiv_without_exact(
+; CHECK-NEXT:[[INDEX:%.*]] = udiv i64 [[OFF:%.*]], 7
+; CHECK-NEXT:[[PTR:%.*]] = getelementptr [[STRUCT_C:%.*]], ptr [[P:%.*]], 
i64 [[INDEX]]
+; CHECK-NEXT:ret ptr [[PTR]]
+;
+  %index = udiv i64 %off, 7
+  %ptr = getelementptr %struct.C, ptr %p, i64 %index
+  ret ptr %ptr
+}
+
 define ptr @gep_ashr_without_exact(ptr %p, i64 %off) {
 ; CHECK-LABEL: @gep_ashr_without_exact(
 ; CHECK-NEXT:[[INDEX:%.*]] = ashr i64 [[OFF:%.*]], 2
@@ -1547,6 +1592,17 @@ define ptr @gep_ashr_without_exact(ptr %p, i64 %off) {
   ret ptr %ptr
 }
 
+define ptr @gep_lshr_without_exact(ptr %p, i64 %off) {
+; CHECK-LABEL: @gep_lshr_without_exact(
+; CHECK-NEXT:[[INDEX:%.*]] = lshr i64 [[OFF:%.*]], 2
+; CHECK-NEXT:[[PTR:%.*]] = getelementptr i32, ptr [[P:%.*]], i64 [[INDEX]]
+; CHECK-NEXT:ret ptr [[PTR]]
+;
+  %index = lshr i64 %off, 2
+  %ptr = getelementptr i32, ptr %p, i64 %index
+  ret ptr %ptr
+}
+
 define i1 @test_only_used_by_icmp(ptr %a, ptr %b, ptr %c) {
 ; CHECK-LABEL: @test_only_used_by_icmp(
 ; CHECK-NEXT:[[CMP:%.*]] = icmp eq ptr [[B:%.*]], [[C:%.*]]



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


[llvm-branch-commits] [llvm] ebc589e - [InstCombine] Fold gep of exact unsigned division (#82334)

2024-02-20 Thread via llvm-branch-commits

Author: Nikita Popov
Date: 2024-02-20T12:02:48Z
New Revision: ebc589e44ffe7b77cc500f3d2dc1a7ba11dd82b1

URL: 
https://github.com/llvm/llvm-project/commit/ebc589e44ffe7b77cc500f3d2dc1a7ba11dd82b1
DIFF: 
https://github.com/llvm/llvm-project/commit/ebc589e44ffe7b77cc500f3d2dc1a7ba11dd82b1.diff

LOG: [InstCombine] Fold gep of exact unsigned division (#82334)

Extend the transform added in
https://github.com/llvm/llvm-project/pull/76458 to also handle unsigned
division. X exact/ Y * Y == X holds independently of whether the
division is signed or unsigned.

Proofs: https://alive2.llvm.org/ce/z/wFd5Ec
(cherry picked from commit 26d4afc3de86ca5416c8e38000362c526b6808cd)

Added: 


Modified: 
llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
llvm/test/Transforms/InstCombine/getelementptr.ll

Removed: 




diff  --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp 
b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
index 249f4a7710e046..5d207dcfd18dd4 100644
--- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
@@ -2594,10 +2594,10 @@ Instruction 
*InstCombinerImpl::visitGetElementPtrInst(GetElementPtrInst &GEP) {
 Value *V;
 if ((has_single_bit(TyAllocSize) &&
  match(GEP.getOperand(1),
-   m_Exact(m_AShr(m_Value(V),
-  m_SpecificInt(countr_zero(TyAllocSize)) 
||
+   m_Exact(m_Shr(m_Value(V),
+ m_SpecificInt(countr_zero(TyAllocSize)) ||
 match(GEP.getOperand(1),
-  m_Exact(m_SDiv(m_Value(V), m_SpecificInt(TyAllocSize) {
+  m_Exact(m_IDiv(m_Value(V), m_SpecificInt(TyAllocSize) {
   GetElementPtrInst *NewGEP = GetElementPtrInst::Create(
   Builder.getInt8Ty(), GEP.getPointerOperand(), V);
   NewGEP->setIsInBounds(GEP.isInBounds());

diff  --git a/llvm/test/Transforms/InstCombine/getelementptr.ll 
b/llvm/test/Transforms/InstCombine/getelementptr.ll
index e6a3b759cf78d6..c90b6c9fb29592 100644
--- a/llvm/test/Transforms/InstCombine/getelementptr.ll
+++ b/llvm/test/Transforms/InstCombine/getelementptr.ll
@@ -1476,8 +1476,7 @@ define ptr @gep_sdiv(ptr %p, i64 %off) {
 
 define ptr @gep_udiv(ptr %p, i64 %off) {
 ; CHECK-LABEL: @gep_udiv(
-; CHECK-NEXT:[[INDEX:%.*]] = udiv exact i64 [[OFF:%.*]], 7
-; CHECK-NEXT:[[PTR:%.*]] = getelementptr [[STRUCT_C:%.*]], ptr [[P:%.*]], 
i64 [[INDEX]]
+; CHECK-NEXT:[[PTR:%.*]] = getelementptr i8, ptr [[P:%.*]], i64 [[OFF:%.*]]
 ; CHECK-NEXT:ret ptr [[PTR]]
 ;
   %index = udiv exact i64 %off, 7
@@ -1517,8 +1516,7 @@ define ptr @gep_ashr(ptr %p, i64 %off) {
 
 define ptr @gep_lshr(ptr %p, i64 %off) {
 ; CHECK-LABEL: @gep_lshr(
-; CHECK-NEXT:[[INDEX:%.*]] = lshr exact i64 [[OFF:%.*]], 2
-; CHECK-NEXT:[[PTR:%.*]] = getelementptr i32, ptr [[P:%.*]], i64 [[INDEX]]
+; CHECK-NEXT:[[PTR:%.*]] = getelementptr i8, ptr [[P:%.*]], i64 [[OFF:%.*]]
 ; CHECK-NEXT:ret ptr [[PTR]]
 ;
   %index = lshr exact i64 %off, 2



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


[llvm-branch-commits] [llvm] release/18.x: [InstCombine] Fold gep of exact unsigned division (#82334) (PR #82347)

2024-02-20 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/82347
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] release/18.x: [cmake] Add minor version to library SONAME (#79376) (PR #82409)

2024-02-20 Thread via llvm-branch-commits

https://github.com/llvmbot created 
https://github.com/llvm/llvm-project/pull/82409

Backport 91a384621e5b762d9c173ffd247cfeadd5f436a2

Requested by: @tstellar

>From 4f49c058f52996c02b791106d73b841cd8552d2c Mon Sep 17 00:00:00 2001
From: Tom Stellard 
Date: Mon, 19 Feb 2024 16:46:16 -0800
Subject: [PATCH] [cmake] Add minor version to library SONAME (#79376)

We need to do this now that we are bumping the minor release number when
we create the release branch.

This also results in a slight change to the library names for LLVM. The
main library now has a more convential library name:
'libLLVM.so.$major.$minor'. The old library name: libLLVM-$major.so is
now a symlink that points to the new library. However, the symlink is
not present in the build directory. It is only present in the install
directory.

The library name was changed because it helped to keep the CMake changes
more simple.

Fixes #76273

(cherry picked from commit 91a384621e5b762d9c173ffd247cfeadd5f436a2)
---
 llvm/CMakeLists.txt  | 2 +-
 llvm/cmake/modules/AddLLVM.cmake | 8 
 llvm/tools/llvm-shlib/CMakeLists.txt | 5 -
 3 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index c2fb77d5a371f4..44f2850b92d522 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -35,7 +35,7 @@ endif()
 
 if(NOT DEFINED LLVM_SHLIB_SYMBOL_VERSION)
   # "Symbol version prefix for libLLVM.so"
-  set(LLVM_SHLIB_SYMBOL_VERSION "LLVM_${LLVM_VERSION_MAJOR}")
+  set(LLVM_SHLIB_SYMBOL_VERSION 
"LLVM_${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}")
 endif()
 
 if ((CMAKE_GENERATOR MATCHES "Visual Studio") AND (MSVC_TOOLSET_VERSION LESS 
142) AND (CMAKE_GENERATOR_TOOLSET STREQUAL ""))
diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index 5e989618552824..5fc663d10b8f77 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -108,7 +108,7 @@ function(add_llvm_symbol_exports target_name export_file)
   COMMAND "${Python3_EXECUTABLE}" "-c"
   "import sys; \
lines = ['' + l.rstrip() for l in sys.stdin] + ['  local: *;']; \
-   print('LLVM_${LLVM_VERSION_MAJOR} {'); \
+   print('LLVM_${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR} {'); \
print('  global:') if len(lines) > 1 else None; \
print(';\\n'.join(lines) + '\\n};')"
   < ${export_file} > ${native_export_file}
@@ -646,9 +646,9 @@ function(llvm_add_library name)
 if(UNIX AND NOT APPLE AND NOT ARG_SONAME)
   set_target_properties(${name}
 PROPERTIES
-# Since 4.0.0, the ABI version is indicated by the major version
-SOVERSION ${LLVM_VERSION_MAJOR}${LLVM_VERSION_SUFFIX}
-VERSION ${LLVM_VERSION_MAJOR}${LLVM_VERSION_SUFFIX})
+# Since 18.1.0, the ABI version is indicated by the major and minor 
version.
+SOVERSION 
${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}${LLVM_VERSION_SUFFIX}
+VERSION 
${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}${LLVM_VERSION_SUFFIX})
 endif()
   endif()
 
diff --git a/llvm/tools/llvm-shlib/CMakeLists.txt 
b/llvm/tools/llvm-shlib/CMakeLists.txt
index a47a0ec84c625c..09c15e304614c4 100644
--- a/llvm/tools/llvm-shlib/CMakeLists.txt
+++ b/llvm/tools/llvm-shlib/CMakeLists.txt
@@ -33,7 +33,10 @@ if(LLVM_BUILD_LLVM_DYLIB)
   if (LLVM_LINK_LLVM_DYLIB)
 set(INSTALL_WITH_TOOLCHAIN INSTALL_WITH_TOOLCHAIN)
   endif()
-  add_llvm_library(LLVM SHARED DISABLE_LLVM_LINK_LLVM_DYLIB SONAME 
${INSTALL_WITH_TOOLCHAIN} ${SOURCES})
+  add_llvm_library(LLVM SHARED DISABLE_LLVM_LINK_LLVM_DYLIB OUTPUT_NAME LLVM 
${INSTALL_WITH_TOOLCHAIN} ${SOURCES})
+  # Add symlink for backwards compatibility with old library name
+  get_target_property(LLVM_DYLIB_FILENAME LLVM OUTPUT_NAME)
+  
llvm_install_library_symlink(LLVM-${LLVM_VERSION_MAJOR}${LLVM_VERSION_SUFFIX} 
${LLVM_DYLIB_FILENAME} SHARED COMPONENT LLVM)
 
   list(REMOVE_DUPLICATES LIB_NAMES)
   if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")

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


[llvm-branch-commits] [llvm] release/18.x: [cmake] Add minor version to library SONAME (#79376) (PR #82409)

2024-02-20 Thread via llvm-branch-commits

https://github.com/llvmbot milestoned 
https://github.com/llvm/llvm-project/pull/82409
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] release/18.x: [cmake] Add minor version to library SONAME (#79376) (PR #82409)

2024-02-20 Thread via llvm-branch-commits

llvmbot wrote:

@jyknight What do you think about merging this PR to the release branch?

https://github.com/llvm/llvm-project/pull/82409
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [openmp] release/18.x: [OpenMP][AIX]Add assembly file containing microtasking routines and unnamed common block definitions (#81770) (PR #82391)

2024-02-20 Thread via llvm-branch-commits

https://github.com/llvmbot updated 
https://github.com/llvm/llvm-project/pull/82391

>From 801a10d3058a44b257236edfa08748c7f7ddbccb Mon Sep 17 00:00:00 2001
From: Xing Xue 
Date: Tue, 20 Feb 2024 12:08:37 -0500
Subject: [PATCH] [OpenMP][AIX]Add assembly file containing microtasking
 routines and unnamed common block definitions (#81770)

This patch adds assembly file `z_AIX_asm.S` that contains the 32- and
64-bit XCOFF version of microtasking routines and unnamed common block
definitions. This code has been run through the libomp LIT tests and a
user package successfully.

(cherry picked from commit 94100bc2fb1a39dbeb43d18a95176097c53f1324)
---
 openmp/runtime/src/z_AIX_asm.S | 410 +
 1 file changed, 410 insertions(+)
 create mode 100644 openmp/runtime/src/z_AIX_asm.S

diff --git a/openmp/runtime/src/z_AIX_asm.S b/openmp/runtime/src/z_AIX_asm.S
new file mode 100644
index 00..d711fcb7a7854f
--- /dev/null
+++ b/openmp/runtime/src/z_AIX_asm.S
@@ -0,0 +1,410 @@
+//  z_AIX_asm.S:  - microtasking routines specifically
+//  written for Power platforms running AIX OS
+
+//
+===--===//
+
+ Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+ See https://llvm.org/LICENSE.txt for license information.
+ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+===--===//
+//
+
+// ---
+// macros
+// ---
+
+#include "kmp_config.h"
+
+#if KMP_OS_AIX
+//
+// int
+// __kmp_invoke_microtask( void (*pkfn) (int *gtid, int *tid, ...),
+// int gtid, int tid,
+// int argc, void *p_argv[]
+// #if OMPT_SUPPORT
+// ,
+// void **exit_frame_ptr
+// #endif
+//   ) {
+// #if OMPT_SUPPORT
+//   *exit_frame_ptr = OMPT_GET_FRAME_ADDRESS(0);
+// #endif
+//
+//   (*pkfn)( & gtid, & tid, p_argv[0], ... );
+//
+// // FIXME: This is done at call-site and can be removed here.
+// #if OMPT_SUPPORT
+//   *exit_frame_ptr = 0;
+// #endif
+//
+//   return 1;
+// }
+//
+// parameters:
+//   r3: pkfn
+//   r4: gtid
+//   r5: tid
+//   r6: argc
+//   r7: p_argv
+//   r8: &exit_frame
+//
+// return:  r3 (always 1/TRUE)
+//
+
+#if KMP_ARCH_PPC64_XCOFF
+
+.globl  __kmp_invoke_microtask[DS]
+.globl  .__kmp_invoke_microtask
+.align  4
+.csect __kmp_invoke_microtask[DS],3
+.vbyte  8, .__kmp_invoke_microtask
+.vbyte  8, TOC[TC0]
+.vbyte  8, 0
+.csect .text[PR],2
+.machine "pwr7"
+.__kmp_invoke_microtask:
+
+
+// -- Begin __kmp_invoke_microtask
+// mark_begin;
+
+// We need to allocate a stack frame large enough to hold all of the parameters
+// on the stack for the microtask plus what this function needs. That's 48
+// bytes under the XCOFF64 ABI, plus max(64, 8*(2 + argc)) for
+// the parameters to the microtask (gtid, tid, argc elements of p_argv),
+// plus 8 bytes to store the values of r4 and r5, and 8 bytes to store r31.
+// With OMP-T support, we need an additional 8 bytes to save r30 to hold
+// a copy of r8.
+// Stack offsets relative to stack pointer:
+//   r31: -8, r30: -16, gtid: -20, tid: -24
+
+mflr 0
+std 31, -8(1)  # Save r31 to the stack
+std 0, 16(1)   # Save LR to the linkage area
+
+// This is unusual because normally we'd set r31 equal to r1 after the stack
+// frame is established. In this case, however, we need to dynamically compute
+// the stack frame size, and so we keep a direct copy of r1 to access our
+// register save areas and restore the r1 value before returning.
+mr 31, 1
+
+// Compute the size of the "argc" portion of the parameter save area.
+// The parameter save area is always at least 64 bytes long (i.e. 8 regs)
+// The microtask has (2 + argc) parameters, so if argc <= 6, we need to
+// to allocate 8*6 bytes, not 8*argc.
+li 0, 6
+cmpwi 0, 6, 6
+iselgt 0, 6, 0 # r0 = (argc > 6)? argc : 6
+sldi 0, 0, 3   # r0 = 8 * max(argc, 6)
+
+// Compute the size necessary for the local stack frame.
+// 88 = 48 + 4 (for r4) + 4 (for r5) + 8 (for r31) + 8 (for OMP-T r30) +
+//  8 (parameter gtid) + 8 (parameter tid)
+li 12, 88
+add 12, 0, 12
+neg 12, 12
+
+// We need to make sure that the stack frame stays aligned (to 16 bytes).
+li 0, -16
+and 12, 0, 12
+
+// Establish the local stack frame.
+stdux 1, 1, 12
+
+#if OMPT_SUPPORT
+std 30, -16(31)# Save r30 to the stack
+std 1, 0(8)
+mr 30, 8
+#endif
+
+// Store gtid and tid to the stack because they're passed by reference to the 
microtask.
+stw 4, -20(31) # Save gtid to the stack
+

[llvm-branch-commits] [openmp] 801a10d - [OpenMP][AIX]Add assembly file containing microtasking routines and unnamed common block definitions (#81770)

2024-02-20 Thread Tom Stellard via llvm-branch-commits

Author: Xing Xue
Date: 2024-02-20T11:54:09-08:00
New Revision: 801a10d3058a44b257236edfa08748c7f7ddbccb

URL: 
https://github.com/llvm/llvm-project/commit/801a10d3058a44b257236edfa08748c7f7ddbccb
DIFF: 
https://github.com/llvm/llvm-project/commit/801a10d3058a44b257236edfa08748c7f7ddbccb.diff

LOG: [OpenMP][AIX]Add assembly file containing microtasking routines and 
unnamed common block definitions (#81770)

This patch adds assembly file `z_AIX_asm.S` that contains the 32- and
64-bit XCOFF version of microtasking routines and unnamed common block
definitions. This code has been run through the libomp LIT tests and a
user package successfully.

(cherry picked from commit 94100bc2fb1a39dbeb43d18a95176097c53f1324)

Added: 
openmp/runtime/src/z_AIX_asm.S

Modified: 


Removed: 




diff  --git a/openmp/runtime/src/z_AIX_asm.S b/openmp/runtime/src/z_AIX_asm.S
new file mode 100644
index 00..d711fcb7a7854f
--- /dev/null
+++ b/openmp/runtime/src/z_AIX_asm.S
@@ -0,0 +1,410 @@
+//  z_AIX_asm.S:  - microtasking routines specifically
+//  written for Power platforms running AIX OS
+
+//
+===--===//
+
+ Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+ See https://llvm.org/LICENSE.txt for license information.
+ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+===--===//
+//
+
+// ---
+// macros
+// ---
+
+#include "kmp_config.h"
+
+#if KMP_OS_AIX
+//
+// int
+// __kmp_invoke_microtask( void (*pkfn) (int *gtid, int *tid, ...),
+// int gtid, int tid,
+// int argc, void *p_argv[]
+// #if OMPT_SUPPORT
+// ,
+// void **exit_frame_ptr
+// #endif
+//   ) {
+// #if OMPT_SUPPORT
+//   *exit_frame_ptr = OMPT_GET_FRAME_ADDRESS(0);
+// #endif
+//
+//   (*pkfn)( & gtid, & tid, p_argv[0], ... );
+//
+// // FIXME: This is done at call-site and can be removed here.
+// #if OMPT_SUPPORT
+//   *exit_frame_ptr = 0;
+// #endif
+//
+//   return 1;
+// }
+//
+// parameters:
+//   r3: pkfn
+//   r4: gtid
+//   r5: tid
+//   r6: argc
+//   r7: p_argv
+//   r8: &exit_frame
+//
+// return:  r3 (always 1/TRUE)
+//
+
+#if KMP_ARCH_PPC64_XCOFF
+
+.globl  __kmp_invoke_microtask[DS]
+.globl  .__kmp_invoke_microtask
+.align  4
+.csect __kmp_invoke_microtask[DS],3
+.vbyte  8, .__kmp_invoke_microtask
+.vbyte  8, TOC[TC0]
+.vbyte  8, 0
+.csect .text[PR],2
+.machine "pwr7"
+.__kmp_invoke_microtask:
+
+
+// -- Begin __kmp_invoke_microtask
+// mark_begin;
+
+// We need to allocate a stack frame large enough to hold all of the parameters
+// on the stack for the microtask plus what this function needs. That's 48
+// bytes under the XCOFF64 ABI, plus max(64, 8*(2 + argc)) for
+// the parameters to the microtask (gtid, tid, argc elements of p_argv),
+// plus 8 bytes to store the values of r4 and r5, and 8 bytes to store r31.
+// With OMP-T support, we need an additional 8 bytes to save r30 to hold
+// a copy of r8.
+// Stack offsets relative to stack pointer:
+//   r31: -8, r30: -16, gtid: -20, tid: -24
+
+mflr 0
+std 31, -8(1)  # Save r31 to the stack
+std 0, 16(1)   # Save LR to the linkage area
+
+// This is unusual because normally we'd set r31 equal to r1 after the stack
+// frame is established. In this case, however, we need to dynamically compute
+// the stack frame size, and so we keep a direct copy of r1 to access our
+// register save areas and restore the r1 value before returning.
+mr 31, 1
+
+// Compute the size of the "argc" portion of the parameter save area.
+// The parameter save area is always at least 64 bytes long (i.e. 8 regs)
+// The microtask has (2 + argc) parameters, so if argc <= 6, we need to
+// to allocate 8*6 bytes, not 8*argc.
+li 0, 6
+cmpwi 0, 6, 6
+iselgt 0, 6, 0 # r0 = (argc > 6)? argc : 6
+sldi 0, 0, 3   # r0 = 8 * max(argc, 6)
+
+// Compute the size necessary for the local stack frame.
+// 88 = 48 + 4 (for r4) + 4 (for r5) + 8 (for r31) + 8 (for OMP-T r30) +
+//  8 (parameter gtid) + 8 (parameter tid)
+li 12, 88
+add 12, 0, 12
+neg 12, 12
+
+// We need to make sure that the stack frame stays aligned (to 16 bytes).
+li 0, -16
+and 12, 0, 12
+
+// Establish the local stack frame.
+stdux 1, 1, 12
+
+#if OMPT_SUPPORT
+std 30, -16(31)# Save r30 to the stack
+std 1, 0(8)
+mr 30, 8
+#endif
+
+// Store gtid and tid to the stack because they're passed by reference to t

[llvm-branch-commits] [openmp] release/18.x: [OpenMP][AIX]Add assembly file containing microtasking routines and unnamed common block definitions (#81770) (PR #82391)

2024-02-20 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/82391
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] release/18.x: [llvm-readobj] Add support for the PT_OPENBSD_SYSCALLS segment type. (#82122) (PR #82318)

2024-02-20 Thread via llvm-branch-commits

https://github.com/llvmbot updated 
https://github.com/llvm/llvm-project/pull/82318

>From 3af6881cab6c98c304eed112f2153f9bbe67b5ee Mon Sep 17 00:00:00 2001
From: Frederic Cambus 
Date: Tue, 20 Feb 2024 09:12:58 +0100
Subject: [PATCH] [llvm-readobj] Add support for the PT_OPENBSD_SYSCALLS
 segment type. (#82122)

Reference: https://github.com/openbsd/src/blob/master/sys/sys/exec_elf.h
(cherry picked from commit a8d7511811c7d7c689c3e8f858e8e00a56aba152)
---
 .../llvm-readobj/ELF/program-headers.test | 254 ++
 llvm/tools/llvm-readobj/ELFDumper.cpp |   1 +
 2 files changed, 138 insertions(+), 117 deletions(-)

diff --git a/llvm/test/tools/llvm-readobj/ELF/program-headers.test 
b/llvm/test/tools/llvm-readobj/ELF/program-headers.test
index 702a06b6403f0a..856cf378ddad95 100644
--- a/llvm/test/tools/llvm-readobj/ELF/program-headers.test
+++ b/llvm/test/tools/llvm-readobj/ELF/program-headers.test
@@ -29,68 +29,70 @@
 # RUN:   FileCheck %s --check-prefixes=ELF64,MAPPING --strict-whitespace 
--match-full-lines
 # RUN: llvm-readobj -l %t64.elf | FileCheck %s 
--check-prefixes=ELF-LLVM,ELF64-LLVM
 
-#   ELF32:There are 25 program headers, starting at offset 52
+#   ELF32:There are 26 program headers, starting at offset 52
 # ELF32-EMPTY:
 # ELF32-NEXT:Program Headers:
 # ELF32-NEXT:  Type   Offset   VirtAddr   PhysAddr   FileSiz MemSiz  
Flg Align
-# ELF32-NEXT:  PHDR   0x000354 0x1000 0x1000 0x3 0x3  
W  0x1
-# ELF32-NEXT:  PHDR   0x000357 0x2000 0x2000 0x7 0x7   
E 0x1
-# ELF32-NEXT:  NULL   0x000357 0x2000 0x2000 0x7 0x7   
E 0x1
-# ELF32-NEXT:  DYNAMIC0x000354 0x1000 0x1000 0x3 0x3 
RWE 0x1
-# ELF32-NEXT:  INTERP 0x00035e 0x3000 0x3000 0x4 0x4 
RW  0x1
+# ELF32-NEXT:  PHDR   0x000374 0x1000 0x1000 0x3 0x3  
W  0x1
+# ELF32-NEXT:  PHDR   0x000377 0x2000 0x2000 0x7 0x7   
E 0x1
+# ELF32-NEXT:  NULL   0x000377 0x2000 0x2000 0x7 0x7   
E 0x1
+# ELF32-NEXT:  DYNAMIC0x000374 0x1000 0x1000 0x3 0x3 
RWE 0x1
+# ELF32-NEXT:  INTERP 0x00037e 0x3000 0x3000 0x4 0x4 
RW  0x1
 # ELF32-NEXT:  [Requesting program interpreter: ABC]
-# ELF32-NEXT:  NOTE   0x000354 0x1000 0x1000 0x3 0x3   
  0x1
-# ELF32-NEXT:  SHLIB  0x000354 0x1000 0x1000 0x1 0x1   
  0x1
-# ELF32-NEXT:  TLS0x000362 0x4000 0x4000 0x1 0x1   
  0x1
-# ELF32-NEXT:  : 0x6000 0x000354 0x1000 0x1000 0x3 
0x3 0x1
-# ELF32-NEXT:  GNU_EH_FRAME   0x000354 0x1000 0x1000 0x3 0x3   
  0x1
-# ELF32-NEXT:  SUNW_UNWIND0x000354 0x1000 0x1000 0x3 0x3   
  0x1
-# ELF32-NEXT:  GNU_STACK  0x000354 0x1000 0x1000 0x3 0x3   
  0x1
-# ELF32-NEXT:  GNU_RELRO  0x000354 0x1000 0x1000 0x3 0x3   
  0x1
-# ELF32-NEXT:  GNU_PROPERTY   0x000354 0x1000 0x1000 0x3 0x3   
  0x1
-# ELF32-NEXT:  OPENBSD_MUTABLE 0x000354 0x1000 0x1000 0x3 0x3  
   0x1
-# ELF32-NEXT:  OPENBSD_RANDOMIZE 0x000354 0x1000 0x1000 0x3 
0x3 0x1
-# ELF32-NEXT:  OPENBSD_WXNEEDED 0x000354 0x1000 0x1000 0x3 0x3 
0x1
-# ELF32-NEXT:  OPENBSD_NOBTCFI 0x000354 0x1000 0x1000 0x3 0x3  
   0x1
-# ELF32-NEXT:  OPENBSD_BOOTDATA 0x000354 0x1000 0x1000 0x3 0x3 
0x1
-# ELF32-NEXT:  : 0x6fff 0x000354 0x1000 0x1000 0x3 
0x3 0x1
-# ELF32-NEXT:  : 0x7000 0x000354 0x1000 0x1000 0x3 
0x3 0x1
-# ELF32-NEXT:  : 0x7001 0x000354 0x1000 0x1000 0x3 
0x3 0x1
-# ELF32-NEXT:  : 0x7002 0x000354 0x1000 0x1000 0x3 
0x3 0x1
-# ELF32-NEXT:  : 0x7003 0x000354 0x1000 0x1000 0x3 
0x3 0x1
-# ELF32-NEXT:  : 0x7fff 0x000354 0x1000 0x1000 0x3 
0x3 0x1
+# ELF32-NEXT:  NOTE   0x000374 0x1000 0x1000 0x3 0x3   
  0x1
+# ELF32-NEXT:  SHLIB  0x000374 0x1000 0x1000 0x1 0x1   
  0x1
+# ELF32-NEXT:  TLS0x000382 0x4000 0x4000 0x1 0x1   
  0x1
+# ELF32-NEXT:  : 0x6000 0x000374 0x1000 0x1000 0x3 
0x3 0x1
+# ELF32-NEXT:  GNU_EH_FRAME   0x000374 0x1000 0x1000 0x3 0x3   
  0x1
+# ELF32-NEXT:  SUNW_UNWIND0x000374 0x1000 0x1000 0x3 0x3   
  0x1
+# ELF32-NEXT:  GNU_STACK  0x000374 0x1000 0x1000 0x3 0x3   
  0x1
+# ELF32-NEXT:  GNU_RELRO  0x000374 0x1000 0x1000 0x3 0x3   
  0x1
+# ELF32-NEXT:  GNU_PROPERTY   0x000374 0x1000 0x1000 0x3 0x3   
  0x1
+# ELF32-NEXT:  OPENBSD_MUTABLE 0x000374 0x1000 0x1000 0x3 0x3  
   0x1
+# ELF32-NEXT:  OPENBSD_RANDOMIZE 0x000374 0x1000 0x100

[llvm-branch-commits] [llvm] 3af6881 - [llvm-readobj] Add support for the PT_OPENBSD_SYSCALLS segment type. (#82122)

2024-02-20 Thread Tom Stellard via llvm-branch-commits

Author: Frederic Cambus
Date: 2024-02-20T11:57:09-08:00
New Revision: 3af6881cab6c98c304eed112f2153f9bbe67b5ee

URL: 
https://github.com/llvm/llvm-project/commit/3af6881cab6c98c304eed112f2153f9bbe67b5ee
DIFF: 
https://github.com/llvm/llvm-project/commit/3af6881cab6c98c304eed112f2153f9bbe67b5ee.diff

LOG: [llvm-readobj] Add support for the PT_OPENBSD_SYSCALLS segment type. 
(#82122)

Reference: https://github.com/openbsd/src/blob/master/sys/sys/exec_elf.h
(cherry picked from commit a8d7511811c7d7c689c3e8f858e8e00a56aba152)

Added: 


Modified: 
llvm/test/tools/llvm-readobj/ELF/program-headers.test
llvm/tools/llvm-readobj/ELFDumper.cpp

Removed: 




diff  --git a/llvm/test/tools/llvm-readobj/ELF/program-headers.test 
b/llvm/test/tools/llvm-readobj/ELF/program-headers.test
index 702a06b6403f0a..856cf378ddad95 100644
--- a/llvm/test/tools/llvm-readobj/ELF/program-headers.test
+++ b/llvm/test/tools/llvm-readobj/ELF/program-headers.test
@@ -29,68 +29,70 @@
 # RUN:   FileCheck %s --check-prefixes=ELF64,MAPPING --strict-whitespace 
--match-full-lines
 # RUN: llvm-readobj -l %t64.elf | FileCheck %s 
--check-prefixes=ELF-LLVM,ELF64-LLVM
 
-#   ELF32:There are 25 program headers, starting at offset 52
+#   ELF32:There are 26 program headers, starting at offset 52
 # ELF32-EMPTY:
 # ELF32-NEXT:Program Headers:
 # ELF32-NEXT:  Type   Offset   VirtAddr   PhysAddr   FileSiz MemSiz  
Flg Align
-# ELF32-NEXT:  PHDR   0x000354 0x1000 0x1000 0x3 0x3  
W  0x1
-# ELF32-NEXT:  PHDR   0x000357 0x2000 0x2000 0x7 0x7   
E 0x1
-# ELF32-NEXT:  NULL   0x000357 0x2000 0x2000 0x7 0x7   
E 0x1
-# ELF32-NEXT:  DYNAMIC0x000354 0x1000 0x1000 0x3 0x3 
RWE 0x1
-# ELF32-NEXT:  INTERP 0x00035e 0x3000 0x3000 0x4 0x4 
RW  0x1
+# ELF32-NEXT:  PHDR   0x000374 0x1000 0x1000 0x3 0x3  
W  0x1
+# ELF32-NEXT:  PHDR   0x000377 0x2000 0x2000 0x7 0x7   
E 0x1
+# ELF32-NEXT:  NULL   0x000377 0x2000 0x2000 0x7 0x7   
E 0x1
+# ELF32-NEXT:  DYNAMIC0x000374 0x1000 0x1000 0x3 0x3 
RWE 0x1
+# ELF32-NEXT:  INTERP 0x00037e 0x3000 0x3000 0x4 0x4 
RW  0x1
 # ELF32-NEXT:  [Requesting program interpreter: ABC]
-# ELF32-NEXT:  NOTE   0x000354 0x1000 0x1000 0x3 0x3   
  0x1
-# ELF32-NEXT:  SHLIB  0x000354 0x1000 0x1000 0x1 0x1   
  0x1
-# ELF32-NEXT:  TLS0x000362 0x4000 0x4000 0x1 0x1   
  0x1
-# ELF32-NEXT:  : 0x6000 0x000354 0x1000 0x1000 0x3 
0x3 0x1
-# ELF32-NEXT:  GNU_EH_FRAME   0x000354 0x1000 0x1000 0x3 0x3   
  0x1
-# ELF32-NEXT:  SUNW_UNWIND0x000354 0x1000 0x1000 0x3 0x3   
  0x1
-# ELF32-NEXT:  GNU_STACK  0x000354 0x1000 0x1000 0x3 0x3   
  0x1
-# ELF32-NEXT:  GNU_RELRO  0x000354 0x1000 0x1000 0x3 0x3   
  0x1
-# ELF32-NEXT:  GNU_PROPERTY   0x000354 0x1000 0x1000 0x3 0x3   
  0x1
-# ELF32-NEXT:  OPENBSD_MUTABLE 0x000354 0x1000 0x1000 0x3 0x3  
   0x1
-# ELF32-NEXT:  OPENBSD_RANDOMIZE 0x000354 0x1000 0x1000 0x3 
0x3 0x1
-# ELF32-NEXT:  OPENBSD_WXNEEDED 0x000354 0x1000 0x1000 0x3 0x3 
0x1
-# ELF32-NEXT:  OPENBSD_NOBTCFI 0x000354 0x1000 0x1000 0x3 0x3  
   0x1
-# ELF32-NEXT:  OPENBSD_BOOTDATA 0x000354 0x1000 0x1000 0x3 0x3 
0x1
-# ELF32-NEXT:  : 0x6fff 0x000354 0x1000 0x1000 0x3 
0x3 0x1
-# ELF32-NEXT:  : 0x7000 0x000354 0x1000 0x1000 0x3 
0x3 0x1
-# ELF32-NEXT:  : 0x7001 0x000354 0x1000 0x1000 0x3 
0x3 0x1
-# ELF32-NEXT:  : 0x7002 0x000354 0x1000 0x1000 0x3 
0x3 0x1
-# ELF32-NEXT:  : 0x7003 0x000354 0x1000 0x1000 0x3 
0x3 0x1
-# ELF32-NEXT:  : 0x7fff 0x000354 0x1000 0x1000 0x3 
0x3 0x1
+# ELF32-NEXT:  NOTE   0x000374 0x1000 0x1000 0x3 0x3   
  0x1
+# ELF32-NEXT:  SHLIB  0x000374 0x1000 0x1000 0x1 0x1   
  0x1
+# ELF32-NEXT:  TLS0x000382 0x4000 0x4000 0x1 0x1   
  0x1
+# ELF32-NEXT:  : 0x6000 0x000374 0x1000 0x1000 0x3 
0x3 0x1
+# ELF32-NEXT:  GNU_EH_FRAME   0x000374 0x1000 0x1000 0x3 0x3   
  0x1
+# ELF32-NEXT:  SUNW_UNWIND0x000374 0x1000 0x1000 0x3 0x3   
  0x1
+# ELF32-NEXT:  GNU_STACK  0x000374 0x1000 0x1000 0x3 0x3   
  0x1
+# ELF32-NEXT:  GNU_RELRO  0x000374 0x1000 0x1000 0x3 0x3   
  0x1
+# ELF32-NEXT:  GNU_PROPERTY   0x000374 0x1000 0x1000 0x3 0x3   
  0x1
+# ELF32-NEXT:  OPENBSD_MUTABLE 0x000374

[llvm-branch-commits] [llvm] release/18.x: [llvm-readobj] Add support for the PT_OPENBSD_SYSCALLS segment type. (#82122) (PR #82318)

2024-02-20 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/82318
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] release/18.x: [llvm-objdump] Add support for the PT_OPENBSD_SYSCALLS segment type. (#82121) (PR #82317)

2024-02-20 Thread via llvm-branch-commits

https://github.com/llvmbot updated 
https://github.com/llvm/llvm-project/pull/82317

>From 12114d2d5a66cf4cb656a6dd83bb17704f2261a0 Mon Sep 17 00:00:00 2001
From: Frederic Cambus 
Date: Tue, 20 Feb 2024 09:11:54 +0100
Subject: [PATCH] [llvm-objdump] Add support for the PT_OPENBSD_SYSCALLS
 segment type. (#82121)

Reference: https://github.com/openbsd/src/blob/master/sys/sys/exec_elf.h
(cherry picked from commit 1b894864862d8049e4a2567a472efdc2eda1e035)
---
 llvm/test/tools/llvm-objdump/openbsd-headers.test | 3 +++
 llvm/tools/llvm-objdump/ELFDump.cpp   | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/llvm/test/tools/llvm-objdump/openbsd-headers.test 
b/llvm/test/tools/llvm-objdump/openbsd-headers.test
index f547854fdf..84fa59bdf89f5c 100644
--- a/llvm/test/tools/llvm-objdump/openbsd-headers.test
+++ b/llvm/test/tools/llvm-objdump/openbsd-headers.test
@@ -11,6 +11,8 @@
 # CHECK-NEXT:  filesz 0x memsz 0x flags ---
 # CHECK-NEXT: OPENBSD_NOBTCFI off0x vaddr 
0x paddr 0x align 2**0
 # CHECK-NEXT:  filesz 0x memsz 0x flags ---
+# CHECK-NEXT: OPENBSD_SYSCALLS off0x vaddr 
0x paddr 0x align 2**0
+# CHECK-NEXT:  filesz 0x memsz 0x flags ---
 # CHECK-NEXT: OPENBSD_BOOTDATA off0x vaddr 
0x paddr 0x align 2**0
 # CHECK-NEXT:  filesz 0x memsz 0x flags ---
 
@@ -25,4 +27,5 @@ ProgramHeaders:
   - Type: 0x65a3dbe6 ## PT_OPENBSD_RANDOMIZE
   - Type: 0x65a3dbe7 ## PT_OPENBSD_WXNEEDED
   - Type: 0x65a3dbe8 ## PT_OPENBSD_NOBTCFI
+  - Type: 0x65a3dbe9 ## PT_OPENBSD_SYSCALLS
   - Type: 0x65a41be6 ## PT_OPENBSD_BOOTDATA
diff --git a/llvm/tools/llvm-objdump/ELFDump.cpp 
b/llvm/tools/llvm-objdump/ELFDump.cpp
index 34861ee92128fd..fda99bd6d33e17 100644
--- a/llvm/tools/llvm-objdump/ELFDump.cpp
+++ b/llvm/tools/llvm-objdump/ELFDump.cpp
@@ -291,6 +291,9 @@ template  void 
ELFDumper::printProgramHeaders() {
 case ELF::PT_OPENBSD_RANDOMIZE:
   outs() << "OPENBSD_RANDOMIZE ";
   break;
+case ELF::PT_OPENBSD_SYSCALLS:
+  outs() << "OPENBSD_SYSCALLS ";
+  break;
 case ELF::PT_OPENBSD_WXNEEDED:
   outs() << "OPENBSD_WXNEEDED ";
   break;

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


[llvm-branch-commits] [llvm] 12114d2 - [llvm-objdump] Add support for the PT_OPENBSD_SYSCALLS segment type. (#82121)

2024-02-20 Thread Tom Stellard via llvm-branch-commits

Author: Frederic Cambus
Date: 2024-02-20T11:59:21-08:00
New Revision: 12114d2d5a66cf4cb656a6dd83bb17704f2261a0

URL: 
https://github.com/llvm/llvm-project/commit/12114d2d5a66cf4cb656a6dd83bb17704f2261a0
DIFF: 
https://github.com/llvm/llvm-project/commit/12114d2d5a66cf4cb656a6dd83bb17704f2261a0.diff

LOG: [llvm-objdump] Add support for the PT_OPENBSD_SYSCALLS segment type. 
(#82121)

Reference: https://github.com/openbsd/src/blob/master/sys/sys/exec_elf.h
(cherry picked from commit 1b894864862d8049e4a2567a472efdc2eda1e035)

Added: 


Modified: 
llvm/test/tools/llvm-objdump/openbsd-headers.test
llvm/tools/llvm-objdump/ELFDump.cpp

Removed: 




diff  --git a/llvm/test/tools/llvm-objdump/openbsd-headers.test 
b/llvm/test/tools/llvm-objdump/openbsd-headers.test
index f547854fdf..84fa59bdf89f5c 100644
--- a/llvm/test/tools/llvm-objdump/openbsd-headers.test
+++ b/llvm/test/tools/llvm-objdump/openbsd-headers.test
@@ -11,6 +11,8 @@
 # CHECK-NEXT:  filesz 0x memsz 0x flags ---
 # CHECK-NEXT: OPENBSD_NOBTCFI off0x vaddr 
0x paddr 0x align 2**0
 # CHECK-NEXT:  filesz 0x memsz 0x flags ---
+# CHECK-NEXT: OPENBSD_SYSCALLS off0x vaddr 
0x paddr 0x align 2**0
+# CHECK-NEXT:  filesz 0x memsz 0x flags ---
 # CHECK-NEXT: OPENBSD_BOOTDATA off0x vaddr 
0x paddr 0x align 2**0
 # CHECK-NEXT:  filesz 0x memsz 0x flags ---
 
@@ -25,4 +27,5 @@ ProgramHeaders:
   - Type: 0x65a3dbe6 ## PT_OPENBSD_RANDOMIZE
   - Type: 0x65a3dbe7 ## PT_OPENBSD_WXNEEDED
   - Type: 0x65a3dbe8 ## PT_OPENBSD_NOBTCFI
+  - Type: 0x65a3dbe9 ## PT_OPENBSD_SYSCALLS
   - Type: 0x65a41be6 ## PT_OPENBSD_BOOTDATA

diff  --git a/llvm/tools/llvm-objdump/ELFDump.cpp 
b/llvm/tools/llvm-objdump/ELFDump.cpp
index 34861ee92128fd..fda99bd6d33e17 100644
--- a/llvm/tools/llvm-objdump/ELFDump.cpp
+++ b/llvm/tools/llvm-objdump/ELFDump.cpp
@@ -291,6 +291,9 @@ template  void 
ELFDumper::printProgramHeaders() {
 case ELF::PT_OPENBSD_RANDOMIZE:
   outs() << "OPENBSD_RANDOMIZE ";
   break;
+case ELF::PT_OPENBSD_SYSCALLS:
+  outs() << "OPENBSD_SYSCALLS ";
+  break;
 case ELF::PT_OPENBSD_WXNEEDED:
   outs() << "OPENBSD_WXNEEDED ";
   break;



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


[llvm-branch-commits] [llvm] release/18.x: [llvm-objdump] Add support for the PT_OPENBSD_SYSCALLS segment type. (#82121) (PR #82317)

2024-02-20 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/82317
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] release/18.x: [PowerPC] Mask constant operands in ValueBit tracking (#67653) (PR #82301)

2024-02-20 Thread via llvm-branch-commits

https://github.com/llvmbot updated 
https://github.com/llvm/llvm-project/pull/82301

>From 3b4b0476423e2340cf6ef370df3c98420014c97b Mon Sep 17 00:00:00 2001
From: Qiu Chaofan 
Date: Tue, 6 Feb 2024 18:37:31 +0800
Subject: [PATCH] [PowerPC] Mask constant operands in ValueBit tracking
 (#67653)

In IR or C code, shift amount larger than value size is undefined
behavior. But in practice, backend lowering for shift_parts produces
add/sub of shift amounts, thus constant shift amounts might be
negative or larger than value size, which depends on ISA definition.

PowerPC ISA says, the lowest 7 bits (6 bits for 32-bit instruction)
will be taken, and if the highest among them is 1, result will be
zero, otherwise the low 6 bits (or 5 on 32-bit) are used as shift
amount.

This commit emulates the behavior and avoids array overflow in bit
permutation's value bits calculator.

(cherry picked from commit 292d9e869fcfc2ece694848db4022b0b939847e3)
---
 llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp |  37 --
 llvm/test/CodeGen/PowerPC/pr59074.ll| 132 
 2 files changed, 156 insertions(+), 13 deletions(-)
 create mode 100644 llvm/test/CodeGen/PowerPC/pr59074.ll

diff --git a/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp 
b/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
index 26ed74108ec36c..18a4223d481ef0 100644
--- a/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
+++ b/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
@@ -1635,7 +1635,8 @@ class BitPermutationSelector {
 default: break;
 case ISD::ROTL:
   if (isa(V.getOperand(1))) {
-unsigned RotAmt = V.getConstantOperandVal(1);
+assert(isPowerOf2_32(NumBits) && "rotl bits should be power of 2!");
+unsigned RotAmt = V.getConstantOperandVal(1) & (NumBits - 1);
 
 const auto &LHSBits = *getValueBits(V.getOperand(0), NumBits).second;
 
@@ -1648,15 +1649,20 @@ class BitPermutationSelector {
 case ISD::SHL:
 case PPCISD::SHL:
   if (isa(V.getOperand(1))) {
-unsigned ShiftAmt = V.getConstantOperandVal(1);
+// sld takes 7 bits, slw takes 6.
+unsigned ShiftAmt = V.getConstantOperandVal(1) & ((NumBits << 1) - 1);
 
 const auto &LHSBits = *getValueBits(V.getOperand(0), NumBits).second;
 
-for (unsigned i = ShiftAmt; i < NumBits; ++i)
-  Bits[i] = LHSBits[i - ShiftAmt];
-
-for (unsigned i = 0; i < ShiftAmt; ++i)
-  Bits[i] = ValueBit(ValueBit::ConstZero);
+if (ShiftAmt >= NumBits) {
+  for (unsigned i = 0; i < NumBits; ++i)
+Bits[i] = ValueBit(ValueBit::ConstZero);
+} else {
+  for (unsigned i = ShiftAmt; i < NumBits; ++i)
+Bits[i] = LHSBits[i - ShiftAmt];
+  for (unsigned i = 0; i < ShiftAmt; ++i)
+Bits[i] = ValueBit(ValueBit::ConstZero);
+}
 
 return std::make_pair(Interesting = true, &Bits);
   }
@@ -1664,15 +1670,20 @@ class BitPermutationSelector {
 case ISD::SRL:
 case PPCISD::SRL:
   if (isa(V.getOperand(1))) {
-unsigned ShiftAmt = V.getConstantOperandVal(1);
+// srd takes lowest 7 bits, srw takes 6.
+unsigned ShiftAmt = V.getConstantOperandVal(1) & ((NumBits << 1) - 1);
 
 const auto &LHSBits = *getValueBits(V.getOperand(0), NumBits).second;
 
-for (unsigned i = 0; i < NumBits - ShiftAmt; ++i)
-  Bits[i] = LHSBits[i + ShiftAmt];
-
-for (unsigned i = NumBits - ShiftAmt; i < NumBits; ++i)
-  Bits[i] = ValueBit(ValueBit::ConstZero);
+if (ShiftAmt >= NumBits) {
+  for (unsigned i = 0; i < NumBits; ++i)
+Bits[i] = ValueBit(ValueBit::ConstZero);
+} else {
+  for (unsigned i = 0; i < NumBits - ShiftAmt; ++i)
+Bits[i] = LHSBits[i + ShiftAmt];
+  for (unsigned i = NumBits - ShiftAmt; i < NumBits; ++i)
+Bits[i] = ValueBit(ValueBit::ConstZero);
+}
 
 return std::make_pair(Interesting = true, &Bits);
   }
diff --git a/llvm/test/CodeGen/PowerPC/pr59074.ll 
b/llvm/test/CodeGen/PowerPC/pr59074.ll
new file mode 100644
index 00..3e328c6ad9f0ba
--- /dev/null
+++ b/llvm/test/CodeGen/PowerPC/pr59074.ll
@@ -0,0 +1,132 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=powerpc64le-unknown-linux-gnu -mcpu=pwr7 < %s | FileCheck 
%s --check-prefix=LE64
+; RUN: llc -mtriple=powerpcle-unknown-linux-gnu -mcpu=pwr7 < %s | FileCheck %s 
--check-prefix=LE32
+; RUN: llc -mtriple=powerpc64-ibm-aix -mcpu=pwr7 < %s | FileCheck %s 
--check-prefix=BE64
+; RUN: llc -mtriple=powerpc-ibm-aix -mcpu=pwr7 < %s | FileCheck %s 
--check-prefix=BE32
+
+; To verify this doesn't crash due to array out of bound.
+define void @pr59074(ptr %0) {
+; LE64-LABEL: pr59074:
+; LE64:   # %bb.0: # %entry
+; LE64-NEXT:lwz 6, 0(3)
+; LE64-NEXT:li 7, 12
+; LE64-NEXT:ld 4, 16(3)
+; LE64-NEXT:ld 5, 24(3)
+; LE64-NEXT:addi 6, 6, -12
+; LE64-NEXT:std 4, 

[llvm-branch-commits] [llvm] 3b4b047 - [PowerPC] Mask constant operands in ValueBit tracking (#67653)

2024-02-20 Thread Tom Stellard via llvm-branch-commits

Author: Qiu Chaofan
Date: 2024-02-20T12:54:33-08:00
New Revision: 3b4b0476423e2340cf6ef370df3c98420014c97b

URL: 
https://github.com/llvm/llvm-project/commit/3b4b0476423e2340cf6ef370df3c98420014c97b
DIFF: 
https://github.com/llvm/llvm-project/commit/3b4b0476423e2340cf6ef370df3c98420014c97b.diff

LOG: [PowerPC] Mask constant operands in ValueBit tracking (#67653)

In IR or C code, shift amount larger than value size is undefined
behavior. But in practice, backend lowering for shift_parts produces
add/sub of shift amounts, thus constant shift amounts might be
negative or larger than value size, which depends on ISA definition.

PowerPC ISA says, the lowest 7 bits (6 bits for 32-bit instruction)
will be taken, and if the highest among them is 1, result will be
zero, otherwise the low 6 bits (or 5 on 32-bit) are used as shift
amount.

This commit emulates the behavior and avoids array overflow in bit
permutation's value bits calculator.

(cherry picked from commit 292d9e869fcfc2ece694848db4022b0b939847e3)

Added: 
llvm/test/CodeGen/PowerPC/pr59074.ll

Modified: 
llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp

Removed: 




diff  --git a/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp 
b/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
index 26ed74108ec36c..18a4223d481ef0 100644
--- a/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
+++ b/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
@@ -1635,7 +1635,8 @@ class BitPermutationSelector {
 default: break;
 case ISD::ROTL:
   if (isa(V.getOperand(1))) {
-unsigned RotAmt = V.getConstantOperandVal(1);
+assert(isPowerOf2_32(NumBits) && "rotl bits should be power of 2!");
+unsigned RotAmt = V.getConstantOperandVal(1) & (NumBits - 1);
 
 const auto &LHSBits = *getValueBits(V.getOperand(0), NumBits).second;
 
@@ -1648,15 +1649,20 @@ class BitPermutationSelector {
 case ISD::SHL:
 case PPCISD::SHL:
   if (isa(V.getOperand(1))) {
-unsigned ShiftAmt = V.getConstantOperandVal(1);
+// sld takes 7 bits, slw takes 6.
+unsigned ShiftAmt = V.getConstantOperandVal(1) & ((NumBits << 1) - 1);
 
 const auto &LHSBits = *getValueBits(V.getOperand(0), NumBits).second;
 
-for (unsigned i = ShiftAmt; i < NumBits; ++i)
-  Bits[i] = LHSBits[i - ShiftAmt];
-
-for (unsigned i = 0; i < ShiftAmt; ++i)
-  Bits[i] = ValueBit(ValueBit::ConstZero);
+if (ShiftAmt >= NumBits) {
+  for (unsigned i = 0; i < NumBits; ++i)
+Bits[i] = ValueBit(ValueBit::ConstZero);
+} else {
+  for (unsigned i = ShiftAmt; i < NumBits; ++i)
+Bits[i] = LHSBits[i - ShiftAmt];
+  for (unsigned i = 0; i < ShiftAmt; ++i)
+Bits[i] = ValueBit(ValueBit::ConstZero);
+}
 
 return std::make_pair(Interesting = true, &Bits);
   }
@@ -1664,15 +1670,20 @@ class BitPermutationSelector {
 case ISD::SRL:
 case PPCISD::SRL:
   if (isa(V.getOperand(1))) {
-unsigned ShiftAmt = V.getConstantOperandVal(1);
+// srd takes lowest 7 bits, srw takes 6.
+unsigned ShiftAmt = V.getConstantOperandVal(1) & ((NumBits << 1) - 1);
 
 const auto &LHSBits = *getValueBits(V.getOperand(0), NumBits).second;
 
-for (unsigned i = 0; i < NumBits - ShiftAmt; ++i)
-  Bits[i] = LHSBits[i + ShiftAmt];
-
-for (unsigned i = NumBits - ShiftAmt; i < NumBits; ++i)
-  Bits[i] = ValueBit(ValueBit::ConstZero);
+if (ShiftAmt >= NumBits) {
+  for (unsigned i = 0; i < NumBits; ++i)
+Bits[i] = ValueBit(ValueBit::ConstZero);
+} else {
+  for (unsigned i = 0; i < NumBits - ShiftAmt; ++i)
+Bits[i] = LHSBits[i + ShiftAmt];
+  for (unsigned i = NumBits - ShiftAmt; i < NumBits; ++i)
+Bits[i] = ValueBit(ValueBit::ConstZero);
+}
 
 return std::make_pair(Interesting = true, &Bits);
   }

diff  --git a/llvm/test/CodeGen/PowerPC/pr59074.ll 
b/llvm/test/CodeGen/PowerPC/pr59074.ll
new file mode 100644
index 00..3e328c6ad9f0ba
--- /dev/null
+++ b/llvm/test/CodeGen/PowerPC/pr59074.ll
@@ -0,0 +1,132 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=powerpc64le-unknown-linux-gnu -mcpu=pwr7 < %s | FileCheck 
%s --check-prefix=LE64
+; RUN: llc -mtriple=powerpcle-unknown-linux-gnu -mcpu=pwr7 < %s | FileCheck %s 
--check-prefix=LE32
+; RUN: llc -mtriple=powerpc64-ibm-aix -mcpu=pwr7 < %s | FileCheck %s 
--check-prefix=BE64
+; RUN: llc -mtriple=powerpc-ibm-aix -mcpu=pwr7 < %s | FileCheck %s 
--check-prefix=BE32
+
+; To verify this doesn't crash due to array out of bound.
+define void @pr59074(ptr %0) {
+; LE64-LABEL: pr59074:
+; LE64:   # %bb.0: # %entry
+; LE64-NEXT:lwz 6, 0(3)
+; LE64-NEXT:li 7, 12
+; LE64-NEXT:ld 4, 16(3)
+; LE64-NEXT:ld 5, 24(3)
+; LE64-NEXT:a

[llvm-branch-commits] [llvm] release/18.x: [PowerPC] Mask constant operands in ValueBit tracking (#67653) (PR #82301)

2024-02-20 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/82301
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] release/18.x: [libc++] Only include from the C library if it exists (#81887) (PR #82045)

2024-02-20 Thread Tom Stellard via llvm-branch-commits

tstellar wrote:

One of these libc++ tests keeps failing.  Is this a real failure?

https://github.com/llvm/llvm-project/pull/82045
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [compiler-rt] release/18.x: [compiler-rt][profile] Fix InstrProfilingFile possible resource leak. (#81363) (PR #81402)

2024-02-20 Thread via llvm-branch-commits

https://github.com/llvmbot updated 
https://github.com/llvm/llvm-project/pull/81402

>From 390dcd4cbbf511954ba1e0ca000d3e1c6394060e Mon Sep 17 00:00:00 2001
From: David CARLIER 
Date: Sat, 10 Feb 2024 19:14:28 +
Subject: [PATCH] [compiler-rt][profile] Fix InstrProfilingFile possible
 resource leak. (#81363)

close #79708

(cherry picked from commit 0a255fcf4a90f9e864ae9321b28e4956f7c865fb)
---
 compiler-rt/lib/profile/InstrProfilingFile.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/compiler-rt/lib/profile/InstrProfilingFile.c 
b/compiler-rt/lib/profile/InstrProfilingFile.c
index 867ae73f0d3b27..f3b457d786e6bd 100644
--- a/compiler-rt/lib/profile/InstrProfilingFile.c
+++ b/compiler-rt/lib/profile/InstrProfilingFile.c
@@ -677,6 +677,7 @@ static void initializeProfileForContinuousMode(void) {
   PROF_ERR("Continuous counter sync mode is enabled, but raw profile is 
not"
"page-aligned. CurrentFileOffset = %" PRIu64 ", pagesz = %u.\n",
(uint64_t)CurrentFileOffset, PageSize);
+  fclose(File);
   return;
 }
 if (writeProfileWithFileObject(Filename, File) != 0) {
@@ -692,6 +693,8 @@ static void initializeProfileForContinuousMode(void) {
 
   if (doMerging()) {
 lprofUnlockFileHandle(File);
+  }
+  if (File != NULL) {
 fclose(File);
   }
 }

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


[llvm-branch-commits] [compiler-rt] 390dcd4 - [compiler-rt][profile] Fix InstrProfilingFile possible resource leak. (#81363)

2024-02-20 Thread Tom Stellard via llvm-branch-commits

Author: David CARLIER
Date: 2024-02-20T12:59:02-08:00
New Revision: 390dcd4cbbf511954ba1e0ca000d3e1c6394060e

URL: 
https://github.com/llvm/llvm-project/commit/390dcd4cbbf511954ba1e0ca000d3e1c6394060e
DIFF: 
https://github.com/llvm/llvm-project/commit/390dcd4cbbf511954ba1e0ca000d3e1c6394060e.diff

LOG: [compiler-rt][profile] Fix InstrProfilingFile possible resource leak. 
(#81363)

close #79708

(cherry picked from commit 0a255fcf4a90f9e864ae9321b28e4956f7c865fb)

Added: 


Modified: 
compiler-rt/lib/profile/InstrProfilingFile.c

Removed: 




diff  --git a/compiler-rt/lib/profile/InstrProfilingFile.c 
b/compiler-rt/lib/profile/InstrProfilingFile.c
index 867ae73f0d3b27..f3b457d786e6bd 100644
--- a/compiler-rt/lib/profile/InstrProfilingFile.c
+++ b/compiler-rt/lib/profile/InstrProfilingFile.c
@@ -677,6 +677,7 @@ static void initializeProfileForContinuousMode(void) {
   PROF_ERR("Continuous counter sync mode is enabled, but raw profile is 
not"
"page-aligned. CurrentFileOffset = %" PRIu64 ", pagesz = %u.\n",
(uint64_t)CurrentFileOffset, PageSize);
+  fclose(File);
   return;
 }
 if (writeProfileWithFileObject(Filename, File) != 0) {
@@ -692,6 +693,8 @@ static void initializeProfileForContinuousMode(void) {
 
   if (doMerging()) {
 lprofUnlockFileHandle(File);
+  }
+  if (File != NULL) {
 fclose(File);
   }
 }



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


[llvm-branch-commits] [compiler-rt] release/18.x: [compiler-rt][profile] Fix InstrProfilingFile possible resource leak. (#81363) (PR #81402)

2024-02-20 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/81402
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] release/18.x: [llvm-objcopy] Add SystemZ support (#81841) (PR #82324)

2024-02-20 Thread Tom Stellard via llvm-branch-commits

tstellar wrote:

@MaskRay What do you think about this?

https://github.com/llvm/llvm-project/pull/82324
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] release/18.x: [Release] Don't build during test-release.sh Phase 3 install (#82001) (PR #82420)

2024-02-20 Thread via llvm-branch-commits

https://github.com/llvmbot created 
https://github.com/llvm/llvm-project/pull/82420

Backport f6ac598c104ed3c9f4bcbbe830f86500c8d1013e

Requested by: @rorth

>From 98228d4cdb8e933be66b3a5cd08992366b31fb1d Mon Sep 17 00:00:00 2001
From: Rainer Orth 
Date: Tue, 20 Feb 2024 07:26:48 +0100
Subject: [PATCH] [Release] Don't build during test-release.sh Phase 3 install
 (#82001)

As described in [test-release.sh ninja install does builds in Phase
3](https://github.com/llvm/llvm-project/issues/80999), considerable
parts of Phase 3 of a `test-release.sh` build are run by `ninja
install`, ignoring both `$Verbose` and the parallelism set via `-j NUM`.

This patches fixes this by not specifying any explicit build target for
Phase 3, thus running the full build as usual.

Tested on `sparc64-unknown-linux-gnu`.

(cherry picked from commit f6ac598c104ed3c9f4bcbbe830f86500c8d1013e)
---
 llvm/utils/release/test-release.sh | 5 +
 1 file changed, 5 insertions(+)

diff --git a/llvm/utils/release/test-release.sh 
b/llvm/utils/release/test-release.sh
index 5b1945df47d24a..0af16387ce1d8e 100755
--- a/llvm/utils/release/test-release.sh
+++ b/llvm/utils/release/test-release.sh
@@ -537,6 +537,11 @@ function build_llvmCore() {
 InstallTarget="$InstallTarget install-runtimes"
   fi
 fi
+if [ "$Phase" -eq "3" ]; then
+  # Build everything at once, with the proper parallelism and verbosity,
+  # in Phase 3.
+  BuildTarget=
+fi
 
 cd $ObjDir
 echo "# Compiling llvm $Release-$RC $Flavor"

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


[llvm-branch-commits] [llvm] release/18.x: [Release] Don't build during test-release.sh Phase 3 install (#82001) (PR #82420)

2024-02-20 Thread via llvm-branch-commits

https://github.com/llvmbot milestoned 
https://github.com/llvm/llvm-project/pull/82420
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] release/18.x: [Release] Don't build during test-release.sh Phase 3 install (#82001) (PR #82420)

2024-02-20 Thread via llvm-branch-commits

llvmbot wrote:

@tstellar What do you think about merging this PR to the release branch?

https://github.com/llvm/llvm-project/pull/82420
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [ELF] Support placing .lbss/.lrodata/.ldata after .bss (PR #81224)

2024-02-20 Thread Arthur Eubanks via llvm-branch-commits


@@ -1436,6 +1436,8 @@ static void readConfigs(opt::InputArgList &args) {
   config->zInterpose = hasZOption(args, "interpose");
   config->zKeepTextSectionPrefix = getZFlag(
   args, "keep-text-section-prefix", "nokeep-text-section-prefix", false);
+  config->zLrodataAfterBss =
+  getZFlag(args, "lrodata-after-bss", "nolrodata-after-bss", false);

aeubanks wrote:

Reiterating what was discussed privately: I don't think `-fpie -no-pie`/`-fpic 
-no-pie` are really in use, that doesn't really make sense. So for anybody 
using `-no-pie`, they are almost certainly using `-fno-pic`, which either `-z 
lrodata-after-bss` doesn't affect if there is no large data, or is necessary to 
prevent relocation overflows. So `-z lrodata-after-bss` really should default 
to the value of `-no-pie`.

And again, the placement of large data shouldn't matter, as long as it doesn't 
affect 32-bit relocation pressure.

But if you won't change your mind, then this PR looks good in its current state.

https://github.com/llvm/llvm-project/pull/81224
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [ELF] Support placing .lbss/.lrodata/.ldata after .bss (PR #81224)

2024-02-20 Thread Arthur Eubanks via llvm-branch-commits

https://github.com/aeubanks approved this pull request.


https://github.com/llvm/llvm-project/pull/81224
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] release/18.x: [Release] Don't build during test-release.sh Phase 3 install (#82001) (PR #82420)

2024-02-20 Thread Rainer Orth via llvm-branch-commits

rorth wrote:

> @tstellar What do you think about merging this PR to the release branch?

I thing this would be very useful: we already have two Issues filed for this 
problem, and `test-release.sh` is probably almost exclusively exercised during 
release testing/building.

The risk should be limited: even if the patch is wrong, the builds will happen 
at full parallelism, no worse than before.

https://github.com/llvm/llvm-project/pull/82420
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [ELF] Support placing .lbss/.lrodata/.ldata after .bss (PR #81224)

2024-02-20 Thread Fangrui Song via llvm-branch-commits


@@ -1436,6 +1436,8 @@ static void readConfigs(opt::InputArgList &args) {
   config->zInterpose = hasZOption(args, "interpose");
   config->zKeepTextSectionPrefix = getZFlag(
   args, "keep-text-section-prefix", "nokeep-text-section-prefix", false);
+  config->zLrodataAfterBss =
+  getZFlag(args, "lrodata-after-bss", "nolrodata-after-bss", false);

MaskRay wrote:

Thanks for understanding. I think I am fairly strong in keeping the stance that 
layout decisions should not magically change due to -no-pie/-pie. If we ever 
decide to deviate from the policy, we can re-consider. But having `-z 
lrodata-after-bss` should make these possible.

https://github.com/llvm/llvm-project/pull/81224
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


  1   2   >