unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
blob cb658d1b67fcba7480b899bf16af84775b337620 3429 bytes (raw)
name: gnu/packages/patches/llvm-D50010-VNCoercion-ni.patch 	 # note: path name is non-authoritative(*)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
 
commit 8eb2b102a203d83fb713f3bf79acf235dabdd8cd
Author: Keno Fischer <keno@juliacomputing.com>
Date:   Mon Jul 30 16:59:08 2018 -0400

    [VNCoercion] Disallow coercion between different ni addrspaces
    
    Summary:
    I'm not sure if it would be legal by the IR reference to introduce
    an addrspacecast here, since the IR reference is a bit vague on
    the exact semantics, but at least for our usage of it (and I
    suspect for many other's usage) it is not. For us, addrspacecasts
    between non-integral address spaces carry frontend information that the
    optimizer cannot deduce afterwards in a generic way (though we
    have frontend specific passes in our pipline that do propagate
    these). In any case, I'm sure nobody is using it this way at
    the moment, since it would have introduced inttoptrs, which
    are definitely illegal.
    
    Fixes PR38375
    
    Reviewers: sanjoy, reames, dberlin
    
    Subscribers: llvm-commits
    
    Differential Revision: https://reviews.llvm.org/D50010

diff --git a/lib/Transforms/Utils/VNCoercion.cpp b/lib/Transforms/Utils/VNCoercion.cpp
index c3feea6a0a4..735d1e7b792 100644
--- a/lib/Transforms/Utils/VNCoercion.cpp
+++ b/lib/Transforms/Utils/VNCoercion.cpp
@@ -20,14 +20,21 @@ bool canCoerceMustAliasedValueToLoad(Value *StoredVal, Type *LoadTy,
       StoredVal->getType()->isStructTy() || StoredVal->getType()->isArrayTy())
     return false;
 
+  Type *StoredValTy = StoredVal->getType();
+
   // The store has to be at least as big as the load.
   if (DL.getTypeSizeInBits(StoredVal->getType()) < DL.getTypeSizeInBits(LoadTy))
     return false;
 
-  // Don't coerce non-integral pointers to integers or vice versa.
-  if (DL.isNonIntegralPointerType(StoredVal->getType()) !=
-      DL.isNonIntegralPointerType(LoadTy))
+  bool StoredNI = DL.isNonIntegralPointerType(StoredValTy);
+  bool LoadNI = DL.isNonIntegralPointerType(LoadTy);
+  if (StoredNI != LoadNI) {
     return false;
+  } else if (StoredNI && LoadNI &&
+             cast<PointerType>(StoredValTy)->getAddressSpace() !=
+                 cast<PointerType>(LoadTy)->getAddressSpace()) {
+    return false;
+  }
 
   return true;
 }
diff --git a/test/Transforms/GVN/non-integral-pointers.ll b/test/Transforms/GVN/non-integral-pointers.ll
index 9ae4132231d..5217fc1a06a 100644
--- a/test/Transforms/GVN/non-integral-pointers.ll
+++ b/test/Transforms/GVN/non-integral-pointers.ll
@@ -1,6 +1,6 @@
 ; RUN: opt -gvn -S < %s | FileCheck %s
 
-target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128-ni:4"
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128-ni:4:5"
 target triple = "x86_64-unknown-linux-gnu"
 
 define void @f0(i1 %alwaysFalse, i64 %val, i64* %loc) {
@@ -37,3 +37,21 @@ define i64 @f1(i1 %alwaysFalse, i8 addrspace(4)* %val, i8 addrspace(4)** %loc) {
  alwaysTaken:
   ret i64 42
 }
+
+ define i8 addrspace(5)* @multini(i1 %alwaysFalse, i8 addrspace(4)* %val, i8 addrspace(4)** %loc) {
+ ; CHECK-LABEL: @multini(
+ ; CHECK-NOT: inttoptr
+ ; CHECK-NOT: ptrtoint
+ ; CHECK-NOT: addrspacecast
+  entry:
+   store i8 addrspace(4)* %val, i8 addrspace(4)** %loc
+   br i1 %alwaysFalse, label %neverTaken, label %alwaysTaken
+
+  neverTaken:
+   %loc.bc = bitcast i8 addrspace(4)** %loc to i8 addrspace(5)**
+   %differentas = load i8 addrspace(5)*, i8 addrspace(5)** %loc.bc
+   ret i8 addrspace(5)* %differentas
+
+  alwaysTaken:
+   ret i8 addrspace(5)* null
+ }

debug log:

solving cb658d1b6 ...
found cb658d1b6 in https://yhetil.org/guix-patches/20190423094936.27413-1-anothersms@gmail.com/ ||
	https://yhetil.org/guix-patches/20190425075114.10284-1-anothersms@gmail.com/

applying [1/1] https://yhetil.org/guix-patches/20190423094936.27413-1-anothersms@gmail.com/
diff --git a/gnu/packages/patches/llvm-D50010-VNCoercion-ni.patch b/gnu/packages/patches/llvm-D50010-VNCoercion-ni.patch
new file mode 100644
index 0000000000..cb658d1b67

1:12: trailing whitespace.
    
1:24: trailing whitespace.
    
1:26: trailing whitespace.
    
1:28: trailing whitespace.
    
1:30: trailing whitespace.
    
Checking patch gnu/packages/patches/llvm-D50010-VNCoercion-ni.patch...
Applied patch gnu/packages/patches/llvm-D50010-VNCoercion-ni.patch cleanly.
warning: squelched 5 whitespace errors
warning: 10 lines add whitespace errors.

skipping https://yhetil.org/guix-patches/20190425075114.10284-1-anothersms@gmail.com/ for cb658d1b67
index at:
100644 cb658d1b67fcba7480b899bf16af84775b337620	gnu/packages/patches/llvm-D50010-VNCoercion-ni.patch

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).