[llvm-branch-commits] [llvm] 38399ce - [ConstantFold] Make areGlobalsPotentiallyEqual less aggressive.
Author: Eli Friedman Date: 2020-10-30T18:51:54-07:00 New Revision: 38399ced95bca0aede9baaecd75936952758b1b6 URL: https://github.com/llvm/llvm-project/commit/38399ced95bca0aede9baaecd75936952758b1b6 DIFF: https://github.com/llvm/llvm-project/commit/38399ced95bca0aede9baaecd75936952758b1b6.diff LOG: [ConstantFold] Make areGlobalsPotentiallyEqual less aggressive. In particular, we shouldn't make assumptions about globals which are unnamed_addr: we can fold them together with other globals. Also while I'm here, use isInterposable() instead of trying to explicitly name all the different kinds of weak linkage. Fixes https://bugs.llvm.org/show_bug.cgi?id=47090 Differential Revision: https://reviews.llvm.org/D87123 (cherry picked from commit d751f86189a7f7ef2a6fe06974a5da3349b02f20) Added: Modified: llvm/lib/IR/ConstantFold.cpp llvm/test/Assembler/ConstantExprNoFold.ll llvm/test/Transforms/InstCombine/2010-03-03-ExtElim.ll Removed: diff --git a/llvm/lib/IR/ConstantFold.cpp b/llvm/lib/IR/ConstantFold.cpp index f3c3e9ad9f69..c20d0955f3d8 100644 --- a/llvm/lib/IR/ConstantFold.cpp +++ b/llvm/lib/IR/ConstantFold.cpp @@ -1589,7 +1589,7 @@ static FCmpInst::Predicate evaluateFCmpRelation(Constant *V1, Constant *V2) { static ICmpInst::Predicate areGlobalsPotentiallyEqual(const GlobalValue *GV1, const GlobalValue *GV2) { auto isGlobalUnsafeForEquality = [](const GlobalValue *GV) { -if (GV->hasExternalWeakLinkage() || GV->hasWeakAnyLinkage()) +if (GV->isInterposable() || GV->hasGlobalUnnamedAddr()) return true; if (const auto *GVar = dyn_cast(GV)) { Type *Ty = GVar->getValueType(); diff --git a/llvm/test/Assembler/ConstantExprNoFold.ll b/llvm/test/Assembler/ConstantExprNoFold.ll index 42e558eb3865..d91855925c89 100644 --- a/llvm/test/Assembler/ConstantExprNoFold.ll +++ b/llvm/test/Assembler/ConstantExprNoFold.ll @@ -42,6 +42,12 @@ target datalayout = "p:32:32" @empty.2 = external global [0 x i8], align 1 @empty.cmp = global i1 icmp eq ([0 x i8]* @empty.1, [0 x i8]* @empty.2) +; Two unnamed_addr globals can share an address +; CHECK: @unnamed.cmp = global i1 icmp eq ([5 x i8]* @unnamed.1, [5 x i8]* @unnamed.2) +@unnamed.1 = unnamed_addr constant [5 x i8] c"asdf\00" +@unnamed.2 = unnamed_addr constant [5 x i8] c"asdf\00" +@unnamed.cmp = global i1 icmp eq ([5 x i8]* @unnamed.1, [5 x i8]* @unnamed.2) + @addrspace3 = internal addrspace(3) global i32 undef ; CHECK: @no.fold.addrspace.icmp.eq.gv.null = global i1 icmp eq (i32 addrspace(3)* @addrspace3, i32 addrspace(3)* null) diff --git a/llvm/test/Transforms/InstCombine/2010-03-03-ExtElim.ll b/llvm/test/Transforms/InstCombine/2010-03-03-ExtElim.ll index ad0fe5a21783..da9d0469e5e2 100644 --- a/llvm/test/Transforms/InstCombine/2010-03-03-ExtElim.ll +++ b/llvm/test/Transforms/InstCombine/2010-03-03-ExtElim.ll @@ -16,8 +16,8 @@ define i1 @PR6486() nounwind { ; CHECK: ret i1 true } -@d = common global i32 0, align 4 -@a = common global [1 x i32] zeroinitializer, align 4 +@d = global i32 0, align 4 +@a = global [1 x i32] zeroinitializer, align 4 define i1 @PR16462_1() nounwind { ; CHECK-LABEL: @PR16462_1( ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] 1ff84a0 - BPF: fix incorrect DAG2DAG load optimization
Author: Yonghong Song Date: 2020-10-31T00:01:08-04:00 New Revision: 1ff84a04aebcafc65e43dfe13d6f2aa352f72637 URL: https://github.com/llvm/llvm-project/commit/1ff84a04aebcafc65e43dfe13d6f2aa352f72637 DIFF: https://github.com/llvm/llvm-project/commit/1ff84a04aebcafc65e43dfe13d6f2aa352f72637.diff LOG: BPF: fix incorrect DAG2DAG load optimization Currently, bpf backend Instruction section DAG2DAG phase has an optimization to replace loading constant struct memeber or array element with direct values. The reason is that these locally defined struct or array variables may have their initial values stored in a readonly section and early bpf ecosystem is not able to handle such cases. Bpf ecosystem now can not only handle readonly sections, but also global variables. global variable can also have initialized data and global variable may or may not be constant, i.e., global variable data can be put in .data section or .rodata section. This exposed a bug in DAG2DAG Load optimization as it did not check whether the global variable is constant or not. This patch fixed the bug by checking whether global variable, representing the initial data, is constant or not and will not do optimization if it is not a constant. Another bug is also fixed in this patch to check whether the load is simple (not volatile/atomic) or not. If it is not simple, we will not do optimization. To summary for globals: - struct t var = { ... } ; // no load optimization - const struct t var = { ... }; // load optimization is possible - volatile const struct t var = { ... }; // no load optimization Differential Revision: https://reviews.llvm.org/D89021 (cherry picked from commit 31611721686760fe59c91a84b025e4dee94d1662) Added: llvm/test/CodeGen/BPF/rodata_6.ll llvm/test/CodeGen/BPF/rodata_7.ll Modified: llvm/lib/Target/BPF/BPFISelDAGToDAG.cpp Removed: diff --git a/llvm/lib/Target/BPF/BPFISelDAGToDAG.cpp b/llvm/lib/Target/BPF/BPFISelDAGToDAG.cpp index d407edfbd966..77f565fb5957 100644 --- a/llvm/lib/Target/BPF/BPFISelDAGToDAG.cpp +++ b/llvm/lib/Target/BPF/BPFISelDAGToDAG.cpp @@ -254,7 +254,7 @@ void BPFDAGToDAGISel::PreprocessLoad(SDNode *Node, const LoadSDNode *LD = cast(Node); uint64_t size = LD->getMemOperand()->getSize(); - if (!size || size > 8 || (size & (size - 1))) + if (!size || size > 8 || (size & (size - 1)) || !LD->isSimple()) return; SDNode *LDAddrNode = LD->getOperand(1).getNode(); @@ -342,7 +342,7 @@ bool BPFDAGToDAGISel::getConstantFieldValue(const GlobalAddressSDNode *Node, unsigned char *ByteSeq) { const GlobalVariable *V = dyn_cast(Node->getGlobal()); - if (!V || !V->hasInitializer()) + if (!V || !V->hasInitializer() || !V->isConstant()) return false; const Constant *Init = V->getInitializer(); diff --git a/llvm/test/CodeGen/BPF/rodata_6.ll b/llvm/test/CodeGen/BPF/rodata_6.ll new file mode 100644 index ..1af3d8dc230f --- /dev/null +++ b/llvm/test/CodeGen/BPF/rodata_6.ll @@ -0,0 +1,25 @@ +; RUN: llc -march=bpf < %s | FileCheck %s +; +; Source code: +; struct t1 { int a; }; +; struct t1 data = { .a = 3 }; +; int foo(void) { +; return data.a + 20; +; } +; Compilation flag: +; clang -target bpf -O2 -S -emit-llvm test.c + +%struct.t1 = type { i32 } + +@data = dso_local local_unnamed_addr global %struct.t1 { i32 3 }, align 4 + +; Function Attrs: norecurse nounwind readonly +define dso_local i32 @foo() local_unnamed_addr { +entry: + %0 = load i32, i32* getelementptr inbounds (%struct.t1, %struct.t1* @data, i64 0, i32 0), align 4 + %add = add nsw i32 %0, 20 +; CHECK: [[REG1:r[0-9]+]] = data ll +; CHECK: r0 = *(u32 *)([[REG1]] + 0) +; CHECK: r0 += 20 + ret i32 %add +} diff --git a/llvm/test/CodeGen/BPF/rodata_7.ll b/llvm/test/CodeGen/BPF/rodata_7.ll new file mode 100644 index ..69969a140302 --- /dev/null +++ b/llvm/test/CodeGen/BPF/rodata_7.ll @@ -0,0 +1,25 @@ +; RUN: llc -march=bpf < %s | FileCheck %s +; +; Source code: +; struct t1 { int a; }; +; volatile const struct t1 data = { .a = 3 }; +; int foo(void) { +; return data.a + 20; +; } +; Compilation flag: +; clang -target bpf -O2 -S -emit-llvm test.c + +%struct.t1 = type { i32 } + +@data = dso_local constant %struct.t1 { i32 3 }, align 4 + +; Function Attrs: nofree norecurse nounwind +define dso_local i32 @foo() local_unnamed_addr { +entry: + %0 = load volatile i32, i32* getelementptr inbounds (%struct.t1, %struct.t1* @data, i64 0, i32 0), align 4 + %add = add nsw i32 %0, 20 +; CHECK: [[REG1:r[0-9]+]] = data ll +; CHECK: r0 = *(u32 *)([[REG1]] + 0) +; CHECK: r0 += 20 + ret i32 %add +} ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [lld] 83716db - [ELF] -r: don't crash when a non-SHF_LINK_ORDER orphan is added before a SHF_LINK_ORDER orphan
Author: Fangrui Song Date: 2020-10-31T00:29:52-04:00 New Revision: 83716db47f94391771bf469262ab4282679d8981 URL: https://github.com/llvm/llvm-project/commit/83716db47f94391771bf469262ab4282679d8981 DIFF: https://github.com/llvm/llvm-project/commit/83716db47f94391771bf469262ab4282679d8981.diff LOG: [ELF] -r: don't crash when a non-SHF_LINK_ORDER orphan is added before a SHF_LINK_ORDER orphan Fixes https://github.com/ClangBuiltLinux/linux/issues/1186 If a non-SHF_LINK_ORDER orphan is added first, `firstIsec->flags & SHF_LINK_ORDER` will be zero and we currently assert when calling `getLinkOrderDep`. Reviewed By: grimar Differential Revision: https://reviews.llvm.org/D90200 (cherry picked from commit ae73091f30245852817c5c0af050a5a731dee50a) Added: lld/test/ELF/linkorder-mixed2.s Modified: lld/ELF/LinkerScript.cpp Removed: diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp index 6de2cd65b973..7314b27659bb 100644 --- a/lld/ELF/LinkerScript.cpp +++ b/lld/ELF/LinkerScript.cpp @@ -679,8 +679,11 @@ addInputSec(StringMap> &map, auto *firstIsec = cast( cast(sec->sectionCommands[0]) ->sectionBases[0]); - if (firstIsec->getLinkOrderDep()->getOutputSection() != - isec->getLinkOrderDep()->getOutputSection()) + OutputSection *firstIsecOut = + firstIsec->flags & SHF_LINK_ORDER + ? firstIsec->getLinkOrderDep()->getOutputSection() + : nullptr; + if (firstIsecOut != isec->getLinkOrderDep()->getOutputSection()) continue; } diff --git a/lld/test/ELF/linkorder-mixed2.s b/lld/test/ELF/linkorder-mixed2.s new file mode 100644 index ..26ab970676aa --- /dev/null +++ b/lld/test/ELF/linkorder-mixed2.s @@ -0,0 +1,22 @@ +# REQUIRES: x86 +## In a relocatable link, don't combine SHF_LINK_ORDER and non-SHF_LINK_ORDER +## like we don't combine SHF_LINK_ORDER with diff erent linked-to sections +## (see linkerscript/linkorder-linked-to.s). +## Test we support adding a non-SHF_LINK_ORDER section as an orphan first. + +# RUN: llvm-mc -filetype=obj --triple=x86_64 %s -o %t.o + +# RUN: ld.lld -r %t.o -o %t.ro +# RUN: llvm-readelf -x foo %t.ro | FileCheck %s + +# CHECK: Hex dump of section 'foo': +# CHECK-NEXT: 0x 0100 + +.section foo,"a" +.byte 0 + +.section .text,"ax",@progbits +ret + +.section foo,"ao",@progbits,.text +.byte 1 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] 8fc424f - Add release tarballs for libclc
Author: Aaron Puchert Date: 2020-10-31T01:00:20-04:00 New Revision: 8fc424f26bf1ea1471bd770a1b4eee4545c2bc96 URL: https://github.com/llvm/llvm-project/commit/8fc424f26bf1ea1471bd770a1b4eee4545c2bc96 DIFF: https://github.com/llvm/llvm-project/commit/8fc424f26bf1ea1471bd770a1b4eee4545c2bc96.diff LOG: Add release tarballs for libclc Fixes PR47917. Reviewed By: tstellar Differential Revision: https://reviews.llvm.org/D90100 (cherry picked from commit 139785dc98ae94717eebaed083eeaad5d775b495) Added: Modified: llvm/utils/release/export.sh Removed: diff --git a/llvm/utils/release/export.sh b/llvm/utils/release/export.sh index c3277de38b53..3ffd7e78dd63 100755 --- a/llvm/utils/release/export.sh +++ b/llvm/utils/release/export.sh @@ -13,7 +13,7 @@ set -e -projects="llvm clang test-suite compiler-rt libcxx libcxxabi clang-tools-extra polly lldb lld openmp libunwind flang" +projects="llvm clang test-suite compiler-rt libcxx libcxxabi libclc clang-tools-extra polly lldb lld openmp libunwind flang" release="" rc="" ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits