File: llvm-loadcse-addrspace_4.0.patch

package info (click to toggle)
julia 1.0.3%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 49,452 kB
  • sloc: lisp: 236,453; ansic: 55,579; cpp: 25,603; makefile: 1,685; pascal: 1,130; sh: 956; asm: 86; xml: 76
file content (61 lines) | stat: -rw-r--r-- 2,111 bytes parent folder | download
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
From 01ae2614aa184fcf88b0880f5944a23da6f215db Mon Sep 17 00:00:00 2001
From: Yichao Yu <yyc1992@gmail.com>
Date: Sun, 18 Jun 2017 16:45:38 -0400
Subject: [PATCH] Disable LoadCSE and Store forwarding between different
 address space or between non-integral pointer and integers.

---
 lib/Analysis/Loads.cpp | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/lib/Analysis/Loads.cpp b/lib/Analysis/Loads.cpp
index e46541e6538..971ce37a4a5 100644
--- a/lib/Analysis/Loads.cpp
+++ b/lib/Analysis/Loads.cpp
@@ -362,6 +362,21 @@ Value *llvm::FindAvailableLoadedValue(LoadInst *Load,
         if (LI->isAtomic() < Load->isAtomic())
           return nullptr;
 
+        if (Load->getType()->isPointerTy()) {
+          PointerType *Ty1 = cast<PointerType>(Load->getType());
+          if (PointerType *Ty2 = dyn_cast<PointerType>(LI->getType())) {
+            if (Ty1->getAddressSpace() != Ty2->getAddressSpace()) {
+              return nullptr;
+            }
+          }
+          else if (DL.isNonIntegralPointerType(Ty1)) {
+            return nullptr;
+          }
+        }
+        else if (DL.isNonIntegralPointerType(LI->getType())) {
+          return nullptr;
+        }
+
         if (IsLoadCSE)
             *IsLoadCSE = true;
         return LI;
@@ -381,6 +396,21 @@ Value *llvm::FindAvailableLoadedValue(LoadInst *Load,
         if (SI->isAtomic() < Load->isAtomic())
           return nullptr;
 
+        if (Load->getType()->isPointerTy()) {
+          PointerType *Ty1 = cast<PointerType>(Load->getType());
+          if (PointerType *Ty2 = dyn_cast<PointerType>(SI->getValueOperand()->getType())) {
+            if (Ty1->getAddressSpace() != Ty2->getAddressSpace()) {
+              return nullptr;
+            }
+          }
+          else if (DL.isNonIntegralPointerType(Ty1)) {
+            return nullptr;
+          }
+        }
+        else if (DL.isNonIntegralPointerType(SI->getValueOperand()->getType())) {
+          return nullptr;
+        }
+
         if (IsLoadCSE)
           *IsLoadCSE = false;
         return SI->getOperand(0);
-- 
2.13.1