Skip to content

Commit

Permalink
Merge pull request #23894 from JuliaLang/yyc/tests/llvm40
Browse files Browse the repository at this point in the history
Add another LLVM patch for non-integral ptrtoint fix on LLVM 4.0
  • Loading branch information
yuyichao authored Sep 27, 2017
2 parents aee64e3 + 2136bbf commit b72af50
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
1 change: 1 addition & 0 deletions deps/llvm.mk
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,7 @@ $(eval $(call LLVM_PATCH,llvm-D32623-GVN-non-integral)) # Remove for 5.0
$(eval $(call LLVM_PATCH,llvm-D33129-scevexpander-non-integral)) # Remove for 5.0
$(eval $(call LLVM_PATCH,llvm-Yet-another-fix))
$(eval $(call LLVM_PATCH,llvm-4.0.0-D37576-NVPTX-sm_70)) # NVPTX, Remove for 6.0
$(eval $(call LLVM_PATCH,llvm-loadcse-addrspace_4.0))
endif # LLVM_VER

$(LLVM_BUILDDIR_withtype)/build-configured: $(LLVM_PATCH_PREV)
Expand Down
61 changes: 61 additions & 0 deletions deps/patches/llvm-loadcse-addrspace_4.0.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,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

0 comments on commit b72af50

Please sign in to comment.