On 01/09/15 13:32, Sylvestre Ledru wrote: > severity 797626 normal > thanks > > Le 01/09/2015 01:05, Ximin Luo a écrit : >> Source: llvm-toolchain-3.6 >> Severity: important >> Tags: upstream patch >> >> Dear Maintainer, >> >> Please apply the attached patch. The origin is: >> >> http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20150622/282940.html >> >> and it is necessary to make later versions of rustc compile correctly, see >> >> https://github.com/rust-lang/rust/issues/26468 >> >> I have tested the patch against 1:3.6.2-1 and it applies cleanly with an >> offset. > I will see what I can do. Any idea if this is going to land in the 3.6 > upstream branch? >
I'm not sure, I don't know what their release policy is like. BTW, I built the previous patch and the tests failed - it was only the first attempt at a patch on a mailing list. I've pulled the actual relevant LLVM commits, see the attached new patch. I'm building it again but it will take a few hours before I get the results. X -- GPG: 4096R/1318EFAC5FBBDBCE git://github.com/infinity0/pubkeys.git
Description: Properly combine metadata when replacing a load with another This includes LLVM revision 241886[1], 241955[2] and is needed to properly compile newer version of the Rust compiler[3]. . [1] http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20150706/286654.html [2] http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20150706/286834.html [3] https://github.com/rust-lang/rust/issues/26468 Author: Bjorn Steinbrink <bstei...@gmail.com> Bug: https://github.com/rust-lang/rust/issues/26468 Applied-Upstream: r241886, r241955 --- This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ --- a/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp +++ b/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp @@ -420,10 +420,25 @@ // where there are several consecutive memory accesses to the same location, // separated by a few arithmetic operations. BasicBlock::iterator BBI = &LI; - if (Value *AvailableVal = FindAvailableLoadedValue(Op, LI.getParent(), BBI,6)) + AAMDNodes AATags; + if (Value *AvailableVal = FindAvailableLoadedValue(Op, LI.getParent(), BBI, + 6, nullptr, &AATags)) { + if (LoadInst *NLI = dyn_cast<LoadInst>(AvailableVal)) { + unsigned KnownIDs[] = { + LLVMContext::MD_tbaa, + LLVMContext::MD_alias_scope, + LLVMContext::MD_noalias, + LLVMContext::MD_range, + LLVMContext::MD_invariant_load, + LLVMContext::MD_nonnull, + }; + combineMetadata(NLI, &LI, KnownIDs); + }; + return ReplaceInstUsesWith( LI, Builder->CreateBitOrPointerCast(AvailableVal, LI.getType(), LI.getName() + ".cast")); + } // load(gep null, ...) -> unreachable if (GetElementPtrInst *GEPI = dyn_cast<GetElementPtrInst>(Op)) { --- /dev/null +++ b/test/Transforms/InstCombine/load-combine-metadata.ll @@ -0,0 +1,29 @@ +; RUN: opt -instcombine -S < %s | FileCheck %s + +target datalayout = "e-m:e-p:64:64:64-i64:64-f80:128-n8:16:32:64-S128" + +; CHECK-LABEL: @test_load_load_combine_metadata( +; Check that range and AA metadata is combined +; CHECK: %[[V:.*]] = load i32, i32* %0 +; CHECK-SAME: !tbaa !{{[0-9]+}} +; CHECK-SAME: !range ![[RANGE:[0-9]+]] +; CHECK: store i32 %[[V]], i32* %1 +; CHECK: store i32 %[[V]], i32* %2 +define void @test_load_load_combine_metadata(i32*, i32*, i32*) { + %a = load i32, i32* %0, !tbaa !8, !range !0, !alias.scope !5, !noalias !6 + %b = load i32, i32* %0, !tbaa !8, !range !1 + store i32 %a, i32* %1 + store i32 %b, i32* %2 + ret void +} + +; CHECK: ![[RANGE]] = !{i32 0, i32 1, i32 8, i32 9} +!0 = !{ i32 0, i32 1 } +!1 = !{ i32 8, i32 9 } +!2 = !{!2} +!3 = !{!3, !2} +!4 = !{!4, !2} +!5 = !{!3} +!6 = !{!4} +!7 = !{ !"tbaa root" } +!8 = !{ !7, !7, i64 0 }