[PATCH] D104876: [lld-macho][nfc] Add absolute-vs-non-absolute symbol test for ICF

Jez Ng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 24 15:07:28 PDT 2021


int3 created this revision.
int3 added a reviewer: lld-macho.
Herald added a reviewer: gkm.
Herald added a project: lld-macho.
int3 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Make sure we don't wrongly fold two sections that refer to
symbols with the same value if they are not both absolute /
non-absolute.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D104876

Files:
  lld/test/MachO/icf.s


Index: lld/test/MachO/icf.s
===================================================================
--- lld/test/MachO/icf.s
+++ lld/test/MachO/icf.s
@@ -13,6 +13,7 @@
 # CHECK:       [[#%x,A]]     g   F __TEXT,__text _a2
 # CHECK:       [[#%x,A]]     g   F __TEXT,__text _a3
 # CHECK:       [[#%x,B:]]    g   F __TEXT,__text _b
+# CHECK:       [[#%x,B2:]]   g   F __TEXT,__text _b2
 # CHECK:       [[#%x,C:]]    g   F __TEXT,__text _c
 # CHECK:       [[#%x,D:]]    g   F __TEXT,__text _d
 # CHECK:       [[#%x,E:]]    g   F __TEXT,__text _e
@@ -34,6 +35,7 @@
 # CHECK-NEXT:  callq 0x[[#%x,A]]  <_a3>
 # CHECK-NEXT:  callq 0x[[#%x,A]]  <_a3>
 # CHECK-NEXT:  callq 0x[[#%x,B]]  <_b>
+# CHECK-NEXT:  callq 0x[[#%x,B2]] <_b2>
 # CHECK-NEXT:  callq 0x[[#%x,C]]  <_c>
 # CHECK-NEXT:  callq 0x[[#%x,D]]  <_d>
 # CHECK-NEXT:  callq 0x[[#%x,E]]  <_e>
@@ -53,14 +55,20 @@
 ### TODO:
 ### * Fold: funcs only differ in alignment
 ### * No fold: func is weak? preemptable?
+### * Test that we hash things appropriately w/ minimal collisions
 
 #--- abs.s
 .subsections_via_symbols
 
-.globl _abs1a, _abs1b, _abs2
-_abs1a = 0xfeedfac3
-_abs1b = 0xfeedfac3
-_abs2 =  0xfeedf00d
+.globl _abs1a, _abs1b, _abs2, _not_abs
+_abs1a = 0xfac3
+_abs1b = 0xfac3
+_abs2 =  0xf00d
+
+.data
+.space 0xfac3
+## _not_abs has the same Defined::value as _abs1{a,b}
+_not_abs:
 
 #--- main.s
 .subsections_via_symbols
@@ -116,6 +124,18 @@
   movl $0, %eax
   ret
 
+### No fold: _not_abs has the same value as _abs1{a,b}, but is not absolute.
+
+.globl _b2
+.p2align 2
+_b2:
+  callq _d
+  mov ___nan at GOTPCREL(%rip), %rax
+  callq ___isnan
+  movabs $_not_abs, %rdx
+  movl $0, %eax
+  ret
+
 ### No fold: _c has slightly different body from _a1 & _a2
 
 .globl _c
@@ -282,6 +302,7 @@
   callq _a2
   callq _a3
   callq _b
+  callq _b2
   callq _c
   callq _d
   callq _e


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D104876.354370.patch
Type: text/x-patch
Size: 1836 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210624/c6a958ad/attachment.bin>


More information about the llvm-commits mailing list