[llvm-branch-commits] [llvm] 80e2fc1 - [X86][ELF] Prefer lowering MC_GlobalAddress operands to .Lfoo$local for STV_DEFAULT only

2020-09-17 Thread Hans Wennborg via llvm-branch-commits

Author: Ben Dunbobbin
Date: 2020-09-17T13:23:29+02:00
New Revision: 80e2fc1e6e68d6ed57dccc03c6a5121e216bfd43

URL: 
https://github.com/llvm/llvm-project/commit/80e2fc1e6e68d6ed57dccc03c6a5121e216bfd43
DIFF: 
https://github.com/llvm/llvm-project/commit/80e2fc1e6e68d6ed57dccc03c6a5121e216bfd43.diff

LOG: [X86][ELF] Prefer lowering MC_GlobalAddress operands to .Lfoo$local for 
STV_DEFAULT only

This patch restricts the behaviour of referencing via .Lfoo$local
local aliases, introduced in https://reviews.llvm.org/D73230, to
STV_DEFAULT globals only.

Hidden symbols via --fvisiblity=hidden (https://gcc.gnu.org/wiki/Visibility)
is an important scenario.

Benefits:

- Improves the size of object files by using fewer STT_SECTION symbols.

- The code reads a bit better (it was not obvious to me without going
  back to the code reviews why the canBenefitFromLocalAlias function
  currently doesn't consider visibility).

- There is also a side benefit in restoring the effectiveness of the
  --wrap linker option and making the behavior of --wrap consistent
  between LTO and normal builds for references within a translation-unit.
  Note: this --wrap behavior (which is specific to LLD) should not be
  considered reliable. See comments on https://reviews.llvm.org/D73230
  for more.

Differential Revision: https://reviews.llvm.org/D85782

(cherry picked from commit 4cb016cd2d8467c572b2e5c5d34f376ee79e4ac1)

Added: 


Modified: 
llvm/lib/IR/Globals.cpp
llvm/test/CodeGen/AArch64/emutls.ll
llvm/test/CodeGen/ARM/emutls.ll
llvm/test/CodeGen/X86/2008-03-12-ThreadLocalAlias.ll
llvm/test/CodeGen/X86/linux-preemption.ll
llvm/test/CodeGen/X86/semantic-interposition-comdat.ll
llvm/test/CodeGen/X86/tailcallpic1.ll
llvm/test/CodeGen/X86/tailcallpic3.ll
llvm/test/CodeGen/X86/tailccpic1.ll

Removed: 




diff  --git a/llvm/lib/IR/Globals.cpp b/llvm/lib/IR/Globals.cpp
index dd8e62164de1..ed946ef3fd12 100644
--- a/llvm/lib/IR/Globals.cpp
+++ b/llvm/lib/IR/Globals.cpp
@@ -104,7 +104,8 @@ bool GlobalValue::isInterposable() const {
 
 bool GlobalValue::canBenefitFromLocalAlias() const {
   // See AsmPrinter::getSymbolPreferLocal().
-  return GlobalObject::isExternalLinkage(getLinkage()) && !isDeclaration() &&
+  return hasDefaultVisibility() &&
+ GlobalObject::isExternalLinkage(getLinkage()) && !isDeclaration() &&
  !isa(this) && !hasComdat();
 }
 

diff  --git a/llvm/test/CodeGen/AArch64/emutls.ll 
b/llvm/test/CodeGen/AArch64/emutls.ll
index 85d2c1a3b315..25be391bbfaa 100644
--- a/llvm/test/CodeGen/AArch64/emutls.ll
+++ b/llvm/test/CodeGen/AArch64/emutls.ll
@@ -155,7 +155,6 @@ entry:
 ; ARM64:  .data{{$}}
 ; ARM64:  .globl __emutls_v.i4
 ; ARM64-LABEL: __emutls_v.i4:
-; ARM64-NEXT: .L__emutls_v.i4$local:
 ; ARM64-NEXT: .xword 4
 ; ARM64-NEXT: .xword 4
 ; ARM64-NEXT: .xword 0
@@ -163,7 +162,6 @@ entry:
 
 ; ARM64:  .section .rodata,
 ; ARM64-LABEL: __emutls_t.i4:
-; ARM64-NEXT: .L__emutls_t.i4$local:
 ; ARM64-NEXT: .word 15
 
 ; ARM64-NOT:   __emutls_v.i5:

diff  --git a/llvm/test/CodeGen/ARM/emutls.ll b/llvm/test/CodeGen/ARM/emutls.ll
index 4327086685e9..92b656d9ba09 100644
--- a/llvm/test/CodeGen/ARM/emutls.ll
+++ b/llvm/test/CodeGen/ARM/emutls.ll
@@ -238,7 +238,6 @@ entry:
 ; ARM32:  .data{{$}}
 ; ARM32:  .globl __emutls_v.i4
 ; ARM32-LABEL: __emutls_v.i4:
-; ARM32-NEXT:  .L__emutls_v.i4$local:
 ; ARM32-NEXT: .long 4
 ; ARM32-NEXT: .long 4
 ; ARM32-NEXT: .long 0
@@ -246,7 +245,6 @@ entry:
 
 ; ARM32:  .section .rodata,
 ; ARM32-LABEL: __emutls_t.i4:
-; ARM32-NEXT:  .L__emutls_t.i4$local:
 ; ARM32-NEXT: .long 15
 
 ; ARM32-NOT:   __emutls_v.i5:

diff  --git a/llvm/test/CodeGen/X86/2008-03-12-ThreadLocalAlias.ll 
b/llvm/test/CodeGen/X86/2008-03-12-ThreadLocalAlias.ll
index 89d249c09178..2ca003e052aa 100644
--- a/llvm/test/CodeGen/X86/2008-03-12-ThreadLocalAlias.ll
+++ b/llvm/test/CodeGen/X86/2008-03-12-ThreadLocalAlias.ll
@@ -12,7 +12,7 @@ target triple = "i386-pc-linux-gnu"
 
 define i32 @foo() {
 ; CHECK-LABEL: foo:
-; CHECK: leal.L__libc_resp$local@TLSLDM
+; CHECK: leal__libc_resp@TLSLD
 entry:
%retval = alloca i32;  [#uses=1]
%"alloca point" = bitcast i32 0 to i32  ;  [#uses=0]
@@ -27,7 +27,7 @@ return:   ; preds = %entry
 
 define i32 @bar() {
 ; CHECK-LABEL: bar:
-; CHECK: leal.L__libc_resp$local@TLSLDM
+; CHECK: leal__libc_resp@TLSLD
 entry:
%retval = alloca i32;  [#uses=1]
%"alloca point" = bitcast i32 0 to i32  ;  [#uses=0]

diff  --git a/llvm/test/CodeGen/X86/linux-preemption.ll 
b/llvm/test/CodeGen/X86/linux-preemption.ll
index 49a7becf1343..15265f401992 100644
--- a/llvm/test/CodeGen/X86/linux-preemption.ll
+++ b/llvm/test/CodeGen/X86/linux-preemption.ll
@@ -20,6 +20,14 @@ define i32* @get_strong_default_global() {
 ; STATIC: movl $strong_default_global, %eax
 ; CHECK32

[llvm-branch-commits] [flang] 4fe4e35 - [Flang] Add GettingInvolved documentation page and sidebar.

2020-09-17 Thread Hans Wennborg via llvm-branch-commits

Author: sameeran joshi
Date: 2020-09-17T13:27:38+02:00
New Revision: 4fe4e35452ef17ce3db08b080e3b0642d36c5094

URL: 
https://github.com/llvm/llvm-project/commit/4fe4e35452ef17ce3db08b080e3b0642d36c5094
DIFF: 
https://github.com/llvm/llvm-project/commit/4fe4e35452ef17ce3db08b080e3b0642d36c5094.diff

LOG: [Flang] Add GettingInvolved documentation page and sidebar.

Adds a new GettingInvolved page to documentation which provides details about
mailing list, chats and calls.

Adds a sidebar page which provides common links on
all documentation pages.
The links include:
-  Getting Started
-  Getting Involved
-  Github Repository
-  Bug Reports
-  Code Review

Depends on https://reviews.llvm.org/D87242

Reviewed By: richard.barton.arm

Differential Revision: https://reviews.llvm.org/D87270

(cherry picked from commit fe395aecd9e70b815e6490639098d815385f9932)

Added: 
flang/docs/GettingInvolved.md
flang/docs/_templates/indexsidebar.html
flang/docs/_templates/layout.html

Modified: 
flang/docs/conf.py
flang/docs/index.md

Removed: 




diff  --git a/flang/docs/GettingInvolved.md b/flang/docs/GettingInvolved.md
new file mode 100644
index ..a244fbcee56a
--- /dev/null
+++ b/flang/docs/GettingInvolved.md
@@ -0,0 +1,72 @@
+
+# Getting Involved
+
+```eval_rst
+.. contents::
+   :local:
+```
+
+The Flang Project welcomes contributions of all kinds.
+Please feel free to join the mailing list or the slack channel for discussions 
related to development of Flang.
+To understand the status of various developments in Flang please join the 
respective call.
+
+## Mailing Lists
+
+[Developer's List 
(flang-dev)](http://lists.llvm.org/mailman/listinfo/flang-dev)
+
+  This list is for people who want to be included in technical discussions 
related to Flang. People post to this list when they have questions about 
writing code
+  for or using the Flang tools. It is relatively low volume.
+
+
+[Commits Archive 
(flang-commits)](http://lists.llvm.org/pipermail/flang-commits)
+
+  This list contains all commit messages that are made when Flang developers
+  commit code changes to the repository. It also serves as a forum for
+  patch review (i.e. send patches here). It is useful for those who want to
+  stay on the bleeding edge of Flang development. This list is high
+  volume.
+
+## Chat
+
+### Flang Slack Workspace
+
+-   There is a Slack workspace dedicated to Flang.
+-   There are a number of topic-oriented channels available (e.g., #driver, 
#f18-semantics, #fir).
+-   Add yourself via the *[invitation 
link](https://join.slack.com/t/flang-compiler/shared_invite/zt-2pcn51lh-VrRQL_YUOkxA_1CEfMGQhw
 "title")*
+
+## Calls
+
+### Flang Community Biweekly Call
+
+-   General updates on the Flang Project, both LLVM Flang and current Flang.
+-   Join [Flang Community Biweekly 
Call](https://nvmeet.webex.com/nvmeet/j.php?MTID=mb4edb8c799f69ec2dc0554acc969a162)
+-   Time: On Wednesdays 8:30 Pacific Time, on the weeks alternating with 
regular Flang Community Technical Biweekly Call.
+-   Minutes: They are sent to 
[flang-dev](http://lists.llvm.org/mailman/listinfo/flang-dev). Search for 
`Flang Biweekly Sync - Notes`.
+
+### Flang Community Technical Biweekly Call
+
+-   Technical topics call.
+-   Join [Flang Community Technical Biweekly 
Call](https://bluejeans.com/625064848?src=join_info)
+-   Time: On Mondays 8:30 Pacific Time, on the weeks alternating with regular 
Flang Community Biweekly Call.
+-   The agenda is in this [Google 
Doc](https://docs.google.com/document/d/1Z2U5UAtJ-Dag5wlMaLaW1KRmNgENNAYynJqLW2j2AZQ/).
+
+### LLVM Alias Analysis Technical Call
+
+-   For people working on improvements to LLVM alias analysis.
+-   Join [LLVM Alias Analysis Technical 
Call](https://bluejeans.com/101176001?src=join_info)
+-   Time: Tuesdays 10:00 AM Pacific Time, every 4 weeks.
+-   The agenda is in this [Google 
Doc](https://docs.google.com/document/d/1ybwEKDVtIbhIhK50qYtwKsL50K-NvB6LfuBsfepBZ9Y/).
+
+### OpenMP Technical Call
+
+-   Development updates on OpenMP and OpenACC in the Flang Project.
+-   Join [OpenMP Technical Call](https://bit.ly/39eQW3o)
+-   Time: Weekly call on every Thursdays 8:00 AM Pacific time.
+-   Meeting minutes are 
[here](https://docs.google.com/document/d/1yA-MeJf6RYY-ZXpdol0t7YoDoqtwAyBhFLr5thu5pFI).
+-   Status tracking 
[page](https://docs.google.com/spreadsheets/d/1FvHPuSkGbl4mQZRAwCIndvQx9dQboffiD-xD0oqxgU0/edit#gid=0).

diff  --git a/flang/docs/_templates/indexsidebar.html 
b/flang/docs/_templates/indexsidebar.html
new file mode 100644
index ..3c8f1abdf900
--- /dev/null
+++ b/flang/docs/_templates/indexsidebar.html
@@ -0,0 +1,26 @@
+{# This template defines sidebar which can be used to provide common links on
+   all documentation pages. #}
+
+Documentation
+
+
+https://github.com/llvm/llvm-project/blob/master/flang/README.md#getting-started";>Getting
 Started
+
+
+Gettin

[llvm-branch-commits] [llvm] b78e5de - [SelectionDAG] Check any use of negation result before removal

2020-09-17 Thread Hans Wennborg via llvm-branch-commits

Author: Qiu Chaofan
Date: 2020-09-17T13:37:11+02:00
New Revision: b78e5de029c26c309f541ab883fa5d6d953b073d

URL: 
https://github.com/llvm/llvm-project/commit/b78e5de029c26c309f541ab883fa5d6d953b073d
DIFF: 
https://github.com/llvm/llvm-project/commit/b78e5de029c26c309f541ab883fa5d6d953b073d.diff

LOG: [SelectionDAG] Check any use of negation result before removal

2508ef01 fixed a bug about constant removal in negation. But after
sanitizing check I found there's still some issue about it so it's
reverted.

Temporary nodes will be removed if useless in negation. Before the
removal, they'd be checked if any other nodes used it. So the removal
was moved after getNode. However in rare cases the node to be removed is
the same as result of getNode. We missed that and will be fixed by this
patch.

Reviewed By: steven.zhang

Differential Revision: https://reviews.llvm.org/D87614

(cherry picked from commit a2fb5446be960ad164060b3c05fc268f7f72d67a)

Added: 
llvm/test/CodeGen/X86/pr47517.ll

Modified: 
llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp

Removed: 




diff  --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp 
b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
index 819e608c6896..64af293caf9e 100644
--- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
@@ -5751,8 +5751,10 @@ SDValue TargetLowering::getNegatedExpression(SDValue Op, 
SelectionDAG &DAG,
 
 // If we already have the use of the negated floating constant, it is free
 // to negate it even it has multiple uses.
-if (!Op.hasOneUse() && CFP.use_empty())
+if (!Op.hasOneUse() && CFP.use_empty()) {
+  RemoveDeadNode(CFP);
   break;
+}
 Cost = NegatibleCost::Neutral;
 return CFP;
   }
@@ -5810,7 +5812,8 @@ SDValue TargetLowering::getNegatedExpression(SDValue Op, 
SelectionDAG &DAG,
 if (NegX && (CostX <= CostY)) {
   Cost = CostX;
   SDValue N = DAG.getNode(ISD::FSUB, DL, VT, NegX, Y, Flags);
-  RemoveDeadNode(NegY);
+  if (NegY != N)
+RemoveDeadNode(NegY);
   return N;
 }
 
@@ -5818,7 +5821,8 @@ SDValue TargetLowering::getNegatedExpression(SDValue Op, 
SelectionDAG &DAG,
 if (NegY) {
   Cost = CostY;
   SDValue N = DAG.getNode(ISD::FSUB, DL, VT, NegY, X, Flags);
-  RemoveDeadNode(NegX);
+  if (NegX != N)
+RemoveDeadNode(NegX);
   return N;
 }
 break;
@@ -5857,7 +5861,8 @@ SDValue TargetLowering::getNegatedExpression(SDValue Op, 
SelectionDAG &DAG,
 if (NegX && (CostX <= CostY)) {
   Cost = CostX;
   SDValue N = DAG.getNode(Opcode, DL, VT, NegX, Y, Flags);
-  RemoveDeadNode(NegY);
+  if (NegY != N)
+RemoveDeadNode(NegY);
   return N;
 }
 
@@ -5870,7 +5875,8 @@ SDValue TargetLowering::getNegatedExpression(SDValue Op, 
SelectionDAG &DAG,
 if (NegY) {
   Cost = CostY;
   SDValue N = DAG.getNode(Opcode, DL, VT, X, NegY, Flags);
-  RemoveDeadNode(NegX);
+  if (NegX != N)
+RemoveDeadNode(NegX);
   return N;
 }
 break;
@@ -5901,7 +5907,8 @@ SDValue TargetLowering::getNegatedExpression(SDValue Op, 
SelectionDAG &DAG,
 if (NegX && (CostX <= CostY)) {
   Cost = std::min(CostX, CostZ);
   SDValue N = DAG.getNode(Opcode, DL, VT, NegX, Y, NegZ, Flags);
-  RemoveDeadNode(NegY);
+  if (NegY != N)
+RemoveDeadNode(NegY);
   return N;
 }
 
@@ -5909,7 +5916,8 @@ SDValue TargetLowering::getNegatedExpression(SDValue Op, 
SelectionDAG &DAG,
 if (NegY) {
   Cost = std::min(CostY, CostZ);
   SDValue N = DAG.getNode(Opcode, DL, VT, X, NegY, NegZ, Flags);
-  RemoveDeadNode(NegX);
+  if (NegX != N)
+RemoveDeadNode(NegX);
   return N;
 }
 break;

diff  --git a/llvm/test/CodeGen/X86/pr47517.ll 
b/llvm/test/CodeGen/X86/pr47517.ll
new file mode 100644
index ..5672fbc69a41
--- /dev/null
+++ b/llvm/test/CodeGen/X86/pr47517.ll
@@ -0,0 +1,28 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple x86_64 < %s | FileCheck %s
+
+; To ensure unused floating point constant is correctly removed
+define float @test(float %src, float* %p) {
+; CHECK-LABEL: test:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:movq $0, (%rdi)
+; CHECK-NEXT:xorps %xmm0, %xmm0
+; CHECK-NEXT:retq
+entry:
+  %a0 = getelementptr inbounds float, float* %p, i32 0
+  %a1 = getelementptr inbounds float, float* %p, i32 1
+  store float 0.00e+00, float* %a0
+  store float 0.00e+00, float* %a1
+  %zero = load float, float* %a0
+  %fmul1 = fmul fast float %zero, %src
+  %fadd1 = fadd fast float %fmul1, %zero
+  %fmul2 = fmul fast float %fadd1, 2.00e+00
+  %fmul3 = fmul fast float %fmul2, %fmul2
+  %fmul4 = fmul fast float %fmul2, 2.00e+00
+  %fadd2 = fadd fast float %fmul4, -3.00e+00
+  %fmul5 = fmul fast float %fadd2, %fmul