[llvm-branch-commits] [llvm] 8456c3a - AArch64: fix regression introduced by fcmp immediate selection.

2021-01-15 Thread Amara Emerson via llvm-branch-commits

Author: Amara Emerson
Date: 2021-01-15T22:53:25-08:00
New Revision: 8456c3a789285079ad35d146e487436b5a27b027

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

LOG: AArch64: fix regression introduced by fcmp immediate selection.

Forgot to check if the predicate is safe to commutate operands.

Added: 


Modified: 
llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
llvm/test/CodeGen/AArch64/GlobalISel/select-fcmp.mir

Removed: 




diff  --git a/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp 
b/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
index b24fad35e32b..0021456a596d 100644
--- a/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
+++ b/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
@@ -34,6 +34,7 @@
 #include "llvm/CodeGen/MachineRegisterInfo.h"
 #include "llvm/CodeGen/TargetOpcodes.h"
 #include "llvm/IR/Constants.h"
+#include "llvm/IR/Instructions.h"
 #include "llvm/IR/PatternMatch.h"
 #include "llvm/IR/Type.h"
 #include "llvm/IR/IntrinsicsAArch64.h"
@@ -177,8 +178,10 @@ class AArch64InstructionSelector : public 
InstructionSelector {
MachineIRBuilder ) const;
 
   /// Emit a floating point comparison between \p LHS and \p RHS.
+  /// \p Pred if given is the intended predicate to use.
   MachineInstr *emitFPCompare(Register LHS, Register RHS,
-  MachineIRBuilder ) const;
+  MachineIRBuilder ,
+  Optional = None) const;
 
   MachineInstr *emitInstr(unsigned Opcode,
   std::initializer_list DstOps,
@@ -1483,11 +1486,11 @@ bool 
AArch64InstructionSelector::selectCompareBranchFedByFCmp(
   assert(I.getOpcode() == TargetOpcode::G_BRCOND);
   // Unfortunately, the mapping of LLVM FP CC's onto AArch64 CC's isn't
   // totally clean.  Some of them require two branches to implement.
-  emitFPCompare(FCmp.getOperand(2).getReg(), FCmp.getOperand(3).getReg(), MIB);
+  auto Pred = (CmpInst::Predicate)FCmp.getOperand(1).getPredicate();
+  emitFPCompare(FCmp.getOperand(2).getReg(), FCmp.getOperand(3).getReg(), MIB,
+Pred);
   AArch64CC::CondCode CC1, CC2;
-  changeFCMPPredToAArch64CC(
-  static_cast(FCmp.getOperand(1).getPredicate()), CC1,
-  CC2);
+  changeFCMPPredToAArch64CC(static_cast(Pred), CC1, CC2);
   MachineBasicBlock *DestMBB = I.getOperand(1).getMBB();
   MIB.buildInstr(AArch64::Bcc, {}, {}).addImm(CC1).addMBB(DestMBB);
   if (CC2 != AArch64CC::AL)
@@ -3090,7 +3093,7 @@ bool AArch64InstructionSelector::select(MachineInstr ) {
 CmpInst::Predicate Pred =
 static_cast(I.getOperand(1).getPredicate());
 if (!emitFPCompare(I.getOperand(2).getReg(), I.getOperand(3).getReg(),
-   MIRBuilder) ||
+   MIRBuilder, Pred) ||
 !emitCSetForFCmp(I.getOperand(0).getReg(), Pred, MIRBuilder))
   return false;
 I.eraseFromParent();
@@ -4211,7 +4214,8 @@ MachineInstr *AArch64InstructionSelector::emitCSetForFCmp(
 
 MachineInstr *
 AArch64InstructionSelector::emitFPCompare(Register LHS, Register RHS,
-  MachineIRBuilder ) const {
+  MachineIRBuilder ,
+  Optional Pred) 
const {
   MachineRegisterInfo  = *MIRBuilder.getMRI();
   LLT Ty = MRI.getType(LHS);
   if (Ty.isVector())
@@ -4224,7 +4228,12 @@ AArch64InstructionSelector::emitFPCompare(Register LHS, 
Register RHS,
   // to explicitly materialize a constant.
   const ConstantFP *FPImm = getConstantFPVRegVal(RHS, MRI);
   bool ShouldUseImm = FPImm && (FPImm->isZero() && !FPImm->isNegative());
-  if (!ShouldUseImm) {
+
+  auto IsEqualityPred = [](CmpInst::Predicate P) {
+return P == CmpInst::FCMP_OEQ || P == CmpInst::FCMP_ONE ||
+   P == CmpInst::FCMP_UEQ || P == CmpInst::FCMP_UNE;
+  };
+  if (!ShouldUseImm && Pred && IsEqualityPred(*Pred)) {
 // Try commutating the operands.
 const ConstantFP *LHSImm = getConstantFPVRegVal(LHS, MRI);
 if (LHSImm && (LHSImm->isZero() && !LHSImm->isNegative())) {

diff  --git a/llvm/test/CodeGen/AArch64/GlobalISel/select-fcmp.mir 
b/llvm/test/CodeGen/AArch64/GlobalISel/select-fcmp.mir
index c12cd3343c7e..cde785a6a446 100644
--- a/llvm/test/CodeGen/AArch64/GlobalISel/select-fcmp.mir
+++ b/llvm/test/CodeGen/AArch64/GlobalISel/select-fcmp.mir
@@ -134,3 +134,29 @@ body: |
 RET_ReallyLR implicit $s0
 
 ...
+---
+name:zero_lhs_not_commutative_pred
+alignment:   4
+legalized:   true
+regBankSelected: true
+tracksRegLiveness: true
+body: |
+  bb.1:
+liveins: $s0, $s1
+
+; CHECK-LABEL: name: zero_lhs_not_commutative_pred
+

[llvm-branch-commits] [llvm] a61e42e - [NPM][Inliner] Temporarily remove inline_stats test case for always

2021-01-15 Thread Mircea Trofin via llvm-branch-commits

Author: Mircea Trofin
Date: 2021-01-15T21:59:35-08:00
New Revision: a61e42efbb73e55c44cbb0eb2686c7b4a25ca812

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

LOG: [NPM][Inliner] Temporarily remove inline_stats test case for always
inline

The stats are printed at InlinePass destruction. When we have 2 of them,
it appears the destruction order of the Passes std::vector of the pass
manager differs in msan builds - example:
http://lab.llvm.org:8011/#/builders/74/builds/2135.

This reproes locally, too.

Temporarily removing the sub-test case, to green the build, and will
follow up with a stat dumping alternative that does not depend on vector
element dtor order.

Added: 


Modified: 
llvm/test/Transforms/Inline/inline_stats.ll

Removed: 




diff  --git a/llvm/test/Transforms/Inline/inline_stats.ll 
b/llvm/test/Transforms/Inline/inline_stats.ll
index 1d06ff5d533f..1553da04c7b6 100644
--- a/llvm/test/Transforms/Inline/inline_stats.ll
+++ b/llvm/test/Transforms/Inline/inline_stats.ll
@@ -9,9 +9,6 @@
 ; RUN: opt -S -passes=inliner-wrapper-no-mandatory-first 
-inliner-function-import-stats=basic < %s 2>&1 | FileCheck %s 
--check-prefixes=CHECK-BASIC,CHECK
 ; RUN: opt -S -passes=inliner-wrapper-no-mandatory-first 
-inliner-function-import-stats=verbose < %s 2>&1 | FileCheck %s 
--check-prefixes="CHECK-VERBOSE",CHECK
 
-; RUN: opt -S -passes=inliner-wrapper -inliner-function-import-stats=basic < 
%s 2>&1 | FileCheck %s --check-prefix=MANDATORY-FIRST
-; RUN: opt -S -passes=inliner-wrapper -inliner-function-import-stats=verbose < 
%s 2>&1 | FileCheck %s --check-prefix=MANDATORY-FIRST
-
 ; CHECK: --- Dumping inliner stats for [] ---
 ; CHECK-BASIC-NOT: -- List of inlined functions:
 ; CHECK-BASIC-NOT: -- Inlined not imported function
@@ -30,21 +27,6 @@
 ; CHECK: non-imported functions inlined anywhere: 1 [33.33% of non-imported 
functions]
 ; CHECK: non-imported functions inlined into importing module: 1 [33.33% of 
non-imported functions]
 
-; MANDATORY-FIRST: -- Summary:
-; MANDATORY-FIRST: All functions: 10, imported functions: 7
-; MANDATORY-FIRST: inlined functions: 4 [40% of all functions]
-; MANDATORY-FIRST: imported functions inlined anywhere: 3 [42.86% of imported 
functions]
-; MANDATORY-FIRST: imported functions inlined into importing module: 2 [28.57% 
of imported functions], remaining: 5 [71.43% of imported functions]
-; MANDATORY-FIRST: non-imported functions inlined anywhere: 1 [33.33% of 
non-imported functions]
-; MANDATORY-FIRST: non-imported functions inlined into importing module: 1 
[33.33% of non-imported functions]
-; MANDATORY-FIRST: -- Summary:
-; MANDATORY-FIRST: All functions: 10, imported functions: 7
-; MANDATORY-FIRST: inlined functions: 1 [10% of all functions]
-; MANDATORY-FIRST: imported functions inlined anywhere: 1 [14.29% of imported 
functions]
-; MANDATORY-FIRST: imported functions inlined into importing module: 1 [14.29% 
of imported functions], remaining: 6 [85.71% of imported functions]
-; MANDATORY-FIRST: non-imported functions inlined anywhere: 0 [0% of 
non-imported functions]
-; MANDATORY-FIRST: non-imported functions inlined into importing module: 0 [0% 
of non-imported functions]
-
 define void @internal() {
 call fastcc void @external1()
 call fastcc void @internal2()



___
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] 4707b21 - [AMDGPU] Use llvm::is_contained (NFC)

2021-01-15 Thread Kazu Hirata via llvm-branch-commits

Author: Kazu Hirata
Date: 2021-01-15T21:00:54-08:00
New Revision: 4707b21298a6daf28b08d9395568ccc94a549711

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

LOG: [AMDGPU] Use llvm::is_contained (NFC)

Added: 


Modified: 
llvm/lib/Target/AMDGPU/R600ControlFlowFinalizer.cpp

Removed: 




diff  --git a/llvm/lib/Target/AMDGPU/R600ControlFlowFinalizer.cpp 
b/llvm/lib/Target/AMDGPU/R600ControlFlowFinalizer.cpp
index 85e402da342b..7635cd39cd2c 100644
--- a/llvm/lib/Target/AMDGPU/R600ControlFlowFinalizer.cpp
+++ b/llvm/lib/Target/AMDGPU/R600ControlFlowFinalizer.cpp
@@ -58,12 +58,7 @@ unsigned CFStack::getLoopDepth() {
 }
 
 bool CFStack::branchStackContains(CFStack::StackItem Item) {
-  for (std::vector::const_iterator I = BranchStack.begin(),
-   E = BranchStack.end(); I != E; ++I) {
-if (*I == Item)
-  return true;
-  }
-  return false;
+  return llvm::is_contained(BranchStack, Item);
 }
 
 bool CFStack::requiresWorkAroundForInst(unsigned Opcode) {



___
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] a396e2e - [utils] Use llvm::sort (NFC)

2021-01-15 Thread Kazu Hirata via llvm-branch-commits

Author: Kazu Hirata
Date: 2021-01-15T21:00:52-08:00
New Revision: a396e2e088eeab974a5d386df9466757a4bdced0

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

LOG: [utils] Use llvm::sort (NFC)

Added: 


Modified: 
llvm/utils/FileCheck/FileCheck.cpp
llvm/utils/TableGen/GlobalISel/GIMatchDag.cpp
llvm/utils/TableGen/GlobalISel/GIMatchDagInstr.cpp

Removed: 




diff  --git a/llvm/utils/FileCheck/FileCheck.cpp 
b/llvm/utils/FileCheck/FileCheck.cpp
index 1721b23ad7b5..be277566620e 100644
--- a/llvm/utils/FileCheck/FileCheck.cpp
+++ b/llvm/utils/FileCheck/FileCheck.cpp
@@ -519,54 +519,54 @@ static void DumpAnnotatedInput(raw_ostream , const 
FileCheckRequest ,
   OS << "Input was:\n<<\n";
 
   // Sort annotations.
-  std::sort(Annotations.begin(), Annotations.end(),
-[](const InputAnnotation , const InputAnnotation ) {
-  // 1. Sort annotations in the order of the input lines.
-  //
-  // This makes it easier to find relevant annotations while
-  // iterating input lines in the implementation below.  FileCheck
-  // does not always produce diagnostics in the order of input
-  // lines due to, for example, CHECK-DAG and CHECK-NOT.
-  if (A.InputLine != B.InputLine)
-return A.InputLine < B.InputLine;
-  // 2. Sort annotations in the temporal order FileCheck produced
-  // their associated diagnostics.
-  //
-  // This sort offers several benefits:
-  //
-  // A. On a single input line, the order of annotations reflects
-  //the FileCheck logic for processing directives/patterns.
-  //This can be helpful in understanding cases in which the
-  //order of the associated directives/patterns in the check
-  //file or on the command line either (i) does not match the
-  //temporal order in which FileCheck looks for matches for the
-  //directives/patterns (due to, for example, CHECK-LABEL,
-  //CHECK-NOT, or `--implicit-check-not`) or (ii) does match
-  //that order but does not match the order of those
-  //diagnostics along an input line (due to, for example,
-  //CHECK-DAG).
-  //
-  //On the other hand, because our presentation format presents
-  //input lines in order, there's no clear way to offer the
-  //same benefit across input lines.  For consistency, it might
-  //then seem worthwhile to have annotations on a single line
-  //also sorted in input order (that is, by input column).
-  //However, in practice, this appears to be more confusing
-  //than helpful.  Perhaps it's intuitive to expect annotations
-  //to be listed in the temporal order in which they were
-  //produced except in cases the presentation format obviously
-  //and inherently cannot support it (that is, across input
-  //lines).
-  //
-  // B. When diagnostics' annotations are split among multiple
-  //input lines, the user must track them from one input line
-  //to the next.  One property of the sort chosen here is that
-  //it facilitates the user in this regard by ensuring the
-  //following: when comparing any two input lines, a
-  //diagnostic's annotations are sorted in the same position
-  //relative to all other diagnostics' annotations.
-  return A.DiagIndex < B.DiagIndex;
-});
+  llvm::sort(Annotations,
+ [](const InputAnnotation , const InputAnnotation ) {
+   // 1. Sort annotations in the order of the input lines.
+   //
+   // This makes it easier to find relevant annotations while
+   // iterating input lines in the implementation below.  FileCheck
+   // does not always produce diagnostics in the order of input
+   // lines due to, for example, CHECK-DAG and CHECK-NOT.
+   if (A.InputLine != B.InputLine)
+ return A.InputLine < B.InputLine;
+   // 2. Sort annotations in the temporal order FileCheck produced
+   // their associated diagnostics.
+   //
+   // This sort offers several benefits:
+   //
+   // A. On a single input line, the order of annotations reflects
+   //the FileCheck logic for processing directives/patterns.

[llvm-branch-commits] [llvm] 029c225 - [Inline] Fix a missing character in inline_stats.ll

2021-01-15 Thread Mircea Trofin via llvm-branch-commits

Author: Mircea Trofin
Date: 2021-01-15T20:28:15-08:00
New Revision: 029c2257c21e15e00806b2083e8881fb2468900e

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

LOG: [Inline] Fix a missing character in inline_stats.ll

Added: 


Modified: 
llvm/test/Transforms/Inline/inline_stats.ll

Removed: 




diff  --git a/llvm/test/Transforms/Inline/inline_stats.ll 
b/llvm/test/Transforms/Inline/inline_stats.ll
index 7c4471e1db97..1d06ff5d533f 100644
--- a/llvm/test/Transforms/Inline/inline_stats.ll
+++ b/llvm/test/Transforms/Inline/inline_stats.ll
@@ -30,7 +30,7 @@
 ; CHECK: non-imported functions inlined anywhere: 1 [33.33% of non-imported 
functions]
 ; CHECK: non-imported functions inlined into importing module: 1 [33.33% of 
non-imported functions]
 
-; MANDATORY-FIRST: - Summary:
+; MANDATORY-FIRST: -- Summary:
 ; MANDATORY-FIRST: All functions: 10, imported functions: 7
 ; MANDATORY-FIRST: inlined functions: 4 [40% of all functions]
 ; MANDATORY-FIRST: imported functions inlined anywhere: 3 [42.86% of imported 
functions]



___
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] [clang] e8049dc - [NewPM][Inliner] Move the 'always inliner' case in the same CGSCC pass as 'regular' inliner

2021-01-15 Thread Mircea Trofin via llvm-branch-commits

Author: Mircea Trofin
Date: 2021-01-15T17:59:38-08:00
New Revision: e8049dc3c8a46ccd75ce2a4f438d695d20feb660

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

LOG: [NewPM][Inliner] Move the 'always inliner' case in the same CGSCC pass as 
'regular' inliner

Expanding from D94808 - we ensure the same InlineAdvisor is used by both
InlinerPass instances. The notion of mandatory inlining is moved into
the core InlineAdvisor: advisors anyway have to handle that case, so
this change also factors out that a bit better.

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

Added: 


Modified: 
clang/test/CodeGen/thinlto-distributed-newpm.ll
clang/test/Frontend/optimization-remark-line-directive.c
clang/test/Frontend/optimization-remark-new-pm.c
clang/test/Frontend/optimization-remark-with-hotness-new-pm.c
clang/test/Frontend/optimization-remark.c
llvm/include/llvm/Analysis/InlineAdvisor.h
llvm/include/llvm/Analysis/MLInlineAdvisor.h
llvm/include/llvm/Analysis/ReplayInlineAdvisor.h
llvm/include/llvm/Passes/PassBuilder.h
llvm/include/llvm/Transforms/IPO/Inliner.h
llvm/lib/Analysis/DevelopmentModeInlineAdvisor.cpp
llvm/lib/Analysis/InlineAdvisor.cpp
llvm/lib/Analysis/MLInlineAdvisor.cpp
llvm/lib/Analysis/ReplayInlineAdvisor.cpp
llvm/lib/Passes/PassBuilder.cpp
llvm/lib/Passes/PassRegistry.def
llvm/lib/Transforms/IPO/Inliner.cpp
llvm/test/Other/new-pm-defaults.ll
llvm/test/Other/new-pm-lto-defaults.ll
llvm/test/Other/new-pm-pgo-preinline.ll
llvm/test/Other/new-pm-thinlto-defaults.ll
llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll
llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll
llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
llvm/test/Transforms/Inline/inline_stats.ll
llvm/test/Transforms/Inline/optimization-remarks-with-hotness.ll
llvm/test/Transforms/Inline/optimization-remarks.ll
llvm/test/Transforms/Inline/pr46945.ll

Removed: 
llvm/test/Other/new-pm-module-inliner-wrapper.ll



diff  --git a/clang/test/CodeGen/thinlto-distributed-newpm.ll 
b/clang/test/CodeGen/thinlto-distributed-newpm.ll
index 8fe53762837e..4c031db6734b 100644
--- a/clang/test/CodeGen/thinlto-distributed-newpm.ll
+++ b/clang/test/CodeGen/thinlto-distributed-newpm.ll
@@ -63,19 +63,10 @@
 ; CHECK-O: Running analysis: OuterAnalysisManagerProxy
 ; CHECK-O: Running pass: SimplifyCFGPass on main
 ; CHECK-O: Finished {{.*}}Function pass manager run.
-; CHECK-O: Running pass: ModuleInlinerWrapperPass
-; CHECK-O: Running analysis: InlineAdvisorAnalysis
 ; CHECK-O: Running analysis: InnerAnalysisManagerProxy
 ; CHECK-O: Running analysis: LazyCallGraphAnalysis
 ; CHECK-O: Running analysis: FunctionAnalysisManagerCGSCCProxy on (main)
 ; CHECK-O: Running analysis: OuterAnalysisManagerProxy
-; CHECK-O: Running pass: InlinerPass on (main)
-; CHECK-O: Finished {{.*}}Module pass manager run
-; CHECK-O: Running pass: ModuleInlinerWrapperPass
-; CHECK-O: Running pass: RequireAnalysisPass<{{.*}}GlobalsAA
-; CHECK-O: Running analysis: GlobalsAA
-; CHECK-O: Running analysis: CallGraphAnalysis
-; CHECK-O: Running pass: RequireAnalysisPass<{{.*}}ProfileSummaryAnalysis
 ; CHECK-O: Starting CGSCC pass manager run.
 ; CHECK-O: Running pass: InlinerPass on (main)
 ; CHECK-O: Running pass: PostOrderFunctionAttrsPass on (main)

diff  --git a/clang/test/Frontend/optimization-remark-line-directive.c 
b/clang/test/Frontend/optimization-remark-line-directive.c
index 5a2dc6754763..59f600125860 100644
--- a/clang/test/Frontend/optimization-remark-line-directive.c
+++ b/clang/test/Frontend/optimization-remark-line-directive.c
@@ -6,7 +6,7 @@
 
 // The new PM inliner is not added to the default pipeline at O0, so we add
 // some optimizations to trigger it.
-// RUN: %clang_cc1 %s -Rpass=inline -fexperimental-new-pass-manager -O1 
-debug-info-kind=line-tables-only -emit-llvm-only -verify -mllvm 
-mandatory-inlining-first=0
+// RUN: %clang_cc1 %s -Rpass=inline -fexperimental-new-pass-manager -O1 
-debug-info-kind=line-tables-only -emit-llvm-only -mllvm 
-mandatory-inlining-first=false -verify
 
 int foo(int x, int y) __attribute__((always_inline));
 int foo(int x, int y) { return x + y; }

diff  --git a/clang/test/Frontend/optimization-remark-new-pm.c 
b/clang/test/Frontend/optimization-remark-new-pm.c
index 79e83014589b..2d89059b13e6 100644
--- a/clang/test/Frontend/optimization-remark-new-pm.c
+++ b/clang/test/Frontend/optimization-remark-new-pm.c
@@ -1,8 +1,8 @@
 // Verify that remarks for the inliner appear. The remarks under the new PM 
will
 // be slightly 
diff erent than those emitted by the legacy PM. The new PM inliner
 // also doesnot appear to 

[llvm-branch-commits] [lldb] 999f5da - [debugserver] Fix inverted if block that resulted in us using the private entitlements

2021-01-15 Thread Jonas Devlieghere via llvm-branch-commits

Author: Jonas Devlieghere
Date: 2021-01-15T17:41:07-08:00
New Revision: 999f5da6b3088fa4c0bb9d05b358d015ca74c71f

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

LOG: [debugserver] Fix inverted if block that resulted in us using the private 
entitlements

Added: 


Modified: 
lldb/tools/debugserver/source/CMakeLists.txt

Removed: 




diff  --git a/lldb/tools/debugserver/source/CMakeLists.txt 
b/lldb/tools/debugserver/source/CMakeLists.txt
index 0318d5051c1f..710e11f8bd8f 100644
--- a/lldb/tools/debugserver/source/CMakeLists.txt
+++ b/lldb/tools/debugserver/source/CMakeLists.txt
@@ -132,9 +132,9 @@ if(LLDB_USE_ENTITLEMENTS)
 set(entitlements 
${CMAKE_CURRENT_SOURCE_DIR}/debugserver-entitlements.plist)
   else()
 if (LLDB_USE_PRIVATE_ENTITLEMENTS)
-  set(entitlements 
${DEBUGSERVER_RESOURCE_DIR}/debugserver-macosx-entitlements.plist)
-else()
   set(entitlements 
${DEBUGSERVER_RESOURCE_DIR}/debugserver-macosx-private-entitlements.plist)
+else()
+  set(entitlements 
${DEBUGSERVER_RESOURCE_DIR}/debugserver-macosx-entitlements.plist)
 endif()
   endif()
 endif()



___
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] [mlir] fd2083d - [mlir] Fixing potential build break in my previous commit

2021-01-15 Thread Thomas Raoux via llvm-branch-commits

Author: Thomas Raoux
Date: 2021-01-15T17:38:16-08:00
New Revision: fd2083d73c2d229e80c1091a0399f7e1076e8c52

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

LOG: [mlir] Fixing potential build break in my previous commit

Added: 


Modified: 
mlir/lib/Dialect/Linalg/Transforms/CMakeLists.txt

Removed: 




diff  --git a/mlir/lib/Dialect/Linalg/Transforms/CMakeLists.txt 
b/mlir/lib/Dialect/Linalg/Transforms/CMakeLists.txt
index 42e2d4dcd244..b063996db55e 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/CMakeLists.txt
+++ b/mlir/lib/Dialect/Linalg/Transforms/CMakeLists.txt
@@ -23,6 +23,7 @@ add_mlir_dialect_library(MLIRLinalgTransforms
 
   LINK_LIBS PUBLIC
   MLIRAffine
+  MLIRAffineUtils
   MLIRAnalysis
   MLIREDSC
   MLIRIR



___
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] [mlir] 2a27a98 - [mlir][AsmPrinter] Properly escape strings when printing locations

2021-01-15 Thread River Riddle via llvm-branch-commits

Author: River Riddle
Date: 2021-01-15T17:14:57-08:00
New Revision: 2a27a9819a1e3371e3e08d7fbad6235cf50d336d

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

LOG: [mlir][AsmPrinter] Properly escape strings when printing locations

This fixes errors when location strings contains newlines, or other non-ascii 
characters.

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

Added: 


Modified: 
mlir/lib/IR/AsmPrinter.cpp
mlir/test/IR/locations.mlir

Removed: 




diff  --git a/mlir/lib/IR/AsmPrinter.cpp b/mlir/lib/IR/AsmPrinter.cpp
index c56fdff2cde5..3182e906ce93 100644
--- a/mlir/lib/IR/AsmPrinter.cpp
+++ b/mlir/lib/IR/AsmPrinter.cpp
@@ -1257,12 +1257,19 @@ void ModulePrinter::printLocationInternal(LocationAttr 
loc, bool pretty) {
   os << "unknown";
   })
   .Case([&](FileLineColLoc loc) {
-StringRef mayQuote = pretty ? "" : "\"";
-os << mayQuote << loc.getFilename() << mayQuote << ':' << loc.getLine()
-   << ':' << loc.getColumn();
+if (pretty) {
+  os << loc.getFilename();
+} else {
+  os << "\"";
+  printEscapedString(loc.getFilename(), os);
+  os << "\"";
+}
+os << ':' << loc.getLine() << ':' << loc.getColumn();
   })
   .Case([&](NameLoc loc) {
-os << '\"' << loc.getName() << '\"';
+os << '\"';
+printEscapedString(loc.getName(), os);
+os << '\"';
 
 // Print the child if it isn't unknown.
 auto childLoc = loc.getChildLoc();

diff  --git a/mlir/test/IR/locations.mlir b/mlir/test/IR/locations.mlir
index 950b67827a0f..5ad854eedc10 100644
--- a/mlir/test/IR/locations.mlir
+++ b/mlir/test/IR/locations.mlir
@@ -27,6 +27,20 @@ func @inline_notation() -> i32 {
 // CHECK-LABEL: func private @loc_attr(i1 {foo.loc_attr = loc(callsite("foo" 
at "mysource.cc":10:8))})
 func private @loc_attr(i1 {foo.loc_attr = loc(callsite("foo" at 
"mysource.cc":10:8))})
 
+  // Check that locations get properly escaped.
+// CHECK-LABEL: func @escape_strings()
+func @escape_strings() {
+  // CHECK: loc("escaped\0A")
+  "foo"() : () -> () loc("escaped\n")
+
+  // CHECK: loc("escaped\0A")
+  "foo"() : () -> () loc("escaped\0A")
+
+  // CHECK: loc("escaped\0A":0:0)
+  "foo"() : () -> () loc("escaped\n":0:0)
+  return
+}
+
 // CHECK-ALIAS: "foo.op"() : () -> () loc(#[[LOC:.*]])
 "foo.op"() : () -> () loc(#loc)
 



___
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] [mlir] 3afbfb4 - [mlir][NFC] Move helper substWithMin into Affine utils

2021-01-15 Thread Thomas Raoux via llvm-branch-commits

Author: Thomas Raoux
Date: 2021-01-15T17:13:56-08:00
New Revision: 3afbfb4145bea3796f1137c34848093c3435

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

LOG: [mlir][NFC] Move helper substWithMin into Affine utils

This allow using this helper outside of the linalg canonicalization.

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

Added: 


Modified: 
mlir/include/mlir/Dialect/Affine/Utils.h
mlir/lib/Dialect/Affine/Utils/Utils.cpp
mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp

Removed: 




diff  --git a/mlir/include/mlir/Dialect/Affine/Utils.h 
b/mlir/include/mlir/Dialect/Affine/Utils.h
index 4f36bb800dd1..be6985dfe403 100644
--- a/mlir/include/mlir/Dialect/Affine/Utils.h
+++ b/mlir/include/mlir/Dialect/Affine/Utils.h
@@ -13,6 +13,7 @@
 #ifndef MLIR_DIALECT_AFFINE_UTILS_H
 #define MLIR_DIALECT_AFFINE_UTILS_H
 
+#include "mlir/IR/AffineExpr.h"
 #include "mlir/Support/LLVM.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/SmallVector.h"
@@ -130,6 +131,15 @@ 
vectorizeAffineLoopNest(std::vector> ,
 /// early if the op is already in a normalized form.
 void normalizeAffineParallel(AffineParallelOp op);
 
+/// Traverse `e` and return an AffineExpr where all occurrences of `dim` have
+/// been replaced by either:
+///  - `min` if `positivePath` is true when we reach an occurrence of `dim`
+///  - `max` if `positivePath` is true when we reach an occurrence of `dim`
+/// `positivePath` is negated each time we hit a multiplicative or divisive
+/// binary op with a constant negative coefficient.
+AffineExpr substWithMin(AffineExpr e, AffineExpr dim, AffineExpr min,
+AffineExpr max, bool positivePath = true);
+
 } // namespace mlir
 
 #endif // MLIR_DIALECT_AFFINE_UTILS_H

diff  --git a/mlir/lib/Dialect/Affine/Utils/Utils.cpp 
b/mlir/lib/Dialect/Affine/Utils/Utils.cpp
index 844a02f8aa21..c66e111fb9cf 100644
--- a/mlir/lib/Dialect/Affine/Utils/Utils.cpp
+++ b/mlir/lib/Dialect/Affine/Utils/Utils.cpp
@@ -226,3 +226,30 @@ LogicalResult mlir::hoistAffineIfOp(AffineIfOp ifOp, bool 
*folded) {
 
   return success();
 }
+
+// Return the min expr after replacing the given dim.
+AffineExpr mlir::substWithMin(AffineExpr e, AffineExpr dim, AffineExpr min,
+  AffineExpr max, bool positivePath) {
+  if (e == dim)
+return positivePath ? min : max;
+  if (auto bin = e.dyn_cast()) {
+AffineExpr lhs = bin.getLHS();
+AffineExpr rhs = bin.getRHS();
+if (bin.getKind() == mlir::AffineExprKind::Add)
+  return substWithMin(lhs, dim, min, max, positivePath) +
+ substWithMin(rhs, dim, min, max, positivePath);
+
+auto c1 = bin.getLHS().dyn_cast();
+auto c2 = bin.getRHS().dyn_cast();
+if (c1 && c1.getValue() < 0)
+  return getAffineBinaryOpExpr(
+  bin.getKind(), c1, substWithMin(rhs, dim, min, max, !positivePath));
+if (c2 && c2.getValue() < 0)
+  return getAffineBinaryOpExpr(
+  bin.getKind(), substWithMin(lhs, dim, min, max, !positivePath), c2);
+return getAffineBinaryOpExpr(
+bin.getKind(), substWithMin(lhs, dim, min, max, positivePath),
+substWithMin(rhs, dim, min, max, positivePath));
+  }
+  return e;
+}

diff  --git a/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp 
b/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
index 5b6302a7e5a2..b6171ff9c5b1 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
@@ -12,6 +12,7 @@
 
//===--===//
 
 #include "mlir/Dialect/Linalg/Transforms/Transforms.h"
+#include "mlir/Dialect/Affine/Utils.h"
 #include "mlir/Dialect/Linalg/Analysis/DependenceAnalysis.h"
 #include "mlir/Dialect/Linalg/IR/LinalgOps.h"
 #include "mlir/Dialect/Linalg/Utils/Utils.h"
@@ -332,38 +333,6 @@ LogicalResult mlir::linalg::applyStagedPatterns(
   return success();
 }
 
-/// Traverse `e` and return an AffineExpr where all occurrences of `dim` have
-/// been replaced by either:
-///  - `min` if `positivePath` is true when we reach an occurrence of `dim`
-///  - `max` if `positivePath` is true when we reach an occurrence of `dim`
-/// `positivePath` is negated each time we hit a multiplicative or divisive
-/// binary op with a constant negative coefficient.
-static AffineExpr substWithMin(AffineExpr e, AffineExpr dim, AffineExpr min,
-   AffineExpr max, bool positivePath = true) {
-  if (e == dim)
-return positivePath ? min : max;
-  if (auto bin = e.dyn_cast()) {
-AffineExpr lhs = bin.getLHS();
-AffineExpr rhs = bin.getRHS();
-if (bin.getKind() == mlir::AffineExprKind::Add)
-  return substWithMin(lhs, dim, min, max, positivePath) +
- 

[llvm-branch-commits] [flang] 1bd083b - [flang] Create names to allow access to inaccessible specifics

2021-01-15 Thread peter klausler via llvm-branch-commits

Author: peter klausler
Date: 2021-01-15T16:56:38-08:00
New Revision: 1bd083b5d6d0619f532a7310e72887ea6d2e87eb

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

LOG: [flang] Create names to allow access to inaccessible specifics

When a reference to a generic interface occurs in a specification
expression that must be emitted to a module file, we have a problem
when the generic resolves to a function whose name is inaccessible
due to being PRIVATE or due to a conflict with another use of the
same name in the scope.  In these cases, construct a new name for
the specific procedure and emit a renaming USE to the module file.
Also, relax enforcement of PRIVATE when analyzing module files.

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

Added: 
flang/test/Semantics/modfile39.f90

Modified: 
flang/include/flang/Semantics/expression.h
flang/include/flang/Semantics/semantics.h
flang/include/flang/Semantics/tools.h
flang/lib/Evaluate/check-expression.cpp
flang/lib/Semantics/expression.cpp
flang/lib/Semantics/resolve-names.cpp
flang/lib/Semantics/semantics.cpp
flang/lib/Semantics/tools.cpp

Removed: 




diff  --git a/flang/include/flang/Semantics/expression.h 
b/flang/include/flang/Semantics/expression.h
index e095928656a8..7b252baa6c7d 100644
--- a/flang/include/flang/Semantics/expression.h
+++ b/flang/include/flang/Semantics/expression.h
@@ -363,6 +363,8 @@ class ExpressionAnalyzer {
   const Symbol *ResolveGeneric(const Symbol &, const ActualArguments &,
   const AdjustActuals &, bool mightBeStructureConstructor = false);
   void EmitGenericResolutionError(const Symbol &);
+  const Symbol (
+  const Symbol , const Symbol );
   std::optional GetCalleeAndArguments(const parser::Name &,
   ActualArguments &&, bool isSubroutine = false,
   bool mightBeStructureConstructor = false);

diff  --git a/flang/include/flang/Semantics/semantics.h 
b/flang/include/flang/Semantics/semantics.h
index de3d9aeac144..4f4bfc7fea2d 100644
--- a/flang/include/flang/Semantics/semantics.h
+++ b/flang/include/flang/Semantics/semantics.h
@@ -16,6 +16,7 @@
 #include "flang/Evaluate/intrinsics.h"
 #include "flang/Parser/message.h"
 #include 
+#include 
 #include 
 #include 
 
@@ -170,6 +171,7 @@ class SemanticsContext {
   void ActivateIndexVar(const parser::Name &, IndexVarKind);
   void DeactivateIndexVar(const parser::Name &);
   SymbolVector GetIndexVars(IndexVarKind);
+  SourceName SaveTempName(std::string &&);
   SourceName GetTempName(const Scope &);
 
 private:
@@ -198,7 +200,7 @@ class SemanticsContext {
   };
   std::map activeIndexVars_;
   std::set errorSymbols_;
-  std::vector tempNames_;
+  std::set tempNames_;
 };
 
 class Semantics {

diff  --git a/flang/include/flang/Semantics/tools.h 
b/flang/include/flang/Semantics/tools.h
index 1a0e2845534b..e809b300b3ad 100644
--- a/flang/include/flang/Semantics/tools.h
+++ b/flang/include/flang/Semantics/tools.h
@@ -38,6 +38,7 @@ const Scope (const Scope &);
 const Scope (const Symbol &);
 
 const Scope *FindModuleContaining(const Scope &);
+const Scope *FindModuleFileContaining(const Scope &);
 const Scope *FindPureProcedureContaining(const Scope &);
 const Scope *FindPureProcedureContaining(const Symbol &);
 const Symbol *FindPointerComponent(const Scope &);

diff  --git a/flang/lib/Evaluate/check-expression.cpp 
b/flang/lib/Evaluate/check-expression.cpp
index 45bfde08dfb9..4bedbe8d1d8f 100644
--- a/flang/lib/Evaluate/check-expression.cpp
+++ b/flang/lib/Evaluate/check-expression.cpp
@@ -485,16 +485,17 @@ class CheckSpecificationExprHelper
 
   template  Result operator()(const FunctionRef ) const {
 if (const auto *symbol{x.proc().GetSymbol()}) {
-  if (!semantics::IsPureProcedure(*symbol)) {
-return "reference to impure function '"s + symbol->name().ToString() +
+  const Symbol {symbol->GetUltimate()};
+  if (!semantics::IsPureProcedure(ultimate)) {
+return "reference to impure function '"s + ultimate.name().ToString() +
 "'";
   }
-  if (semantics::IsStmtFunction(*symbol)) {
+  if (semantics::IsStmtFunction(ultimate)) {
 return "reference to statement function '"s +
-symbol->name().ToString() + "'";
+ultimate.name().ToString() + "'";
   }
   if (scope_.IsDerivedType()) { // C750, C754
-return "reference to function '"s + symbol->name().ToString() +
+return "reference to function '"s + ultimate.name().ToString() +
 "' not allowed for derived type components or type parameter"
 " values";
   }

diff  --git a/flang/lib/Semantics/expression.cpp 
b/flang/lib/Semantics/expression.cpp
index a4961af71bbc..56a26d7e9bd8 100644
--- a/flang/lib/Semantics/expression.cpp
+++ 

[llvm-branch-commits] [llvm] aa3d4d9 - [NFC] Disallow unused prefixes under MC/RISCV

2021-01-15 Thread Mircea Trofin via llvm-branch-commits

Author: Mircea Trofin
Date: 2021-01-15T16:21:30-08:00
New Revision: aa3d4d9939595295d19969c62077cc09e4823f58

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

LOG: [NFC] Disallow unused prefixes under MC/RISCV

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

Added: 


Modified: 
llvm/test/MC/RISCV/lit.local.cfg
llvm/test/MC/RISCV/rv32c-only-valid.s
llvm/test/MC/RISCV/rv32zfh-valid.s
llvm/test/MC/RISCV/rv64zfh-valid.s

Removed: 




diff  --git a/llvm/test/MC/RISCV/lit.local.cfg 
b/llvm/test/MC/RISCV/lit.local.cfg
index c63820126f8c..896e7941295e 100644
--- a/llvm/test/MC/RISCV/lit.local.cfg
+++ b/llvm/test/MC/RISCV/lit.local.cfg
@@ -1,2 +1,10 @@
+from lit.llvm.subst import ToolSubst
+
 if not 'RISCV' in config.root.targets:
 config.unsupported = True
+
+fc = ToolSubst('FileCheck', unresolved='fatal')
+# Insert this first. Then, we'll first update the blank FileCheck command; 
then,
+# the default substitution of FileCheck will replace it to its full path.
+config.substitutions.insert(0, (fc.regex,
+'FileCheck --allow-unused-prefixes=false'))

diff  --git a/llvm/test/MC/RISCV/rv32c-only-valid.s 
b/llvm/test/MC/RISCV/rv32c-only-valid.s
index edd5a656eeae..0b10b3f0e90e 100644
--- a/llvm/test/MC/RISCV/rv32c-only-valid.s
+++ b/llvm/test/MC/RISCV/rv32c-only-valid.s
@@ -1,18 +1,18 @@
 # RUN: llvm-mc %s -triple=riscv32 -mattr=+c -riscv-no-aliases -show-encoding \
-# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
+# RUN: | FileCheck --check-prefix=CHECK-ASM %s
 # RUN: llvm-mc -filetype=obj -triple=riscv32 -mattr=+c < %s \
 # RUN: | llvm-objdump --mattr=+c -M no-aliases -d -r - \
-# RUN: | FileCheck --check-prefixes=CHECK-OBJ,CHECK-ASM-AND-OBJ %s
+# RUN: | FileCheck --check-prefix=CHECK-OBJ %s
 #
 # RUN: not llvm-mc -triple riscv32 \
 # RUN: -riscv-no-aliases -show-encoding < %s 2>&1 \
-# RUN: | FileCheck -check-prefixes=CHECK-NO-EXT %s
+# RUN: | FileCheck --check-prefix=CHECK-NO-EXT %s
 # RUN: not llvm-mc -triple riscv64 -mattr=+c \
 # RUN: -riscv-no-aliases -show-encoding < %s 2>&1 \
-# RUN: | FileCheck -check-prefixes=CHECK-NO-RV32 %s
+# RUN: | FileCheck --check-prefix=CHECK-NO-RV32 %s
 # RUN: not llvm-mc -triple riscv64 \
 # RUN: -riscv-no-aliases -show-encoding < %s 2>&1 \
-# RUN: | FileCheck -check-prefixes=CHECK-NO-RV32-AND-EXT %s
+# RUN: | FileCheck --check-prefix=CHECK-NO-RV32-AND-EXT %s
 
 # CHECK-OBJ: c.jal 0x7fe
 # CHECK-ASM: c.jal 2046

diff  --git a/llvm/test/MC/RISCV/rv32zfh-valid.s 
b/llvm/test/MC/RISCV/rv32zfh-valid.s
index a6853fb95ea0..f257ad0d91fe 100644
--- a/llvm/test/MC/RISCV/rv32zfh-valid.s
+++ b/llvm/test/MC/RISCV/rv32zfh-valid.s
@@ -4,10 +4,10 @@
 # RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
 # RUN: llvm-mc -filetype=obj -triple=riscv32 -mattr=+experimental-zfh < %s \
 # RUN: | llvm-objdump --mattr=+experimental-zfh -M no-aliases -d -r - \
-# RUN: | FileCheck -check-prefixes=CHECK-OBJ,CHECK-ASM-AND-OBJ %s
+# RUN: | FileCheck --check-prefix=CHECK-ASM-AND-OBJ %s
 # RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+experimental-zfh < %s \
 # RUN: | llvm-objdump --mattr=+experimental-zfh -M no-aliases -d -r - \
-# RUN: | FileCheck -check-prefixes=CHECK-OBJ,CHECK-ASM-AND-OBJ %s
+# RUN: | FileCheck --check-prefix=CHECK-ASM-AND-OBJ %s
 
 # CHECK-ASM-AND-OBJ: flh ft0, 12(a0)
 # CHECK-ASM: encoding: [0x07,0x10,0xc5,0x00]

diff  --git a/llvm/test/MC/RISCV/rv64zfh-valid.s 
b/llvm/test/MC/RISCV/rv64zfh-valid.s
index 0a667f668d4f..49aa4e7aaaef 100644
--- a/llvm/test/MC/RISCV/rv64zfh-valid.s
+++ b/llvm/test/MC/RISCV/rv64zfh-valid.s
@@ -2,7 +2,7 @@
 # RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
 # RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+experimental-zfh < %s \
 # RUN: | llvm-objdump --mattr=+experimental-zfh -M no-aliases -d -r - \
-# RUN: | FileCheck -check-prefixes=CHECK-OBJ,CHECK-ASM-AND-OBJ %s
+# RUN: | FileCheck --check-prefix=CHECK-ASM-AND-OBJ %s
 #
 # RUN: not llvm-mc -triple riscv32 -mattr=+experimental-zfh < %s 2>&1 \
 # RUN: | FileCheck -check-prefix=CHECK-RV32 %s



___
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] [compiler-rt] d302398 - hwasan: Update register-dump-read.c test to reserve x23 instead of x20.

2021-01-15 Thread Peter Collingbourne via llvm-branch-commits

Author: Peter Collingbourne
Date: 2021-01-15T16:14:36-08:00
New Revision: d302398ff05f6d2bfbcb5c4fdafccf8a0e3b9875

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

LOG: hwasan: Update register-dump-read.c test to reserve x23 instead of x20.

D90422 changed this test to write a fixed value into register x23
instead of x20, but it did not update the list of reserved registers.
This meant that x23 may have been live across the register write,
although this happens to not be the case with the current compiler.
Fix the problem by updating the reserved register list.

Added: 


Modified: 
compiler-rt/test/hwasan/TestCases/register-dump-read.c

Removed: 




diff  --git a/compiler-rt/test/hwasan/TestCases/register-dump-read.c 
b/compiler-rt/test/hwasan/TestCases/register-dump-read.c
index 8325857fa916..002c5dd5e1f9 100644
--- a/compiler-rt/test/hwasan/TestCases/register-dump-read.c
+++ b/compiler-rt/test/hwasan/TestCases/register-dump-read.c
@@ -1,11 +1,11 @@
-// RUN: %clang_hwasan -ffixed-x10 -ffixed-x20 -ffixed-x27 -O0 %s -o %t && not 
%run %t 2>&1 | FileCheck %s --check-prefixes=CHECK
-// RUN: %clang_hwasan -ffixed-x10 -ffixed-x20 -ffixed-x27 -O1 %s -o %t && not 
%run %t 2>&1 | FileCheck %s --check-prefixes=CHECK
-// RUN: %clang_hwasan -ffixed-x10 -ffixed-x20 -ffixed-x27 -O2 %s -o %t && not 
%run %t 2>&1 | FileCheck %s --check-prefixes=CHECK
-// RUN: %clang_hwasan -ffixed-x10 -ffixed-x20 -ffixed-x27 -O3 %s -o %t && not 
%run %t 2>&1 | FileCheck %s --check-prefixes=CHECK
+// RUN: %clang_hwasan -ffixed-x10 -ffixed-x23 -ffixed-x27 -O0 %s -o %t && not 
%run %t 2>&1 | FileCheck %s --check-prefixes=CHECK
+// RUN: %clang_hwasan -ffixed-x10 -ffixed-x23 -ffixed-x27 -O1 %s -o %t && not 
%run %t 2>&1 | FileCheck %s --check-prefixes=CHECK
+// RUN: %clang_hwasan -ffixed-x10 -ffixed-x23 -ffixed-x27 -O2 %s -o %t && not 
%run %t 2>&1 | FileCheck %s --check-prefixes=CHECK
+// RUN: %clang_hwasan -ffixed-x10 -ffixed-x23 -ffixed-x27 -O3 %s -o %t && not 
%run %t 2>&1 | FileCheck %s --check-prefixes=CHECK
 // REQUIRES: aarch64-target-arch
 
-// RUN: %clang_hwasan -ffixed-x10 -ffixed-x20 -ffixed-x27 -O2 %s -o %t && not 
%env_hwasan_opts=fast_unwind_on_fatal=true %run %t 2>&1 | FileCheck %s 
--check-prefixes=CHECK
-// RUN: %clang_hwasan -ffixed-x10 -ffixed-x20 -ffixed-x27 -O2 %s -o %t && not 
%env_hwasan_opts=fast_unwind_on_fatal=false %run %t 2>&1 | FileCheck %s 
--check-prefixes=CHECK
+// RUN: %clang_hwasan -ffixed-x10 -ffixed-x23 -ffixed-x27 -O2 %s -o %t && not 
%env_hwasan_opts=fast_unwind_on_fatal=true %run %t 2>&1 | FileCheck %s 
--check-prefixes=CHECK
+// RUN: %clang_hwasan -ffixed-x10 -ffixed-x23 -ffixed-x27 -O2 %s -o %t && not 
%env_hwasan_opts=fast_unwind_on_fatal=false %run %t 2>&1 | FileCheck %s 
--check-prefixes=CHECK
 
 #include 
 #include 



___
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] 187d771 - Revert "[WebAssembly] Add support for table linking to wasm-ld"

2021-01-15 Thread Derek Schuff via llvm-branch-commits

Author: Derek Schuff
Date: 2021-01-15T15:50:41-08:00
New Revision: 187d771d27ed9059675b53e92e8fb8aeee9c43d8

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

LOG: Revert "[WebAssembly] Add support for table linking to wasm-ld"

This reverts commit 38dfce706f796dc109ea495dd69a8cb4c8fa819d.
CI discovered a bug where the table is exported twice: see
D91870

Added: 


Modified: 
lld/test/wasm/alias.s
lld/test/wasm/init-fini.ll
lld/test/wasm/local-symbols.ll
lld/test/wasm/locals-duplicate.test
lld/test/wasm/pie.ll
lld/test/wasm/section-symbol-relocs.yaml
lld/test/wasm/shared.ll
lld/test/wasm/signature-mismatch.ll
lld/test/wasm/stack-pointer.ll
lld/test/wasm/weak-alias.ll
lld/wasm/Driver.cpp
lld/wasm/InputFiles.cpp
lld/wasm/InputFiles.h
lld/wasm/MarkLive.cpp
lld/wasm/SymbolTable.cpp
lld/wasm/SymbolTable.h
lld/wasm/Symbols.cpp
lld/wasm/Symbols.h
lld/wasm/SyntheticSections.cpp
lld/wasm/SyntheticSections.h
lld/wasm/Writer.cpp

Removed: 




diff  --git a/lld/test/wasm/alias.s b/lld/test/wasm/alias.s
index b2ab45e98d95..6c99f69da8b8 100644
--- a/lld/test/wasm/alias.s
+++ b/lld/test/wasm/alias.s
@@ -22,6 +22,14 @@ _start:
 # CHECK-NEXT: ReturnTypes: []
 # CHECK-NEXT:   - Type:FUNCTION
 # CHECK-NEXT: FunctionTypes:   [ 0 ]
+# CHECK-NEXT:   - Type:TABLE
+# CHECK-NEXT: Tables:
+# CHECK-NEXT:   - Index:   0
+# CHECK-NEXT: ElemType:FUNCREF
+# CHECK-NEXT: Limits:
+# CHECK-NEXT:   Flags:   [ HAS_MAX ]
+# CHECK-NEXT:   Initial: 0x1
+# CHECK-NEXT:   Maximum: 0x1
 # CHECK-NEXT:   - Type:MEMORY
 # CHECK-NEXT: Memories:
 # CHECK-NEXT:   - Initial: 0x2

diff  --git a/lld/test/wasm/init-fini.ll b/lld/test/wasm/init-fini.ll
index 5631d58d68e5..1e7644bc6d35 100644
--- a/lld/test/wasm/init-fini.ll
+++ b/lld/test/wasm/init-fini.ll
@@ -139,15 +139,15 @@ entry:
 ; RELOC-NEXT:  InitFunctions [
 ; RELOC-NEXT:0 (priority=101)
 ; RELOC-NEXT:1 (priority=101)
-; RELOC-NEXT:15 (priority=101)
-; RELOC-NEXT:11 (priority=101)
-; RELOC-NEXT:21 (priority=101)
-; RELOC-NEXT:11 (priority=202)
-; RELOC-NEXT:23 (priority=202)
+; RELOC-NEXT:14 (priority=101)
+; RELOC-NEXT:10 (priority=101)
+; RELOC-NEXT:20 (priority=101)
+; RELOC-NEXT:10 (priority=202)
+; RELOC-NEXT:22 (priority=202)
 ; RELOC-NEXT:0 (priority=1001)
-; RELOC-NEXT:17 (priority=1001)
-; RELOC-NEXT:11 (priority=2002)
-; RELOC-NEXT:25 (priority=2002)
+; RELOC-NEXT:16 (priority=1001)
+; RELOC-NEXT:10 (priority=2002)
+; RELOC-NEXT:24 (priority=2002)
 ; RELOC-NEXT:9 (priority=4000)
-; RELOC-NEXT:19 (priority=4000)
+; RELOC-NEXT:18 (priority=4000)
 ; RELOC-NEXT:  ]

diff  --git a/lld/test/wasm/local-symbols.ll b/lld/test/wasm/local-symbols.ll
index 216aced9cf07..13c200d648e9 100644
--- a/lld/test/wasm/local-symbols.ll
+++ b/lld/test/wasm/local-symbols.ll
@@ -35,6 +35,14 @@ entry:
 ; CHECK-NEXT: ReturnTypes: []
 ; CHECK-NEXT:   - Type:FUNCTION
 ; CHECK-NEXT: FunctionTypes:   [ 0, 1 ]
+; CHECK-NEXT:   - Type:TABLE
+; CHECK-NEXT: Tables:
+; CHECK-NEXT:   - Index:   0
+; CHECK-NEXT: ElemType:FUNCREF
+; CHECK-NEXT: Limits:
+; CHECK-NEXT:   Flags:   [ HAS_MAX ]
+; CHECK-NEXT:   Initial: 0x1
+; CHECK-NEXT:   Maximum: 0x1
 ; CHECK-NEXT:   - Type:MEMORY
 ; CHECK-NEXT: Memories:
 ; CHECK-NEXT:   - Initial: 0x2

diff  --git a/lld/test/wasm/locals-duplicate.test 
b/lld/test/wasm/locals-duplicate.test
index cf9a148d4ab7..07abb7485381 100644
--- a/lld/test/wasm/locals-duplicate.test
+++ b/lld/test/wasm/locals-duplicate.test
@@ -254,40 +254,40 @@
 ; RELOC-NEXT:   - Type:CODE
 ; RELOC-NEXT: Relocations:
 ; RELOC-NEXT:   - Type:R_WASM_MEMORY_ADDR_SLEB
-; RELOC-NEXT: Index:   19
+; RELOC-NEXT: Index:   18
 ; RELOC-NEXT: Offset:  0x13
 ; RELOC-NEXT:   - Type:R_WASM_MEMORY_ADDR_SLEB
 ; RELOC-NEXT: Index:   3
 ; RELOC-NEXT: Offset:  0x1C
 ; RELOC-NEXT:   - Type:R_WASM_MEMORY_ADDR_SLEB
-; RELOC-NEXT: Index:   20
+; RELOC-NEXT: Index:   19
 ; RELOC-NEXT: Offset:  0x25
 ; RELOC-NEXT:   - Type:R_WASM_TABLE_INDEX_SLEB
-; RELOC-NEXT: Index:   17
+; RELOC-NEXT: Index:   16
 ; RELOC-NEXT: Offset:  0x2E
 ; RELOC-NEXT:   - Type:R_WASM_TABLE_INDEX_SLEB
 ; 

[llvm-branch-commits] [llvm] e65b9b0 - Revert "[WebAssembly] MC layer writes table symbols to object files"

2021-01-15 Thread Derek Schuff via llvm-branch-commits

Author: Derek Schuff
Date: 2021-01-15T15:50:22-08:00
New Revision: e65b9b04cdeff17fbcdae8d2bb268da832e4a267

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

LOG: Revert "[WebAssembly] MC layer writes table symbols to object files"

This reverts commit e9f1ed2306b1b3aedcb1acef2b50e252a77a04b9.

Reverting because it depends on 38dfce706f

Added: 


Modified: 
llvm/lib/MC/WasmObjectWriter.cpp
llvm/test/MC/WebAssembly/debug-info.ll
llvm/test/MC/WebAssembly/debug-info64.ll
llvm/test/MC/WebAssembly/function-alias.ll
llvm/test/MC/WebAssembly/global-ctor-dtor.ll
llvm/test/MC/WebAssembly/reloc-pic.s
llvm/test/MC/WebAssembly/type-index.s
llvm/test/MC/WebAssembly/weak-alias.s

Removed: 




diff  --git a/llvm/lib/MC/WasmObjectWriter.cpp 
b/llvm/lib/MC/WasmObjectWriter.cpp
index b2d94dcadd81..fb41c3763c15 100644
--- a/llvm/lib/MC/WasmObjectWriter.cpp
+++ b/llvm/lib/MC/WasmObjectWriter.cpp
@@ -519,13 +519,6 @@ void WasmObjectWriter::recordRelocation(MCAssembler ,
   Sym->setUndefined();
 }
 Sym->setUsedInReloc();
-// Any time we have a TABLE_INDEX relocation against a function symbol, we
-// need to ensure that table itself is part of the final output too.  In 
the
-// future we may want to define a new kind of reloc against both the
-// function and the table, so that the linker can see that the function
-// symbol keeps the table alive, but for now manually mark the table as
-// live.
-Sym->setNoStrip();
 Asm.registerSymbol(*Sym);
   }
 
@@ -1677,6 +1670,10 @@ uint64_t WasmObjectWriter::writeOneObject(MCAssembler 
,
   WS.setIndex(InvalidIndex);
   continue;
 }
+if (WS.isTable() && WS.getName() == "__indirect_function_table") {
+  // For the moment, don't emit table symbols -- wasm-ld can't handle them.
+  continue;
+}
 LLVM_DEBUG(dbgs() << "adding to symtab: " << WS << "\n");
 
 uint32_t Flags = 0;

diff  --git a/llvm/test/MC/WebAssembly/debug-info.ll 
b/llvm/test/MC/WebAssembly/debug-info.ll
index 88d19d9191a9..167d912c84a2 100644
--- a/llvm/test/MC/WebAssembly/debug-info.ll
+++ b/llvm/test/MC/WebAssembly/debug-info.ll
@@ -89,44 +89,44 @@
 ; CHECK-NEXT:  }
 ; CHECK-NEXT:  Section {
 ; CHECK-NEXT:Type: CUSTOM (0x0)
-; CHECK-NEXT:Size: 95
+; CHECK-NEXT:Size: 91
 ; CHECK-NEXT:Offset: 731
 ; CHECK-NEXT:Name: linking
 ; CHECK-NEXT:  }
 ; CHECK-NEXT:  Section {
 ; CHECK-NEXT:Type: CUSTOM (0x0)
 ; CHECK-NEXT:Size: 9
-; CHECK-NEXT:Offset: 840
+; CHECK-NEXT:Offset: 836
 ; CHECK-NEXT:Name: reloc.DATA
 ; CHECK-NEXT:  }
 ; CHECK-NEXT:  Section {
 ; CHECK-NEXT:Type: CUSTOM (0x0)
 ; CHECK-NEXT:Size: 61
-; CHECK-NEXT:Offset: 866
+; CHECK-NEXT:Offset: 862
 ; CHECK-NEXT:Name: reloc..debug_info
 ; CHECK-NEXT:  }
 ; CHECK-NEXT:  Section {
 ; CHECK-NEXT:Type: CUSTOM (0x0)
 ; CHECK-NEXT:Size: 6
-; CHECK-NEXT:Offset: 951
+; CHECK-NEXT:Offset: 947
 ; CHECK-NEXT:Name: reloc..debug_pubnames
 ; CHECK-NEXT:  }
 ; CHECK-NEXT:  Section {
 ; CHECK-NEXT:Type: CUSTOM (0x0)
 ; CHECK-NEXT:Size: 6
-; CHECK-NEXT:Offset: 985
+; CHECK-NEXT:Offset: 981
 ; CHECK-NEXT:Name: reloc..debug_pubtypes
 ; CHECK-NEXT:  }
 ; CHECK-NEXT:  Section {
 ; CHECK-NEXT:Type: CUSTOM (0x0)
 ; CHECK-NEXT:Size: 6
-; CHECK-NEXT:Offset: 1019
+; CHECK-NEXT:Offset: 1015
 ; CHECK-NEXT:Name: reloc..debug_line
 ; CHECK-NEXT:  }
 ; CHECK-NEXT:  Section {
 ; CHECK-NEXT:Type: CUSTOM (0x0)
 ; CHECK-NEXT:Size: 77
-; CHECK-NEXT:Offset: 1049
+; CHECK-NEXT:Offset: 1045
 ; CHECK-NEXT:Name: producers
 ; CHECK-NEXT:  }
 ; CHECK-NEXT:]
@@ -238,16 +238,6 @@
 ; CHECK-NEXT:]
 ; CHECK-NEXT:ElementIndex: 0xC
 ; CHECK-NEXT:  }
-; CHECK-NEXT:  Symbol {
-; CHECK-NEXT:Name: __indirect_function_table
-; CHECK-NEXT:Type: TABLE (0x5)
-; CHECK-NEXT:Flags [ (0x90)
-; CHECK-NEXT:  NO_STRIP (0x80)
-; CHECK-NEXT:  UNDEFINED (0x10)
-; CHECK-NEXT:]
-; CHECK-NEXT:ImportModule: env
-; CHECK-NEXT:ElementIndex: 0x0
-; CHECK-NEXT:  }
 ; CHECK-NEXT:]
 
 ; generated from the following C code using: clang --target=wasm32 -g -O0 -S 
-emit-llvm test.c

diff  --git a/llvm/test/MC/WebAssembly/debug-info64.ll 
b/llvm/test/MC/WebAssembly/debug-info64.ll
index 1755f2b7ef5c..acba8aa27360 100644
--- a/llvm/test/MC/WebAssembly/debug-info64.ll
+++ b/llvm/test/MC/WebAssembly/debug-info64.ll
@@ -89,44 +89,44 @@
 ; CHECK-NEXT:   }
 ; CHECK-NEXT:   Section {
 ; CHECK-NEXT: Type: CUSTOM (0x0)
-; CHECK-NEXT: Size: 95
+; CHECK-NEXT: Size: 91
 ; CHECK-NEXT: Offset: 759
 ; CHECK-NEXT: Name: linking
 ; CHECK-NEXT:   }
 ; CHECK-NEXT:   Section {
 ; CHECK-NEXT: Type: CUSTOM (0x0)
 ; CHECK-NEXT: Size: 9

[llvm-branch-commits] [llvm] a150010 - [SimplifyCFG] Optimize CFG when null is passed to a function with nonnull argument

2021-01-15 Thread Dávid Bolvanský via llvm-branch-commits

Author: Dávid Bolvanský
Date: 2021-01-15T23:53:43+01:00
New Revision: a1500105ee6074f992f376c916dcfa3a54acb717

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

LOG: [SimplifyCFG] Optimize CFG when null is passed to a function with nonnull 
argument

Example:

```
__attribute__((nonnull,noinline)) char * pinc(char *p)  {
  return ++p;
}

char * foo(bool b, char *a) {
   return pinc(b ? 0 : a);

}
```

optimize to

```
char * foo(bool b, char *a) {
   return pinc(a);

}
```

Reviewed By: jdoerfert

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

Added: 


Modified: 
llvm/lib/Transforms/Utils/SimplifyCFG.cpp
llvm/test/Transforms/SimplifyCFG/UnreachableEliminate.ll

Removed: 




diff  --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp 
b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index 559830ed9a17..7fe33fd3c759 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -1345,7 +1345,7 @@ static bool isSafeToHoistInvoke(BasicBlock *BB1, 
BasicBlock *BB2,
   return true;
 }
 
-static bool passingValueIsAlwaysUndefined(Value *V, Instruction *I);
+static bool passingValueIsAlwaysUndefined(Value *V, Instruction *I, bool 
PtrValueMayBeModified = false);
 
 /// Given a conditional branch that goes to BB1 and BB2, hoist any common code
 /// in the two blocks up into the branch block. The caller of this function
@@ -6545,7 +6545,7 @@ bool SimplifyCFGOpt::simplifyCondBranch(BranchInst *BI, 
IRBuilder<> ) {
 }
 
 /// Check if passing a value to an instruction will cause undefined behavior.
-static bool passingValueIsAlwaysUndefined(Value *V, Instruction *I) {
+static bool passingValueIsAlwaysUndefined(Value *V, Instruction *I, bool 
PtrValueMayBeModified) {
   Constant *C = dyn_cast(V);
   if (!C)
 return false;
@@ -6568,12 +6568,15 @@ static bool passingValueIsAlwaysUndefined(Value *V, 
Instruction *I) {
 
 // Look through GEPs. A load from a GEP derived from NULL is still 
undefined
 if (GetElementPtrInst *GEP = dyn_cast(Use))
-  if (GEP->getPointerOperand() == I)
-return passingValueIsAlwaysUndefined(V, GEP);
+  if (GEP->getPointerOperand() == I) {
+if (!GEP->isInBounds() || !GEP->hasAllZeroIndices())
+  PtrValueMayBeModified = true;
+return passingValueIsAlwaysUndefined(V, GEP, PtrValueMayBeModified);
+  }
 
 // Look through bitcasts.
 if (BitCastInst *BC = dyn_cast(Use))
-  return passingValueIsAlwaysUndefined(V, BC);
+  return passingValueIsAlwaysUndefined(V, BC, PtrValueMayBeModified);
 
 // Load from null is undefined.
 if (LoadInst *LI = dyn_cast(Use))
@@ -6588,10 +6591,35 @@ static bool passingValueIsAlwaysUndefined(Value *V, 
Instruction *I) {
   SI->getPointerAddressSpace())) &&
SI->getPointerOperand() == I;
 
-// A call to null is undefined.
-if (auto *CB = dyn_cast(Use))
-  return !NullPointerIsDefined(CB->getFunction()) &&
- CB->getCalledOperand() == I;
+if (auto *CB = dyn_cast(Use)) {
+  if (C->isNullValue() && NullPointerIsDefined(CB->getFunction()))
+return false;
+  // A call to null is undefined.
+  if (CB->getCalledOperand() == I)
+return true;
+
+  if (C->isNullValue()) {
+for (const llvm::Use  : CB->args())
+  if (Arg == I) {
+unsigned ArgIdx = CB->getArgOperandNo();
+if (CB->paramHasAttr(ArgIdx, Attribute::NonNull) &&
+CB->paramHasAttr(ArgIdx, Attribute::NoUndef)) {
+  // Passing null to a nonnnull+noundef argument is undefined.
+  return !PtrValueMayBeModified;
+}
+  }
+  } else if (isa(C)) {
+// Passing undef to a noundef argument is undefined.
+for (const llvm::Use  : CB->args())
+  if (Arg == I) {
+unsigned ArgIdx = CB->getArgOperandNo();
+if (CB->paramHasAttr(ArgIdx, Attribute::NoUndef)) {
+  // Passing undef to a noundef argument is undefined.
+  return true;
+}
+  }
+  }
+}
   }
   return false;
 }

diff  --git a/llvm/test/Transforms/SimplifyCFG/UnreachableEliminate.ll 
b/llvm/test/Transforms/SimplifyCFG/UnreachableEliminate.ll
index b3b7abe9ff0d..4c984819cfcf 100644
--- a/llvm/test/Transforms/SimplifyCFG/UnreachableEliminate.ll
+++ b/llvm/test/Transforms/SimplifyCFG/UnreachableEliminate.ll
@@ -69,7 +69,6 @@ define void @test5(i1 %cond, i8* %ptr) {
 ; CHECK-NEXT:store i8 2, i8* [[PTR:%.*]], align 8
 ; CHECK-NEXT:ret void
 ;
-
 entry:
   br i1 %cond, label %bb1, label %bb3
 
@@ -88,11 +87,10 @@ bb2:
 define void @test5_no_null_opt(i1 %cond, i8* %ptr) #0 {
 ; CHECK-LABEL: @test5_no_null_opt(
 ; 

[llvm-branch-commits] [llvm] 76f5c5a - [ADT][Support] Fix C4146 error from MSVC

2021-01-15 Thread David Blaikie via llvm-branch-commits

Author: Vladislav Vinogradov
Date: 2021-01-15T14:34:14-08:00
New Revision: 76f5c5a7b059929f0e0352ad4ff5ec1b78511868

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

LOG: [ADT][Support] Fix C4146 error from MSVC

Unary minus operator applied to unsigned type, result still unsigned.

Use `~0U` instead of `-1U` and `1 + ~VAL` instead of `-VAL`.

Reviewed By: dblaikie

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

Added: 


Modified: 
llvm/include/llvm/ADT/StringExtras.h
llvm/include/llvm/Support/MathExtras.h

Removed: 




diff  --git a/llvm/include/llvm/ADT/StringExtras.h 
b/llvm/include/llvm/ADT/StringExtras.h
index caa1ed547bb2..fe5c5967a2cf 100644
--- a/llvm/include/llvm/ADT/StringExtras.h
+++ b/llvm/include/llvm/ADT/StringExtras.h
@@ -71,7 +71,7 @@ inline unsigned hexDigitValue(char C) {
 constexpr HexTable() {
   // Default initialize everything to invalid.
   for (int i = 0; i < 255; ++i)
-LUT[i] = -1U;
+LUT[i] = ~0U;
   // Initialize `0`-`9`.
   for (int i = 0; i < 10; ++i)
 LUT['0' + i] = i;
@@ -88,7 +88,7 @@ inline unsigned hexDigitValue(char C) {
 inline bool isDigit(char C) { return C >= '0' && C <= '9'; }
 
 /// Checks if character \p C is a hexadecimal numeric character.
-inline bool isHexDigit(char C) { return hexDigitValue(C) != -1U; }
+inline bool isHexDigit(char C) { return hexDigitValue(C) != ~0U; }
 
 /// Checks if character \p C is a valid letter as classified by "C" locale.
 inline bool isAlpha(char C) {
@@ -184,7 +184,7 @@ inline std::string toHex(ArrayRef Input, bool 
LowerCase = false) {
 inline bool tryGetHexFromNibbles(char MSB, char LSB, uint8_t ) {
   unsigned U1 = hexDigitValue(MSB);
   unsigned U2 = hexDigitValue(LSB);
-  if (U1 == -1U || U2 == -1U)
+  if (U1 == ~0U || U2 == ~0U)
 return false;
 
   Hex = static_cast((U1 << 4) | U2);
@@ -291,7 +291,7 @@ inline std::string utostr(uint64_t X, bool isNeg = false) {
 
 inline std::string itostr(int64_t X) {
   if (X < 0)
-return utostr(-static_cast(X), true);
+return utostr(static_cast(1) + ~static_cast(X), true);
   else
 return utostr(static_cast(X));
 }

diff  --git a/llvm/include/llvm/Support/MathExtras.h 
b/llvm/include/llvm/Support/MathExtras.h
index 16da3046c8ce..33b9065261e8 100644
--- a/llvm/include/llvm/Support/MathExtras.h
+++ b/llvm/include/llvm/Support/MathExtras.h
@@ -440,7 +440,7 @@ inline uint64_t maxUIntN(uint64_t N) {
 inline int64_t minIntN(int64_t N) {
   assert(N > 0 && N <= 64 && "integer width out of range");
 
-  return -(UINT64_C(1)<<(N-1));
+  return UINT64_C(1) + ~(UINT64_C(1) << (N - 1));
 }
 
 /// Gets the maximum value for a N-bit signed integer.



___
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] aa8a2d8 - [AArch64][GlobalISel] Select immediate fcmp if the zero is on the LHS.

2021-01-15 Thread Amara Emerson via llvm-branch-commits

Author: Amara Emerson
Date: 2021-01-15T14:31:39-08:00
New Revision: aa8a2d8a3da3704f82ba4ea3a6e7b463737597e1

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

LOG: [AArch64][GlobalISel] Select immediate fcmp if the zero is on the LHS.

Added: 


Modified: 
llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
llvm/test/CodeGen/AArch64/GlobalISel/select-fcmp.mir

Removed: 




diff  --git a/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp 
b/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
index 797f33ce2ab4..b24fad35e32b 100644
--- a/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
+++ b/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
@@ -4224,6 +4224,14 @@ AArch64InstructionSelector::emitFPCompare(Register LHS, 
Register RHS,
   // to explicitly materialize a constant.
   const ConstantFP *FPImm = getConstantFPVRegVal(RHS, MRI);
   bool ShouldUseImm = FPImm && (FPImm->isZero() && !FPImm->isNegative());
+  if (!ShouldUseImm) {
+// Try commutating the operands.
+const ConstantFP *LHSImm = getConstantFPVRegVal(LHS, MRI);
+if (LHSImm && (LHSImm->isZero() && !LHSImm->isNegative())) {
+  ShouldUseImm = true;
+  std::swap(LHS, RHS);
+}
+  }
   unsigned CmpOpcTbl[2][2] = {{AArch64::FCMPSrr, AArch64::FCMPDrr},
   {AArch64::FCMPSri, AArch64::FCMPDri}};
   unsigned CmpOpc = CmpOpcTbl[ShouldUseImm][OpSize == 64];

diff  --git a/llvm/test/CodeGen/AArch64/GlobalISel/select-fcmp.mir 
b/llvm/test/CodeGen/AArch64/GlobalISel/select-fcmp.mir
index 45799079f920..c12cd3343c7e 100644
--- a/llvm/test/CodeGen/AArch64/GlobalISel/select-fcmp.mir
+++ b/llvm/test/CodeGen/AArch64/GlobalISel/select-fcmp.mir
@@ -107,3 +107,30 @@ body: |
 %3:gpr(s32) = G_FCMP floatpred(oeq), %0(s64), %2
 $s0 = COPY %3(s32)
 RET_ReallyLR implicit $s0
+...
+
+---
+name:zero_lhs
+alignment:   4
+legalized:   true
+regBankSelected: true
+tracksRegLiveness: true
+body: |
+  bb.1:
+liveins: $s0, $s1
+
+; CHECK-LABEL: name: zero_lhs
+; CHECK: liveins: $s0, $s1
+; CHECK: [[COPY:%[0-9]+]]:fpr32 = COPY $s0
+; CHECK: FCMPSri [[COPY]], implicit-def $nzcv
+; CHECK: [[CSINCWr:%[0-9]+]]:gpr32 = CSINCWr $wzr, $wzr, 1, implicit $nzcv
+; CHECK: $s0 = COPY [[CSINCWr]]
+; CHECK: RET_ReallyLR implicit $s0
+%0:fpr(s32) = COPY $s0
+%1:fpr(s32) = COPY $s1
+%2:fpr(s32) = G_FCONSTANT float 0.00e+00
+%3:gpr(s32) = G_FCMP floatpred(oeq), %2(s32), %0
+$s0 = COPY %3(s32)
+RET_ReallyLR implicit $s0
+
+...



___
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] ceaf011 - Revert "Revert "ADT: Fix reference invalidation in SmallVector...""

2021-01-15 Thread Duncan P. N. Exon Smith via llvm-branch-commits

Author: Duncan P. N. Exon Smith
Date: 2021-01-15T14:27:48-08:00
New Revision: ceaf0110ff5e0c2de1f03d65d13703d34d0d5737

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

LOG: Revert "Revert "ADT: Fix reference invalidation in SmallVector...""

This reverts commit 33be50daa9ce1074c3b423a4ab27c70c0722113a,
effectively reapplying:

- 260a856c2abcef49c7cb3bdcd999701db3e2af38
- 3043e5a5c33c4c871f4a1dfd621a8839f9a1f0b3
- 49142991a685bd427d7e877c29c77371dfb7634c

... with a fix to skip a call to `SmallVector::isReferenceToStorage()`
when we know the parameter had been taken by value for small, POD-like
`T`. See https://reviews.llvm.org/D93779 for the discussion on the
revert.

At a high-level, these commits fix reference invalidation in
SmallVector's push_back, append, insert (one or N), and resize
operations. For more details, please see the original commit messages.

This commit fixes a bug that crept into
`SmallVectorTemplateCommon::reserveForAndGetAddress()` during the review
process after performance analysis was done. That function is now called
`reserveForParamAndGetAddress()`, clarifying that it only works for
parameter values. It uses that knowledge to bypass
`SmallVector::isReferenceToStorage()` when `TakesParamByValue`. This is
`constexpr` and avoids adding overhead for "small enough", trivially
copyable `T`.

Performance could potentially be tuned further by increasing the
threshold for `TakesParamByValue`, which is currently defined as:
```
bool TakesParamByValue = sizeof(T) <= 2 * sizeof(void *);
```
in the POD-like version of SmallVectorTemplateBase (else, `false`).

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

Added: 


Modified: 
llvm/include/llvm/ADT/SmallVector.h
llvm/unittests/ADT/SmallVectorTest.cpp

Removed: 




diff  --git a/llvm/include/llvm/ADT/SmallVector.h 
b/llvm/include/llvm/ADT/SmallVector.h
index 78d0848b1fcc..2e47846ee7cf 100644
--- a/llvm/include/llvm/ADT/SmallVector.h
+++ b/llvm/include/llvm/ADT/SmallVector.h
@@ -220,6 +220,27 @@ class SmallVectorTemplateCommon
   }
   void assertSafeToEmplace() {}
 
+  /// Reserve enough space to add one element, and return the updated element
+  /// pointer in case it was a reference to the storage.
+  template 
+  static const T *reserveForParamAndGetAddressImpl(U *This, const T ,
+   size_t N) {
+size_t NewSize = This->size() + N;
+if (LLVM_LIKELY(NewSize <= This->capacity()))
+  return 
+
+bool ReferencesStorage = false;
+int64_t Index = -1;
+if (!U::TakesParamByValue) {
+  if (LLVM_UNLIKELY(This->isReferenceToStorage())) {
+ReferencesStorage = true;
+Index =  - This->begin();
+  }
+}
+This->grow(NewSize);
+return ReferencesStorage ? This->begin() + Index : 
+  }
+
 public:
   using size_type = size_t;
   using 
diff erence_type = ptr
diff _t;
@@ -303,7 +324,12 @@ template ::value) &&
  (is_trivially_move_constructible::value) &&
  std::is_trivially_destructible::value>
 class SmallVectorTemplateBase : public SmallVectorTemplateCommon {
+  friend class SmallVectorTemplateCommon;
+
 protected:
+  static constexpr bool TakesParamByValue = false;
+  using ValueParamT = const T &;
+
   SmallVectorTemplateBase(size_t Size) : SmallVectorTemplateCommon(Size) {}
 
   static void destroy_range(T *S, T *E) {
@@ -333,20 +359,32 @@ class SmallVectorTemplateBase : public 
SmallVectorTemplateCommon {
   /// element, or MinSize more elements if specified.
   void grow(size_t MinSize = 0);
 
+  /// Reserve enough space to add one element, and return the updated element
+  /// pointer in case it was a reference to the storage.
+  const T *reserveForParamAndGetAddress(const T , size_t N = 1) {
+return this->reserveForParamAndGetAddressImpl(this, Elt, N);
+  }
+
+  /// Reserve enough space to add one element, and return the updated element
+  /// pointer in case it was a reference to the storage.
+  T *reserveForParamAndGetAddress(T , size_t N = 1) {
+return const_cast(
+this->reserveForParamAndGetAddressImpl(this, Elt, N));
+  }
+
+  static T &_value_param(T &) { return std::move(V); }
+  static const T _value_param(const T ) { return V; }
+
 public:
   void push_back(const T ) {
-this->assertSafeToAdd();
-if (LLVM_UNLIKELY(this->size() >= this->capacity()))
-  this->grow();
-::new ((void*) this->end()) T(Elt);
+const T *EltPtr = reserveForParamAndGetAddress(Elt);
+::new ((void *)this->end()) T(*EltPtr);
 this->set_size(this->size() + 1);
   }
 
   void push_back(T &) {
-this->assertSafeToAdd();
-if (LLVM_UNLIKELY(this->size() >= this->capacity()))
-  this->grow();
-::new ((void*) this->end()) 

[llvm-branch-commits] [llvm] ceb3cdc - [SLP] remove dead code in reduction matching; NFC

2021-01-15 Thread Sanjay Patel via llvm-branch-commits

Author: Sanjay Patel
Date: 2021-01-15T17:03:26-05:00
New Revision: ceb3cdccd0fb597659147e0f538fdee91414541e

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

LOG: [SLP] remove dead code in reduction matching; NFC

To get into this block we had: !A || B || C
and we checked C in the first 'if' clause
leaving !A || B. But the 2nd 'if' is checking:
A && !B --> !(!A || B)

Added: 


Modified: 
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Removed: 




diff  --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp 
b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index e1befc449492..cf7c05e30d06 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -6877,12 +6877,6 @@ class HorizontalReduction {
 markExtraArg(Stack.back(), I);
 continue;
   }
-} else if (RdxLeafVal && RdxLeafVal != EdgeOpData) {
-  // Make sure that the opcodes of the operations that we are going to
-  // reduce match.
-  // I is an extra argument for TreeN (its parent operation).
-  markExtraArg(Stack.back(), I);
-  continue;
 } else if (!RdxLeafVal) {
   RdxLeafVal = EdgeOpData;
 }



___
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] [lldb] 10ac9b2 - Skip 'g' packet tests when running on darwin; debugserver doesn't impl

2021-01-15 Thread Jason Molenda via llvm-branch-commits

Author: Jason Molenda
Date: 2021-01-15T13:57:59-08:00
New Revision: 10ac9b29a4ca9e75bcbfa9576e3d8ee83cc9cd78

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

LOG: Skip 'g' packet tests when running on darwin; debugserver doesn't impl

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

Added: 


Modified: 
lldb/test/API/tools/lldb-server/register-reading/TestGdbRemoteGPacket.py

Removed: 




diff  --git 
a/lldb/test/API/tools/lldb-server/register-reading/TestGdbRemoteGPacket.py 
b/lldb/test/API/tools/lldb-server/register-reading/TestGdbRemoteGPacket.py
index 63f2e977a805..2e02a2ccacf7 100644
--- a/lldb/test/API/tools/lldb-server/register-reading/TestGdbRemoteGPacket.py
+++ b/lldb/test/API/tools/lldb-server/register-reading/TestGdbRemoteGPacket.py
@@ -130,6 +130,7 @@ def g_returns_correct_data(self, with_suffix):
 
 @expectedFailureAll(oslist=["freebsd"], bugnumber="llvm.org/pr48420")
 @expectedFailureNetBSD
+@skipIfDarwin # g packet not supported
 def test_g_returns_correct_data_with_suffix(self):
 self.build()
 self.set_inferior_startup_launch()
@@ -137,6 +138,7 @@ def test_g_returns_correct_data_with_suffix(self):
 
 @expectedFailureAll(oslist=["freebsd"], bugnumber="llvm.org/pr48420")
 @expectedFailureNetBSD
+@skipIfDarwin # g packet not supported
 def test_g_returns_correct_data_no_suffix(self):
 self.build()
 self.set_inferior_startup_launch()



___
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] [mlir] d7bc3b7 - [mlir][Linalg] Add missing check to canonicalization of GenericOp that are identity ops.

2021-01-15 Thread via llvm-branch-commits

Author: MaheshRavishankar
Date: 2021-01-15T13:55:35-08:00
New Revision: d7bc3b7ce23b664d6620cdc32370a8614523ca2f

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

LOG: [mlir][Linalg] Add missing check to canonicalization of GenericOp that are 
identity ops.

The operantion is an identity if the values yielded by the operation
is the argument of the basic block of that operation. Add this missing check.

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

Added: 


Modified: 
mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
mlir/test/Dialect/Linalg/canonicalize.mlir

Removed: 




diff  --git a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp 
b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
index 30a6b9c0c371..fa98ed0cfbc9 100644
--- a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
+++ b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
@@ -2276,13 +2276,15 @@ struct RemoveIdentityLinalgOps : public RewritePattern {
 SmallVector returnedArgs;
 for (Value yieldVal : yieldOp.values()) {
   auto yieldArg = yieldVal.dyn_cast();
-  if (!yieldArg)
+  if (!yieldArg || yieldArg.getOwner() != )
 return failure();
   unsigned argumentNumber = yieldArg.getArgNumber();
   if (argumentNumber < numIndexArgs)
 return failure();
   returnedArgs.push_back(op->getOperand(argumentNumber - numIndexArgs));
 }
+if (returnedArgs.size() != genericOp.getOperation()->getNumResults())
+  return failure();
 rewriter.replaceOp(genericOp, returnedArgs);
 return success();
   }

diff  --git a/mlir/test/Dialect/Linalg/canonicalize.mlir 
b/mlir/test/Dialect/Linalg/canonicalize.mlir
index ca7f82c1b254..cc00b98d376c 100644
--- a/mlir/test/Dialect/Linalg/canonicalize.mlir
+++ b/mlir/test/Dialect/Linalg/canonicalize.mlir
@@ -615,3 +615,56 @@ func @remove_no_op(%arg0 : tensor, %arg1 : 
tensor)
 //  CHECK-SAME:   %[[ARG0:[a-zA-Z0-9_]+]]: tensor
 //  CHECK-SAME:   %[[ARG1:[a-zA-Z0-9_]+]]: tensor
 //   CHECK: return %[[ARG1]], %[[ARG0]]
+
+// -
+
+#map = affine_map<(d0, d1) -> (d0, d1)>
+func @keep_not_noop(%arg0 : tensor) -> tensor {
+  %c0 = constant 0 : index
+  %c1 = constant 1 : index
+  %cst = constant 1.00e+00 : f32
+  %0 = dim %arg0, %c0 : tensor
+  %1 = dim %arg0, %c1 : tensor
+  %2 = linalg.init_tensor [%0, %1] : tensor
+  br ^bb1(%cst : f32)
+
+^bb1(%arg1 : f32):
+  %3 = linalg.generic
+{indexing_maps = [#map, #map], iterator_types = ["parallel", "parallel"]}
+ins(%arg0 : tensor) outs(%2 : tensor) {
+^bb0(%arg2: f32, %arg3 : f32):
+  linalg.yield %arg1 : f32
+} -> tensor
+  return %3 : tensor
+}
+// CHECK-LABEL: func @keep_not_noop
+//   CHECK:   %[[RESULT:.+]] = linalg.generic
+//   CHECK:   return %[[RESULT]]
+
+// -
+
+#map = affine_map<(d0, d1) -> (d0, d1)>
+func @keep_not_noop(%arg0 : tensor, %arg1 : tensor)
+  -> (tensor, tensor) {
+  %c0 = constant 0 : index
+  %c1 = constant 1 : index
+  %cst = constant 1.00e+00 : f32
+  %0 = dim %arg0, %c0 : tensor
+  %1 = dim %arg0, %c1 : tensor
+  %2 = linalg.init_tensor [%0, %1] : tensor
+  br ^bb1(%cst : f32)
+
+^bb1(%arg2 : f32):
+  %3:2 = linalg.generic
+{indexing_maps = [#map, #map, #map, #map],
+ iterator_types = ["parallel", "parallel"]}
+ins(%arg0, %arg1 : tensor, tensor)
+outs(%2, %2 : tensor, tensor) {
+^bb0(%arg3: f32, %arg4 : f32, %arg5 : f32, %arg6 : f32):
+  linalg.yield %arg2, %arg4 : f32, f32
+} -> tensor, tensor
+  return %3#0, %3#1 : tensor, tensor
+}
+// CHECK-LABEL: func @keep_not_noop
+//   CHECK:   %[[RESULT:.+]]:2 = linalg.generic
+//   CHECK:   return %[[RESULT]]#0, %[[RESULT]]#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] ed0fd56 - BreakCriticalEdges: do not split the critical edge from a CallBr indirect successor

2021-01-15 Thread Nick Desaulniers via llvm-branch-commits

Author: Nick Desaulniers
Date: 2021-01-15T13:51:47-08:00
New Revision: ed0fd567ebdc61eb87346a58196a73f9b814

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

LOG: BreakCriticalEdges: do not split the critical edge from a CallBr indirect 
successor

Otherwise we'll fail the assertion in SplitBlockPredecessors() related
to splitting the edges from CallBr's.

Fixes: https://github.com/ClangBuiltLinux/linux/issues/1161
Fixes: https://github.com/ClangBuiltLinux/linux/issues/1252

Reviewed By: void, MaskRay, jyknight

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

Added: 
llvm/test/Transforms/LoopStrengthReduce/callbr-critical-edge-splitting.ll
llvm/test/Transforms/LoopStrengthReduce/callbr-critical-edge-splitting2.ll

Modified: 
llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp

Removed: 




diff  --git a/llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp 
b/llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp
index c9f08e5a9ed5..939a1a3a868d 100644
--- a/llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp
+++ b/llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp
@@ -158,22 +158,21 @@ BasicBlock *llvm::SplitCriticalEdge(Instruction *TI, 
unsigned SuccNum,
   SmallVector LoopPreds;
   // Check if extra modifications will be required to preserve loop-simplify
   // form after splitting. If it would require splitting blocks with IndirectBr
-  // terminators, bail out if preserving loop-simplify form is requested.
+  // or CallBr terminators, bail out if preserving loop-simplify form is
+  // requested.
   if (LI) {
 if (Loop *TIL = LI->getLoopFor(TIBB)) {
 
-  // The only that we can break LoopSimplify form by splitting a critical
-  // edge is if after the split there exists some edge from TIL to DestBB
-  // *and* the only edge into DestBB from outside of TIL is that of
+  // The only way that we can break LoopSimplify form by splitting a
+  // critical edge is if after the split there exists some edge from TIL to
+  // DestBB *and* the only edge into DestBB from outside of TIL is that of
   // NewBB. If the first isn't true, then LoopSimplify still holds, NewBB
   // is the new exit block and it has no non-loop predecessors. If the
   // second isn't true, then DestBB was not in LoopSimplify form prior to
   // the split as it had a non-loop predecessor. In both of these cases,
   // the predecessor must be directly in TIL, not in a subloop, or again
   // LoopSimplify doesn't hold.
-  for (pred_iterator I = pred_begin(DestBB), E = pred_end(DestBB); I != E;
-   ++I) {
-BasicBlock *P = *I;
+  for (BasicBlock *P : predecessors(DestBB)) {
 if (P == TIBB)
   continue; // The new block is known.
 if (LI->getLoopFor(P) != TIL) {
@@ -186,7 +185,10 @@ BasicBlock *llvm::SplitCriticalEdge(Instruction *TI, 
unsigned SuccNum,
   // Loop-simplify form can be preserved, if we can split all in-loop
   // predecessors.
   if (any_of(LoopPreds, [](BasicBlock *Pred) {
-return isa(Pred->getTerminator());
+const Instruction *T = Pred->getTerminator();
+if (const auto *CBR = dyn_cast(T))
+  return CBR->getDefaultDest() != Pred;
+return isa(T);
   })) {
 if (Options.PreserveLoopSimplify)
   return nullptr;

diff  --git 
a/llvm/test/Transforms/LoopStrengthReduce/callbr-critical-edge-splitting.ll 
b/llvm/test/Transforms/LoopStrengthReduce/callbr-critical-edge-splitting.ll
new file mode 100644
index ..8c62e9cf5caa
--- /dev/null
+++ b/llvm/test/Transforms/LoopStrengthReduce/callbr-critical-edge-splitting.ll
@@ -0,0 +1,39 @@
+; RUN: opt -loop-reduce %s -o - -S | FileCheck %s
+; RUN: opt -passes='loop(loop-reduce)' %s -o - -S | FileCheck %s
+
+target datalayout = 
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+
+define dso_local i32 @test1() local_unnamed_addr {
+entry:
+  br label %for.cond
+
+for.cond: ; preds = %for.inc, %entry
+; It's ok to modify this test in the future should be able to split critical
+; edges here, just noting that this is the critical edge that we care about.
+; CHECK: callbr void asm sideeffect "", "X,X,~{dirflag},~{fpsr},~{flags}"(i8* 
blockaddress(@test1, %cond.true.i), i8* blockaddress(@test1, %for.end))
+; CHECK-NEXT: to label %asm.fallthrough.i.i [label %cond.true.i, label 
%for.end]
+  callbr void asm sideeffect "", "X,X,~{dirflag},~{fpsr},~{flags}"(i8* 
blockaddress(@test1, %cond.true.i), i8* blockaddress(@test1, %for.end))
+  to label %asm.fallthrough.i.i [label %cond.true.i, label %for.end]
+
+asm.fallthrough.i.i:  ; preds = %for.cond
+  unreachable
+
+cond.true.i: 

[llvm-branch-commits] [clang] 4a47da2 - [Sema] turns -Wfree-nonheap-object on by default

2021-01-15 Thread Christopher Di Bella via llvm-branch-commits

Author: Christopher Di Bella
Date: 2021-01-15T21:38:47Z
New Revision: 4a47da2cf440c2f2006d9b04acfef4292de1e263

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

LOG: [Sema] turns -Wfree-nonheap-object on by default

We'd discussed adding the warning to -Wall in D89988. This patch honours that.

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/test/Analysis/NewDelete-intersections.mm
clang/test/Analysis/free.c

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index d500ab321058..04ba89aa457e 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -110,6 +110,7 @@ def FloatConversion :
  FloatZeroConversion]>;
 
 def FrameAddress : DiagGroup<"frame-address">;
+def FreeNonHeapObject : DiagGroup<"free-nonheap-object">;
 def DoublePromotion : DiagGroup<"double-promotion">;
 def EnumTooLarge : DiagGroup<"enum-too-large">;
 def UnsupportedNan : DiagGroup<"unsupported-nan">;

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 7d36397a7993..e93657898f58 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -7609,7 +7609,7 @@ def err_no_typeid_with_fno_rtti : Error<
 def err_no_dynamic_cast_with_fno_rtti : Error<
   "use of dynamic_cast requires -frtti">;
 def warn_no_dynamic_cast_with_rtti_disabled: Warning<
-  "dynamic_cast will not work since RTTI data is disabled by " 
+  "dynamic_cast will not work since RTTI data is disabled by "
   "%select{-fno-rtti-data|/GR-}0">, InGroup;
 def warn_no_typeid_with_rtti_disabled: Warning<
   "typeid will not work since RTTI data is disabled by "
@@ -7625,8 +7625,7 @@ def warn_condition_is_assignment : Warning<"using the 
result of an "
   InGroup;
 def warn_free_nonheap_object
   : Warning<"attempt to call %0 on non-heap object %1">,
-InGroup>,
-DefaultIgnore; // FIXME: add to -Wall after sufficient testing
+InGroup;
 
 // Completely identical except off by default.
 def warn_condition_is_idiomatic_assignment : Warning<"using the result "

diff  --git a/clang/test/Analysis/NewDelete-intersections.mm 
b/clang/test/Analysis/NewDelete-intersections.mm
index f01d62f8d365..6f81034ee349 100644
--- a/clang/test/Analysis/NewDelete-intersections.mm
+++ b/clang/test/Analysis/NewDelete-intersections.mm
@@ -24,9 +24,6 @@
 extern "C" void free(void *);
 
 void testMallocFreeNoWarn() {
-  int i;
-  free(); // no warn
-
   int *p1 = (int *)malloc(sizeof(int));
   free(++p1); // no warn
 
@@ -51,7 +48,7 @@ void testDeleteMalloced() {
 
   int *p2 = (int *)__builtin_alloca(sizeof(int));
   delete p2; // no warn
-} 
+}
 
 void testUseZeroAllocatedMalloced() {
   int *p1 = (int *)malloc(0);
@@ -79,13 +76,13 @@ void testObjcFreeNewed() {
 }
 
 void testFreeAfterDelete() {
-  int *p = new int;  
+  int *p = new int;
   delete p;
   free(p); // newdelete-warning{{Use of memory after it is freed}}
 }
 
 void testStandardPlacementNewAfterDelete() {
-  int *p = new int;  
+  int *p = new int;
   delete p;
   p = new (p) int; // newdelete-warning{{Use of memory after it is freed}}
 }

diff  --git a/clang/test/Analysis/free.c b/clang/test/Analysis/free.c
index 0d29bacf274c..b50145713924 100644
--- a/clang/test/Analysis/free.c
+++ b/clang/test/Analysis/free.c
@@ -12,17 +12,23 @@ void *alloca(size_t);
 
 void t1 () {
   int a[] = { 1 };
-  free(a); // expected-warning {{Argument to free() is the address of the 
local variable 'a', which is not memory allocated by malloc()}}
+  free(a);
+  // expected-warning@-1{{Argument to free() is the address of the local 
variable 'a', which is not memory allocated by malloc()}}
+  // expected-warning@-2{{attempt to call free on non-heap object 'a'}}
 }
 
 void t2 () {
   int a = 1;
-  free(); // expected-warning {{Argument to free() is the address of the 
local variable 'a', which is not memory allocated by malloc()}}
+  free();
+  // expected-warning@-1{{Argument to free() is the address of the local 
variable 'a', which is not memory allocated by malloc()}}
+  // expected-warning@-2{{attempt to call free on non-heap object 'a'}}
 }
 
 void t3 () {
   static int a[] = { 1 };
-  free(a); // expected-warning {{Argument to free() is the address of the 
static variable 'a', which is not memory allocated by malloc()}}
+  free(a);
+  // expected-warning@-1{{Argument to free() is the address of the static 
variable 'a', which is not memory allocated by malloc()}}
+  // expected-warning@-2{{attempt to call free on non-heap object 'a'}}
 }
 
 void t4 

[llvm-branch-commits] [compiler-rt] 6a42cbf - [GWP-ASan] Add inbuilt options parser.

2021-01-15 Thread Mitch Phillips via llvm-branch-commits

Author: Mitch Phillips
Date: 2021-01-15T12:57:05-08:00
New Revision: 6a42cbf6d2116b52cb59aa3e23bef93a30cf2dc8

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

LOG: [GWP-ASan] Add inbuilt options parser.

Adds a modified options parser (shamefully pulled from Scudo, which
shamefully pulled it from sanitizer-common) to GWP-ASan. This allows
customers (Android) to parse options strings in a common way.

Depends on D94117.

AOSP side of these patches is staged at:

 - sepolicy (sysprops should only be settable by the shell, in both root and
 unrooted conditions):
 https://android-review.googlesource.com/c/platform/system/sepolicy/+/1517238

 - zygote updates:
 https://android-review.googlesource.com/c/platform/frameworks/base/+/1515009

 - bionic changes to add `gwp_asan.` system property, and
 GWP_ASAN_OPTIONS environment variable:
 https://android-review.googlesource.com/c/platform/bionic/+/1514989

Reviewed By: eugenis

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

Added: 
compiler-rt/lib/gwp_asan/tests/options.cpp
compiler-rt/tools/gwp_asan/options_parser_fuzzer.cpp

Modified: 
compiler-rt/lib/gwp_asan/CMakeLists.txt
compiler-rt/lib/gwp_asan/optional/options_parser.cpp
compiler-rt/lib/gwp_asan/optional/options_parser.h
compiler-rt/lib/gwp_asan/options.inc
compiler-rt/lib/gwp_asan/tests/CMakeLists.txt
compiler-rt/lib/scudo/scudo_allocator.cpp
compiler-rt/lib/scudo/standalone/CMakeLists.txt
compiler-rt/lib/scudo/standalone/combined.h
compiler-rt/lib/scudo/standalone/flags.cpp
compiler-rt/lib/scudo/standalone/tests/CMakeLists.txt
compiler-rt/lib/scudo/standalone/tests/flags_test.cpp
compiler-rt/test/scudo/standalone/unit/lit.site.cfg.py.in
compiler-rt/tools/gwp_asan/CMakeLists.txt

Removed: 




diff  --git a/compiler-rt/lib/gwp_asan/CMakeLists.txt 
b/compiler-rt/lib/gwp_asan/CMakeLists.txt
index 92f578585b54..599fa9904e47 100644
--- a/compiler-rt/lib/gwp_asan/CMakeLists.txt
+++ b/compiler-rt/lib/gwp_asan/CMakeLists.txt
@@ -41,11 +41,10 @@ append_list_if(COMPILER_RT_HAS_FPIC_FLAG -fPIC 
GWP_ASAN_CFLAGS)
 # Remove -stdlib= which is unused when passing -nostdinc++.
 string(REGEX REPLACE "-stdlib=[a-zA-Z+]*" "" CMAKE_CXX_FLAGS 
${CMAKE_CXX_FLAGS})
 
-# Options parsing support is optional. GwpAsan is totally independent of
-# sanitizer_common, the options parser is not. This is an optional library
-# that can be used by an allocator to automatically parse GwpAsan options from
-# the environment variable GWP_ASAN_FLAGS, but the allocator can choose to
-# implement its own options parsing and populate the Options struct itself.
+# Options parsing support is optional. This is an optional library that can be
+# used by an allocator to automatically parse GwpAsan options from the
+# environment variable GWP_ASAN_FLAGS, but the allocator can choose to 
implement
+# its own options parsing and populate the Options struct itself.
 set(GWP_ASAN_OPTIONS_PARSER_SOURCES
   optional/options_parser.cpp
 )
@@ -64,11 +63,7 @@ set(GWP_ASAN_SEGV_HANDLER_HEADERS
   options.h)
 
 set(GWP_ASAN_OPTIONS_PARSER_CFLAGS
-${GWP_ASAN_CFLAGS}
-${SANITIZER_COMMON_CFLAGS})
-set(GWP_ASAN_OPTIONS_PARSER_OBJECT_LIBS
-RTSanitizerCommon
-RTSanitizerCommonNoLibc)
+${GWP_ASAN_CFLAGS})
 
 if (COMPILER_RT_HAS_GWP_ASAN)
   foreach(arch ${GWP_ASAN_SUPPORTED_ARCH})
@@ -89,11 +84,6 @@ if (COMPILER_RT_HAS_GWP_ASAN)
   ADDITIONAL_HEADERS ${GWP_ASAN_HEADERS}
   CFLAGS ${GWP_ASAN_CFLAGS})
 
-  # Note: If you choose to add this as an object library, ensure you also
-  # include the sanitizer_common flag parsing object lib (generally
-  # 'RTSanitizerCommonNoTermination'). Also, you'll need to either implement
-  # your own backtrace support (see optional/backtrace.h), or choose between 
one
-  # of the pre-implemented backtrace support options (see below).
   add_compiler_rt_object_libraries(RTGwpAsanOptionsParser
   ARCHS ${GWP_ASAN_SUPPORTED_ARCH}
   SOURCES ${GWP_ASAN_OPTIONS_PARSER_SOURCES}

diff  --git a/compiler-rt/lib/gwp_asan/optional/options_parser.cpp 
b/compiler-rt/lib/gwp_asan/optional/options_parser.cpp
index 2e6386286745..60234124e8ed 100644
--- a/compiler-rt/lib/gwp_asan/optional/options_parser.cpp
+++ b/compiler-rt/lib/gwp_asan/optional/options_parser.cpp
@@ -7,84 +7,251 @@
 
//===--===//
 
 #include "gwp_asan/optional/options_parser.h"
+#include "gwp_asan/optional/printf.h"
+#include "gwp_asan/utilities.h"
 
+#include 
 #include 
 #include 
 #include 
 #include 
 
-#include "gwp_asan/options.h"
-#include "sanitizer_common/sanitizer_common.h"
-#include "sanitizer_common/sanitizer_flag_parser.h"
-#include "sanitizer_common/sanitizer_flags.h"
-

[llvm-branch-commits] [llvm] a14c36f - [SimplifyCFG] switchToSelect(): don't forget to insert DomTree edge iff needed

2021-01-15 Thread Roman Lebedev via llvm-branch-commits

Author: Roman Lebedev
Date: 2021-01-15T23:35:57+03:00
New Revision: a14c36fe27f5c36de44049237011d140a724

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

LOG: [SimplifyCFG] switchToSelect(): don't forget to insert DomTree edge iff 
needed

DestBB might or might not already be a successor of SelectBB,
and it wasn't we need to ensure that we record the fact in DomTree.

The testcase used to crash in lazy domtree updater mode + non-per-function
domtree validity checks disabled.

Added: 


Modified: 
llvm/lib/Transforms/Utils/SimplifyCFG.cpp

llvm/test/Transforms/SimplifyCFG/switchToSelect-domtree-preservation-edgecase.ll

Removed: 




diff  --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp 
b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index 4c0427e103f7..559830ed9a17 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -5394,20 +5394,25 @@ static void 
RemoveSwitchAfterSelectConversion(SwitchInst *SI, PHINode *PHI,
   Value *SelectValue,
   IRBuilder<> ,
   DomTreeUpdater *DTU) {
+  std::vector Updates;
+
   BasicBlock *SelectBB = SI->getParent();
+  BasicBlock *DestBB = PHI->getParent();
+
+  if (!is_contained(predecessors(DestBB), SelectBB))
+Updates.push_back({DominatorTree::Insert, SelectBB, DestBB});
+  Builder.CreateBr(DestBB);
+
+  // Remove the switch.
+
   while (PHI->getBasicBlockIndex(SelectBB) >= 0)
 PHI->removeIncomingValue(SelectBB);
   PHI->addIncoming(SelectValue, SelectBB);
 
-  Builder.CreateBr(PHI->getParent());
-
-  std::vector Updates;
-
-  // Remove the switch.
   for (unsigned i = 0, e = SI->getNumSuccessors(); i < e; ++i) {
 BasicBlock *Succ = SI->getSuccessor(i);
 
-if (Succ == PHI->getParent())
+if (Succ == DestBB)
   continue;
 Succ->removePredecessor(SelectBB);
 Updates.push_back({DominatorTree::Delete, SelectBB, Succ});

diff  --git 
a/llvm/test/Transforms/SimplifyCFG/switchToSelect-domtree-preservation-edgecase.ll
 
b/llvm/test/Transforms/SimplifyCFG/switchToSelect-domtree-preservation-edgecase.ll
index 7f3428ba8c7b..72e887502694 100644
--- 
a/llvm/test/Transforms/SimplifyCFG/switchToSelect-domtree-preservation-edgecase.ll
+++ 
b/llvm/test/Transforms/SimplifyCFG/switchToSelect-domtree-preservation-edgecase.ll
@@ -1,5 +1,5 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
-; RUN: opt -S -simplifycfg -simplifycfg-require-and-preserve-domtree=0 
-sink-common-insts=1 < %s | FileCheck %s
+; RUN: opt -S -simplifycfg -simplifycfg-require-and-preserve-domtree=1 
-sink-common-insts=1 < %s | FileCheck %s
 
 declare void @widget(i8)
 



___
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] c6654a4 - [SimplifyCFG][BasicBlockUtils] Port SplitBlockPredecessors()/SplitLandingPadPredecessors() to DomTreeUpdater

2021-01-15 Thread Roman Lebedev via llvm-branch-commits

Author: Roman Lebedev
Date: 2021-01-15T23:35:56+03:00
New Revision: c6654a4cdab4156bae51970fa64993e790fc4adb

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

LOG: [SimplifyCFG][BasicBlockUtils] Port 
SplitBlockPredecessors()/SplitLandingPadPredecessors() to DomTreeUpdater

This is not nice, but it's the best transient solution possible,
and is better than just duplicating the whole function.

The problem is, this function is widely used,
and it is not at all obvious that all the users
could be painlessly switched to operate on DomTreeUpdater,
and somehow i don't feel like porting all those users first.

This function is one of last three that not operate on DomTreeUpdater.

Added: 


Modified: 
llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h
llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
llvm/lib/Transforms/Utils/SimplifyCFG.cpp

Removed: 




diff  --git a/llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h 
b/llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h
index b75fe1f0f9f7..1dda73913826 100644
--- a/llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h
+++ b/llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h
@@ -289,6 +289,28 @@ BasicBlock *splitBlockBefore(BasicBlock *Old, Instruction 
*SplitPt,
  DomTreeUpdater *DTU, LoopInfo *LI,
  MemorySSAUpdater *MSSAU, const Twine  = 
"");
 
+/// This method introduces at least one new basic block into the function and
+/// moves some of the predecessors of BB to be predecessors of the new block.
+/// The new predecessors are indicated by the Preds array. The new block is
+/// given a suffix of 'Suffix'. Returns new basic block to which predecessors
+/// from Preds are now pointing.
+///
+/// If BB is a landingpad block then additional basicblock might be introduced.
+/// It will have Suffix+".split_lp". See SplitLandingPadPredecessors for more
+/// details on this case.
+///
+/// This currently updates the LLVM IR, DominatorTree, LoopInfo, and LCCSA but
+/// no other analyses. In particular, it does not preserve LoopSimplify
+/// (because it's complicated to handle the case where one of the edges being
+/// split is an exit of a loop with other exits).
+///
+/// FIXME: deprecated, switch to the DomTreeUpdater-based one.
+BasicBlock *SplitBlockPredecessors(BasicBlock *BB, ArrayRef 
Preds,
+   const char *Suffix, DominatorTree *DT,
+   LoopInfo *LI = nullptr,
+   MemorySSAUpdater *MSSAU = nullptr,
+   bool PreserveLCSSA = false);
+
 /// This method introduces at least one new basic block into the function and
 /// moves some of the predecessors of BB to be predecessors of the new block.
 /// The new predecessors are indicated by the Preds array. The new block is
@@ -305,11 +327,32 @@ BasicBlock *splitBlockBefore(BasicBlock *Old, Instruction 
*SplitPt,
 /// split is an exit of a loop with other exits).
 BasicBlock *SplitBlockPredecessors(BasicBlock *BB, ArrayRef 
Preds,
const char *Suffix,
-   DominatorTree *DT = nullptr,
+   DomTreeUpdater *DTU = nullptr,
LoopInfo *LI = nullptr,
MemorySSAUpdater *MSSAU = nullptr,
bool PreserveLCSSA = false);
 
+/// This method transforms the landing pad, OrigBB, by introducing two new 
basic
+/// blocks into the function. One of those new basic blocks gets the
+/// predecessors listed in Preds. The other basic block gets the remaining
+/// predecessors of OrigBB. The landingpad instruction OrigBB is clone into 
both
+/// of the new basic blocks. The new blocks are given the suffixes 'Suffix1' 
and
+/// 'Suffix2', and are returned in the NewBBs vector.
+///
+/// This currently updates the LLVM IR, DominatorTree, LoopInfo, and LCCSA but
+/// no other analyses. In particular, it does not preserve LoopSimplify
+/// (because it's complicated to handle the case where one of the edges being
+/// split is an exit of a loop with other exits).
+///
+/// FIXME: deprecated, switch to the DomTreeUpdater-based one.
+void SplitLandingPadPredecessors(BasicBlock *OrigBB,
+ ArrayRef Preds,
+ const char *Suffix, const char *Suffix2,
+ SmallVectorImpl ,
+ DominatorTree *DT, LoopInfo *LI = nullptr,
+ MemorySSAUpdater *MSSAU = nullptr,
+ bool PreserveLCSSA = false);
+
 /// This method transforms the landing pad, OrigBB, by 

[llvm-branch-commits] [llvm] 286cf6c - [SimplifyCFG] Port SplitBlockAndInsertIfThen() to DomTreeUpdater

2021-01-15 Thread Roman Lebedev via llvm-branch-commits

Author: Roman Lebedev
Date: 2021-01-15T23:35:56+03:00
New Revision: 286cf6cb029a9942df6ff1d99570e93c25fe29f0

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

LOG: [SimplifyCFG] Port SplitBlockAndInsertIfThen() to DomTreeUpdater

This is not nice, but it's the best transient solution possible,
and is better than just duplicating the whole function.

The problem is, this function is widely used,
and it is not at all obvious that all the users
could be painlessly switched to operate on DomTreeUpdater,
and somehow i don't feel like porting all those users first.

This function is one of last three that not operate on DomTreeUpdater.

Added: 


Modified: 
llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h
llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
llvm/lib/Transforms/Utils/SimplifyCFG.cpp

Removed: 




diff  --git a/llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h 
b/llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h
index a75e49d75c53..b75fe1f0f9f7 100644
--- a/llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h
+++ b/llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h
@@ -335,6 +335,35 @@ ReturnInst *FoldReturnIntoUncondBranch(ReturnInst *RI, 
BasicBlock *BB,
BasicBlock *Pred,
DomTreeUpdater *DTU = nullptr);
 
+/// Split the containing block at the specified instruction - everything before
+/// SplitBefore stays in the old basic block, and the rest of the instructions
+/// in the BB are moved to a new block. The two blocks are connected by a
+/// conditional branch (with value of Cmp being the condition).
+/// Before:
+///   Head
+///   SplitBefore
+///   Tail
+/// After:
+///   Head
+///   if (Cond)
+/// ThenBlock
+///   SplitBefore
+///   Tail
+///
+/// If \p ThenBlock is not specified, a new block will be created for it.
+/// If \p Unreachable is true, the newly created block will end with
+/// UnreachableInst, otherwise it branches to Tail.
+/// Returns the NewBasicBlock's terminator.
+///
+/// Updates DT and LI if given.
+///
+/// FIXME: deprecated, switch to the DomTreeUpdater-based one.
+Instruction *SplitBlockAndInsertIfThen(Value *Cond, Instruction *SplitBefore,
+   bool Unreachable, MDNode *BranchWeights,
+   DominatorTree *DT,
+   LoopInfo *LI = nullptr,
+   BasicBlock *ThenBlock = nullptr);
+
 /// Split the containing block at the specified instruction - everything before
 /// SplitBefore stays in the old basic block, and the rest of the instructions
 /// in the BB are moved to a new block. The two blocks are connected by a
@@ -359,7 +388,7 @@ ReturnInst *FoldReturnIntoUncondBranch(ReturnInst *RI, 
BasicBlock *BB,
 Instruction *SplitBlockAndInsertIfThen(Value *Cond, Instruction *SplitBefore,
bool Unreachable,
MDNode *BranchWeights = nullptr,
-   DominatorTree *DT = nullptr,
+   DomTreeUpdater *DTU = nullptr,
LoopInfo *LI = nullptr,
BasicBlock *ThenBlock = nullptr);
 

diff  --git a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp 
b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
index 79a2aa354339..fedd9bfc977e 100644
--- a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
@@ -773,7 +773,8 @@ void HWAddressSanitizer::instrumentMemAccessInline(Value 
*Ptr, bool IsWrite,
   Value *PtrLowBitsOOB = IRB.CreateICmpUGE(PtrLowBits, MemTag);
   SplitBlockAndInsertIfThen(PtrLowBitsOOB, CheckTerm, false,
 MDBuilder(*C).createBranchWeights(1, 10),
-nullptr, nullptr, CheckFailTerm->getParent());
+(DomTreeUpdater *)nullptr, nullptr,
+CheckFailTerm->getParent());
 
   IRB.SetInsertPoint(CheckTerm);
   Value *InlineTagAddr = IRB.CreateOr(AddrLong, 15);
@@ -782,7 +783,8 @@ void HWAddressSanitizer::instrumentMemAccessInline(Value 
*Ptr, bool IsWrite,
   Value *InlineTagMismatch = IRB.CreateICmpNE(PtrTag, InlineTag);
   SplitBlockAndInsertIfThen(InlineTagMismatch, CheckTerm, false,
 MDBuilder(*C).createBranchWeights(1, 10),
-nullptr, nullptr, CheckFailTerm->getParent());
+(DomTreeUpdater *)nullptr, nullptr,
+

[llvm-branch-commits] [llvm] c845c72 - [Utils][SimplifyCFG] Port SplitBlock() to DomTreeUpdater

2021-01-15 Thread Roman Lebedev via llvm-branch-commits

Author: Roman Lebedev
Date: 2021-01-15T23:35:56+03:00
New Revision: c845c724c2323660e81a0b284aaa461842f1b402

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

LOG: [Utils][SimplifyCFG] Port SplitBlock() to DomTreeUpdater

This is not nice, but it's the best transient solution possible,
and is better than just duplicating the whole function.

The problem is, this function is widely used,
and it is not at all obvious that all the users
could be painlessly switched to operate on DomTreeUpdater,
and somehow i don't feel like porting all those users first.

This function is one of last three that not operate on DomTreeUpdater.

Added: 


Modified: 
llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h
llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp
llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
llvm/lib/Transforms/Utils/SimplifyCFG.cpp

Removed: 




diff  --git a/llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h 
b/llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h
index a8380981ccfa..a75e49d75c53 100644
--- a/llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h
+++ b/llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h
@@ -252,6 +252,21 @@ BasicBlock *SplitEdge(BasicBlock *From, BasicBlock *To,
   MemorySSAUpdater *MSSAU = nullptr,
   const Twine  = "");
 
+/// Split the specified block at the specified instruction.
+///
+/// If \p Before is true, splitBlockBefore handles the block
+/// splitting. Otherwise, execution proceeds as described below.
+///
+/// Everything before \p SplitPt stays in \p Old and everything starting with 
\p
+/// SplitPt moves to a new block. The two blocks are joined by an unconditional
+/// branch. The new block with name \p BBName is returned.
+///
+/// FIXME: deprecated, switch to the DomTreeUpdater-based one.
+BasicBlock *SplitBlock(BasicBlock *Old, Instruction *SplitPt, DominatorTree 
*DT,
+   LoopInfo *LI = nullptr,
+   MemorySSAUpdater *MSSAU = nullptr,
+   const Twine  = "", bool Before = false);
+
 /// Split the specified block at the specified instruction.
 ///
 /// If \p Before is true, splitBlockBefore handles the block
@@ -261,7 +276,7 @@ BasicBlock *SplitEdge(BasicBlock *From, BasicBlock *To,
 /// SplitPt moves to a new block. The two blocks are joined by an unconditional
 /// branch. The new block with name \p BBName is returned.
 BasicBlock *SplitBlock(BasicBlock *Old, Instruction *SplitPt,
-   DominatorTree *DT = nullptr, LoopInfo *LI = nullptr,
+   DomTreeUpdater *DTU = nullptr, LoopInfo *LI = nullptr,
MemorySSAUpdater *MSSAU = nullptr,
const Twine  = "", bool Before = false);
 

diff  --git a/llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp 
b/llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp
index a2276193b460..aa9894ca32b3 100644
--- a/llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp
+++ b/llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp
@@ -1106,12 +1106,15 @@ class LowerMatrixIntrinsics {
 for (BasicBlock *Succ : successors(Check0))
   DTUpdates.push_back({DT->Delete, Check0, Succ});
 
-BasicBlock *Check1 = SplitBlock(MatMul->getParent(), MatMul, nullptr, LI,
-nullptr, "alias_cont");
+BasicBlock *Check1 =
+SplitBlock(MatMul->getParent(), MatMul, (DomTreeUpdater *)nullptr, LI,
+   nullptr, "alias_cont");
 BasicBlock *Copy =
-SplitBlock(MatMul->getParent(), MatMul, nullptr, LI, nullptr, "copy");
-BasicBlock *Fusion = SplitBlock(MatMul->getParent(), MatMul, nullptr, LI,
-nullptr, "no_alias");
+SplitBlock(MatMul->getParent(), MatMul, (DomTreeUpdater *)nullptr, LI,
+   nullptr, "copy");
+BasicBlock *Fusion =
+SplitBlock(MatMul->getParent(), MatMul, (DomTreeUpdater *)nullptr, LI,
+   nullptr, "no_alias");
 
 // Check if the loaded memory location begins before the end of the store
 // location. If the condition holds, they might overlap, otherwise they are

diff  --git a/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp 
b/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
index f89a1fad5f1d..91ce48509132 100644
--- a/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
+++ b/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
@@ -542,13 +542,15 @@ llvm::SplitAllCriticalEdges(Function ,
   return NumBroken;
 }
 
-BasicBlock *llvm::SplitBlock(BasicBlock *Old, Instruction *SplitPt,
- DominatorTree *DT, LoopInfo *LI,
- MemorySSAUpdater *MSSAU, const Twine ,
- bool Before) {

[llvm-branch-commits] [llvm] b81f75f - [Utils] splitBlockBefore() always operates on DomTreeUpdater, so take it, not DomTree

2021-01-15 Thread Roman Lebedev via llvm-branch-commits

Author: Roman Lebedev
Date: 2021-01-15T23:35:56+03:00
New Revision: b81f75fa79162e9e2ba84d6b4cdd72f564b050c6

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

LOG: [Utils] splitBlockBefore() always operates on DomTreeUpdater, so take it, 
not DomTree

Even though not all it's users operate on DomTreeUpdater,
it itself internally operates on DomTreeUpdater,
so it must mean everything is fine with that,
so just do that globally.

Added: 


Modified: 
llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h
llvm/lib/Transforms/Utils/BasicBlockUtils.cpp

Removed: 




diff  --git a/llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h 
b/llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h
index a1d5ee8fb91b..a8380981ccfa 100644
--- a/llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h
+++ b/llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h
@@ -271,7 +271,7 @@ BasicBlock *SplitBlock(BasicBlock *Old, Instruction 
*SplitPt,
 /// old block are joined by inserting an unconditional branch to the end of the
 /// new block. The new block with name \p BBName is returned.
 BasicBlock *splitBlockBefore(BasicBlock *Old, Instruction *SplitPt,
- DominatorTree *DT, LoopInfo *LI,
+ DomTreeUpdater *DTU, LoopInfo *LI,
  MemorySSAUpdater *MSSAU, const Twine  = 
"");
 
 /// This method introduces at least one new basic block into the function and

diff  --git a/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp 
b/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
index bfad88f64c7d..f89a1fad5f1d 100644
--- a/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
+++ b/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
@@ -546,8 +546,10 @@ BasicBlock *llvm::SplitBlock(BasicBlock *Old, Instruction 
*SplitPt,
  DominatorTree *DT, LoopInfo *LI,
  MemorySSAUpdater *MSSAU, const Twine ,
  bool Before) {
-  if (Before)
-return splitBlockBefore(Old, SplitPt, DT, LI, MSSAU, BBName);
+  if (Before) {
+DomTreeUpdater DTU(DT, DomTreeUpdater::UpdateStrategy::Lazy);
+return splitBlockBefore(Old, SplitPt, , LI, MSSAU, BBName);
+  }
   BasicBlock::iterator SplitIt = SplitPt->getIterator();
   while (isa(SplitIt) || SplitIt->isEHPad())
 ++SplitIt;
@@ -580,7 +582,7 @@ BasicBlock *llvm::SplitBlock(BasicBlock *Old, Instruction 
*SplitPt,
 }
 
 BasicBlock *llvm::splitBlockBefore(BasicBlock *Old, Instruction *SplitPt,
-   DominatorTree *DT, LoopInfo *LI,
+   DomTreeUpdater *DTU, LoopInfo *LI,
MemorySSAUpdater *MSSAU,
const Twine ) {
 
@@ -598,25 +600,25 @@ BasicBlock *llvm::splitBlockBefore(BasicBlock *Old, 
Instruction *SplitPt,
 if (Loop *L = LI->getLoopFor(Old))
   L->addBasicBlockToLoop(New, *LI);
 
-  if (DT) {
-DomTreeUpdater DTU(DT, DomTreeUpdater::UpdateStrategy::Lazy);
+  if (DTU) {
 SmallVector DTUpdates;
 // New dominates Old. The predecessor nodes of the Old node dominate
 // New node.
+SmallSetVector UniquePredecessorsOfOld(pred_begin(New),
+pred_end(New));
 DTUpdates.push_back({DominatorTree::Insert, New, Old});
-for (BasicBlock *Pred : predecessors(New))
-  if (DT->getNode(Pred)) {
-DTUpdates.push_back({DominatorTree::Insert, Pred, New});
-DTUpdates.push_back({DominatorTree::Delete, Pred, Old});
-  }
+DTUpdates.reserve(DTUpdates.size() + 2 * UniquePredecessorsOfOld.size());
+for (BasicBlock *UniquePredecessorOfOld : UniquePredecessorsOfOld) {
+  DTUpdates.push_back({DominatorTree::Insert, UniquePredecessorOfOld, 
New});
+  DTUpdates.push_back({DominatorTree::Delete, UniquePredecessorOfOld, 
Old});
+}
 
-DTU.applyUpdates(DTUpdates);
-DTU.flush();
+DTU->applyUpdates(DTUpdates);
 
 // Move MemoryAccesses still tracked in Old, but part of New now.
 // Update accesses in successor blocks accordingly.
 if (MSSAU) {
-  MSSAU->applyUpdates(DTUpdates, *DT);
+  MSSAU->applyUpdates(DTUpdates, DTU->getDomTree());
   if (VerifyMemorySSA)
 MSSAU->getMemorySSA()->verifyMemorySSA();
 }



___
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] 61ec228 - [NFC][SimplifyCFG] Add testcase showing that we fail to preserve DomTree in switchToSelect()

2021-01-15 Thread Roman Lebedev via llvm-branch-commits

Author: Roman Lebedev
Date: 2021-01-15T23:35:55+03:00
New Revision: 61ec2280308bd5e2161efe2959d7d26798c85cb4

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

LOG: [NFC][SimplifyCFG] Add testcase showing that we fail to preserve DomTree 
in switchToSelect()

Added: 

llvm/test/Transforms/SimplifyCFG/switchToSelect-domtree-preservation-edgecase.ll

Modified: 


Removed: 




diff  --git 
a/llvm/test/Transforms/SimplifyCFG/switchToSelect-domtree-preservation-edgecase.ll
 
b/llvm/test/Transforms/SimplifyCFG/switchToSelect-domtree-preservation-edgecase.ll
new file mode 100644
index ..7f3428ba8c7b
--- /dev/null
+++ 
b/llvm/test/Transforms/SimplifyCFG/switchToSelect-domtree-preservation-edgecase.ll
@@ -0,0 +1,57 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -S -simplifycfg -simplifycfg-require-and-preserve-domtree=0 
-sink-common-insts=1 < %s | FileCheck %s
+
+declare void @widget(i8)
+
+define void @baz(i8 %arg, i8 %arg10, i1 %arg11) {
+; CHECK-LABEL: @baz(
+; CHECK-NEXT:  bb:
+; CHECK-NEXT:br label [[BB12:%.*]]
+; CHECK:   bb12:
+; CHECK-NEXT:[[TMP:%.*]] = icmp eq i8 [[ARG:%.*]], 0
+; CHECK-NEXT:br i1 [[TMP]], label [[BB17:%.*]], label [[BB13:%.*]]
+; CHECK:   bb13:
+; CHECK-NEXT:tail call void @widget(i8 11)
+; CHECK-NEXT:[[SWITCH_SELECTCMP:%.*]] = icmp eq i8 [[ARG10:%.*]], 73
+; CHECK-NEXT:[[SWITCH_SELECT:%.*]] = select i1 [[SWITCH_SELECTCMP]], i8 
44, i8 22
+; CHECK-NEXT:[[SWITCH_SELECTCMP1:%.*]] = icmp eq i8 [[ARG10]], 68
+; CHECK-NEXT:[[SWITCH_SELECT2:%.*]] = select i1 [[SWITCH_SELECTCMP1]], i8 
33, i8 [[SWITCH_SELECT]]
+; CHECK-NEXT:tail call void @widget(i8 [[SWITCH_SELECT2]])
+; CHECK-NEXT:br label [[BB17]]
+; CHECK:   bb17:
+; CHECK-NEXT:br i1 [[ARG11:%.*]], label [[BB12]], label [[BB18:%.*]]
+; CHECK:   bb18:
+; CHECK-NEXT:ret void
+;
+bb:
+  br label %bb12
+
+bb12: ; preds = %bb17, %bb
+  %tmp = icmp eq i8 %arg, 0
+  br i1 %tmp, label %bb17, label %bb13
+
+bb13: ; preds = %bb12
+  tail call void @widget(i8 11)
+  switch i8 %arg10, label %bb14 [
+  i8 68, label %bb15
+  i8 73, label %bb16
+  ]
+
+bb14: ; preds = %bb13
+  tail call void @widget(i8 22)
+  br label %bb17
+
+bb15: ; preds = %bb13
+  tail call void @widget(i8 33)
+  br label %bb17
+
+bb16: ; preds = %bb13
+  tail call void @widget(i8 44)
+  br label %bb17
+
+bb17: ; preds = %bb16, %bb15, 
%bb14, %bb12
+  br i1 %arg11, label %bb12, label %bb18
+
+bb18: ; preds = %bb17
+  ret void
+}



___
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] 64db296 - Revert "[BasicAA] Handle recursive queries more efficiently"

2021-01-15 Thread Reid Kleckner via llvm-branch-commits

Author: Reid Kleckner
Date: 2021-01-15T12:29:57-08:00
New Revision: 64db296e5a8c9fdc2f7feb4afb60d59c140a78aa

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

LOG: Revert "[BasicAA] Handle recursive queries more efficiently"

This reverts commit a3904cc77f181cff7355357688edfc392a236f5d.
It causes the compiler to crash while building Harfbuzz for ARM in
Chromium, reduced reproducer forthcoming:
https://crbug.com/1167305

Added: 


Modified: 
llvm/include/llvm/Analysis/BasicAliasAnalysis.h
llvm/lib/Analysis/BasicAliasAnalysis.cpp
llvm/lib/Analysis/GlobalsModRef.cpp

Removed: 




diff  --git a/llvm/include/llvm/Analysis/BasicAliasAnalysis.h 
b/llvm/include/llvm/Analysis/BasicAliasAnalysis.h
index b95365d0481f..635c35585f81 100644
--- a/llvm/include/llvm/Analysis/BasicAliasAnalysis.h
+++ b/llvm/include/llvm/Analysis/BasicAliasAnalysis.h
@@ -240,17 +240,18 @@ class BasicAAResult : public AAResultBase {
   AliasResult aliasPHI(const PHINode *PN, LocationSize PNSize,
const AAMDNodes , const Value *V2,
LocationSize V2Size, const AAMDNodes ,
-   AAQueryInfo );
+   const Value *UnderV2, AAQueryInfo );
 
   AliasResult aliasSelect(const SelectInst *SI, LocationSize SISize,
   const AAMDNodes , const Value *V2,
   LocationSize V2Size, const AAMDNodes ,
-  AAQueryInfo );
+  const Value *UnderV2, AAQueryInfo );
 
   AliasResult aliasCheck(const Value *V1, LocationSize V1Size,
  const AAMDNodes , const Value *V2,
  LocationSize V2Size, const AAMDNodes ,
- AAQueryInfo );
+ AAQueryInfo , const Value *O1 = nullptr,
+ const Value *O2 = nullptr);
 
   AliasResult aliasCheckRecursive(const Value *V1, LocationSize V1Size,
   const AAMDNodes , const Value *V2,

diff  --git a/llvm/lib/Analysis/BasicAliasAnalysis.cpp 
b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
index 29fd58e6e5d7..313a85ccc4de 100644
--- a/llvm/lib/Analysis/BasicAliasAnalysis.cpp
+++ b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
@@ -798,8 +798,26 @@ AliasResult BasicAAResult::alias(const MemoryLocation 
,
  AAQueryInfo ) {
   assert(notDifferentParent(LocA.Ptr, LocB.Ptr) &&
  "BasicAliasAnalysis doesn't support interprocedural queries.");
-  return aliasCheck(LocA.Ptr, LocA.Size, LocA.AATags, LocB.Ptr, LocB.Size,
-LocB.AATags, AAQI);
+
+  // If we have a directly cached entry for these locations, we have recursed
+  // through this once, so just return the cached results. Notably, when this
+  // happens, we don't clear the cache.
+  AAQueryInfo::LocPair Locs(LocA, LocB);
+  if (Locs.first.Ptr > Locs.second.Ptr)
+std::swap(Locs.first, Locs.second);
+  auto CacheIt = AAQI.AliasCache.find(Locs);
+  if (CacheIt != AAQI.AliasCache.end()) {
+// This code exists to skip a second BasicAA call while recursing into
+// BestAA. Don't make use of assumptions here.
+const auto  = CacheIt->second;
+return Entry.isDefinitive() ? Entry.Result : MayAlias;
+  }
+
+  AliasResult Alias = aliasCheck(LocA.Ptr, LocA.Size, LocA.AATags, LocB.Ptr,
+ LocB.Size, LocB.AATags, AAQI);
+
+  assert(VisitedPhiBBs.empty());
+  return Alias;
 }
 
 /// Checks to see if the specified callsite can clobber the specified memory
@@ -1112,17 +1130,16 @@ AliasResult BasicAAResult::aliasGEP(
 if (isGEPBaseAtNegativeOffset(GEP2, DecompGEP2, DecompGEP1, V1Size))
   return NoAlias;
 // Do the base pointers alias?
-AliasResult BaseAlias = getBestAAResults().alias(
-MemoryLocation::getBeforeOrAfter(UnderlyingV1),
-MemoryLocation::getBeforeOrAfter(UnderlyingV2), AAQI);
+AliasResult BaseAlias = aliasCheck(
+UnderlyingV1, LocationSize::beforeOrAfterPointer(), AAMDNodes(),
+UnderlyingV2, LocationSize::beforeOrAfterPointer(), AAMDNodes(), AAQI);
 
 // For GEPs with identical offsets, we can preserve the size and AAInfo
 // when performing the alias check on the underlying objects.
 if (BaseAlias == MayAlias && DecompGEP1.Offset == DecompGEP2.Offset &&
 DecompGEP1.VarIndices == DecompGEP2.VarIndices) {
-  AliasResult PreciseBaseAlias = getBestAAResults().alias(
-  MemoryLocation(UnderlyingV1, V1Size, V1AAInfo),
-  MemoryLocation(UnderlyingV2, V2Size, V2AAInfo), AAQI);
+  AliasResult PreciseBaseAlias = aliasCheck(
+  UnderlyingV1, V1Size, V1AAInfo, UnderlyingV2, V2Size, V2AAInfo, 
AAQI);
   if (PreciseBaseAlias == NoAlias)
 return 

[llvm-branch-commits] [clang] a1be47b - [CodeView][DebugInfo] Add test case to show that linkage names are not

2021-01-15 Thread Amy Huang via llvm-branch-commits

Author: Amy Huang
Date: 2021-01-15T12:05:33-08:00
New Revision: a1be47b4771467998d7549dcd1b9f9cebdaa9af9

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

LOG: [CodeView][DebugInfo] Add test case to show that linkage names are not
being added to class types in -gline-tables-only.
Also changed the name of the test file for clarity.
(follow up to D94639)

Added: 
clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp

Modified: 


Removed: 
clang/test/CodeGenCXX/debug-info-codeview-scopes.cpp



diff  --git a/clang/test/CodeGenCXX/debug-info-codeview-scopes.cpp 
b/clang/test/CodeGenCXX/debug-info-codeview-scopes.cpp
deleted file mode 100644
index f096e334a158..
--- a/clang/test/CodeGenCXX/debug-info-codeview-scopes.cpp
+++ /dev/null
@@ -1,34 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu 
-debug-info-kind=line-tables-only -S -emit-llvm -std=c++11 -o - %s | FileCheck 
--check-prefix LINUX %s
-// RUN: %clang_cc1 -triple x86_64-windows-msvc 
-debug-info-kind=line-tables-only -gcodeview -S -emit-llvm -std=c++11 -o - %s | 
FileCheck --check-prefix MSVC %s
-
-// Check that we emit type information for function scopes in line tables for
-// CodeView.
-
-namespace A {
-void f() {}
-
-struct S {
-  static void m() {}
-};
-}
-
-int main() {
-  A::f();
-  A::S::m();
-  return 0;
-  // MSVC:   !{{[0-9]+}} = distinct !DISubprogram(name: "f"
-  // MSVC-SAME: scope: [[SCOPE1:![0-9]+]]
-  // MSVC-SAME: )
-  // MSVC:   [[SCOPE1]] = !DINamespace(name: "A", {{.*}})
-  // MSVC:   !{{[0-9]+}} = distinct !DISubprogram(name: "m"
-  // MSVC-SAME: scope: [[SCOPE2:![0-9]+]]
-  // MSVC-SAME: )
-  // MSVC:   [[SCOPE2]] = !DICompositeType(tag: DW_TAG_structure_type,
-  // MSVC-SAME: name: "S",
-  // MSVC-SAME: scope: [[SCOPE1]]
-  // MSVC-SAME: )
-
-  // LINUX-NOT: !DINamespace
-  // LINUX-NOT: !DICompositeType
-  return 0;
-}

diff  --git a/clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp 
b/clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp
new file mode 100644
index ..25f801737f74
--- /dev/null
+++ b/clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 %s -gcodeview -debug-info-kind=line-tables-only -S \
+// RUN:   -emit-llvm -o - | FileCheck %s
+// Checks that clang with "-gline-tables-only" with CodeView emits some debug
+// info for variables and types when they appear in function scopes.
+
+namespace NS {
+struct C {
+public:
+  void m() {}
+};
+void f() {}
+}
+
+NS::C c;
+
+void test() {
+  // CHECK: ![[EMPTY:[0-9]+]] = !{}
+  // CHECK: !DISubprogram(name: "f", scope: ![[NS:[0-9]+]],
+  // CHECK-SAME:  type: ![[F:[0-9]+]]
+  // CHECK: ![[NS]] = !DINamespace(name: "NS", scope: null)
+  // CHECK: ![[F]] = !DISubroutineType(types: ![[EMPTY]])
+  NS::f();
+
+  // CHECK: !DISubprogram(name: "m", scope: ![[C:[0-9]+]],
+  // CHECK-SAME:  type: ![[F]]
+  // CHECK: ![[C]] = !DICompositeType(tag: DW_TAG_structure_type, name: "C",
+  // CHECK-SAME:  flags: DIFlagFwdDecl
+  // CHECK-NOT: identifier
+  c.m();
+}



___
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] 1f21de5 - [SLP] remove unused reduction functions; NFC

2021-01-15 Thread Sanjay Patel via llvm-branch-commits

Author: Sanjay Patel
Date: 2021-01-15T14:59:33-05:00
New Revision: 1f21de535d37997c41b9b1ecb2f7ca0e472e9f77

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

LOG: [SLP] remove unused reduction functions; NFC

These were made obsolete by simplifying the code in recent patches.

Added: 


Modified: 
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Removed: 




diff  --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp 
b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 3f1279b67519..e1befc449492 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -6615,16 +6615,6 @@ class HorizontalReduction {
   return Kind == OD.Kind && Opcode == OD.Opcode;
 }
 bool operator!=(const OperationData ) const { return !(*this == OD); }
-void clear() {
-  Opcode = 0;
-  Kind = RecurKind::None;
-}
-
-/// Get the opcode of the reduction operation.
-unsigned getOpcode() const {
-  assert(isVectorizable() && "Expected vectorizable operation.");
-  return Opcode;
-}
 
 /// Get kind of reduction data.
 RecurKind getKind() const { return Kind; }



___
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] a9e9397 - [CodeGen] Removes unwanted optimisation for TargetConstantFP

2021-01-15 Thread Craig Topper via llvm-branch-commits

Author: Craig Topper
Date: 2021-01-15T11:52:53-08:00
New Revision: a9e939760c6f21476109559cc3e21779baff

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

LOG: [CodeGen] Removes unwanted optimisation for TargetConstantFP

This 'FIXME' popped up in the development of an out-of-tree backend.
Quick fix, but first llvm upstream patch, therefore I do not have commit 
rights, so if approved please commit?

- Test is not included as this came up in an out-of-tree backend (if required, 
please hint on how to test this).

Patch by simveg (Simon)

Reviewed By: craig.topper

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

Added: 


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

Removed: 




diff  --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp 
b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
index 523895200f6a..2437b07e7d0e 100644
--- a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
@@ -431,7 +431,6 @@ SDValue 
SelectionDAGLegalize::OptimizeFloatStore(StoreSDNode* ST) {
 
   LLVM_DEBUG(dbgs() << "Optimizing float store operations\n");
   // Turn 'store float 1.0, Ptr' -> 'store int 0x12345678, Ptr'
-  // FIXME: We shouldn't do this for TargetConstantFP's.
   // FIXME: move this to the DAG Combiner!  Note that we can't regress due
   // to phase ordering between legalized code and the dag combiner.  This
   // probably means that we need to integrate dag combiner and legalizer
@@ -439,10 +438,16 @@ SDValue 
SelectionDAGLegalize::OptimizeFloatStore(StoreSDNode* ST) {
   // We generally can't do this one for long doubles.
   SDValue Chain = ST->getChain();
   SDValue Ptr = ST->getBasePtr();
+  SDValue Value = ST->getValue();
   MachineMemOperand::Flags MMOFlags = ST->getMemOperand()->getFlags();
   AAMDNodes AAInfo = ST->getAAInfo();
   SDLoc dl(ST);
-  if (ConstantFPSDNode *CFP = dyn_cast(ST->getValue())) {
+
+  // Don't optimise TargetConstantFP
+  if (Value.getOpcode() == ISD::TargetConstantFP)
+return SDValue();
+
+  if (ConstantFPSDNode *CFP = dyn_cast(Value)) {
 if (CFP->getValueType(0) == MVT::f32 &&
 TLI.isTypeLegal(MVT::i32)) {
   SDValue Con = DAG.getConstant(CFP->getValueAPF().
@@ -482,7 +487,7 @@ SDValue 
SelectionDAGLegalize::OptimizeFloatStore(StoreSDNode* ST) {
   }
 }
   }
-  return SDValue(nullptr, 0);
+  return SDValue();
 }
 
 void SelectionDAGLegalize::LegalizeStoreOps(SDNode *Node) {



___
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] [libcxx] 4f24d0d - Fix libc++ clang-cl build, swap attribute order

2021-01-15 Thread Reid Kleckner via llvm-branch-commits

Author: Reid Kleckner
Date: 2021-01-15T11:44:13-08:00
New Revision: 4f24d0dd5386cc0ff61be23062b89855da87094b

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

LOG: Fix libc++ clang-cl build, swap attribute order

Clang insists that __attribute__ attributes precede __declspec
attributes. This is a longstanding known issue:
https://llvm.org/pr24559. Re-order the visibility and deprecation macros
to fix the build.

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

Added: 


Modified: 
libcxx/include/__locale
libcxx/src/locale.cpp

Removed: 




diff  --git a/libcxx/include/__locale b/libcxx/include/__locale
index 4e9e0c08acf0..7b7331d74a01 100644
--- a/libcxx/include/__locale
+++ b/libcxx/include/__locale
@@ -1078,7 +1078,7 @@ protected:
 // template <> class codecvt // deprecated in C++20
 
 template <>
-class _LIBCPP_TYPE_VIS _LIBCPP_DEPRECATED_IN_CXX20 codecvt
+class _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_TYPE_VIS codecvt
 : public locale::facet,
   public codecvt_base
 {
@@ -1254,7 +1254,7 @@ protected:
 // template <> class codecvt // deprecated in C++20
 
 template <>
-class _LIBCPP_TYPE_VIS _LIBCPP_DEPRECATED_IN_CXX20 codecvt
+class _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_TYPE_VIS codecvt
 : public locale::facet,
   public codecvt_base
 {
@@ -1453,8 +1453,8 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP
 
 _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS 
codecvt_byname)
 _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS 
codecvt_byname)
-_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS 
_LIBCPP_DEPRECATED_IN_CXX20 codecvt_byname) // 
deprecated in C++20
-_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS 
_LIBCPP_DEPRECATED_IN_CXX20 codecvt_byname) // 
deprecated in C++20
+_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_DEPRECATED_IN_CXX20 
_LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname) // 
deprecated in C++20
+_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_DEPRECATED_IN_CXX20 
_LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname) // 
deprecated in C++20
 #ifndef _LIBCPP_NO_HAS_CHAR8_T
 _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS 
codecvt_byname) // C++20
 _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS 
codecvt_byname) // C++20

diff  --git a/libcxx/src/locale.cpp b/libcxx/src/locale.cpp
index 42bac3c371cd..f109389f68f3 100644
--- a/libcxx/src/locale.cpp
+++ b/libcxx/src/locale.cpp
@@ -6334,8 +6334,8 @@ template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS 
messages_byname
 
 template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS codecvt_byname;
 template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS 
codecvt_byname;
-template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS 
_LIBCPP_DEPRECATED_IN_CXX20 codecvt_byname;
-template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS 
_LIBCPP_DEPRECATED_IN_CXX20 codecvt_byname;
+template class _LIBCPP_DEPRECATED_IN_CXX20 
_LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS codecvt_byname;
+template class _LIBCPP_DEPRECATED_IN_CXX20 
_LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS codecvt_byname;
 #ifndef _LIBCPP_NO_HAS_CHAR8_T
 template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS 
codecvt_byname;
 template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS 
codecvt_byname;



___
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] [compiler-rt] 84de4fa - GetMacosAlignedVersion() fails if sysctl is not setup

2021-01-15 Thread Julian Lettner via llvm-branch-commits

Author: Julian Lettner
Date: 2021-01-15T11:42:25-08:00
New Revision: 84de4faf4cae2885056c608db8256e9f039050b3

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

LOG: GetMacosAlignedVersion() fails if sysctl is not setup

`GetMacosAlignedVersion()` fails for ASan-ified launchd because the
sanitizer initialization code runs before `sysctl` has been setup by
launchd.  In this situation, `sysctl kern.osproductversion` returns a
non-empty string that does not match our expectations of a
well-formatted version string.

Retrieving the kernel version (via `sysctl kern.osrelease`) still works,
so we can use it to add a fallback for this corner case.

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

Added: 


Modified: 
compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp

Removed: 




diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp 
b/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
index 6fe6991bc816..2b53d7d730d7 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
@@ -620,6 +620,23 @@ constexpr u16 GetOSMajorKernelOffset() {
 
 using VersStr = char[64];
 
+static uptr ApproximateOSVersionViaKernelVersion(VersStr vers) {
+  u16 kernel_major = GetDarwinKernelVersion().major;
+  u16 offset = GetOSMajorKernelOffset();
+  CHECK_GE(kernel_major, offset);
+  u16 os_major = kernel_major - offset;
+
+  const char *format = "%d.0";
+  if (TARGET_OS_OSX) {
+if (os_major >= 16) {  // macOS 11+
+  os_major -= 5;
+} else {  // macOS 10.15 and below
+  format = "10.%d";
+}
+  }
+  return internal_snprintf(vers, sizeof(VersStr), format, os_major);
+}
+
 static void GetOSVersion(VersStr vers) {
   uptr len = sizeof(VersStr);
   if (SANITIZER_IOSSIM) {
@@ -633,17 +650,19 @@ static void GetOSVersion(VersStr vers) {
   } else {
 int res =
 internal_sysctlbyname("kern.osproductversion", vers, , nullptr, 0);
-if (res) {
-  // Fallback for XNU 17 (macOS 10.13) and below that do not provide the
-  // `kern.osproductversion` property.
-  u16 kernel_major = GetDarwinKernelVersion().major;
-  u16 offset = GetOSMajorKernelOffset();
-  CHECK_LE(kernel_major, 17);
-  CHECK_GE(kernel_major, offset);
-  u16 os_major = kernel_major - offset;
-
-  auto format = TARGET_OS_OSX ? "10.%d" : "%d.0";
-  len = internal_snprintf(vers, len, format, os_major);
+
+// XNU 17 (macOS 10.13) and below do not provide the sysctl
+// `kern.osproductversion` entry (res != 0).
+bool no_os_version = res != 0;
+
+// For launchd, sanitizer initialization runs before sysctl is setup
+// (res == 0 && len != strlen(vers), vers is not a valid version).  
However,
+// the kernel version `kern.osrelease` is available.
+bool launchd = (res == 0 && internal_strlen(vers) < 3);
+if (launchd) CHECK_EQ(internal_getpid(), 1);
+
+if (no_os_version || launchd) {
+  len = ApproximateOSVersionViaKernelVersion(vers);
 }
   }
   CHECK_LT(len, sizeof(VersStr));
@@ -681,7 +700,7 @@ static void MapToMacos(u16 *major, u16 *minor) {
 }
 
 static MacosVersion GetMacosAlignedVersionInternal() {
-  VersStr vers;
+  VersStr vers = {};
   GetOSVersion(vers);
 
   u16 major, minor;
@@ -707,7 +726,7 @@ MacosVersion GetMacosAlignedVersion() {
 }
 
 DarwinKernelVersion GetDarwinKernelVersion() {
-  VersStr vers;
+  VersStr vers = {};
   uptr len = sizeof(VersStr);
   int res = internal_sysctlbyname("kern.osrelease", vers, , nullptr, 0);
   CHECK_EQ(res, 0);



___
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] 86e604c - [RISCV] Add implementation of targetShrinkDemandedConstant to optimize AND immediates.

2021-01-15 Thread Craig Topper via llvm-branch-commits

Author: Craig Topper
Date: 2021-01-15T11:14:14-08:00
New Revision: 86e604c4d68528478333a8901d7c79c09ca16fa8

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

LOG: [RISCV] Add implementation of targetShrinkDemandedConstant to optimize AND 
immediates.

SimplifyDemandedBits can remove set bits from immediates from instructions
like AND/OR/XOR. This can prevent them from being efficiently
codegened on RISCV.

This adds an initial version that tries to keep or form 12 bit
sign extended immediates for AND operations to enable use of ANDI.
If that doesn't work we'll try to create a 32 bit sign extended immediate
to use LUI+ADDIW.

More optimizations are possible for different size immediates or
different operations. But this is a good starting point that already
has test coverage.

Reviewed By: frasercrmck

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

Added: 


Modified: 
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
llvm/lib/Target/RISCV/RISCVISelLowering.h
llvm/test/CodeGen/RISCV/copysign-casts.ll
llvm/test/CodeGen/RISCV/frame-info.ll
llvm/test/CodeGen/RISCV/half-bitmanip-dagcombines.ll
llvm/test/CodeGen/RISCV/rv64Zbp.ll
llvm/test/CodeGen/RISCV/srem-lkk.ll
llvm/test/CodeGen/RISCV/srem-vector-lkk.ll
llvm/test/CodeGen/RISCV/stack-realignment-with-variable-sized-objects.ll
llvm/test/CodeGen/RISCV/vararg.ll

Removed: 




diff  --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp 
b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index 9b034e594f63..16e3a94839c6 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -1900,6 +1900,71 @@ bool RISCVTargetLowering::isDesirableToCommuteWithShift(
   return true;
 }
 
+bool RISCVTargetLowering::targetShrinkDemandedConstant(
+SDValue Op, const APInt , const APInt ,
+TargetLoweringOpt ) const {
+  // Delay this optimization as late as possible.
+  if (!TLO.LegalOps)
+return false;
+
+  EVT VT = Op.getValueType();
+  if (VT.isVector())
+return false;
+
+  // Only handle AND for now.
+  if (Op.getOpcode() != ISD::AND)
+return false;
+
+  ConstantSDNode *C = dyn_cast(Op.getOperand(1));
+  if (!C)
+return false;
+
+  const APInt  = C->getAPIntValue();
+
+  // Clear all non-demanded bits initially.
+  APInt ShrunkMask = Mask & DemandedBits;
+
+  // If the shrunk mask fits in sign extended 12 bits, let the target
+  // independent code apply it.
+  if (ShrunkMask.isSignedIntN(12))
+return false;
+
+  // Try to make a smaller immediate by setting undemanded bits.
+
+  // We need to be able to make a negative number through a combination of mask
+  // and undemanded bits.
+  APInt ExpandedMask = Mask | ~DemandedBits;
+  if (!ExpandedMask.isNegative())
+return false;
+
+  // What is the fewest number of bits we need to represent the negative 
number.
+  unsigned MinSignedBits = ExpandedMask.getMinSignedBits();
+
+  // Try to make a 12 bit negative immediate. If that fails try to make a 32
+  // bit negative immediate unless the shrunk immediate already fits in 32 
bits.
+  APInt NewMask = ShrunkMask;
+  if (MinSignedBits <= 12)
+NewMask.setBitsFrom(11);
+  else if (MinSignedBits <= 32 && !ShrunkMask.isSignedIntN(32))
+NewMask.setBitsFrom(31);
+  else
+return false;
+
+  // Sanity check that our new mask is a subset of the demanded mask.
+  assert(NewMask.isSubsetOf(ExpandedMask));
+
+  // If we aren't changing the mask, just return true to keep it and prevent
+  // the caller from optimizing.
+  if (NewMask == Mask)
+return true;
+
+  // Replace the constant with the new mask.
+  SDLoc DL(Op);
+  SDValue NewC = TLO.DAG.getConstant(NewMask, DL, VT);
+  SDValue NewOp = TLO.DAG.getNode(ISD::AND, DL, VT, Op.getOperand(0), NewC);
+  return TLO.CombineTo(Op, NewOp);
+}
+
 void RISCVTargetLowering::computeKnownBitsForTargetNode(const SDValue Op,
 KnownBits ,
 const APInt 
,

diff  --git a/llvm/lib/Target/RISCV/RISCVISelLowering.h 
b/llvm/lib/Target/RISCV/RISCVISelLowering.h
index 081d62a33ef0..b1f6e55766ff 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.h
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.h
@@ -131,6 +131,10 @@ class RISCVTargetLowering : public TargetLowering {
 
   SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo ) const override;
 
+  bool targetShrinkDemandedConstant(SDValue Op, const APInt ,
+const APInt ,
+TargetLoweringOpt ) const override;
+
   void computeKnownBitsForTargetNode(const SDValue Op,
  KnownBits ,
  const APInt ,

diff  --git 

[llvm-branch-commits] [mlir] d0cb0d3 - [mlir] Add Complex dialect.

2021-01-15 Thread Alexander Belyaev via llvm-branch-commits

Author: Alexander Belyaev
Date: 2021-01-15T19:58:10+01:00
New Revision: d0cb0d30a431578ecedb98c57780154789f3c594

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

LOG: [mlir] Add Complex dialect.

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

Added: 
mlir/include/mlir/Conversion/ComplexToLLVM/ComplexToLLVM.h
mlir/include/mlir/Dialect/Complex/CMakeLists.txt
mlir/include/mlir/Dialect/Complex/IR/CMakeLists.txt
mlir/include/mlir/Dialect/Complex/IR/Complex.h
mlir/include/mlir/Dialect/Complex/IR/ComplexBase.td
mlir/include/mlir/Dialect/Complex/IR/ComplexOps.td
mlir/lib/Conversion/ComplexToLLVM/CMakeLists.txt
mlir/lib/Conversion/ComplexToLLVM/ComplexToLLVM.cpp
mlir/lib/Dialect/Complex/CMakeLists.txt
mlir/lib/Dialect/Complex/IR/CMakeLists.txt
mlir/lib/Dialect/Complex/IR/ComplexDialect.cpp
mlir/lib/Dialect/Complex/IR/ComplexOps.cpp
mlir/test/Conversion/ComplexToLLVM/convert-to-llvm.mlir
mlir/test/Dialect/Complex/ops.mlir

Modified: 
mlir/include/mlir/Conversion/Passes.h
mlir/include/mlir/Conversion/Passes.td
mlir/include/mlir/Dialect/CMakeLists.txt
mlir/include/mlir/InitAllDialects.h
mlir/lib/Conversion/CMakeLists.txt
mlir/lib/Conversion/PassDetail.h
mlir/lib/Dialect/CMakeLists.txt
mlir/test/mlir-opt/commandline.mlir

Removed: 




diff  --git a/mlir/include/mlir/Conversion/ComplexToLLVM/ComplexToLLVM.h 
b/mlir/include/mlir/Conversion/ComplexToLLVM/ComplexToLLVM.h
new file mode 100644
index ..3dab2a136b28
--- /dev/null
+++ b/mlir/include/mlir/Conversion/ComplexToLLVM/ComplexToLLVM.h
@@ -0,0 +1,29 @@
+//===- ComplexToLLVM.h - Utils to convert from the complex dialect 
===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+#ifndef MLIR_CONVERSION_COMPLEXTOLLVM_COMPLEXTOLLVM_H_
+#define MLIR_CONVERSION_COMPLEXTOLLVM_COMPLEXTOLLVM_H_
+
+#include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h"
+#include "mlir/Transforms/DialectConversion.h"
+
+namespace mlir {
+class MLIRContext;
+class ModuleOp;
+template 
+class OperationPass;
+
+/// Populate the given list with patterns that convert from Complex to LLVM.
+void populateComplexToLLVMConversionPatterns(
+LLVMTypeConverter , OwningRewritePatternList );
+
+/// Create a pass to convert Complex operations to the LLVMIR dialect.
+std::unique_ptr> createConvertComplexToLLVMPass();
+
+} // namespace mlir
+
+#endif // MLIR_CONVERSION_COMPLEXTOLLVM_COMPLEXTOLLVM_H_

diff  --git a/mlir/include/mlir/Conversion/Passes.h 
b/mlir/include/mlir/Conversion/Passes.h
index 2e07a795b6c7..121dae6f46f8 100644
--- a/mlir/include/mlir/Conversion/Passes.h
+++ b/mlir/include/mlir/Conversion/Passes.h
@@ -11,6 +11,7 @@
 
 #include "mlir/Conversion/AffineToStandard/AffineToStandard.h"
 #include "mlir/Conversion/AsyncToLLVM/AsyncToLLVM.h"
+#include "mlir/Conversion/ComplexToLLVM/ComplexToLLVM.h"
 #include "mlir/Conversion/GPUCommon/GPUCommonPass.h"
 #include "mlir/Conversion/GPUToNVVM/GPUToNVVMPass.h"
 #include "mlir/Conversion/GPUToROCDL/GPUToROCDLPass.h"

diff  --git a/mlir/include/mlir/Conversion/Passes.td 
b/mlir/include/mlir/Conversion/Passes.td
index e8ca058adedd..aa228784e48a 100644
--- a/mlir/include/mlir/Conversion/Passes.td
+++ b/mlir/include/mlir/Conversion/Passes.td
@@ -88,6 +88,16 @@ def ConvertAsyncToLLVM : Pass<"convert-async-to-llvm", 
"ModuleOp"> {
   let dependentDialects = ["LLVM::LLVMDialect"];
 }
 
+//===--===//
+// ComplexToLLVM
+//===--===//
+
+def ConvertComplexToLLVM : Pass<"convert-complex-to-llvm", "ModuleOp"> {
+  let summary = "Convert Complex dialect to LLVM dialect";
+  let constructor = "mlir::createConvertComplexToLLVMPass()";
+  let dependentDialects = ["LLVM::LLVMDialect"];
+}
+
 
//===--===//
 // GPUCommon
 
//===--===//

diff  --git a/mlir/include/mlir/Dialect/CMakeLists.txt 
b/mlir/include/mlir/Dialect/CMakeLists.txt
index 51b423ee3b98..df0c751b6ba6 100644
--- a/mlir/include/mlir/Dialect/CMakeLists.txt
+++ b/mlir/include/mlir/Dialect/CMakeLists.txt
@@ -3,6 +3,7 @@ add_subdirectory(Async)
 add_subdirectory(ArmNeon)
 add_subdirectory(ArmSVE)
 add_subdirectory(AVX512)
+add_subdirectory(Complex)
 add_subdirectory(GPU)
 add_subdirectory(Linalg)
 add_subdirectory(LLVMIR)

diff  --git 

[llvm-branch-commits] [llvm] cc90d41 - [MIPatternMatch] Add m_OneNonDBGUse

2021-01-15 Thread Jessica Paquette via llvm-branch-commits

Author: Jessica Paquette
Date: 2021-01-15T10:18:46-08:00
New Revision: cc90d41945f6c72d92fbbc6e7b38ceff6e7e1e93

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

LOG: [MIPatternMatch] Add m_OneNonDBGUse

Add a matcher that checks if the given subpattern has only one non-debug use.

Also improve existing m_OneUse testcase.

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

Added: 


Modified: 
llvm/include/llvm/CodeGen/GlobalISel/MIPatternMatch.h
llvm/unittests/CodeGen/GlobalISel/PatternMatchTest.cpp

Removed: 




diff  --git a/llvm/include/llvm/CodeGen/GlobalISel/MIPatternMatch.h 
b/llvm/include/llvm/CodeGen/GlobalISel/MIPatternMatch.h
index ed93dae24c05..55d6d365fbb4 100644
--- a/llvm/include/llvm/CodeGen/GlobalISel/MIPatternMatch.h
+++ b/llvm/include/llvm/CodeGen/GlobalISel/MIPatternMatch.h
@@ -39,6 +39,20 @@ inline OneUse_match m_OneUse(const SubPat ) {
   return SP;
 }
 
+template  struct OneNonDBGUse_match {
+  SubPatternT SubPat;
+  OneNonDBGUse_match(const SubPatternT ) : SubPat(SP) {}
+
+  bool match(const MachineRegisterInfo , Register Reg) {
+return MRI.hasOneNonDBGUse(Reg) && SubPat.match(MRI, Reg);
+  }
+};
+
+template 
+inline OneNonDBGUse_match m_OneNonDBGUse(const SubPat ) {
+  return SP;
+}
+
 struct ConstantMatch {
   int64_t 
   ConstantMatch(int64_t ) : CR(C) {}

diff  --git a/llvm/unittests/CodeGen/GlobalISel/PatternMatchTest.cpp 
b/llvm/unittests/CodeGen/GlobalISel/PatternMatchTest.cpp
index a63a34f91545..8a5d8e783399 100644
--- a/llvm/unittests/CodeGen/GlobalISel/PatternMatchTest.cpp
+++ b/llvm/unittests/CodeGen/GlobalISel/PatternMatchTest.cpp
@@ -392,13 +392,24 @@ TEST_F(AArch64GISelMITest, MatchMiscellaneous) {
 
   LLT s64 = LLT::scalar(64);
   auto MIBAdd = B.buildAdd(s64, Copies[0], Copies[1]);
-  // Make multiple uses of this add.
+  Register Reg = MIBAdd.getReg(0);
+
+  // Only one use of Reg.
   B.buildCast(LLT::pointer(0, 32), MIBAdd);
+  EXPECT_TRUE(mi_match(Reg, *MRI, m_OneUse(m_GAdd(m_Reg(), m_Reg();
+  EXPECT_TRUE(mi_match(Reg, *MRI, m_OneNonDBGUse(m_GAdd(m_Reg(), m_Reg();
+
+  // Add multiple debug uses of Reg.
+  B.buildInstr(TargetOpcode::DBG_VALUE, {}, {Reg})->getOperand(0).setIsDebug();
+  B.buildInstr(TargetOpcode::DBG_VALUE, {}, {Reg})->getOperand(0).setIsDebug();
+
+  EXPECT_FALSE(mi_match(Reg, *MRI, m_OneUse(m_GAdd(m_Reg(), m_Reg();
+  EXPECT_TRUE(mi_match(Reg, *MRI, m_OneNonDBGUse(m_GAdd(m_Reg(), m_Reg();
+
+  // Multiple non-debug uses of Reg.
   B.buildCast(LLT::pointer(1, 32), MIBAdd);
-  bool match = mi_match(MIBAdd.getReg(0), *MRI, m_GAdd(m_Reg(), m_Reg()));
-  EXPECT_TRUE(match);
-  match = mi_match(MIBAdd.getReg(0), *MRI, m_OneUse(m_GAdd(m_Reg(), m_Reg(;
-  EXPECT_FALSE(match);
+  EXPECT_FALSE(mi_match(Reg, *MRI, m_OneUse(m_GAdd(m_Reg(), m_Reg();
+  EXPECT_FALSE(mi_match(Reg, *MRI, m_OneNonDBGUse(m_GAdd(m_Reg(), m_Reg();
 }
 
 TEST_F(AArch64GISelMITest, MatchSpecificConstant) {



___
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] f5abf0b - [ARM] Tail predication with constant loop bounds

2021-01-15 Thread David Green via llvm-branch-commits

Author: David Green
Date: 2021-01-15T18:17:31Z
New Revision: f5abf0bd485a1fa7e332f5f8266c25755d385a8a

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

LOG: [ARM] Tail predication with constant loop bounds

The TripCount for a predicated vector loop body will be
ceil(ElementCount/Width). This alters the conversion of an
active.lane.mask to a VCPT intrinsics to match.

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

Added: 


Modified: 
llvm/lib/Target/ARM/MVETailPredication.cpp
llvm/test/CodeGen/Thumb2/LowOverheadLoops/constbound.ll
llvm/test/CodeGen/Thumb2/LowOverheadLoops/tp-multiple-vpst.ll

Removed: 




diff  --git a/llvm/lib/Target/ARM/MVETailPredication.cpp 
b/llvm/lib/Target/ARM/MVETailPredication.cpp
index 8055b5cf500d..b705208660df 100644
--- a/llvm/lib/Target/ARM/MVETailPredication.cpp
+++ b/llvm/lib/Target/ARM/MVETailPredication.cpp
@@ -230,18 +230,16 @@ bool MVETailPredication::IsSafeActiveMask(IntrinsicInst 
*ActiveLaneMask,
 }
 
 // Calculate 2 tripcount values and check that they are consistent with
-// each other:
-// i) The number of loop iterations extracted from the set.loop.iterations
-//intrinsic, multipled by the vector width:
-uint64_t TC1 = TC->getZExtValue() * VectorWidth;
-
-// ii) TC1 has to be equal to TC + 1, with the + 1 to compensate for start
-// counting from 0.
-uint64_t TC2 = ConstElemCount->getZExtValue() + 1;
-
-// If the tripcount values are inconsistent, we don't want to insert the
-// VCTP and trigger tail-predication; it's better to keep intrinsic
-// get.active.lane.mask and legalize this.
+// each other. The TripCount for a predicated vector loop body is
+// ceil(ElementCount/Width), or floor((ElementCount+Width-1)/Width) as we
+// work it out here.
+uint64_t TC1 = TC->getZExtValue();
+uint64_t TC2 =
+(ConstElemCount->getZExtValue() + VectorWidth - 1) / VectorWidth;
+
+// If the tripcount values are inconsistent, we can't insert the VCTP and
+// trigger tail-predication; keep the intrinsic as a get.active.lane.mask
+// and legalize this.
 if (TC1 != TC2) {
   LLVM_DEBUG(dbgs() << "ARM TP: inconsistent constant tripcount values: "
  << TC1 << " from set.loop.iterations, and "

diff  --git a/llvm/test/CodeGen/Thumb2/LowOverheadLoops/constbound.ll 
b/llvm/test/CodeGen/Thumb2/LowOverheadLoops/constbound.ll
index 480680bee89d..d1f5a07bc4a9 100644
--- a/llvm/test/CodeGen/Thumb2/LowOverheadLoops/constbound.ll
+++ b/llvm/test/CodeGen/Thumb2/LowOverheadLoops/constbound.ll
@@ -62,41 +62,17 @@ define dso_local i32 @test_501_504(i32* nocapture readonly 
%x) {
 ; CHECK:   @ %bb.0: @ %entry
 ; CHECK-NEXT:.save {r7, lr}
 ; CHECK-NEXT:push {r7, lr}
-; CHECK-NEXT:adr r2, .LCPI1_0
-; CHECK-NEXT:mov.w lr, #126
-; CHECK-NEXT:vldrw.u32 q0, [r2]
-; CHECK-NEXT:adr r2, .LCPI1_1
-; CHECK-NEXT:vldrw.u32 q1, [r2]
-; CHECK-NEXT:dls lr, lr
-; CHECK-NEXT:movs r1, #0
+; CHECK-NEXT:movw r1, #501
 ; CHECK-NEXT:movs r2, #0
+; CHECK-NEXT:dlstp.32 lr, r1
 ; CHECK-NEXT:  .LBB1_1: @ %vector.body
 ; CHECK-NEXT:@ =>This Inner Loop Header: Depth=1
-; CHECK-NEXT:vadd.i32 q2, q0, r1
-; CHECK-NEXT:vdup.32 q3, r1
-; CHECK-NEXT:vcmp.u32 hi, q3, q2
-; CHECK-NEXT:adds r1, #4
-; CHECK-NEXT:vpnot
-; CHECK-NEXT:vpsttt
-; CHECK-NEXT:vcmpt.u32 hi, q1, q2
-; CHECK-NEXT:vldrwt.u32 q2, [r0], #16
-; CHECK-NEXT:vaddvat.u32 r2, q2
-; CHECK-NEXT:le lr, .LBB1_1
+; CHECK-NEXT:vldrw.u32 q0, [r0], #16
+; CHECK-NEXT:vaddva.u32 r2, q0
+; CHECK-NEXT:letp lr, .LBB1_1
 ; CHECK-NEXT:  @ %bb.2: @ %for.cond.cleanup
 ; CHECK-NEXT:mov r0, r2
 ; CHECK-NEXT:pop {r7, pc}
-; CHECK-NEXT:.p2align 4
-; CHECK-NEXT:  @ %bb.3:
-; CHECK-NEXT:  .LCPI1_0:
-; CHECK-NEXT:.long 0 @ 0x0
-; CHECK-NEXT:.long 1 @ 0x1
-; CHECK-NEXT:.long 2 @ 0x2
-; CHECK-NEXT:.long 3 @ 0x3
-; CHECK-NEXT:  .LCPI1_1:
-; CHECK-NEXT:.long 501 @ 0x1f5
-; CHECK-NEXT:.long 501 @ 0x1f5
-; CHECK-NEXT:.long 501 @ 0x1f5
-; CHECK-NEXT:.long 501 @ 0x1f5
 entry:
   br label %vector.body
 
@@ -123,41 +99,17 @@ define dso_local i32 @test_502_504(i32* nocapture readonly 
%x) {
 ; CHECK:   @ %bb.0: @ %entry
 ; CHECK-NEXT:.save {r7, lr}
 ; CHECK-NEXT:push {r7, lr}
-; CHECK-NEXT:adr r2, .LCPI2_0
-; CHECK-NEXT:mov.w lr, #126
-; CHECK-NEXT:vldrw.u32 q0, [r2]
-; CHECK-NEXT:adr r2, .LCPI2_1
-; CHECK-NEXT:vldrw.u32 q1, [r2]
-; CHECK-NEXT:dls lr, lr
-; CHECK-NEXT:movs r1, #0
+; CHECK-NEXT:mov.w r1, #502
 ; CHECK-NEXT:movs r2, #0
+; CHECK-NEXT:dlstp.32 lr, r1
 ; CHECK-NEXT:  .LBB2_1: @ %vector.body
 ; CHECK-NEXT:@ =>This Inner Loop 

[llvm-branch-commits] [llvm] a0770f9 - [ARM] Constant tripcount tail predication loop tests. NFC

2021-01-15 Thread David Green via llvm-branch-commits

Author: David Green
Date: 2021-01-15T18:02:07Z
New Revision: a0770f9e4e923292066dd095cf01a28671e40ad6

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

LOG: [ARM] Constant tripcount tail predication loop tests. NFC

Added: 
llvm/test/CodeGen/Thumb2/LowOverheadLoops/constbound.ll

Modified: 


Removed: 




diff  --git a/llvm/test/CodeGen/Thumb2/LowOverheadLoops/constbound.ll 
b/llvm/test/CodeGen/Thumb2/LowOverheadLoops/constbound.ll
new file mode 100644
index ..480680bee89d
--- /dev/null
+++ b/llvm/test/CodeGen/Thumb2/LowOverheadLoops/constbound.ll
@@ -0,0 +1,277 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=thumbv8.1m.main-none-none-eabi -mattr=+mve %s -o - | 
FileCheck %s
+
+define dso_local i32 @test_500_504(i32* nocapture readonly %x) {
+; CHECK-LABEL: test_500_504:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:.save {r7, lr}
+; CHECK-NEXT:push {r7, lr}
+; CHECK-NEXT:mov.w lr, #126
+; CHECK-NEXT:adr r2, .LCPI0_0
+; CHECK-NEXT:vldrw.u32 q0, [r2]
+; CHECK-NEXT:mov.w r2, #500
+; CHECK-NEXT:dls lr, lr
+; CHECK-NEXT:vdup.32 q1, r2
+; CHECK-NEXT:movs r1, #0
+; CHECK-NEXT:movs r2, #0
+; CHECK-NEXT:  .LBB0_1: @ %vector.body
+; CHECK-NEXT:@ =>This Inner Loop Header: Depth=1
+; CHECK-NEXT:vadd.i32 q2, q0, r1
+; CHECK-NEXT:vdup.32 q3, r1
+; CHECK-NEXT:vcmp.u32 hi, q3, q2
+; CHECK-NEXT:adds r1, #4
+; CHECK-NEXT:vpnot
+; CHECK-NEXT:vpsttt
+; CHECK-NEXT:vcmpt.u32 hi, q1, q2
+; CHECK-NEXT:vldrwt.u32 q2, [r0], #16
+; CHECK-NEXT:vaddvat.u32 r2, q2
+; CHECK-NEXT:le lr, .LBB0_1
+; CHECK-NEXT:  @ %bb.2: @ %for.cond.cleanup
+; CHECK-NEXT:mov r0, r2
+; CHECK-NEXT:pop {r7, pc}
+; CHECK-NEXT:.p2align 4
+; CHECK-NEXT:  @ %bb.3:
+; CHECK-NEXT:  .LCPI0_0:
+; CHECK-NEXT:.long 0 @ 0x0
+; CHECK-NEXT:.long 1 @ 0x1
+; CHECK-NEXT:.long 2 @ 0x2
+; CHECK-NEXT:.long 3 @ 0x3
+entry:
+  br label %vector.body
+
+vector.body:  ; preds = %vector.body, 
%entry
+  %index = phi i32 [ 0, %entry ], [ %index.next, %vector.body ]
+  %vec.phi = phi i32 [ 0, %entry ], [ %4, %vector.body ]
+  %active.lane.mask = call <4 x i1> @llvm.get.active.lane.mask.v4i1.i32(i32 
%index, i32 500)
+  %0 = getelementptr inbounds i32, i32* %x, i32 %index
+  %1 = bitcast i32* %0 to <4 x i32>*
+  %wide.masked.load = call <4 x i32> @llvm.masked.load.v4i32.p0v4i32(<4 x 
i32>* %1, i32 4, <4 x i1> %active.lane.mask, <4 x i32> undef)
+  %2 = select <4 x i1> %active.lane.mask, <4 x i32> %wide.masked.load, <4 x 
i32> zeroinitializer
+  %3 = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %2)
+  %4 = add i32 %3, %vec.phi
+  %index.next = add i32 %index, 4
+  %5 = icmp eq i32 %index.next, 504
+  br i1 %5, label %for.cond.cleanup, label %vector.body
+
+for.cond.cleanup: ; preds = %vector.body
+  ret i32 %4
+}
+
+define dso_local i32 @test_501_504(i32* nocapture readonly %x) {
+; CHECK-LABEL: test_501_504:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:.save {r7, lr}
+; CHECK-NEXT:push {r7, lr}
+; CHECK-NEXT:adr r2, .LCPI1_0
+; CHECK-NEXT:mov.w lr, #126
+; CHECK-NEXT:vldrw.u32 q0, [r2]
+; CHECK-NEXT:adr r2, .LCPI1_1
+; CHECK-NEXT:vldrw.u32 q1, [r2]
+; CHECK-NEXT:dls lr, lr
+; CHECK-NEXT:movs r1, #0
+; CHECK-NEXT:movs r2, #0
+; CHECK-NEXT:  .LBB1_1: @ %vector.body
+; CHECK-NEXT:@ =>This Inner Loop Header: Depth=1
+; CHECK-NEXT:vadd.i32 q2, q0, r1
+; CHECK-NEXT:vdup.32 q3, r1
+; CHECK-NEXT:vcmp.u32 hi, q3, q2
+; CHECK-NEXT:adds r1, #4
+; CHECK-NEXT:vpnot
+; CHECK-NEXT:vpsttt
+; CHECK-NEXT:vcmpt.u32 hi, q1, q2
+; CHECK-NEXT:vldrwt.u32 q2, [r0], #16
+; CHECK-NEXT:vaddvat.u32 r2, q2
+; CHECK-NEXT:le lr, .LBB1_1
+; CHECK-NEXT:  @ %bb.2: @ %for.cond.cleanup
+; CHECK-NEXT:mov r0, r2
+; CHECK-NEXT:pop {r7, pc}
+; CHECK-NEXT:.p2align 4
+; CHECK-NEXT:  @ %bb.3:
+; CHECK-NEXT:  .LCPI1_0:
+; CHECK-NEXT:.long 0 @ 0x0
+; CHECK-NEXT:.long 1 @ 0x1
+; CHECK-NEXT:.long 2 @ 0x2
+; CHECK-NEXT:.long 3 @ 0x3
+; CHECK-NEXT:  .LCPI1_1:
+; CHECK-NEXT:.long 501 @ 0x1f5
+; CHECK-NEXT:.long 501 @ 0x1f5
+; CHECK-NEXT:.long 501 @ 0x1f5
+; CHECK-NEXT:.long 501 @ 0x1f5
+entry:
+  br label %vector.body
+
+vector.body:  ; preds = %vector.body, 
%entry
+  %index = phi i32 [ 0, %entry ], [ %index.next, %vector.body ]
+  %vec.phi = phi i32 [ 0, %entry ], [ %4, %vector.body ]
+  %active.lane.mask = call <4 x i1> @llvm.get.active.lane.mask.v4i1.i32(i32 
%index, i32 501)
+  %0 = getelementptr inbounds i32, i32* %x, i32 %index
+  %1 = bitcast i32* %0 to <4 x i32>*
+  %wide.masked.load 

[llvm-branch-commits] [clang] 6227069 - [DebugInfo][CodeView] Change in line tables only mode to emit type information

2021-01-15 Thread Amy Huang via llvm-branch-commits

Author: Amy Huang
Date: 2021-01-15T09:28:27-08:00
New Revision: 6227069bdce6b0c3c22f0a0c8f1aef705985125a

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

LOG: [DebugInfo][CodeView] Change in line tables only mode to emit type 
information
for function scopes, rather than using the qualified name.

In line-tables-only mode, we used to emit qualified names as the display name 
for functions when using CodeView.
This patch changes to emitting the parent scopes instead, with forward 
declarations for class types.
The total object file size ends up being slightly smaller than if we use the 
full qualified names.

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

Added: 
clang/test/CodeGenCXX/debug-info-codeview-scopes.cpp

Modified: 
clang/lib/CodeGen/CGDebugInfo.cpp
clang/test/CodeGenCXX/debug-info-codeview-display-name.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 881ee24546c2..00606d3ae507 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -254,24 +254,12 @@ StringRef CGDebugInfo::getFunctionName(const FunctionDecl 
*FD) {
   FunctionTemplateSpecializationInfo *Info =
   FD->getTemplateSpecializationInfo();
 
-  // Emit the unqualified name in normal operation. LLVM and the debugger can
-  // compute the fully qualified name from the scope chain. If we're only
-  // emitting line table info, there won't be any scope chains, so emit the
-  // fully qualified name here so that stack traces are more accurate.
-  // FIXME: Do this when emitting DWARF as well as when emitting CodeView after
-  // evaluating the size impact.
-  bool UseQualifiedName = DebugKind == codegenoptions::DebugLineTablesOnly &&
-  CGM.getCodeGenOpts().EmitCodeView;
-
-  if (!Info && FII && !UseQualifiedName)
+  if (!Info && FII)
 return FII->getName();
 
   SmallString<128> NS;
   llvm::raw_svector_ostream OS(NS);
-  if (!UseQualifiedName)
-FD->printName(OS);
-  else
-FD->printQualifiedName(OS, getPrintingPolicy());
+  FD->printName(OS);
 
   // Add any template specialization args.
   if (Info) {
@@ -1058,7 +1046,10 @@ CGDebugInfo::getOrCreateRecordFwdDecl(const RecordType 
*Ty,
   Flags |= llvm::DINode::FlagNonTrivial;
 
   // Create the type.
-  SmallString<256> Identifier = getTypeIdentifier(Ty, CGM, TheCU);
+  SmallString<256> Identifier;
+  // Don't include a linkage name in line tables only.
+  if (CGM.getCodeGenOpts().hasReducedDebugInfo())
+Identifier = getTypeIdentifier(Ty, CGM, TheCU);
   llvm::DICompositeType *RetTy = DBuilder.createReplaceableCompositeType(
   getTagForRecord(RD), RDName, Ctx, DefUnit, Line, 0, Size, Align, Flags,
   Identifier);
@@ -2326,6 +2317,9 @@ static bool 
shouldOmitDefinition(codegenoptions::DebugInfoKind DebugKind,
 if (ES->hasExternalDefinitions(RD) == ExternalASTSource::EK_Always)
   return true;
 
+  if (DebugKind == codegenoptions::DebugLineTablesOnly)
+return true;
+
   if (DebugKind > codegenoptions::LimitedDebugInfo)
 return false;
 
@@ -3473,7 +3467,11 @@ void CGDebugInfo::collectFunctionDeclProps(GlobalDecl 
GD, llvm::DIFile *Unit,
   DebugKind <= 
codegenoptions::DebugLineTablesOnly))
 LinkageName = StringRef();
 
-  if (CGM.getCodeGenOpts().hasReducedDebugInfo()) {
+  // Emit the function scope in line tables only mode (if CodeView) to
+  // 
diff erentiate between function names.
+  if (CGM.getCodeGenOpts().hasReducedDebugInfo() ||
+  (DebugKind == codegenoptions::DebugLineTablesOnly &&
+   CGM.getCodeGenOpts().EmitCodeView)) {
 if (const NamespaceDecl *NSDecl =
 dyn_cast_or_null(FD->getDeclContext()))
   FDContext = getOrCreateNamespace(NSDecl);
@@ -3482,6 +3480,8 @@ void CGDebugInfo::collectFunctionDeclProps(GlobalDecl GD, 
llvm::DIFile *Unit,
   llvm::DIScope *Mod = getParentModuleOrNull(RDecl);
   FDContext = getContextDescriptor(RDecl, Mod ? Mod : TheCU);
 }
+  }
+  if (CGM.getCodeGenOpts().hasReducedDebugInfo()) {
 // Check if it is a noreturn-marked function
 if (FD->isNoReturn())
   Flags |= llvm::DINode::FlagNoReturn;

diff  --git a/clang/test/CodeGenCXX/debug-info-codeview-display-name.cpp 
b/clang/test/CodeGenCXX/debug-info-codeview-display-name.cpp
index 15f625d8832d..935fded5e67c 100644
--- a/clang/test/CodeGenCXX/debug-info-codeview-display-name.cpp
+++ b/clang/test/CodeGenCXX/debug-info-codeview-display-name.cpp
@@ -20,11 +20,9 @@ void freefunc() { }
 
 namespace N {
   int b() { return 0; }
-// UNQUAL-DAG: "b"
-// QUAL-DAG: "N::b"
+// CHECK-DAG: "b"
   namespace { void func() { } }
-// UNQUAL-DAG: "func"
-// QUAL-DAG: "N::`anonymous namespace'::func"
+// CHECK-DAG: "func"
 }
 
 

[llvm-branch-commits] [clang] bc84f89 - [OpenCL][Docs] Fixed cross-section reference in OpenCLSupport

2021-01-15 Thread Anastasia Stulova via llvm-branch-commits

Author: Anastasia Stulova
Date: 2021-01-15T17:20:13Z
New Revision: bc84f89c71ab62d510973f64f022bee31e53af96

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

LOG: [OpenCL][Docs] Fixed cross-section reference in OpenCLSupport

Tags: #clang

Added: 


Modified: 
clang/docs/OpenCLSupport.rst

Removed: 




diff  --git a/clang/docs/OpenCLSupport.rst b/clang/docs/OpenCLSupport.rst
index 7e5bb41f7dbc..5be7e91adcaf 100644
--- a/clang/docs/OpenCLSupport.rst
+++ b/clang/docs/OpenCLSupport.rst
@@ -37,7 +37,7 @@ Clang implements language version 1.0 published in `the 
official
 release of C++ for OpenCL Documentation
 
`_.
 
-Limited support of experimental C++ libraries is described in the 
`experimental features `.
+Limited support of experimental C++ libraries is described in the 
:ref:`experimental features `.
 
 Bugzilla bugs for this functionality are typically prefixed
 with '[C++4OpenCL]' - click `here



___
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] [clang-tools-extra] d5047d7 - [clangd] Update CC Ranking model with better sampling.

2021-01-15 Thread Utkarsh Saxena via llvm-branch-commits

Author: Utkarsh Saxena
Date: 2021-01-15T18:13:24+01:00
New Revision: d5047d762f391c94939d67fc84cae25b24125694

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

LOG: [clangd] Update CC Ranking model with better sampling.

A better sampling strategy was used to generate the dataset for this
model.
New signals introduced in this model:
- NumNameInContext: Number of words in the context that matches the name
of the candidate.
- FractionNameInContext: Fraction of the words in context matching the
name of the candidate.

We remove the signal `IsForbidden` from the model and down rank
forbidden signals aggresively.

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

Added: 


Modified: 
clang-tools-extra/clangd/Quality.cpp
clang-tools-extra/clangd/quality/model/features.json
clang-tools-extra/clangd/quality/model/forest.json

Removed: 



error:
 too big or took too long to generate


___
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] [flang] b6e06a7 - [flang][driver] Copy test file into a temp dir when testing (nfc)

2021-01-15 Thread Andrzej Warzynski via llvm-branch-commits

Author: Andrzej Warzynski
Date: 2021-01-15T17:12:42Z
New Revision: b6e06a740c26b2b9d91455ad49a5009335089242

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

LOG: [flang][driver] Copy test file into a temp dir when testing (nfc)

The following driver invocation will generate an output file
in the same directory as the input file:

```
flang-new -fc1 -test-io test-input.f90
```

This is the desired behaviour. However, when testing we need to make
sure that we don't pollute the source directory. To this end, copy the
input file into a temporary directory before testing.

This is similar to https://reviews.llvm.org/D94243.

Added: 


Modified: 
flang/test/Frontend/input-output-file.f90

Removed: 




diff  --git a/flang/test/Frontend/input-output-file.f90 
b/flang/test/Frontend/input-output-file.f90
index bd7ed1558a8e..8964f163feb1 100644
--- a/flang/test/Frontend/input-output-file.f90
+++ b/flang/test/Frontend/input-output-file.f90
@@ -16,7 +16,11 @@
 ! FLANG FRONTEND DRIVER (flang-new -fc1)
 !
 ! TEST 4: Write to a file (implicit)
-! RUN: %flang-new -fc1 -test-io  %s 2>&1 && FileCheck %s --match-full-lines 
--input-file=%S/input-output-file.txt
+! This particular test case generates an output file in the same directory as 
the input file. We need to copy the input file into a
+! temporary directory to avoid polluting the source directory.
+! RUN: rm -rf %t-dir && mkdir -p %t-dir && cd %t-dir
+! RUN: cp %s .
+! RUN: %flang-new -fc1 -test-io input-output-file.f90  2>&1 && FileCheck %s 
--match-full-lines --input-file=input-output-file.txt
 ! TEST 5: Write to a file (explicit)
 ! RUN: %flang-new -fc1 -test-io  -o %t %s 2>&1 && FileCheck %s 
--match-full-lines --input-file=%t
 



___
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] 4c5066b - [TargetLowering] Don't speculatively call ComputeNumSignBits. NFC

2021-01-15 Thread Craig Topper via llvm-branch-commits

Author: Craig Topper
Date: 2021-01-15T09:09:35-08:00
New Revision: 4c5066b0789d9c38d6362a684346b68261911d29

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

LOG: [TargetLowering] Don't speculatively call ComputeNumSignBits. NFC

These methods are recursive so a little costly.

We only look at the result in one place in this function and it's
conditional. We also only need the second call if the first had
enough returned enough sign bits.

Added: 


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 6ae0a39962b33..21953373b745a 100644
--- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
@@ -6092,8 +6092,6 @@ bool TargetLowering::expandMUL_LOHI(unsigned Opcode, EVT 
VT, const SDLoc ,
 
   unsigned OuterBitSize = VT.getScalarSizeInBits();
   unsigned InnerBitSize = HiLoVT.getScalarSizeInBits();
-  unsigned LHSSB = DAG.ComputeNumSignBits(LHS);
-  unsigned RHSSB = DAG.ComputeNumSignBits(RHS);
 
   // LL, LH, RL, and RH must be either all NULL or all set to a value.
   assert((LL.getNode() && LH.getNode() && RL.getNode() && RH.getNode()) ||
@@ -6142,8 +6140,9 @@ bool TargetLowering::expandMUL_LOHI(unsigned Opcode, EVT 
VT, const SDLoc ,
 }
   }
 
-  if (!VT.isVector() && Opcode == ISD::MUL && LHSSB > InnerBitSize &&
-  RHSSB > InnerBitSize) {
+  if (!VT.isVector() && Opcode == ISD::MUL &&
+  DAG.ComputeNumSignBits(LHS) > InnerBitSize &&
+  DAG.ComputeNumSignBits(RHS) > InnerBitSize) {
 // The input values are both sign-extended.
 // TODO non-MUL case?
 if (MakeMUL_LOHI(LL, RL, Lo, Hi, true)) {



___
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] [flang] 1e1a011 - [flang] Disallow INTENT attribute on procedure dummy arguments

2021-01-15 Thread Peter Steinfeld via llvm-branch-commits

Author: Peter Steinfeld
Date: 2021-01-15T08:53:43-08:00
New Revision: 1e1a011b09d0e6e9ff62b37721906485c386708c

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

LOG: [flang] Disallow INTENT attribute on procedure dummy arguments

C843 states that "An entity with the INTENT attribute shall be a dummy
data object or a dummy procedure pointer."  This change enforces that
and fixes some tests that erroneously violated this rule.

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

Added: 


Modified: 
flang/lib/Semantics/check-declarations.cpp
flang/test/Semantics/assign03.f90
flang/test/Semantics/call09.f90
flang/test/Semantics/separate-mp02.f90

Removed: 




diff  --git a/flang/lib/Semantics/check-declarations.cpp 
b/flang/lib/Semantics/check-declarations.cpp
index 9bb82156e955..aca5392e507f 100644
--- a/flang/lib/Semantics/check-declarations.cpp
+++ b/flang/lib/Semantics/check-declarations.cpp
@@ -632,6 +632,14 @@ void CheckHelper::CheckArraySpec(
 void CheckHelper::CheckProcEntity(
 const Symbol , const ProcEntityDetails ) {
   if (details.isDummy()) {
+if (!symbol.attrs().test(Attr::POINTER) && // C843
+(symbol.attrs().test(Attr::INTENT_IN) ||
+symbol.attrs().test(Attr::INTENT_OUT) ||
+symbol.attrs().test(Attr::INTENT_INOUT))) {
+  messages_.Say("A dummy procedure without the POINTER attribute"
+" may not have an INTENT attribute"_err_en_US);
+}
+
 const Symbol *interface{details.interface().symbol()};
 if (!symbol.attrs().test(Attr::INTRINSIC) &&
 (symbol.attrs().test(Attr::ELEMENTAL) ||

diff  --git a/flang/test/Semantics/assign03.f90 
b/flang/test/Semantics/assign03.f90
index 1435342b1ead..c53bb0ed291a 100644
--- a/flang/test/Semantics/assign03.f90
+++ b/flang/test/Semantics/assign03.f90
@@ -42,7 +42,7 @@ function f()
 
   ! C1030 and 10.2.2.4 - procedure names as target of procedure pointer
   subroutine s4(s_dummy)
-procedure(s), intent(in) :: s_dummy
+procedure(s) :: s_dummy
 procedure(s), pointer :: p, q
 procedure(), pointer :: r
 integer :: i

diff  --git a/flang/test/Semantics/call09.f90 b/flang/test/Semantics/call09.f90
index e7f22e32ed44..36aaa8f4ab46 100644
--- a/flang/test/Semantics/call09.f90
+++ b/flang/test/Semantics/call09.f90
@@ -1,5 +1,8 @@
 ! RUN: %S/test_errors.sh %s %t %f18
 ! Test 15.5.2.9(2,3,5) dummy procedure requirements
+! C843
+!   An entity with the INTENT attribute shall be a dummy data object or a 
+!   dummy procedure pointer.
 
 module m
  contains
@@ -22,6 +25,10 @@ subroutine s02(p)
   subroutine s03(p)
 procedure(realfunc) :: p
   end subroutine
+  subroutine s04(p)
+!ERROR: A dummy procedure without the POINTER attribute may not have an 
INTENT attribute
+procedure(realfunc), intent(in) :: p
+  end subroutine
 
   subroutine selemental1(p)
 procedure(cos) :: p ! ok

diff  --git a/flang/test/Semantics/separate-mp02.f90 
b/flang/test/Semantics/separate-mp02.f90
index 47abc83bff1e..6d620e71118b 100644
--- a/flang/test/Semantics/separate-mp02.f90
+++ b/flang/test/Semantics/separate-mp02.f90
@@ -157,9 +157,9 @@ module subroutine s3() bind(c, name="s3" // suffix)
 module m3
   interface
 module subroutine s1(x, y, z)
-  procedure(real), intent(in) :: x
-  procedure(real), intent(out) :: y
-  procedure(real), intent(out) :: z
+  procedure(real), pointer, intent(in) :: x
+  procedure(real), pointer, intent(out) :: y
+  procedure(real), pointer, intent(out) :: z
 end
 module subroutine s2(x, y)
   procedure(real), pointer :: x
@@ -171,11 +171,11 @@ module subroutine s2(x, y)
 submodule(m3) sm3
 contains
   module subroutine s1(x, y, z)
-procedure(real), intent(in) :: x
+procedure(real), pointer, intent(in) :: x
 !ERROR: The intent of dummy argument 'y' does not match the intent of the 
corresponding argument in the interface body
-procedure(real), intent(inout) :: y
+procedure(real), pointer, intent(inout) :: y
 !ERROR: The intent of dummy argument 'z' does not match the intent of the 
corresponding argument in the interface body
-procedure(real) :: z
+procedure(real), pointer :: z
   end
   module subroutine s2(x, y)
 !ERROR: Dummy argument 'x' has the OPTIONAL attribute; the corresponding 
argument in the interface body does not



___
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] be69e66 - [X86][SSE] Attempt to fold shuffle(binop(), binop()) -> binop(shuffle(), shuffle())

2021-01-15 Thread Simon Pilgrim via llvm-branch-commits

Author: Simon Pilgrim
Date: 2021-01-15T16:25:25Z
New Revision: be69e66b1cd826f499566e1c3dadbf04e872baa0

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

LOG: [X86][SSE] Attempt to fold shuffle(binop(),binop()) -> 
binop(shuffle(),shuffle())

If this will help us fold shuffles together, then push the shuffle through the 
merged binops.

Ideally this would be performed in DAGCombiner::visitVECTOR_SHUFFLE but getting 
an efficient+legal merged shuffle can be tricky - on SSE we can be confident 
that for 32/64-bit elements vectors shuffles should easily fold.

Added: 


Modified: 
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/test/CodeGen/X86/haddsub-shuf.ll

Removed: 




diff  --git a/llvm/lib/Target/X86/X86ISelLowering.cpp 
b/llvm/lib/Target/X86/X86ISelLowering.cpp
index a84250782c19..d2cc2395576a 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -37939,6 +37939,33 @@ static SDValue combineShuffle(SDNode *N, SelectionDAG 
,
 
 if (SDValue HAddSub = foldShuffleOfHorizOp(N, DAG))
   return HAddSub;
+
+// Merge shuffles through binops if its likely we'll be able to merge it
+// with other shuffles.
+// shuffle(bop(shuffle(x,y),shuffle(z,w)),bop(shuffle(a,b),shuffle(c,d)))
+// TODO: We might be able to move this to DAGCombiner::visitVECTOR_SHUFFLE.
+if (auto *SVN = dyn_cast(N)) {
+  unsigned SrcOpcode = N->getOperand(0).getOpcode();
+  if (SrcOpcode == N->getOperand(1).getOpcode() && TLI.isBinOp(SrcOpcode) 
&&
+  N->isOnlyUserOf(N->getOperand(0).getNode()) &&
+  N->isOnlyUserOf(N->getOperand(1).getNode()) &&
+  VT.getScalarSizeInBits() >= 32) {
+SDValue Op00 = N->getOperand(0).getOperand(0);
+SDValue Op10 = N->getOperand(1).getOperand(0);
+SDValue Op01 = N->getOperand(0).getOperand(1);
+SDValue Op11 = N->getOperand(1).getOperand(1);
+if ((Op00.getOpcode() == ISD::VECTOR_SHUFFLE ||
+ Op10.getOpcode() == ISD::VECTOR_SHUFFLE) &&
+(Op01.getOpcode() == ISD::VECTOR_SHUFFLE ||
+ Op11.getOpcode() == ISD::VECTOR_SHUFFLE)) {
+  SDLoc DL(N);
+  ArrayRef Mask = SVN->getMask();
+  SDValue LHS = DAG.getVectorShuffle(VT, DL, Op00, Op10, Mask);
+  SDValue RHS = DAG.getVectorShuffle(VT, DL, Op01, Op11, Mask);
+  return DAG.getNode(SrcOpcode, DL, VT, LHS, RHS);
+}
+  }
+}
   }
 
   // Attempt to combine into a vector load/broadcast.

diff  --git a/llvm/test/CodeGen/X86/haddsub-shuf.ll 
b/llvm/test/CodeGen/X86/haddsub-shuf.ll
index 9b2dfc1ce0cb..37eedcd54441 100644
--- a/llvm/test/CodeGen/X86/haddsub-shuf.ll
+++ b/llvm/test/CodeGen/X86/haddsub-shuf.ll
@@ -923,45 +923,15 @@ define <4 x float> @PR34724_1(<4 x float> %a, <4 x float> 
%b) {
 }
 
 define <4 x float> @PR34724_2(<4 x float> %a, <4 x float> %b) {
-; SSSE3_SLOW-LABEL: PR34724_2:
-; SSSE3_SLOW:   # %bb.0:
-; SSSE3_SLOW-NEXT:haddps %xmm1, %xmm0
-; SSSE3_SLOW-NEXT:movsldup {{.*#+}} xmm2 = xmm1[0,0,2,2]
-; SSSE3_SLOW-NEXT:addps %xmm1, %xmm2
-; SSSE3_SLOW-NEXT:shufps {{.*#+}} xmm2 = xmm2[3,0],xmm0[2,0]
-; SSSE3_SLOW-NEXT:shufps {{.*#+}} xmm0 = xmm0[0,1],xmm2[2,0]
-; SSSE3_SLOW-NEXT:retq
-;
-; SSSE3_FAST-LABEL: PR34724_2:
-; SSSE3_FAST:   # %bb.0:
-; SSSE3_FAST-NEXT:haddps %xmm1, %xmm0
-; SSSE3_FAST-NEXT:retq
-;
-; AVX1_SLOW-LABEL: PR34724_2:
-; AVX1_SLOW:   # %bb.0:
-; AVX1_SLOW-NEXT:vhaddps %xmm1, %xmm0, %xmm0
-; AVX1_SLOW-NEXT:vmovsldup {{.*#+}} xmm2 = xmm1[0,0,2,2]
-; AVX1_SLOW-NEXT:vaddps %xmm1, %xmm2, %xmm1
-; AVX1_SLOW-NEXT:vblendps {{.*#+}} xmm0 = xmm0[0,1,2],xmm1[3]
-; AVX1_SLOW-NEXT:retq
-;
-; AVX1_FAST-LABEL: PR34724_2:
-; AVX1_FAST:   # %bb.0:
-; AVX1_FAST-NEXT:vhaddps %xmm1, %xmm0, %xmm0
-; AVX1_FAST-NEXT:retq
-;
-; AVX2_SLOW-LABEL: PR34724_2:
-; AVX2_SLOW:   # %bb.0:
-; AVX2_SLOW-NEXT:vhaddps %xmm1, %xmm0, %xmm0
-; AVX2_SLOW-NEXT:vmovsldup {{.*#+}} xmm2 = xmm1[0,0,2,2]
-; AVX2_SLOW-NEXT:vaddps %xmm1, %xmm2, %xmm1
-; AVX2_SLOW-NEXT:vblendps {{.*#+}} xmm0 = xmm0[0,1,2],xmm1[3]
-; AVX2_SLOW-NEXT:retq
+; SSSE3-LABEL: PR34724_2:
+; SSSE3:   # %bb.0:
+; SSSE3-NEXT:haddps %xmm1, %xmm0
+; SSSE3-NEXT:retq
 ;
-; AVX2_FAST-LABEL: PR34724_2:
-; AVX2_FAST:   # %bb.0:
-; AVX2_FAST-NEXT:vhaddps %xmm1, %xmm0, %xmm0
-; AVX2_FAST-NEXT:retq
+; AVX-LABEL: PR34724_2:
+; AVX:   # %bb.0:
+; AVX-NEXT:vhaddps %xmm1, %xmm0, %xmm0
+; AVX-NEXT:retq
   %t0 = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> 
   %t1 = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> 
   %t2 = fadd <4 x float> %t0, %t1



___

[llvm-branch-commits] [llvm] 1a497ae - [ARM][Block placement] Check the predecessor exists before processing it

2021-01-15 Thread Sam Tebbs via llvm-branch-commits

Author: Sam Tebbs
Date: 2021-01-15T15:45:13Z
New Revision: 1a497ae9b83653682d6d20f1ec131394e523375d

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

LOG: [ARM][Block placement] Check the predecessor exists before processing it

Not all machine loops will have a predecessor. so the pass needs to
check it before continuing.

Reviewed By: dmgreen

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

Added: 


Modified: 
llvm/lib/Target/ARM/ARMBlockPlacement.cpp
llvm/test/CodeGen/Thumb2/block-placement.mir

Removed: 




diff  --git a/llvm/lib/Target/ARM/ARMBlockPlacement.cpp 
b/llvm/lib/Target/ARM/ARMBlockPlacement.cpp
index 20491273ea5d4..581b4b9857af3 100644
--- a/llvm/lib/Target/ARM/ARMBlockPlacement.cpp
+++ b/llvm/lib/Target/ARM/ARMBlockPlacement.cpp
@@ -79,6 +79,8 @@ bool ARMBlockPlacement::runOnMachineFunction(MachineFunction 
) {
   // LE branch then move the target block after the preheader.
   for (auto *ML : *MLI) {
 MachineBasicBlock *Preheader = ML->getLoopPredecessor();
+if (!Preheader)
+  continue;
 
 for (auto  : Preheader->terminators()) {
   if (Terminator.getOpcode() != ARM::t2WhileLoopStart)

diff  --git a/llvm/test/CodeGen/Thumb2/block-placement.mir 
b/llvm/test/CodeGen/Thumb2/block-placement.mir
index d96a1fb49abbb..ed4a0a6b493d8 100644
--- a/llvm/test/CodeGen/Thumb2/block-placement.mir
+++ b/llvm/test/CodeGen/Thumb2/block-placement.mir
@@ -25,6 +25,16 @@
   entry:
 unreachable
   }
+
+  define void @no_preheader(i32 %N, i32 %M, i32* nocapture %a, i32* nocapture 
%b, i32* nocapture %c) local_unnamed_addr #0 {
+  entry:
+unreachable
+  }
+
+  declare dso_local i32 @g(...) local_unnamed_addr #1
+
+  declare dso_local i32 @h(...) local_unnamed_addr #1
+
 ...
 ---
 name:backwards_branch
@@ -343,3 +353,91 @@ body: |
 t2B %bb.1, 14 /* CC::al */, $noreg
 
 ...
+---
+name:no_preheader
+body: |
+  ; CHECK-LABEL: name: no_preheader
+  ; CHECK: bb.0:
+  ; CHECK:   successors: %bb.2(0x3000), %bb.1(0x5000)
+  ; CHECK:   frame-setup tPUSH 14 /* CC::al */, $noreg, killed $r4, killed 
$r5, $r7, killed $lr, implicit-def $sp, implicit $sp
+  ; CHECK:   frame-setup CFI_INSTRUCTION def_cfa_offset 16
+  ; CHECK:   frame-setup CFI_INSTRUCTION offset $lr, -4
+  ; CHECK:   frame-setup CFI_INSTRUCTION offset $r7, -8
+  ; CHECK:   frame-setup CFI_INSTRUCTION offset $r5, -12
+  ; CHECK:   frame-setup CFI_INSTRUCTION offset $r4, -16
+  ; CHECK:   $r7 = frame-setup tADDrSPi $sp, 2, 14 /* CC::al */, $noreg
+  ; CHECK:   frame-setup CFI_INSTRUCTION def_cfa $r7, 8
+  ; CHECK:   $r4 = tMOVr killed $r0, 14 /* CC::al */, $noreg
+  ; CHECK:   tBL 14 /* CC::al */, $noreg, @g, csr_aapcs, implicit-def dead 
$lr, implicit $sp, implicit-def $sp, implicit-def $r0
+  ; CHECK:   tCMPi8 killed renamable $r0, 0, 14 /* CC::al */, $noreg, 
implicit-def $cpsr
+  ; CHECK:   t2Bcc %bb.2, 0 /* CC::eq */, killed $cpsr
+  ; CHECK: bb.1:
+  ; CHECK:   successors: %bb.4(0x8000)
+  ; CHECK:   renamable $r0, dead $cpsr = tMOVi8 4, 14 /* CC::al */, $noreg
+  ; CHECK:   renamable $r5 = t2LDRSHi12 killed renamable $r0, 0, 14 /* CC::al 
*/, $noreg
+  ; CHECK:   t2B %bb.4, 14 /* CC::al */, $noreg
+  ; CHECK: bb.2:
+  ; CHECK:   successors: %bb.4(0x8000)
+  ; CHECK:   renamable $r5, dead $cpsr = tMOVi8 0, 14 /* CC::al */, $noreg
+  ; CHECK:   t2B %bb.4, 14 /* CC::al */, $noreg
+  ; CHECK: bb.3:
+  ; CHECK:   successors: %bb.4(0x8000)
+  ; CHECK:   $r0 = tMOVr $r5, 14 /* CC::al */, $noreg
+  ; CHECK:   tBL 14 /* CC::al */, $noreg, @h, csr_aapcs, implicit-def dead 
$lr, implicit $sp, implicit killed $r0, implicit-def $sp, implicit-def dead $r0
+  ; CHECK: bb.4:
+  ; CHECK:   successors: %bb.5(0x0400), %bb.3(0x7c00)
+  ; CHECK:   renamable $r0 = tLDRi renamable $r4, 0, 14 /* CC::al */, $noreg
+  ; CHECK:   tCMPi8 killed renamable $r0, 0, 14 /* CC::al */, $noreg, 
implicit-def $cpsr
+  ; CHECK:   t2Bcc %bb.3, 1 /* CC::ne */, killed $cpsr
+  ; CHECK: bb.5:
+  ; CHECK:   frame-destroy tPOP_RET 14 /* CC::al */, $noreg, def $r4, def $r5, 
def $r7, def $pc
+  bb.0:
+successors: %bb.1(0x3000), %bb.2(0x5000)
+liveins: $r0, $r4, $r5, $lr
+
+frame-setup tPUSH 14 /* CC::al */, $noreg, killed $r4, killed $r5, $r7, 
killed $lr, implicit-def $sp, implicit $sp
+frame-setup CFI_INSTRUCTION def_cfa_offset 16
+frame-setup CFI_INSTRUCTION offset $lr, -4
+frame-setup CFI_INSTRUCTION offset $r7, -8
+frame-setup CFI_INSTRUCTION offset $r5, -12
+frame-setup CFI_INSTRUCTION offset $r4, -16
+$r7 = frame-setup tADDrSPi $sp, 2, 14 /* CC::al */, $noreg
+frame-setup CFI_INSTRUCTION def_cfa $r7, 8
+$r4 = tMOVr killed $r0, 14 /* CC::al */, $noreg
+tBL 14 /* CC::al */, $noreg, @g, 

[llvm-branch-commits] [clang] 1744f4c - [clang][cli] NFC: Promote ParseLangArgs and ParseCodeGenArgs to members

2021-01-15 Thread Jan Svoboda via llvm-branch-commits

Author: Jan Svoboda
Date: 2021-01-15T16:41:34+01:00
New Revision: 1744f4c676411ebd2e38afd5a6b56e5dd533c6ac

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

LOG: [clang][cli] NFC: Promote ParseLangArgs and ParseCodeGenArgs to members

This patch promotes `ParseLangArgs` and `ParseCodeGenArgs` to members of 
`CompilerInvocation`. That will be useful in the following patch D94682, where 
we need to access protected members of `LangOptions` and `CodeGenOptions`. Both 
of those classes already have `friend CompilerInvocation`.

This is cleaner than keeping those functions freestanding and having to specify 
the exact signature of both in extra `friend` declarations.

Reviewed By: Bigcheese

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

Added: 


Modified: 
clang/include/clang/Frontend/CompilerInvocation.h
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/include/clang/Frontend/CompilerInvocation.h 
b/clang/include/clang/Frontend/CompilerInvocation.h
index 9f16c5077154..b65b087510ce 100644
--- a/clang/include/clang/Frontend/CompilerInvocation.h
+++ b/clang/include/clang/Frontend/CompilerInvocation.h
@@ -247,6 +247,18 @@ class CompilerInvocation : public CompilerInvocationBase {
   /// \returns - True if parsing was successful, false otherwise
   bool parseSimpleArgs(const llvm::opt::ArgList ,
DiagnosticsEngine );
+
+  /// Parse command line options that map to LangOptions.
+  static void ParseLangArgs(LangOptions , llvm::opt::ArgList ,
+InputKind IK, const llvm::Triple ,
+std::vector ,
+DiagnosticsEngine );
+
+  /// Parse command line options that map to CodeGenOptions.
+  static bool ParseCodeGenArgs(CodeGenOptions , llvm::opt::ArgList ,
+   InputKind IK, DiagnosticsEngine ,
+   const llvm::Triple ,
+   const std::string );
 };
 
 IntrusiveRefCntPtr

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index c672834a7970..25b3610e50db 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -907,9 +907,11 @@ static void setPGOUseInstrumentor(CodeGenOptions ,
 Opts.setProfileUse(CodeGenOptions::ProfileClangInstr);
 }
 
-static bool ParseCodeGenArgs(CodeGenOptions , ArgList , InputKind IK,
- DiagnosticsEngine , const llvm::Triple ,
- const std::string ) {
+bool CompilerInvocation::ParseCodeGenArgs(CodeGenOptions , ArgList ,
+  InputKind IK,
+  DiagnosticsEngine ,
+  const llvm::Triple ,
+  const std::string ) {
   bool Success = true;
 
   unsigned OptimizationLevel = getOptimizationLevel(Args, IK, Diags);
@@ -2151,10 +2153,10 @@ static void GenerateLangArgs(const LangOptions ,
 Args.push_back(SA(GetOptName(OPT_fdeclare_opencl_builtins)));
 }
 
-static void ParseLangArgs(LangOptions , ArgList , InputKind IK,
-  const llvm::Triple ,
-  std::vector ,
-  DiagnosticsEngine ) {
+void CompilerInvocation::ParseLangArgs(LangOptions , ArgList ,
+   InputKind IK, const llvm::Triple ,
+   std::vector ,
+   DiagnosticsEngine ) {
   // FIXME: Cleanup per-file based stuff.
   LangStandard::Kind LangStd = LangStandard::lang_unspecified;
   if (const Arg *A = Args.getLastArg(OPT_std_EQ)) {



___
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] [clang] 3832629 - [clang][cli] NFC: Add PIE parsing for precompiled input and IR

2021-01-15 Thread Jan Svoboda via llvm-branch-commits

Author: Jan Svoboda
Date: 2021-01-15T16:41:34+01:00
New Revision: 383262933045e1c138362105be4ee4d1b62ab4cc

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

LOG: [clang][cli] NFC: Add PIE parsing for precompiled input and IR

This patch effectively reverts a small part of D83979.

When we stop parsing `LangOpts` unconditionally in `parseSimpleArgs` (above the 
diff) and move them back to `ParseLangArgs` (called in `else` branch) in 
D94682, `LangOpts.PIE` would never get parsed in this `if` branch. This patch 
ensures this doesn't happen.

Right now, this causes `LangOpts.PIE` to be parsed twice, but that will be 
immediately corrected in D94682.

Reviewed By: Bigcheese

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

Added: 


Modified: 
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index c85b0f9d65cf..d261eb7f45cd 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -2970,6 +2970,7 @@ bool 
CompilerInvocation::CreateFromArgs(CompilerInvocation ,
 // PIClevel and PIELevel are needed during code generation and this should 
be
 // set regardless of the input type.
 LangOpts.PICLevel = getLastArgIntValue(Args, OPT_pic_level, 0, Diags);
+LangOpts.PIE = Args.hasArg(OPT_pic_is_pie);
 parseSanitizerKinds("-fsanitize=", Args.getAllArgValues(OPT_fsanitize_EQ),
 Diags, LangOpts.Sanitize);
   } else {



___
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] [clang] a7dcd3a - [clang][cli] NFC: Parse some LangOpts after the defaults are set

2021-01-15 Thread Jan Svoboda via llvm-branch-commits

Author: Jan Svoboda
Date: 2021-01-15T16:41:34+01:00
New Revision: a7dcd3aeb0fb58ad774bc89428ed6c925f31f8aa

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

LOG: [clang][cli] NFC: Parse some LangOpts after the defaults are set

This patch ensures we only parse the necessary options before calling 
`setLangDefaults` (explained in D94678).

Because neither `LangOpts.CFProtectionBranch` nor `LangOpts.SYCLIsDevice` are 
used in `setLangDefaults`, this is a NFC.

Reviewed By: Bigcheese

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

Added: 


Modified: 
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index d261eb7f45cd..c672834a7970 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -2196,12 +2196,6 @@ static void ParseLangArgs(LangOptions , ArgList 
, InputKind IK,
 }
   }
 
-  if (const Arg *A = Args.getLastArg(OPT_fcf_protection_EQ)) {
-StringRef Name = A->getValue();
-if (Name == "full" || Name == "branch") {
-  Opts.CFProtectionBranch = 1;
-}
-  }
   // -cl-std only applies for OpenCL language standards.
   // Override the -std option in this case.
   if (const Arg *A = Args.getLastArg(OPT_cl_std_EQ)) {
@@ -2224,14 +2218,21 @@ static void ParseLangArgs(LangOptions , ArgList 
, InputKind IK,
   LangStd = OpenCLLangStd;
   }
 
-  Opts.SYCLIsDevice = Opts.SYCL && Args.hasArg(options::OPT_fsycl_is_device);
-
   // These need to be parsed now. They are used to set OpenCL defaults.
   Opts.IncludeDefaultHeader = Args.hasArg(OPT_finclude_default_header);
   Opts.DeclareOpenCLBuiltins = Args.hasArg(OPT_fdeclare_opencl_builtins);
 
   CompilerInvocation::setLangDefaults(Opts, IK, T, Includes, LangStd);
 
+  if (const Arg *A = Args.getLastArg(OPT_fcf_protection_EQ)) {
+StringRef Name = A->getValue();
+if (Name == "full" || Name == "branch") {
+  Opts.CFProtectionBranch = 1;
+}
+  }
+
+  Opts.SYCLIsDevice = Opts.SYCL && Args.hasArg(options::OPT_fsycl_is_device);
+
   // -cl-strict-aliasing needs to emit diagnostic in the case where CL > 1.0.
   // This option should be deprecated for CL > 1.0 because
   // this option was added for compatibility with OpenCL 1.0.



___
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] bf1aa5d - [RISCV][NFC] Fix order of parameters in cmov ge/le tests

2021-01-15 Thread Sam Elliott via llvm-branch-commits

Author: Michael Munday
Date: 2021-01-15T15:35:13Z
New Revision: bf1aa5db5c76d187df8dfef28bc5b8889fb53c4b

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

LOG: [RISCV][NFC] Fix order of parameters in cmov ge/le tests

The first parameter should be selected if the condition is true and
the last parameter if the condition is false. Prior to this change
it was the other way round which was confusing.

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

Added: 


Modified: 
llvm/test/CodeGen/RISCV/rv32Zbt.ll
llvm/test/CodeGen/RISCV/rv64Zbt.ll

Removed: 




diff  --git a/llvm/test/CodeGen/RISCV/rv32Zbt.ll 
b/llvm/test/CodeGen/RISCV/rv32Zbt.ll
index 7011698c13a9..279c39344b7d 100644
--- a/llvm/test/CodeGen/RISCV/rv32Zbt.ll
+++ b/llvm/test/CodeGen/RISCV/rv32Zbt.ll
@@ -91,30 +91,27 @@ define i32 @cmov_sle_i32(i32 %a, i32 %b, i32 %c, i32 %d) 
nounwind {
 ; RV32I:   # %bb.0:
 ; RV32I-NEXT:bge a2, a1, .LBB3_2
 ; RV32I-NEXT:  # %bb.1:
-; RV32I-NEXT:mv a3, a0
-; RV32I-NEXT:  .LBB3_2:
 ; RV32I-NEXT:mv a0, a3
+; RV32I-NEXT:  .LBB3_2:
 ; RV32I-NEXT:ret
 ;
 ; RV32IB-LABEL: cmov_sle_i32:
 ; RV32IB:   # %bb.0:
 ; RV32IB-NEXT:bge a2, a1, .LBB3_2
 ; RV32IB-NEXT:  # %bb.1:
-; RV32IB-NEXT:mv a3, a0
-; RV32IB-NEXT:  .LBB3_2:
 ; RV32IB-NEXT:mv a0, a3
+; RV32IB-NEXT:  .LBB3_2:
 ; RV32IB-NEXT:ret
 ;
 ; RV32IBT-LABEL: cmov_sle_i32:
 ; RV32IBT:   # %bb.0:
 ; RV32IBT-NEXT:bge a2, a1, .LBB3_2
 ; RV32IBT-NEXT:  # %bb.1:
-; RV32IBT-NEXT:mv a3, a0
-; RV32IBT-NEXT:  .LBB3_2:
 ; RV32IBT-NEXT:mv a0, a3
+; RV32IBT-NEXT:  .LBB3_2:
 ; RV32IBT-NEXT:ret
   %tobool = icmp sle i32 %b, %c
-  %cond = select i1 %tobool, i32 %d, i32 %a
+  %cond = select i1 %tobool, i32 %a, i32 %d
   ret i32 %cond
 }
 
@@ -123,30 +120,27 @@ define i32 @cmov_sge_i32(i32 %a, i32 %b, i32 %c, i32 %d) 
nounwind {
 ; RV32I:   # %bb.0:
 ; RV32I-NEXT:bge a1, a2, .LBB4_2
 ; RV32I-NEXT:  # %bb.1:
-; RV32I-NEXT:mv a3, a0
-; RV32I-NEXT:  .LBB4_2:
 ; RV32I-NEXT:mv a0, a3
+; RV32I-NEXT:  .LBB4_2:
 ; RV32I-NEXT:ret
 ;
 ; RV32IB-LABEL: cmov_sge_i32:
 ; RV32IB:   # %bb.0:
 ; RV32IB-NEXT:bge a1, a2, .LBB4_2
 ; RV32IB-NEXT:  # %bb.1:
-; RV32IB-NEXT:mv a3, a0
-; RV32IB-NEXT:  .LBB4_2:
 ; RV32IB-NEXT:mv a0, a3
+; RV32IB-NEXT:  .LBB4_2:
 ; RV32IB-NEXT:ret
 ;
 ; RV32IBT-LABEL: cmov_sge_i32:
 ; RV32IBT:   # %bb.0:
 ; RV32IBT-NEXT:bge a1, a2, .LBB4_2
 ; RV32IBT-NEXT:  # %bb.1:
-; RV32IBT-NEXT:mv a3, a0
-; RV32IBT-NEXT:  .LBB4_2:
 ; RV32IBT-NEXT:mv a0, a3
+; RV32IBT-NEXT:  .LBB4_2:
 ; RV32IBT-NEXT:ret
   %tobool = icmp sge i32 %b, %c
-  %cond = select i1 %tobool, i32 %d, i32 %a
+  %cond = select i1 %tobool, i32 %a, i32 %d
   ret i32 %cond
 }
 
@@ -155,30 +149,27 @@ define i32 @cmov_ule_i32(i32 %a, i32 %b, i32 %c, i32 %d) 
nounwind {
 ; RV32I:   # %bb.0:
 ; RV32I-NEXT:bgeu a2, a1, .LBB5_2
 ; RV32I-NEXT:  # %bb.1:
-; RV32I-NEXT:mv a3, a0
-; RV32I-NEXT:  .LBB5_2:
 ; RV32I-NEXT:mv a0, a3
+; RV32I-NEXT:  .LBB5_2:
 ; RV32I-NEXT:ret
 ;
 ; RV32IB-LABEL: cmov_ule_i32:
 ; RV32IB:   # %bb.0:
 ; RV32IB-NEXT:bgeu a2, a1, .LBB5_2
 ; RV32IB-NEXT:  # %bb.1:
-; RV32IB-NEXT:mv a3, a0
-; RV32IB-NEXT:  .LBB5_2:
 ; RV32IB-NEXT:mv a0, a3
+; RV32IB-NEXT:  .LBB5_2:
 ; RV32IB-NEXT:ret
 ;
 ; RV32IBT-LABEL: cmov_ule_i32:
 ; RV32IBT:   # %bb.0:
 ; RV32IBT-NEXT:bgeu a2, a1, .LBB5_2
 ; RV32IBT-NEXT:  # %bb.1:
-; RV32IBT-NEXT:mv a3, a0
-; RV32IBT-NEXT:  .LBB5_2:
 ; RV32IBT-NEXT:mv a0, a3
+; RV32IBT-NEXT:  .LBB5_2:
 ; RV32IBT-NEXT:ret
   %tobool = icmp ule i32 %b, %c
-  %cond = select i1 %tobool, i32 %d, i32 %a
+  %cond = select i1 %tobool, i32 %a, i32 %d
   ret i32 %cond
 }
 
@@ -187,30 +178,27 @@ define i32 @cmov_uge_i32(i32 %a, i32 %b, i32 %c, i32 %d) 
nounwind {
 ; RV32I:   # %bb.0:
 ; RV32I-NEXT:bgeu a1, a2, .LBB6_2
 ; RV32I-NEXT:  # %bb.1:
-; RV32I-NEXT:mv a3, a0
-; RV32I-NEXT:  .LBB6_2:
 ; RV32I-NEXT:mv a0, a3
+; RV32I-NEXT:  .LBB6_2:
 ; RV32I-NEXT:ret
 ;
 ; RV32IB-LABEL: cmov_uge_i32:
 ; RV32IB:   # %bb.0:
 ; RV32IB-NEXT:bgeu a1, a2, .LBB6_2
 ; RV32IB-NEXT:  # %bb.1:
-; RV32IB-NEXT:mv a3, a0
-; RV32IB-NEXT:  .LBB6_2:
 ; RV32IB-NEXT:mv a0, a3
+; RV32IB-NEXT:  .LBB6_2:
 ; RV32IB-NEXT:ret
 ;
 ; RV32IBT-LABEL: cmov_uge_i32:
 ; RV32IBT:   # %bb.0:
 ; RV32IBT-NEXT:bgeu a1, a2, .LBB6_2
 ; RV32IBT-NEXT:  # %bb.1:
-; RV32IBT-NEXT:mv a3, a0
-; RV32IBT-NEXT:  .LBB6_2:
 ; RV32IBT-NEXT:mv a0, a3
+; RV32IBT-NEXT:  .LBB6_2:
 ; RV32IBT-NEXT:ret
   %tobool = icmp uge i32 %b, %c
-  %cond = select i1 %tobool, i32 %d, i32 %a
+  %cond = select i1 %tobool, i32 %a, i32 %d
   ret i32 %cond
 }
 
@@ -259,11 +247,9 @@ define i64 @cmov_sle_i64(i64 %a, i64 %b, i64 %c, i64 

[llvm-branch-commits] [mlir] cf0173d - [mlir] Add better support for f80 and f128

2021-01-15 Thread via llvm-branch-commits

Author: Valentin Clement
Date: 2021-01-15T10:29:48-05:00
New Revision: cf0173de69a760d1b17f8ef5b2c3b4f2b6f58966

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

LOG: [mlir] Add better support for f80 and f128

Add builtin f80 and f128 following @schweitz proposition
https://llvm.discourse.group/t/rfc-adding-better-support-for-higher-precision-floating-point/2526/5

Reviewed By: ftynse, rriddle

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

Added: 


Modified: 
mlir/docs/ConversionToLLVMDialect.md
mlir/docs/Dialects/LLVM.md
mlir/docs/LangRef.md
mlir/include/mlir/Dialect/LLVMIR/LLVMTypes.h
mlir/include/mlir/IR/Builders.h
mlir/include/mlir/IR/BuiltinTypes.h
mlir/include/mlir/IR/BuiltinTypes.td
mlir/include/mlir/IR/OpBase.td
mlir/include/mlir/IR/Types.h
mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
mlir/lib/Dialect/LLVMIR/IR/LLVMTypeSyntax.cpp
mlir/lib/Dialect/LLVMIR/IR/LLVMTypes.cpp
mlir/lib/IR/AsmPrinter.cpp
mlir/lib/IR/Builders.cpp
mlir/lib/IR/BuiltinDialect.cpp
mlir/lib/IR/BuiltinTypes.cpp
mlir/lib/IR/MLIRContext.cpp
mlir/lib/IR/Types.cpp
mlir/lib/Parser/TokenKinds.def
mlir/lib/Parser/TypeParser.cpp
mlir/lib/Target/LLVMIR/TypeTranslation.cpp
mlir/test/Dialect/LLVMIR/roundtrip.mlir
mlir/test/Dialect/LLVMIR/types.mlir
mlir/test/IR/parser.mlir
mlir/test/Target/llvmir-types.mlir
mlir/utils/gdb-scripts/prettyprinters.py

Removed: 




diff  --git a/mlir/docs/ConversionToLLVMDialect.md 
b/mlir/docs/ConversionToLLVMDialect.md
index d36b4498272c..47fe018872b7 100644
--- a/mlir/docs/ConversionToLLVMDialect.md
+++ b/mlir/docs/ConversionToLLVMDialect.md
@@ -29,6 +29,8 @@ following conversions are currently implemented:
 -   `f16` converts to `f16`
 -   `f32` converts to `f32`
 -   `f64` converts to `f64`
+-   `f80` converts to `f80`
+-   `f128` converts to `f128`
 
 ### Index Type
 

diff  --git a/mlir/docs/Dialects/LLVM.md b/mlir/docs/Dialects/LLVM.md
index 1b85091b0756..b396cdebf067 100644
--- a/mlir/docs/Dialects/LLVM.md
+++ b/mlir/docs/Dialects/LLVM.md
@@ -214,7 +214,8 @@ LLVM dialect accepts a subset of built-in types that are 
referred to as _LLVM
 dialect-compatible types_. The following types are compatible:
 
 -   Signless integers - `iN` (`IntegerType`).
--   Floating point types - `bfloat`, `half`, `float`, `double` (`FloatType`).
+-   Floating point types - `bfloat`, `half`, `float`, `double` , `f80`, `f128`
+(`FloatType`).
 -   1D vectors of signless integers or floating point types - `vector`
 (`VectorType`).
 
@@ -228,9 +229,6 @@ compatibility check.
 The following non-parametric types derived from the LLVM IR are available in 
the
 LLVM dialect:
 
--   `!llvm.fp128` (`LLVMFP128Type`) - 128-bit floating-point value as per
-IEEE-754-2008.
--   `!llvm.x86_fp80` (`LLVMX86FP80Type`) - 80-bit floating-point value (x87).
 -   `!llvm.x86_mmx` (`LLVMX86MMXType`) - value held in an MMX register on x86
 machine.
 -   `!llvm.ppc_fp128` (`LLVMPPCFP128Type`) - 128-bit floating-point value (two

diff  --git a/mlir/docs/LangRef.md b/mlir/docs/LangRef.md
index 017ec02af7ae..0cca6e90b5bc 100644
--- a/mlir/docs/LangRef.md
+++ b/mlir/docs/LangRef.md
@@ -850,7 +850,7 @@ Syntax:
 
 ```
 // Floating point.
-float-type ::= `f16` | `bf16` | `f32` | `f64`
+float-type ::= `f16` | `bf16` | `f32` | `f64` | `f80` | `f128`
 ```
 
 MLIR supports float types of certain widths that are widely used as indicated

diff  --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMTypes.h 
b/mlir/include/mlir/Dialect/LLVMIR/LLVMTypes.h
index f21dd1de995e..95a8e4c6950e 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/LLVMTypes.h
+++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMTypes.h
@@ -36,9 +36,6 @@ struct LLVMStructTypeStorage;
 struct LLVMTypeAndSizeStorage;
 } // namespace detail
 
-class LLVMFP128Type;
-class LLVMX86FP80Type;
-
 
//===--===//
 // Trivial types.
 
//===--===//
@@ -51,8 +48,6 @@ class LLVMX86FP80Type;
   }
 
 DEFINE_TRIVIAL_LLVM_TYPE(LLVMVoidType);
-DEFINE_TRIVIAL_LLVM_TYPE(LLVMFP128Type);
-DEFINE_TRIVIAL_LLVM_TYPE(LLVMX86FP80Type);
 DEFINE_TRIVIAL_LLVM_TYPE(LLVMPPCFP128Type);
 DEFINE_TRIVIAL_LLVM_TYPE(LLVMX86MMXType);
 DEFINE_TRIVIAL_LLVM_TYPE(LLVMTokenType);

diff  --git a/mlir/include/mlir/IR/Builders.h b/mlir/include/mlir/IR/Builders.h
index f5650480e3ca..eaaabc80686c 100644
--- a/mlir/include/mlir/IR/Builders.h
+++ b/mlir/include/mlir/IR/Builders.h
@@ -66,6 +66,8 @@ class Builder {
   FloatType getF16Type();
   FloatType getF32Type();
   FloatType getF64Type();
+  FloatType getF80Type();
+  FloatType getF128Type();
 
   IndexType getIndexType();
 

diff 

[llvm-branch-commits] [llvm] 17d0fb7 - Set option default for enabling memory ssa for new pass manager loop sink pass to true.

2021-01-15 Thread Jamie Schmeiser via llvm-branch-commits

Author: Jamie Schmeiser
Date: 2021-01-15T09:56:44-05:00
New Revision: 17d0fb7f574ebc8a6449382983d91715b6977c32

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

LOG: Set option default for enabling memory ssa for new pass manager loop sink 
pass to true.
Summary:
Set the default for the option enabling memory ssa use in the loop sink
pass to true for the new pass manager.
Author: Jamie Schmeiser 
Reviewed By: asbirlea (Alina Sbirlea)
Differential Revision: https://reviews.llvm.org/D92486

Added: 


Modified: 
llvm/lib/Transforms/Scalar/LoopSink.cpp

Removed: 




diff  --git a/llvm/lib/Transforms/Scalar/LoopSink.cpp 
b/llvm/lib/Transforms/Scalar/LoopSink.cpp
index c20e5e0cbfb3..47698fdde69f 100644
--- a/llvm/lib/Transforms/Scalar/LoopSink.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopSink.cpp
@@ -70,7 +70,7 @@ static cl::opt MaxNumberOfUseBBsForSinking(
 cl::desc("Do not sink instructions that have too many uses."));
 
 static cl::opt EnableMSSAInLoopSink(
-"enable-mssa-in-loop-sink", cl::Hidden, cl::init(false),
+"enable-mssa-in-loop-sink", cl::Hidden, cl::init(true),
 cl::desc("Enable MemorySSA for LoopSink in new pass manager"));
 
 static cl::opt EnableMSSAInLegacyLoopSink(



___
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] 5183a13 - [X86] Add umin knownbits/demandedbits ult test for D94532

2021-01-15 Thread Simon Pilgrim via llvm-branch-commits

Author: Simon Pilgrim
Date: 2021-01-15T14:42:55Z
New Revision: 5183a13d37825f93d92c23c257dbb1c994098bdc

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

LOG: [X86] Add umin knownbits/demandedbits ult test for D94532

Added: 


Modified: 
llvm/test/CodeGen/X86/combine-umin.ll

Removed: 




diff  --git a/llvm/test/CodeGen/X86/combine-umin.ll 
b/llvm/test/CodeGen/X86/combine-umin.ll
index 558d4df9adb4..b22c45bbce45 100644
--- a/llvm/test/CodeGen/X86/combine-umin.ll
+++ b/llvm/test/CodeGen/X86/combine-umin.ll
@@ -1,11 +1,33 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
-; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+sse2 | FileCheck %s 
--check-prefix=SSE2
-; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+sse4.1 | FileCheck %s 
--check-prefix=SSE41
-; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+sse4.2 | FileCheck %s 
--check-prefix=SSE42
-; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx | FileCheck %s 
--check-prefix=AVX
-; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx2 | FileCheck %s 
--check-prefix=AVX
-; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx512f | FileCheck %s 
--check-prefix=AVX
-; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx512bw | FileCheck 
%s --check-prefix=AVX
+; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+sse2 | FileCheck %s 
--check-prefixes=CHECK,SSE2
+; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+sse4.1 | FileCheck %s 
--check-prefixes=CHECK,SSE41
+; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+sse4.2 | FileCheck %s 
--check-prefixes=CHECK,SSE42
+; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx | FileCheck %s 
--check-prefixes=CHECK,AVX
+; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx2 | FileCheck %s 
--check-prefixes=CHECK,AVX
+; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx512f | FileCheck %s 
--check-prefixes=CHECK,AVX
+; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx512bw | FileCheck 
%s --check-prefixes=CHECK,AVX
+
+define i8 @test_demandedbits_umin_ult(i8 %a0, i8 %a1) {
+; CHECK-LABEL: test_demandedbits_umin_ult:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:orb $12, %dil
+; CHECK-NEXT:orb $4, %sil
+; CHECK-NEXT:andb $13, %dil
+; CHECK-NEXT:andb $12, %sil
+; CHECK-NEXT:movzbl %dil, %ecx
+; CHECK-NEXT:movzbl %sil, %eax
+; CHECK-NEXT:cmpb %al, %cl
+; CHECK-NEXT:cmovbl %ecx, %eax
+; CHECK-NEXT:# kill: def $al killed $al killed $eax
+; CHECK-NEXT:retq
+  %lhs0 = and i8 %a0, 13  ; b1101
+  %rhs0 = and i8 %a1, 12  ; b1100
+  %lhs1 = or i8 %lhs0, 12 ; b1100
+  %rhs1 = or i8 %rhs0, 4  ; b0100
+  %umin = tail call i8 @llvm.umin.i8(i8 %lhs1, i8 %rhs1)
+  ret i8 %umin
+}
+declare i8 @llvm.umin.i8(i8, i8)
 
 define <8 x i16> @test_v8i16_nosignbit(<8 x i16> %a, <8 x i16> %b) {
 ; SSE2-LABEL: test_v8i16_nosignbit:



___
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] [clang] 791634b - [clang][cli] Parse & generate options necessary for LangOptions defaults manually

2021-01-15 Thread Jan Svoboda via llvm-branch-commits

Author: Jan Svoboda
Date: 2021-01-15T15:38:43+01:00
New Revision: 791634b999e33e029aeeda91eeb5fae13757dcdc

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

LOG: [clang][cli] Parse & generate options necessary for LangOptions defaults 
manually

It turns out we need to handle `LangOptions` separately from the rest of the 
options. `LangOptions` used to be conditionally parsed only when 
`!(DashX.getFormat() == InputKind::Precompiled || DashX.getLanguage() == 
Language::LLVM_IR)` and we need to restore this order (for more info, see 
D94682).

D94682 moves the parsing of marshalled `LangOpts` from `parseSimpleArgs` back 
to `ParseLangArgs`.

We need to parse marshalled `LangOpts` **after** `ParseLangArgs` calls 
`setLangDefaults`. This will enable future patches, where values of some 
`LangOpts` depend on the defaults.

However, two language options (`-finclude-default-header` and 
`-fdeclare-opencl-builtins`) need to be parsed **before** `ParseLangArgs` calls 
`setLangDefaults`, because they are necessary for setting up OpenCL defaults 
correctly.
This patch implements this by removing their marshalling info and manually 
parsing (and generating) them exactly where necessary.

Reviewed By: Bigcheese

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

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 2f7bd9e552e1..3722192c7eee 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -5207,12 +5207,13 @@ def fdefault_calling_conv_EQ : Joined<["-"], 
"fdefault-calling-conv=">,
   NormalizedValuesScope<"LangOptions">,
   NormalizedValues<["DCC_CDecl", "DCC_FastCall", "DCC_StdCall", 
"DCC_VectorCall", "DCC_RegCall"]>,
   MarshallingInfoString, "DCC_None">, 
AutoNormalizeEnum;
+
+// These options cannot be marshalled, because they are used to set up the 
LangOptions defaults.
 def finclude_default_header : Flag<["-"], "finclude-default-header">,
-  HelpText<"Include default header file for OpenCL">,
-  MarshallingInfoFlag>;
+  HelpText<"Include default header file for OpenCL">;
 def fdeclare_opencl_builtins : Flag<["-"], "fdeclare-opencl-builtins">,
-  HelpText<"Add OpenCL builtin function declarations (experimental)">,
-  MarshallingInfoFlag>;
+  HelpText<"Add OpenCL builtin function declarations (experimental)">;
+
 def fpreserve_vec3_type : Flag<["-"], "fpreserve-vec3-type">,
   HelpText<"Preserve 3-component vector type">,
   MarshallingInfoFlag>;

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 37d7f6f3f0fa..c85b0f9d65cf 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -491,6 +491,11 @@ static unsigned getOptimizationLevelSize(ArgList ) {
   return 0;
 }
 
+static std::string GetOptName(llvm::opt::OptSpecifier OptSpecifier) {
+  static const OptTable  = getDriverOptTable();
+  return OptTable.getOption(OptSpecifier).getPrefixedName();
+}
+
 static void addDiagnosticArgs(ArgList , OptSpecifier Group,
   OptSpecifier GroupWithValue,
   std::vector ) {
@@ -2137,6 +2142,15 @@ static const StringRef GetInputKindName(InputKind IK) {
   llvm_unreachable("unknown input language");
 }
 
+static void GenerateLangArgs(const LangOptions ,
+ SmallVectorImpl ,
+ CompilerInvocation::StringAllocator SA) {
+  if (Opts.IncludeDefaultHeader)
+Args.push_back(SA(GetOptName(OPT_finclude_default_header)));
+  if (Opts.DeclareOpenCLBuiltins)
+Args.push_back(SA(GetOptName(OPT_fdeclare_opencl_builtins)));
+}
+
 static void ParseLangArgs(LangOptions , ArgList , InputKind IK,
   const llvm::Triple ,
   std::vector ,
@@ -2212,6 +2226,10 @@ static void ParseLangArgs(LangOptions , ArgList 
, InputKind IK,
 
   Opts.SYCLIsDevice = Opts.SYCL && Args.hasArg(options::OPT_fsycl_is_device);
 
+  // These need to be parsed now. They are used to set OpenCL defaults.
+  Opts.IncludeDefaultHeader = Args.hasArg(OPT_finclude_default_header);
+  Opts.DeclareOpenCLBuiltins = Args.hasArg(OPT_fdeclare_opencl_builtins);
+
   CompilerInvocation::setLangDefaults(Opts, IK, T, Includes, LangStd);
 
   // -cl-strict-aliasing needs to emit diagnostic in the case where CL > 1.0.
@@ -3163,6 +3181,8 @@ void CompilerInvocation::generateCC1CommandLine(
 #undef DIAG_OPTION_WITH_MARSHALLING
 #undef OPTION_WITH_MARSHALLING
 #undef GENERATE_OPTION_WITH_MARSHALLING
+
+  GenerateLangArgs(*LangOpts, Args, SA);
 }
 
 IntrusiveRefCntPtr




[llvm-branch-commits] [clang] d1862a1 - [OpenCL][Docs] Fixed malformed table in OpenCLSupport

2021-01-15 Thread Anastasia Stulova via llvm-branch-commits

Author: Anastasia Stulova
Date: 2021-01-15T14:27:26Z
New Revision: d1862a16310379179a40b309a9721318ae7e3254

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

LOG: [OpenCL][Docs] Fixed malformed table in OpenCLSupport

 Tags: #clang

Added: 


Modified: 
clang/docs/OpenCLSupport.rst

Removed: 




diff  --git a/clang/docs/OpenCLSupport.rst b/clang/docs/OpenCLSupport.rst
index 9c17bd8f2692..7e5bb41f7dbc 100644
--- a/clang/docs/OpenCLSupport.rst
+++ b/clang/docs/OpenCLSupport.rst
@@ -67,40 +67,39 @@ OpenCL 3.0 Implementation Status
 The following table provides an overview of features in OpenCL C 3.0 and their
 implementation status. 
 
-+--+--+--+---
+
-| Category | Feature   
   | Status   | Reviews 
  |
-+==+==+==+===
+
-| Command line interface   | New value for ``-cl-std`` flag
   | :good:`done` | https://reviews.llvm.org/D88300 
  |
-+--+--+--+---
+
-| Predefined macros| New version macro 
   | :good:`done` | https://reviews.llvm.org/D88300 
  |
-+--+--+--+---
+
-| Predefined macros| Feature macros
   | :part:`worked on`| https://reviews.llvm.org/D89869 
  |
-+--+--+--+---
+
-| Feature optionality  | Generic address space 
   | :none:`unclaimed`| 
  |
-+--+--+--+---
+
-| Feature optionality  | Builtin function overloads with generic 
address space| :part:`worked on`| https://reviews.llvm.o
rg/D92004   |
-
-+--+--+--+---
+
-| Feature optionality  | Program scope variables in global memory  
   | :none:`unclaimed`| 
  |
-+--+--+--+---
+
-| Feature optionality  | 3D image writes including builtin functions   
   | :none:`unclaimed`| 
  |
-+--+--+--+---
+
-| Feature optionality  | read_write images including builtin functions 
   | :none:`unclaimed`| 
  |
-+--+--+--+---
+
-| Feature optionality  | C11 atomics memory scopes, ordering and 
builtin function | :part:`worked on`| https://reviews.llvm.o
rg/D92004 (functions only)  |

[llvm-branch-commits] [llvm] 061d152 - [SVE] Fix unused variable.

2021-01-15 Thread Stephan Herhut via llvm-branch-commits

Author: Stephan Herhut
Date: 2021-01-15T15:10:33+01:00
New Revision: 061d1520858a6e394663e12cc715ddfe3ab0240d

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

LOG: [SVE] Fix unused variable.

Introduced by [SVE] Restrict the usage of REINTERPRET_CAST.

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

Added: 


Modified: 
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp

Removed: 




diff  --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp 
b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
index d72eee5abc26..6e4ac0f711dd 100644
--- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -17173,6 +17173,7 @@ SDValue AArch64TargetLowering::getSVESafeBitCast(EVT 
VT, SDValue Op,
   SDLoc DL(Op);
   EVT InVT = Op.getValueType();
   const TargetLowering  = DAG.getTargetLoweringInfo();
+  (void)TLI;
 
   assert(VT.isScalableVector() && TLI.isTypeLegal(VT) &&
  InVT.isScalableVector() && TLI.isTypeLegal(InVT) &&



___
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] [mlir] 0acc260 - [mlir][linalg] Support generating builders for named op attributes

2021-01-15 Thread Lei Zhang via llvm-branch-commits

Author: Lei Zhang
Date: 2021-01-15T09:00:30-05:00
New Revision: 0acc260b574e28f5247e8ad4d8c9805b8005c841

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

LOG: [mlir][linalg] Support generating builders for named op attributes

This commit adds support to generate an additional builder for
each named op that has attributes. This gives better experience
when creating the named ops.

Along the way adds support for i64.

Reviewed By: hanchung

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

Added: 


Modified: 
mlir/test/mlir-linalg-ods-gen/test-linalg-ods-gen.tc
mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-gen.cpp

Removed: 




diff  --git a/mlir/test/mlir-linalg-ods-gen/test-linalg-ods-gen.tc 
b/mlir/test/mlir-linalg-ods-gen/test-linalg-ods-gen.tc
index 226a09669b1c..9bd6152f07da 100644
--- a/mlir/test/mlir-linalg-ods-gen/test-linalg-ods-gen.tc
+++ b/mlir/test/mlir-linalg-ods-gen/test-linalg-ods-gen.tc
@@ -88,6 +88,7 @@ def test3(A: f32(Batch, M, K), B: f32(K, N)) -> (C: 
f32(Batch, M, N)) {
 // ODS: F32:$f32_attr,
 // ODS: RankedF32ElementsAttr<[4]>:$fvec_attr,
 // ODS: I32:$i32_attr,
+// ODS: I64:$i64_attr,
 // ODS: RankedI32ElementsAttr<[5, 6]>:$ivec_attr,
 // ODS: OptionalAttr:$optional_attr
 //
@@ -96,6 +97,7 @@ def test4(A: f32(Batch, M, K), B: f32(K, N)) -> (C: 
f32(Batch, M, N))
 attr(
   f32_attr: f32,
   i32_attr: i32,
+  i64_attr: i64,
   fvec_attr: 4xf32,
   ivec_attr: 5x6xi32,
   array_attr : f32[],
@@ -126,6 +128,7 @@ def test5(I: f32(N, H, W, C), K: f32(F, KH, KW, C)) -> (O: 
f32(N, H, W, F))
 I(n, h * strides[0] + kh, w * strides[1] + kw, c), K(f, kh, kw, c)));
 }
 
+// Test documentation
 // ODS-LABEL: def Test6Op
 // ODS:   let summary = [{ My magic op. }];
 // ODS-NEXT:  let description = [{
@@ -144,3 +147,18 @@ It has one output.
 {
   C(m) = std_addf(std_mulf(A(m, k), B(k)));
 }
+
+// Test attribute builder
+// ODS-LABEL: def Test7Op
+// ODS: OpBuilderDAG<
+// ODS:   (ins "TypeRange":$resultTensorTypes, "ValueRange":$inputs,
+// ODS:"ValueRange":$outputs, "Attribute":$attr_a, 
"Attribute":$attr_b)
+// ODS:   $_state.addAttribute("attr_a", attr_a);
+// ODS:   $_state.addAttribute("attr_b", attr_b);
+//
+ods_def:
+def test7(A: f32(M, K), B: f32(K)) -> (C: f32(M))
+ attr(attr_a: f32, attr_b: 4xi32)
+{
+  C(m) = std_addf(std_mulf(A(m, k), B(k)));
+}

diff  --git a/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-gen.cpp 
b/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-gen.cpp
index f4b7f9f9323a..47841c840fe5 100644
--- a/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-gen.cpp
+++ b/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-gen.cpp
@@ -1768,6 +1768,7 @@ void TCParser::printODS(llvm::raw_ostream , StringRef 
cppOpName,
 std::string odsType = llvm::StringSwitch(elementType)
   .Case("f32", "F32")
   .Case("i32", "I32")
+  .Case("i64", "I64")
   .Default("");
 if (odsType.empty()) {
   parser.emitError("unimplemented support for attribute element type: " +
@@ -1811,7 +1812,8 @@ void TCParser::printODS(llvm::raw_ostream , StringRef 
cppOpName,
   let regions = (region AnyRegion:$region);
 
   let skipDefaultBuilders = 1;
-  let builders = [ OpBuilderDAG<
+  let builders = [
+OpBuilderDAG<
 (ins "ValueRange":$inputs, "ValueRange":$outputs),
 [{{
   $_state.addOperands(inputs);
@@ -1826,7 +1828,8 @@ void TCParser::printODS(llvm::raw_ostream , StringRef 
cppOpName,
 $_state,
 TypeRange(inputs),
 TypeRange(outputs));
-}]>, OpBuilderDAG<
+}]>,
+OpBuilderDAG<
 (ins "TypeRange":$resultTensorTypes, "ValueRange":$inputs,
  "ValueRange":$outputs),
 [{{
@@ -1843,7 +1846,8 @@ void TCParser::printODS(llvm::raw_ostream , StringRef 
cppOpName,
 $_state,
 TypeRange(inputs),
 TypeRange(outputs));
-}]>, OpBuilderDAG<
+}]>,
+OpBuilderDAG<
 (ins "TypeRange":$resultTensorTypes, "ValueRange":$operands,
  CArg<"ArrayRef", "{{}">:$attributes),
 [{{
@@ -1852,6 +1856,7 @@ void TCParser::printODS(llvm::raw_ostream , StringRef 
cppOpName,
   $_state.addTypes(resultTensorTypes);
   (void)$_state.addRegion();
 }]>
+{5}
   ];
   let printer = [{{ return ::printNamedStructuredOp(p, *this); }];
   let parser = [{{ return ::parseNamedStructuredOp<{0}>(parser, result); 
}];
@@ -1873,8 +1878,8 @@ void TCParser::printODS(llvm::raw_ostream , StringRef 
cppOpName,
   }];
   })FMT";
 
+  // Generate documentation.
   std::string doc;
-
   if 

[llvm-branch-commits] [llvm] 5e4480b - [ARM] Don't run the block placement pass at O0

2021-01-15 Thread Sam Tebbs via llvm-branch-commits

Author: Sam Tebbs
Date: 2021-01-15T13:59:29Z
New Revision: 5e4480b6c0f02beef5ca7f62c3427031872fcd52

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

LOG: [ARM] Don't run the block placement pass at O0

The block placement pass shouldn't run unless optimisations are enabled.

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

Added: 


Modified: 
llvm/lib/Target/ARM/ARMBlockPlacement.cpp
llvm/lib/Target/ARM/ARMTargetMachine.cpp

Removed: 




diff  --git a/llvm/lib/Target/ARM/ARMBlockPlacement.cpp 
b/llvm/lib/Target/ARM/ARMBlockPlacement.cpp
index fda05f526335..20491273ea5d 100644
--- a/llvm/lib/Target/ARM/ARMBlockPlacement.cpp
+++ b/llvm/lib/Target/ARM/ARMBlockPlacement.cpp
@@ -58,6 +58,8 @@ INITIALIZE_PASS(ARMBlockPlacement, DEBUG_TYPE, "ARM block 
placement", false,
 false)
 
 bool ARMBlockPlacement::runOnMachineFunction(MachineFunction ) {
+  if (skipFunction(MF.getFunction()))
+  return false;
   const ARMSubtarget  = static_cast(MF.getSubtarget());
   if (!ST.hasLOB())
 return false;

diff  --git a/llvm/lib/Target/ARM/ARMTargetMachine.cpp 
b/llvm/lib/Target/ARM/ARMTargetMachine.cpp
index 51399941629a..237ef54c8339 100644
--- a/llvm/lib/Target/ARM/ARMTargetMachine.cpp
+++ b/llvm/lib/Target/ARM/ARMTargetMachine.cpp
@@ -553,11 +553,11 @@ void ARMPassConfig::addPreEmitPass() {
 return MF.getSubtarget().isThumb2();
   }));
 
-  addPass(createARMBlockPlacementPass());
-
-  // Don't optimize barriers at -O0.
-  if (getOptLevel() != CodeGenOpt::None)
+  // Don't optimize barriers or block placement at -O0.
+  if (getOptLevel() != CodeGenOpt::None) {
+addPass(createARMBlockPlacementPass());
 addPass(createARMOptimizeBarriersPass());
+  }
 }
 
 void ARMPassConfig::addPreEmitPass2() {



___
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] e9f1ed2 - [WebAssembly] MC layer writes table symbols to object files

2021-01-15 Thread Andy Wingo via llvm-branch-commits

Author: Andy Wingo
Date: 2021-01-15T14:55:55+01:00
New Revision: e9f1ed2306b1b3aedcb1acef2b50e252a77a04b9

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

LOG: [WebAssembly] MC layer writes table symbols to object files

Now that the linker handles table symbols, we can allow the frontend to
produce them.

Depends on D91870.

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

Added: 


Modified: 
llvm/lib/MC/WasmObjectWriter.cpp
llvm/test/MC/WebAssembly/debug-info.ll
llvm/test/MC/WebAssembly/debug-info64.ll
llvm/test/MC/WebAssembly/function-alias.ll
llvm/test/MC/WebAssembly/global-ctor-dtor.ll
llvm/test/MC/WebAssembly/reloc-pic.s
llvm/test/MC/WebAssembly/type-index.s
llvm/test/MC/WebAssembly/weak-alias.s

Removed: 




diff  --git a/llvm/lib/MC/WasmObjectWriter.cpp 
b/llvm/lib/MC/WasmObjectWriter.cpp
index fb41c3763c15..b2d94dcadd81 100644
--- a/llvm/lib/MC/WasmObjectWriter.cpp
+++ b/llvm/lib/MC/WasmObjectWriter.cpp
@@ -519,6 +519,13 @@ void WasmObjectWriter::recordRelocation(MCAssembler ,
   Sym->setUndefined();
 }
 Sym->setUsedInReloc();
+// Any time we have a TABLE_INDEX relocation against a function symbol, we
+// need to ensure that table itself is part of the final output too.  In 
the
+// future we may want to define a new kind of reloc against both the
+// function and the table, so that the linker can see that the function
+// symbol keeps the table alive, but for now manually mark the table as
+// live.
+Sym->setNoStrip();
 Asm.registerSymbol(*Sym);
   }
 
@@ -1670,10 +1677,6 @@ uint64_t WasmObjectWriter::writeOneObject(MCAssembler 
,
   WS.setIndex(InvalidIndex);
   continue;
 }
-if (WS.isTable() && WS.getName() == "__indirect_function_table") {
-  // For the moment, don't emit table symbols -- wasm-ld can't handle them.
-  continue;
-}
 LLVM_DEBUG(dbgs() << "adding to symtab: " << WS << "\n");
 
 uint32_t Flags = 0;

diff  --git a/llvm/test/MC/WebAssembly/debug-info.ll 
b/llvm/test/MC/WebAssembly/debug-info.ll
index 167d912c84a2..88d19d9191a9 100644
--- a/llvm/test/MC/WebAssembly/debug-info.ll
+++ b/llvm/test/MC/WebAssembly/debug-info.ll
@@ -89,44 +89,44 @@
 ; CHECK-NEXT:  }
 ; CHECK-NEXT:  Section {
 ; CHECK-NEXT:Type: CUSTOM (0x0)
-; CHECK-NEXT:Size: 91
+; CHECK-NEXT:Size: 95
 ; CHECK-NEXT:Offset: 731
 ; CHECK-NEXT:Name: linking
 ; CHECK-NEXT:  }
 ; CHECK-NEXT:  Section {
 ; CHECK-NEXT:Type: CUSTOM (0x0)
 ; CHECK-NEXT:Size: 9
-; CHECK-NEXT:Offset: 836
+; CHECK-NEXT:Offset: 840
 ; CHECK-NEXT:Name: reloc.DATA
 ; CHECK-NEXT:  }
 ; CHECK-NEXT:  Section {
 ; CHECK-NEXT:Type: CUSTOM (0x0)
 ; CHECK-NEXT:Size: 61
-; CHECK-NEXT:Offset: 862
+; CHECK-NEXT:Offset: 866
 ; CHECK-NEXT:Name: reloc..debug_info
 ; CHECK-NEXT:  }
 ; CHECK-NEXT:  Section {
 ; CHECK-NEXT:Type: CUSTOM (0x0)
 ; CHECK-NEXT:Size: 6
-; CHECK-NEXT:Offset: 947
+; CHECK-NEXT:Offset: 951
 ; CHECK-NEXT:Name: reloc..debug_pubnames
 ; CHECK-NEXT:  }
 ; CHECK-NEXT:  Section {
 ; CHECK-NEXT:Type: CUSTOM (0x0)
 ; CHECK-NEXT:Size: 6
-; CHECK-NEXT:Offset: 981
+; CHECK-NEXT:Offset: 985
 ; CHECK-NEXT:Name: reloc..debug_pubtypes
 ; CHECK-NEXT:  }
 ; CHECK-NEXT:  Section {
 ; CHECK-NEXT:Type: CUSTOM (0x0)
 ; CHECK-NEXT:Size: 6
-; CHECK-NEXT:Offset: 1015
+; CHECK-NEXT:Offset: 1019
 ; CHECK-NEXT:Name: reloc..debug_line
 ; CHECK-NEXT:  }
 ; CHECK-NEXT:  Section {
 ; CHECK-NEXT:Type: CUSTOM (0x0)
 ; CHECK-NEXT:Size: 77
-; CHECK-NEXT:Offset: 1045
+; CHECK-NEXT:Offset: 1049
 ; CHECK-NEXT:Name: producers
 ; CHECK-NEXT:  }
 ; CHECK-NEXT:]
@@ -238,6 +238,16 @@
 ; CHECK-NEXT:]
 ; CHECK-NEXT:ElementIndex: 0xC
 ; CHECK-NEXT:  }
+; CHECK-NEXT:  Symbol {
+; CHECK-NEXT:Name: __indirect_function_table
+; CHECK-NEXT:Type: TABLE (0x5)
+; CHECK-NEXT:Flags [ (0x90)
+; CHECK-NEXT:  NO_STRIP (0x80)
+; CHECK-NEXT:  UNDEFINED (0x10)
+; CHECK-NEXT:]
+; CHECK-NEXT:ImportModule: env
+; CHECK-NEXT:ElementIndex: 0x0
+; CHECK-NEXT:  }
 ; CHECK-NEXT:]
 
 ; generated from the following C code using: clang --target=wasm32 -g -O0 -S 
-emit-llvm test.c

diff  --git a/llvm/test/MC/WebAssembly/debug-info64.ll 
b/llvm/test/MC/WebAssembly/debug-info64.ll
index acba8aa27360..1755f2b7ef5c 100644
--- a/llvm/test/MC/WebAssembly/debug-info64.ll
+++ b/llvm/test/MC/WebAssembly/debug-info64.ll
@@ -89,44 +89,44 @@
 ; CHECK-NEXT:   }
 ; CHECK-NEXT:   Section {
 ; CHECK-NEXT: Type: CUSTOM (0x0)
-; CHECK-NEXT: Size: 91
+; CHECK-NEXT: Size: 95
 ; CHECK-NEXT: Offset: 759
 ; CHECK-NEXT: Name: linking
 ; CHECK-NEXT:   }
 ; CHECK-NEXT:   Section {
 ; CHECK-NEXT: 

[llvm-branch-commits] [llvm] 1dfd5c9 - [X86][AVX] combineHorizOpWithShuffle - support target shuffles in HOP(SHUFFLE(X, Y), SHUFFLE(X, Y)) -> SHUFFLE(HOP(X, Y))

2021-01-15 Thread Simon Pilgrim via llvm-branch-commits

Author: Simon Pilgrim
Date: 2021-01-15T13:55:30Z
New Revision: 1dfd5c9ad8cf677fb4c9c3ccf39d7b1f20c397d3

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

LOG: [X86][AVX] combineHorizOpWithShuffle - support target shuffles in 
HOP(SHUFFLE(X,Y),SHUFFLE(X,Y)) -> SHUFFLE(HOP(X,Y))

Be more aggressive on (AVX2+) folds of lane shuffles of 256-bit horizontal ops 
by working on target/faux shuffles as well.

Added: 


Modified: 
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/test/CodeGen/X86/haddsub-2.ll
llvm/test/CodeGen/X86/haddsub-undef.ll

Removed: 




diff  --git a/llvm/lib/Target/X86/X86ISelLowering.cpp 
b/llvm/lib/Target/X86/X86ISelLowering.cpp
index d45eb5366bfe..a84250782c19 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -43114,30 +43114,32 @@ static SDValue combineHorizOpWithShuffle(SDNode *N, 
SelectionDAG ,
   // Attempt to fold HOP(SHUFFLE(X,Y),SHUFFLE(X,Y)) -> SHUFFLE(HOP(X,Y)).
   // TODO: Relax shuffle scaling to support sub-128-bit subvector shuffles.
   if (VT.is256BitVector() && Subtarget.hasInt256()) {
-if (auto *SVN0 = dyn_cast(N0)) {
-  if (auto *SVN1 = dyn_cast(N1)) {
-SmallVector ShuffleMask0, ShuffleMask1;
-if (scaleShuffleElements(SVN0->getMask(), 2, ShuffleMask0) &&
-scaleShuffleElements(SVN1->getMask(), 2, ShuffleMask1)) {
-  SDValue Op00 = SVN0->getOperand(0);
-  SDValue Op01 = SVN0->getOperand(1);
-  SDValue Op10 = SVN1->getOperand(0);
-  SDValue Op11 = SVN1->getOperand(1);
-  if ((Op00 == Op11) && (Op01 == Op10)) {
-std::swap(Op10, Op11);
-ShuffleVectorSDNode::commuteMask(ShuffleMask1);
-  }
-  if ((Op00 == Op10) && (Op01 == Op11)) {
-SmallVector ShuffleMask;
-ShuffleMask.append(ShuffleMask0.begin(), ShuffleMask0.end());
-ShuffleMask.append(ShuffleMask1.begin(), ShuffleMask1.end());
-SDLoc DL(N);
-MVT ShufVT = VT.isFloatingPoint() ? MVT::v4f64 : MVT::v4i64;
-SDValue Res = DAG.getNode(Opcode, DL, VT, Op00, Op01);
-Res = DAG.getBitcast(ShufVT, Res);
-Res = DAG.getVectorShuffle(ShufVT, DL, Res, Res, ShuffleMask);
-return DAG.getBitcast(VT, Res);
-  }
+SmallVector Mask0, Mask1;
+SmallVector Ops0, Ops1;
+if (getTargetShuffleInputs(N0, Ops0, Mask0, DAG) && !isAnyZero(Mask0) &&
+getTargetShuffleInputs(N1, Ops1, Mask1, DAG) && !isAnyZero(Mask1) &&
+!Ops0.empty() && !Ops1.empty()) {
+  SDValue Op00 = Ops0.front(), Op01 = Ops0.back();
+  SDValue Op10 = Ops1.front(), Op11 = Ops1.back();
+  SmallVector ShuffleMask0, ShuffleMask1;
+  if (Op00.getValueType() == SrcVT && Op01.getValueType() == SrcVT &&
+  Op11.getValueType() == SrcVT && Op11.getValueType() == SrcVT &&
+  scaleShuffleElements(Mask0, 2, ShuffleMask0) &&
+  scaleShuffleElements(Mask1, 2, ShuffleMask1)) {
+if ((Op00 == Op11) && (Op01 == Op10)) {
+  std::swap(Op10, Op11);
+  ShuffleVectorSDNode::commuteMask(ShuffleMask1);
+}
+if ((Op00 == Op10) && (Op01 == Op11)) {
+  SmallVector ShuffleMask;
+  ShuffleMask.append(ShuffleMask0.begin(), ShuffleMask0.end());
+  ShuffleMask.append(ShuffleMask1.begin(), ShuffleMask1.end());
+  SDLoc DL(N);
+  MVT ShufVT = VT.isFloatingPoint() ? MVT::v4f64 : MVT::v4i64;
+  SDValue Res = DAG.getNode(Opcode, DL, VT, Op00, Op01);
+  Res = DAG.getBitcast(ShufVT, Res);
+  Res = DAG.getVectorShuffle(ShufVT, DL, Res, Res, ShuffleMask);
+  return DAG.getBitcast(VT, Res);
 }
   }
 }

diff  --git a/llvm/test/CodeGen/X86/haddsub-2.ll 
b/llvm/test/CodeGen/X86/haddsub-2.ll
index a025604f44a5..82fd7a2699a5 100644
--- a/llvm/test/CodeGen/X86/haddsub-2.ll
+++ b/llvm/test/CodeGen/X86/haddsub-2.ll
@@ -444,12 +444,18 @@ define <4 x double> @avx_vhadd_pd_test(<4 x double> %A, 
<4 x double> %B) {
 ; SSE-NEXT:movapd %xmm2, %xmm1
 ; SSE-NEXT:retq
 ;
-; AVX-LABEL: avx_vhadd_pd_test:
-; AVX:   # %bb.0:
-; AVX-NEXT:vperm2f128 {{.*#+}} ymm2 = ymm0[2,3],ymm1[2,3]
-; AVX-NEXT:vinsertf128 $1, %xmm1, %ymm0, %ymm0
-; AVX-NEXT:vhaddpd %ymm2, %ymm0, %ymm0
-; AVX-NEXT:retq
+; AVX1-LABEL: avx_vhadd_pd_test:
+; AVX1:   # %bb.0:
+; AVX1-NEXT:vperm2f128 {{.*#+}} ymm2 = ymm0[2,3],ymm1[2,3]
+; AVX1-NEXT:vinsertf128 $1, %xmm1, %ymm0, %ymm0
+; AVX1-NEXT:vhaddpd %ymm2, %ymm0, %ymm0
+; AVX1-NEXT:retq
+;
+; AVX2-LABEL: avx_vhadd_pd_test:
+; AVX2:   # %bb.0:
+; AVX2-NEXT:vhaddpd %ymm1, %ymm0, %ymm0
+; AVX2-NEXT:vpermpd {{.*#+}} ymm0 = ymm0[0,2,1,3]
+; AVX2-NEXT:retq
   %vecext = 

[llvm-branch-commits] [lldb] 4017c6f - [lldb][docs] Translate ASCII art to restructured text formatting

2021-01-15 Thread Raphael Isemann via llvm-branch-commits

Author: Raphael Isemann
Date: 2021-01-15T14:43:27+01:00
New Revision: 4017c6fe7f11db5f266306bcd504690be586620a

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

LOG: [lldb][docs] Translate ASCII art to restructured text formatting

This translates most of the old ASCII art in our documentation to the
equivalent in restructured text (which the new version of the LLDB docs
is using).

Added: 


Modified: 
lldb/bindings/interface/SBAddress.i
lldb/bindings/interface/SBBreakpoint.i
lldb/bindings/interface/SBBreakpointLocation.i
lldb/bindings/interface/SBBreakpointName.i
lldb/bindings/interface/SBCommandInterpreter.i
lldb/bindings/interface/SBCommandInterpreterRunOptions.i
lldb/bindings/interface/SBCommandReturnObject.i
lldb/bindings/interface/SBCompileUnit.i
lldb/bindings/interface/SBEnvironment.i
lldb/bindings/interface/SBError.i
lldb/bindings/interface/SBEvent.i
lldb/bindings/interface/SBFileSpec.i
lldb/bindings/interface/SBFrame.i
lldb/bindings/interface/SBFunction.i
lldb/bindings/interface/SBInstructionList.i
lldb/bindings/interface/SBLineEntry.i
lldb/bindings/interface/SBListener.i
lldb/bindings/interface/SBModule.i
lldb/bindings/interface/SBPlatform.i
lldb/bindings/interface/SBProcess.i
lldb/bindings/interface/SBSection.i
lldb/bindings/interface/SBSourceManager.i
lldb/bindings/interface/SBStream.i
lldb/bindings/interface/SBSymbol.i
lldb/bindings/interface/SBSymbolContext.i
lldb/bindings/interface/SBSymbolContextList.i
lldb/bindings/interface/SBTarget.i
lldb/bindings/interface/SBThread.i
lldb/bindings/interface/SBType.i
lldb/bindings/interface/SBTypeEnumMember.i
lldb/bindings/interface/SBValue.i
lldb/bindings/interface/SBValueList.i
lldb/bindings/interface/SBWatchpoint.i
lldb/bindings/python/python-extensions.swig
lldb/bindings/python/python.swig

Removed: 




diff  --git a/lldb/bindings/interface/SBAddress.i 
b/lldb/bindings/interface/SBAddress.i
index 6fd06c83d293..694a7723e225 100644
--- a/lldb/bindings/interface/SBAddress.i
+++ b/lldb/bindings/interface/SBAddress.i
@@ -17,8 +17,9 @@ libraries, bundles, frameworks) being loaded at 
diff erent
 addresses than the addresses found in the object file that
 represents them on disk. There are currently two types of addresses
 for a section:
-o file addresses
-o load addresses
+
+* file addresses
+* load addresses
 
 File addresses represents the virtual addresses that are in the 'on
 disk' object files. These virtual addresses are converted to be

diff  --git a/lldb/bindings/interface/SBBreakpoint.i 
b/lldb/bindings/interface/SBBreakpoint.i
index 696795241b11..983e9facfe20 100644
--- a/lldb/bindings/interface/SBBreakpoint.i
+++ b/lldb/bindings/interface/SBBreakpoint.i
@@ -11,7 +11,7 @@ namespace lldb {
 "Represents a logical breakpoint and its associated settings.
 
 For example (from test/functionalities/breakpoint/breakpoint_ignore_count/
-TestBreakpointIgnoreCount.py),
+TestBreakpointIgnoreCount.py),::
 
 def breakpoint_ignore_count_python(self):
 '''Use Python APIs to set breakpoint ignore count.'''
@@ -62,13 +62,13 @@ TestBreakpointIgnoreCount.py),
 
 process.Continue()
 
-SBBreakpoint supports breakpoint location iteration, for example,
+SBBreakpoint supports breakpoint location iteration, for example,::
 
 for bl in breakpoint:
 print('breakpoint location load addr: %s' % hex(bl.GetLoadAddress()))
 print('breakpoint location condition: %s' % hex(bl.GetCondition()))
 
-and rich comparison methods which allow the API program to use,
+and rich comparison methods which allow the API program to use,::
 
 if aBreakpoint == bBreakpoint:
 ...
@@ -102,7 +102,7 @@ public:
 
 lldb::SBTarget
 GetTarget() const;
-  
+
 lldb::SBBreakpointLocation
 FindLocationByAddress (lldb::addr_t vm_addr);
 

diff  --git a/lldb/bindings/interface/SBBreakpointLocation.i 
b/lldb/bindings/interface/SBBreakpointLocation.i
index dc39c83c2d67..fc37475ba745 100644
--- a/lldb/bindings/interface/SBBreakpointLocation.i
+++ b/lldb/bindings/interface/SBBreakpointLocation.i
@@ -15,7 +15,7 @@ A breakpoint location is defined by the breakpoint that 
produces it,
 and the address that resulted in this particular instantiation.
 Each breakpoint location has its settable options.
 
-SBBreakpoint contains SBBreakpointLocation(s). See docstring of SBBreakpoint
+:py:class:`SBBreakpoint` contains SBBreakpointLocation(s). See docstring of 
SBBreakpoint
 for retrieval of an SBBreakpointLocation from an SBBreakpoint."
 ) SBBreakpointLocation;
 class SBBreakpointLocation

diff  --git a/lldb/bindings/interface/SBBreakpointName.i 

[llvm-branch-commits] [clang-tools-extra] c77c3d1 - [clangd] Set correct CWD when using compile_flags.txt

2021-01-15 Thread Adam Czachorowski via llvm-branch-commits

Author: Adam Czachorowski
Date: 2021-01-15T14:26:24+01:00
New Revision: c77c3d1d18cdd58989f9d35bbf6c31f5fda0a125

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

LOG: [clangd] Set correct CWD when using compile_flags.txt

This fixes a bug where clangd would attempt to set CWD to the
compile_flags.txt file itself.

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

Added: 


Modified: 
clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp 
b/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
index d983f76e227f..fde4e56ac72d 100644
--- a/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
+++ b/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
@@ -271,7 +271,8 @@ parseJSON(PathRef Path, llvm::StringRef Data, std::string 
) {
 }
 static std::unique_ptr
 parseFixed(PathRef Path, llvm::StringRef Data, std::string ) {
-  return tooling::FixedCompilationDatabase::loadFromBuffer(Path, Data, Error);
+  return tooling::FixedCompilationDatabase::loadFromBuffer(
+  llvm::sys::path::parent_path(Path), Data, Error);
 }
 
 bool DirectoryBasedGlobalCompilationDatabase::DirectoryCache::load(

diff  --git 
a/clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp 
b/clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
index 63b1b731656a..fbb85684af5f 100644
--- a/clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
+++ b/clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
@@ -279,6 +279,17 @@ TEST(GlobalCompilationDatabaseTest, BuildDir) {
   << "x/build/compile_flags.json only applicable to x/";
 }
 
+TEST(GlobalCompilationDatabaseTest, CompileFlagsDirectory) {
+  MockFS FS;
+  FS.Files[testPath("x/compile_flags.txt")] = "-DFOO";
+  DirectoryBasedGlobalCompilationDatabase CDB(FS);
+  auto Commands = CDB.getCompileCommand(testPath("x/y.cpp"));
+  ASSERT_TRUE(Commands.hasValue());
+  EXPECT_THAT(Commands.getValue().CommandLine, Contains("-DFOO"));
+  // Make sure we pick the right working directory.
+  EXPECT_EQ(testPath("x"), Commands.getValue().Directory);
+}
+
 TEST(GlobalCompilationDatabaseTest, NonCanonicalFilenames) {
   OverlayCDB DB(nullptr);
   std::vector DiscoveredFiles;



___
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] [clang-tools-extra] aeaeb9e - [clangd] Make ExpandAutoType not available on template params.

2021-01-15 Thread Adam Czachorowski via llvm-branch-commits

Author: Adam Czachorowski
Date: 2021-01-15T14:19:05+01:00
New Revision: aeaeb9e6bdc90d9c4b839ac0e4edc6255021cced

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

LOG: [clangd] Make ExpandAutoType not available on template params.

We cannot expand auto when used inside a template param (C++17 feature),
so do not offer it there.

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

Added: 


Modified: 
clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp
clang-tools-extra/clangd/unittests/tweaks/ExpandAutoTypeTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp 
b/clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp
index cb87cc764bc3..3776e1c3505d 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp
+++ b/clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp
@@ -82,6 +82,15 @@ bool isDeducedAsLambda(const SelectionTree::Node *Node, 
SourceLocation Loc) {
   return false;
 }
 
+// Returns true iff "auto" in Node is really part of the template parameter,
+// which we cannot expand.
+bool isTemplateParam(const SelectionTree::Node *Node) {
+  if (Node->Parent)
+if (Node->Parent->ASTNode.get())
+  return true;
+  return false;
+}
+
 bool ExpandAutoType::prepare(const Selection& Inputs) {
   CachedLocation = llvm::None;
   if (auto *Node = Inputs.ASTSelection.commonAncestor()) {
@@ -90,7 +99,8 @@ bool ExpandAutoType::prepare(const Selection& Inputs) {
 // Code in apply() does handle 'decltype(auto)' yet.
 if (!Result.getTypePtr()->isDecltypeAuto() &&
 !isStructuredBindingType(Node) &&
-!isDeducedAsLambda(Node, Result.getBeginLoc()))
+!isDeducedAsLambda(Node, Result.getBeginLoc()) &&
+!isTemplateParam(Node))
   CachedLocation = Result;
   }
 }

diff  --git a/clang-tools-extra/clangd/unittests/tweaks/ExpandAutoTypeTests.cpp 
b/clang-tools-extra/clangd/unittests/tweaks/ExpandAutoTypeTests.cpp
index 6c96ecc2332f..5554b68b31c7 100644
--- a/clang-tools-extra/clangd/unittests/tweaks/ExpandAutoTypeTests.cpp
+++ b/clang-tools-extra/clangd/unittests/tweaks/ExpandAutoTypeTests.cpp
@@ -80,6 +80,9 @@ TEST_F(ExpandAutoTypeTest, Test) {
   // unknown types in a template should not be replaced
   EXPECT_THAT(apply("template  void x() { ^auto y = T::z(); }"),
   StartsWith("fail: Could not deduce type for 'auto' type"));
+
+  ExtraArgs.push_back("-std=c++17");
+  EXPECT_UNAVAILABLE("template  class Y;");
 }
 
 } // namespace



___
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] 6edc3fe - [Orc] Fix OrcV2Examples after D94690

2021-01-15 Thread Stefan Gränitz via llvm-branch-commits

Author: Stefan Gränitz
Date: 2021-01-15T13:45:46+01:00
New Revision: 6edc3fe598aff04f9c1de6cc2ac97950b73b832d

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

LOG: [Orc] Fix OrcV2Examples after D94690

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

Added: 


Modified: 
llvm/examples/OrcV2Examples/LLJITDumpObjects/LLJITDumpObjects.cpp

llvm/examples/OrcV2Examples/LLJITWithGDBRegistrationListener/LLJITWithGDBRegistrationListener.cpp

llvm/examples/OrcV2Examples/LLJITWithObjectLinkingLayerPlugin/LLJITWithObjectLinkingLayerPlugin.cpp

Removed: 




diff  --git a/llvm/examples/OrcV2Examples/LLJITDumpObjects/LLJITDumpObjects.cpp 
b/llvm/examples/OrcV2Examples/LLJITDumpObjects/LLJITDumpObjects.cpp
index 9b020ef8c49d..2c975b188fb6 100644
--- a/llvm/examples/OrcV2Examples/LLJITDumpObjects/LLJITDumpObjects.cpp
+++ b/llvm/examples/OrcV2Examples/LLJITDumpObjects/LLJITDumpObjects.cpp
@@ -9,6 +9,7 @@
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ExecutionEngine/Orc/DebugUtils.h"
 #include "llvm/ExecutionEngine/Orc/LLJIT.h"
+#include "llvm/ExecutionEngine/Orc/ObjectTransformLayer.h"
 #include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/TargetSelect.h"
 #include "llvm/Support/raw_ostream.h"

diff  --git 
a/llvm/examples/OrcV2Examples/LLJITWithGDBRegistrationListener/LLJITWithGDBRegistrationListener.cpp
 
b/llvm/examples/OrcV2Examples/LLJITWithGDBRegistrationListener/LLJITWithGDBRegistrationListener.cpp
index e37b761913fc..78a0c5b197db 100644
--- 
a/llvm/examples/OrcV2Examples/LLJITWithGDBRegistrationListener/LLJITWithGDBRegistrationListener.cpp
+++ 
b/llvm/examples/OrcV2Examples/LLJITWithGDBRegistrationListener/LLJITWithGDBRegistrationListener.cpp
@@ -78,7 +78,7 @@ int main(int argc, char *argv[]) {
   // Make sure the debug info sections aren't stripped.
   ObjLinkingLayer->setProcessAllSections(true);
 
-  return std::move(ObjLinkingLayer);
+  return ObjLinkingLayer;
 })
 .create());
 

diff  --git 
a/llvm/examples/OrcV2Examples/LLJITWithObjectLinkingLayerPlugin/LLJITWithObjectLinkingLayerPlugin.cpp
 
b/llvm/examples/OrcV2Examples/LLJITWithObjectLinkingLayerPlugin/LLJITWithObjectLinkingLayerPlugin.cpp
index 36d28ab1..f349ce900e61 100644
--- 
a/llvm/examples/OrcV2Examples/LLJITWithObjectLinkingLayerPlugin/LLJITWithObjectLinkingLayerPlugin.cpp
+++ 
b/llvm/examples/OrcV2Examples/LLJITWithObjectLinkingLayerPlugin/LLJITWithObjectLinkingLayerPlugin.cpp
@@ -147,7 +147,7 @@ int main(int argc, char *argv[]) {
 ES, std::make_unique());
 // Add an instance of our plugin.
 ObjLinkingLayer->addPlugin(std::make_unique());
-return std::move(ObjLinkingLayer);
+return ObjLinkingLayer;
   })
   .create());
 



___
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] [lldb] bab121a - [lldb][docs] Use sphinx instead of epydoc to generate LLDB's Python reference

2021-01-15 Thread Raphael Isemann via llvm-branch-commits

Author: Raphael Isemann
Date: 2021-01-15T13:26:42+01:00
New Revision: bab121a1b66e85390cad019ec921febcba35519d

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

LOG: [lldb][docs] Use sphinx instead of epydoc to generate LLDB's Python 
reference

Currently LLDB uses epydoc to generate the Python API reference for the website.
epydoc however is unmaintained since more than a decade and no longer works with
Python 3. Also whatever setup we had once for generating the documentation on
the website server no longer seems to work, so the current website documentation
has been stale since more than a year.

This patch replaces epydoc with sphinx and its automodapi plugin that can
generate Python API references. LLVM already uses sphinx for the rest of the
documentation, so this way we are more consistent with the rest of LLVM. The
only new dependency is the automodapi plugin for sphinx.

This patch effectively does the following things:
* Remove the epydoc code.
* Make a new dummy Python API page in our website that just calls the Sphinx
  command for generated the API documentation.
* Add a mock _lldb module that is only used when generating the Python API.
 This way we don't have to build all of LLDB to generate the API reference.

Some notes:
* The long list of skips is necessary due to boilerplate functions that SWIG
  is generating. Sadly automodapi is not really scriptable from what I can see,
  so we have to blacklist this stuff manually.
* The .gitignore change because automodapi wants a subfolder of our
  documentation directory to place generated documentation files there. The path
  is also what is used on the website, so we can't really workaround this
  (without copying the whole `docs` dir somewhere else when we build).
* We have to use environment variables to pass our build path to our sphinx
  configuration. Sphinx doesn't support passing variables onto that script.

Reviewed By: JDevlieghere

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

Added: 
lldb/docs/_lldb/__init__.py
lldb/docs/python_api.rst

Modified: 
.gitignore
lldb/docs/CMakeLists.txt
lldb/docs/conf.py
lldb/docs/index.rst
llvm/cmake/modules/AddSphinxTarget.cmake

Removed: 




diff  --git a/.gitignore b/.gitignore
index 5e937552c5f8..c58c673c198a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -63,3 +63,5 @@ pythonenv*
 /clang/utils/analyzer/projects/*/PatchedSource
 /clang/utils/analyzer/projects/*/ScanBuildResults
 /clang/utils/analyzer/projects/*/RefScanBuildResults
+# automodapi puts generated documentation files here.
+/lldb/docs/python_api/

diff  --git a/lldb/docs/CMakeLists.txt b/lldb/docs/CMakeLists.txt
index b633a4abf054..af18eb22e954 100644
--- a/lldb/docs/CMakeLists.txt
+++ b/lldb/docs/CMakeLists.txt
@@ -15,60 +15,39 @@ if(DOXYGEN_FOUND)
   )
 endif()
 
-if (LLDB_ENABLE_PYTHON)
-  find_program(EPYDOC_EXECUTABLE NAMES epydoc epydoc.py)
-  if(EPYDOC_EXECUTABLE)
-message(STATUS "Found epydoc - ${EPYDOC_EXECUTABLE}")
-
-find_program(DOT_EXECUTABLE dot)
-if(DOT_EXECUTABLE)
-  set(EPYDOC_OPTIONS ${EPYDOC_OPTIONS} --graph all --dotpath 
${DOT_EXECUTABLE})
-  message(STATUS "Found dot - ${DOT_EXECUTABLE}")
-endif()
+if (LLVM_ENABLE_SPHINX)
+  include(AddSphinxTarget)
+endif()
 
-# Pretend to make a python package so that we can generate the reference.
-# Because we don't build liblldb, epydoc will complain that the import of
-# _lldb.so failed, but that doesn't prevent it from generating the docs.
+if (LLDB_ENABLE_PYTHON AND SPHINX_FOUND)
+  if (${SPHINX_OUTPUT_HTML})
+# Pretend that the SWIG generated API is a Python package.
 file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lldb)
 get_target_property(lldb_bindings_dir swig_wrapper_python BINARY_DIR)
 add_custom_target(lldb-python-doc-package
   COMMAND "${CMAKE_COMMAND}" -E copy "${lldb_bindings_dir}/lldb.py" 
"${CMAKE_CURRENT_BINARY_DIR}/lldb/__init__.py"
-  COMMENT "Copying lldb.py to pretend package.")
+  COMMENT "Copying lldb.py to pretend its a Python package.")
 add_dependencies(lldb-python-doc-package swig_wrapper_python)
 
-set(DOC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/doc")
-file(MAKE_DIRECTORY "${DOC_DIR}")
-add_custom_target(lldb-python-doc
-  ${EPYDOC_EXECUTABLE}
-  --html
-  lldb
-  -o ${CMAKE_CURRENT_BINARY_DIR}/python_reference
-  --name "LLDB python API"
-  --url "http://lldb.llvm.org;
-  ${EPYDOC_OPTIONS}
-  WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
-  COMMENT "Generating LLDB Python API reference with epydoc" VERBATIM
-)
-add_dependencies(lldb-python-doc swig_wrapper_python 
lldb-python-doc-package)
-  else()
-message(STATUS "Could NOT find epydoc")
+# FIXME: Don't treat Sphinx 

[llvm-branch-commits] [llvm] 619eb14 - [NFC][RISCV] Remove useless code in RISCVRegisterInfo.td.

2021-01-15 Thread Hsiangkai Wang via llvm-branch-commits

Author: Hsiangkai Wang
Date: 2021-01-15T20:08:51+08:00
New Revision: 619eb14775990d610236288f414a486d86df47cc

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

LOG: [NFC][RISCV] Remove useless code in RISCVRegisterInfo.td.

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

Added: 


Modified: 
llvm/lib/Target/RISCV/RISCVRegisterInfo.td

Removed: 




diff  --git a/llvm/lib/Target/RISCV/RISCVRegisterInfo.td 
b/llvm/lib/Target/RISCV/RISCVRegisterInfo.td
index fdac1eeb4fe4..99f74bfc2a09 100644
--- a/llvm/lib/Target/RISCV/RISCVRegisterInfo.td
+++ b/llvm/lib/Target/RISCV/RISCVRegisterInfo.td
@@ -383,10 +383,6 @@ let RegAltNameIndices = [ABIRegAltName] in {
   def VXRM   : RISCVReg<0, "vxrm", ["vxrm"]>;
 }
 
-class RegisterTypes reg_types> {
-  list types = reg_types;
-}
-
 class VReg regTypes, dag regList, int Vlmul>
   : RegisterClass<"RISCV",
   regTypes,



___
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] cf90527 - [Orc] Allow LLJITBuilder's CreateObjectLinkingLayer to return errors

2021-01-15 Thread Stefan Gränitz via llvm-branch-commits

Author: Stefan Gränitz
Date: 2021-01-15T12:53:41+01:00
New Revision: cf905274c6f4ec119fdb06a283070dcae4ed5881

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

LOG: [Orc] Allow LLJITBuilder's CreateObjectLinkingLayer to return errors

It can be useful for an ObjectLinkingLayerCreator to allow callee errors to get 
propagated to the builder. Specifically, this is the case when the ObjectLayer 
uses the EHFrameRegistrationPlugin, because it requires a TPCEHFrameRegistrar 
and instantiation for it may fail (e.g. if the required registration symbols 
are missing in the target process).

Reviewed By: lhames

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

Added: 


Modified: 

llvm/examples/OrcV2Examples/LLJITWithGDBRegistrationListener/LLJITWithGDBRegistrationListener.cpp

llvm/examples/OrcV2Examples/LLJITWithObjectLinkingLayerPlugin/LLJITWithObjectLinkingLayerPlugin.cpp
llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h
llvm/lib/ExecutionEngine/Orc/LLJIT.cpp

Removed: 




diff  --git 
a/llvm/examples/OrcV2Examples/LLJITWithGDBRegistrationListener/LLJITWithGDBRegistrationListener.cpp
 
b/llvm/examples/OrcV2Examples/LLJITWithGDBRegistrationListener/LLJITWithGDBRegistrationListener.cpp
index 78a0c5b197db..e37b761913fc 100644
--- 
a/llvm/examples/OrcV2Examples/LLJITWithGDBRegistrationListener/LLJITWithGDBRegistrationListener.cpp
+++ 
b/llvm/examples/OrcV2Examples/LLJITWithGDBRegistrationListener/LLJITWithGDBRegistrationListener.cpp
@@ -78,7 +78,7 @@ int main(int argc, char *argv[]) {
   // Make sure the debug info sections aren't stripped.
   ObjLinkingLayer->setProcessAllSections(true);
 
-  return ObjLinkingLayer;
+  return std::move(ObjLinkingLayer);
 })
 .create());
 

diff  --git 
a/llvm/examples/OrcV2Examples/LLJITWithObjectLinkingLayerPlugin/LLJITWithObjectLinkingLayerPlugin.cpp
 
b/llvm/examples/OrcV2Examples/LLJITWithObjectLinkingLayerPlugin/LLJITWithObjectLinkingLayerPlugin.cpp
index f349ce900e61..36d28ab1 100644
--- 
a/llvm/examples/OrcV2Examples/LLJITWithObjectLinkingLayerPlugin/LLJITWithObjectLinkingLayerPlugin.cpp
+++ 
b/llvm/examples/OrcV2Examples/LLJITWithObjectLinkingLayerPlugin/LLJITWithObjectLinkingLayerPlugin.cpp
@@ -147,7 +147,7 @@ int main(int argc, char *argv[]) {
 ES, std::make_unique());
 // Add an instance of our plugin.
 ObjLinkingLayer->addPlugin(std::make_unique());
-return ObjLinkingLayer;
+return std::move(ObjLinkingLayer);
   })
   .create());
 

diff  --git a/llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h 
b/llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h
index b0a06aa9cb4b..ff0aa0238523 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h
@@ -186,7 +186,7 @@ class LLJIT {
   }
 
 protected:
-  static std::unique_ptr
+  static Expected>
   createObjectLinkingLayer(LLJITBuilderState , ExecutionSession );
 
   static Expected>
@@ -250,8 +250,9 @@ class LLLazyJIT : public LLJIT {
 
 class LLJITBuilderState {
 public:
-  using ObjectLinkingLayerCreator = std::function(
-  ExecutionSession &, const Triple )>;
+  using ObjectLinkingLayerCreator =
+  std::function>(ExecutionSession &,
+   const Triple &)>;
 
   using CompileFunctionCreator =
   std::function>(

diff  --git a/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp 
b/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp
index 056f7b7e5cc0..d26cc6549487 100644
--- a/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp
@@ -954,8 +954,9 @@ Error LLJITBuilderState::prepareForConstruction() {
   JTMB->setRelocationModel(Reloc::PIC_);
   JTMB->setCodeModel(CodeModel::Small);
   CreateObjectLinkingLayer =
-  [TPC = this->TPC](ExecutionSession ,
-const Triple &) -> std::unique_ptr {
+  [TPC = this->TPC](
+  ExecutionSession ,
+  const Triple &) -> Expected> {
 std::unique_ptr ObjLinkingLayer;
 if (TPC)
   ObjLinkingLayer =
@@ -1011,7 +1012,7 @@ Expected 
LLJIT::lookupLinkerMangled(JITDylib ,
   makeJITDylibSearchOrder(, JITDylibLookupFlags::MatchAllSymbols), 
Name);
 }
 
-std::unique_ptr
+Expected>
 LLJIT::createObjectLinkingLayer(LLJITBuilderState , ExecutionSession ) {
 
   // If the config state provided an ObjectLinkingLayer factory then use it.
@@ -1057,8 +1058,7 @@ LLJIT::createCompileFunction(LLJITBuilderState ,
 
 LLJIT::LLJIT(LLJITBuilderState , Error )
 : ES(S.ES ? std::move(S.ES) : std::make_unique()), 
Main(),
-  

[llvm-branch-commits] [llvm] a5eb9df - [Orc][NFC] Turn LLJIT member ObjTransformLayer into unique_ptr

2021-01-15 Thread Stefan Gränitz via llvm-branch-commits

Author: Stefan Gränitz
Date: 2021-01-15T12:53:24+01:00
New Revision: a5eb9df1e3ba0a1c5d755f29f6f4cdcca4aec285

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

LOG: [Orc][NFC] Turn LLJIT member ObjTransformLayer into unique_ptr

All other layers in LLJIT are stored as unique_ptr's already. At this point, it 
is not strictly necessary for ObjTransformLayer, but it makes a follow-up 
change more straightforward.

Reviewed By: lhames

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

Added: 


Modified: 
llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h
llvm/lib/ExecutionEngine/Orc/LLJIT.cpp

Removed: 




diff  --git a/llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h 
b/llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h
index 354cf8ff757e..b0a06aa9cb4b 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h
@@ -19,7 +19,6 @@
 #include "llvm/ExecutionEngine/Orc/IRCompileLayer.h"
 #include "llvm/ExecutionEngine/Orc/IRTransformLayer.h"
 #include "llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h"
-#include "llvm/ExecutionEngine/Orc/ObjectTransformLayer.h"
 #include "llvm/ExecutionEngine/Orc/ThreadSafeModule.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/ThreadPool.h"
@@ -29,6 +28,7 @@ namespace orc {
 
 class LLJITBuilderState;
 class LLLazyJITBuilderState;
+class ObjectTransformLayer;
 class TargetProcessControl;
 
 /// A pre-fabricated ORC JIT stack that can serve as an alternative to MCJIT.
@@ -169,7 +169,7 @@ class LLJIT {
   ObjectLayer () { return *ObjLinkingLayer; }
 
   /// Returns a reference to the object transform layer.
-  ObjectTransformLayer () { return ObjTransformLayer; }
+  ObjectTransformLayer () { return *ObjTransformLayer; }
 
   /// Returns a reference to the IR transform layer.
   IRTransformLayer () { return *TransformLayer; }
@@ -209,7 +209,7 @@ class LLJIT {
   std::unique_ptr CompileThreads;
 
   std::unique_ptr ObjLinkingLayer;
-  ObjectTransformLayer ObjTransformLayer;
+  std::unique_ptr ObjTransformLayer;
   std::unique_ptr CompileLayer;
   std::unique_ptr TransformLayer;
   std::unique_ptr InitHelperTransformLayer;

diff  --git a/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp 
b/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp
index 13d447563d37..056f7b7e5cc0 100644
--- a/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp
@@ -11,6 +11,7 @@
 #include "llvm/ExecutionEngine/JITLink/JITLinkMemoryManager.h"
 #include "llvm/ExecutionEngine/Orc/MachOPlatform.h"
 #include "llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h"
+#include "llvm/ExecutionEngine/Orc/ObjectTransformLayer.h"
 #include "llvm/ExecutionEngine/Orc/OrcError.h"
 #include "llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h"
 #include "llvm/ExecutionEngine/Orc/TargetProcessControl.h"
@@ -997,7 +998,7 @@ Error LLJIT::addObjectFile(ResourceTrackerSP RT,
std::unique_ptr Obj) {
   assert(Obj && "Can not add null object");
 
-  return ObjTransformLayer.add(std::move(RT), std::move(Obj));
+  return ObjTransformLayer->add(std::move(RT), std::move(Obj));
 }
 
 Error LLJIT::addObjectFile(JITDylib , std::unique_ptr Obj) {
@@ -1057,8 +1058,7 @@ LLJIT::createCompileFunction(LLJITBuilderState ,
 LLJIT::LLJIT(LLJITBuilderState , Error )
 : ES(S.ES ? std::move(S.ES) : std::make_unique()), 
Main(),
   DL(""), TT(S.JTMB->getTargetTriple()),
-  ObjLinkingLayer(createObjectLinkingLayer(S, *ES)),
-  ObjTransformLayer(*this->ES, *ObjLinkingLayer) {
+  ObjLinkingLayer(createObjectLinkingLayer(S, *ES)) {
 
   ErrorAsOutParameter _();
 
@@ -1078,6 +1078,9 @@ LLJIT::LLJIT(LLJITBuilderState , Error )
 return;
   }
 
+  ObjTransformLayer =
+  std::make_unique(*ES, *ObjLinkingLayer);
+
   {
 auto CompileFunction = createCompileFunction(S, std::move(*S.JTMB));
 if (!CompileFunction) {
@@ -1085,7 +1088,7 @@ LLJIT::LLJIT(LLJITBuilderState , Error )
   return;
 }
 CompileLayer = std::make_unique(
-*ES, ObjTransformLayer, std::move(*CompileFunction));
+*ES, *ObjTransformLayer, std::move(*CompileFunction));
 TransformLayer = std::make_unique(*ES, *CompileLayer);
 InitHelperTransformLayer =
 std::make_unique(*ES, *TransformLayer);



___
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] 2b8db40 - [SVE] Restrict the usage of REINTERPRET_CAST.

2021-01-15 Thread Paul Walker via llvm-branch-commits

Author: Paul Walker
Date: 2021-01-15T11:32:13Z
New Revision: 2b8db40c92186731effd8948049919db8cf37dee

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

LOG: [SVE] Restrict the usage of REINTERPRET_CAST.

In order to limit the number of combinations of REINTERPRET_CAST,
whilst at the same time prevent overlap with BITCAST, this patch
establishes the following rules:

1. The operand and result element types must be the same.
2. The operand and/or result type must be an unpacked type.

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

Added: 


Modified: 
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
llvm/lib/Target/AArch64/AArch64ISelLowering.h
llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td

Removed: 




diff  --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp 
b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
index adfe492d6181..d72eee5abc26 100644
--- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -144,6 +144,25 @@ static inline EVT getPackedSVEVectorVT(EVT VT) {
 return MVT::nxv4f32;
   case MVT::f64:
 return MVT::nxv2f64;
+  case MVT::bf16:
+return MVT::nxv8bf16;
+  }
+}
+
+// NOTE: Currently there's only a need to return integer vector types. If this
+// changes then just add an extra "type" parameter.
+static inline EVT getPackedSVEVectorVT(ElementCount EC) {
+  switch (EC.getKnownMinValue()) {
+  default:
+llvm_unreachable("unexpected element count for vector");
+  case 16:
+return MVT::nxv16i8;
+  case 8:
+return MVT::nxv8i16;
+  case 4:
+return MVT::nxv4i32;
+  case 2:
+return MVT::nxv2i64;
   }
 }
 
@@ -3988,14 +4007,10 @@ SDValue AArch64TargetLowering::LowerMGATHER(SDValue Op,
   !static_cast(DAG.getSubtarget()).hasBF16())
 return SDValue();
 
-  // Handle FP data
+  // Handle FP data by using an integer gather and casting the result.
   if (VT.isFloatingPoint()) {
-ElementCount EC = VT.getVectorElementCount();
-auto ScalarIntVT =
-MVT::getIntegerVT(AArch64::SVEBitsPerBlock / EC.getKnownMinValue());
-PassThru = DAG.getNode(AArch64ISD::REINTERPRET_CAST, DL,
-   MVT::getVectorVT(ScalarIntVT, EC), PassThru);
-
+EVT PassThruVT = getPackedSVEVectorVT(VT.getVectorElementCount());
+PassThru = getSVESafeBitCast(PassThruVT, PassThru, DAG);
 InputVT = DAG.getValueType(MemVT.changeVectorElementTypeToInteger());
   }
 
@@ -4015,7 +4030,7 @@ SDValue AArch64TargetLowering::LowerMGATHER(SDValue Op,
   SDValue Gather = DAG.getNode(Opcode, DL, VTs, Ops);
 
   if (VT.isFloatingPoint()) {
-SDValue Cast = DAG.getNode(AArch64ISD::REINTERPRET_CAST, DL, VT, Gather);
+SDValue Cast = getSVESafeBitCast(VT, Gather, DAG);
 return DAG.getMergeValues({Cast, Gather}, DL);
   }
 
@@ -4052,15 +4067,10 @@ SDValue AArch64TargetLowering::LowerMSCATTER(SDValue Op,
   !static_cast(DAG.getSubtarget()).hasBF16())
 return SDValue();
 
-  // Handle FP data
+  // Handle FP data by casting the data so an integer scatter can be used.
   if (VT.isFloatingPoint()) {
-VT = VT.changeVectorElementTypeToInteger();
-ElementCount EC = VT.getVectorElementCount();
-auto ScalarIntVT =
-MVT::getIntegerVT(AArch64::SVEBitsPerBlock / EC.getKnownMinValue());
-StoreVal = DAG.getNode(AArch64ISD::REINTERPRET_CAST, DL,
-   MVT::getVectorVT(ScalarIntVT, EC), StoreVal);
-
+EVT StoreValVT = getPackedSVEVectorVT(VT.getVectorElementCount());
+StoreVal = getSVESafeBitCast(StoreValVT, StoreVal, DAG);
 InputVT = DAG.getValueType(MemVT.changeVectorElementTypeToInteger());
   }
 
@@ -17157,3 +17167,40 @@ SDValue 
AArch64TargetLowering::LowerFixedLengthVectorSetccToSVE(
   auto Promote = DAG.getBoolExtOrTrunc(Cmp, DL, PromoteVT, InVT);
   return convertFromScalableVector(DAG, Op.getValueType(), Promote);
 }
+
+SDValue AArch64TargetLowering::getSVESafeBitCast(EVT VT, SDValue Op,
+ SelectionDAG ) const {
+  SDLoc DL(Op);
+  EVT InVT = Op.getValueType();
+  const TargetLowering  = DAG.getTargetLoweringInfo();
+
+  assert(VT.isScalableVector() && TLI.isTypeLegal(VT) &&
+ InVT.isScalableVector() && TLI.isTypeLegal(InVT) &&
+ "Only expect to cast between legal scalable vector types!");
+  assert((VT.getVectorElementType() == MVT::i1) ==
+ (InVT.getVectorElementType() == MVT::i1) &&
+ "Cannot cast between data and predicate scalable vector types!");
+
+  if (InVT == VT)
+return Op;
+
+  if (VT.getVectorElementType() == MVT::i1)
+return DAG.getNode(AArch64ISD::REINTERPRET_CAST, DL, VT, Op);
+
+  EVT PackedVT = getPackedSVEVectorVT(VT.getVectorElementType());
+  EVT PackedInVT = 

[llvm-branch-commits] [llvm] 141e45b - [RISCV] Optimize Branch Comparisons

2021-01-15 Thread Sam Elliott via llvm-branch-commits

Author: Sam Elliott
Date: 2021-01-15T11:28:19Z
New Revision: 141e45b99ca09235b985504e8108dbb3cf210fbd

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

LOG: [RISCV] Optimize Branch Comparisons

I noticed in D94450 that there were quite a few places where we generate
the sequence:
```
  xN <- comparison ...
  xN <- xor xN, 1
  bnez xN, symbol
```

Given we know the XOR will be used by BRCOND, which only looks at the lowest
bit, I think we can remove the XOR and just invert the branch condition in
these cases?

The case mostly seems to come up in floating point tests, where there is often
more logic to combine the results of multiple SETCCs, rather than a single
(BRCOND (SETCC ...) ...).

Reviewed By: craig.topper

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

Added: 


Modified: 
llvm/lib/Target/RISCV/RISCVInstrInfo.td
llvm/test/CodeGen/RISCV/double-br-fcmp.ll
llvm/test/CodeGen/RISCV/float-br-fcmp.ll
llvm/test/CodeGen/RISCV/half-br-fcmp.ll

Removed: 




diff  --git a/llvm/lib/Target/RISCV/RISCVInstrInfo.td 
b/llvm/lib/Target/RISCV/RISCVInstrInfo.td
index 4aee8ae39cc2..6b0967e12736 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfo.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfo.td
@@ -966,9 +966,13 @@ def : BccSwapPat;
 def : BccSwapPat;
 def : BccSwapPat;
 
-// An extra pattern is needed for a brcond without a setcc (i.e. where the
+// Extra patterns are needed for a brcond without a setcc (i.e. where the
 // condition was calculated elsewhere).
 def : Pat<(brcond GPR:$cond, bb:$imm12), (BNE GPR:$cond, X0, bb:$imm12)>;
+// In this pattern, the `(xor $cond, 1)` functions like (boolean) `not`, as the
+// `brcond` only uses the lowest bit.
+def : Pat<(brcond (XLenVT (xor GPR:$cond, 1)), bb:$imm12),
+  (BEQ GPR:$cond, X0, bb:$imm12)>;
 
 let isBarrier = 1, isBranch = 1, isTerminator = 1 in
 def PseudoBR : Pseudo<(outs), (ins simm21_lsb0_jal:$imm20), [(br bb:$imm20)]>,

diff  --git a/llvm/test/CodeGen/RISCV/double-br-fcmp.ll 
b/llvm/test/CodeGen/RISCV/double-br-fcmp.ll
index 94744a22364d..6336d7b12ef3 100644
--- a/llvm/test/CodeGen/RISCV/double-br-fcmp.ll
+++ b/llvm/test/CodeGen/RISCV/double-br-fcmp.ll
@@ -100,8 +100,7 @@ define void @br_fcmp_oeq_alt(double %a, double %b) nounwind 
{
 ; RV32IFD-NEXT:sw a1, 4(sp)
 ; RV32IFD-NEXT:fld ft1, 0(sp)
 ; RV32IFD-NEXT:feq.d a0, ft1, ft0
-; RV32IFD-NEXT:xori a0, a0, 1
-; RV32IFD-NEXT:beqz a0, .LBB2_2
+; RV32IFD-NEXT:bnez a0, .LBB2_2
 ; RV32IFD-NEXT:  # %bb.1: # %if.else
 ; RV32IFD-NEXT:lw ra, 12(sp) # 4-byte Folded Reload
 ; RV32IFD-NEXT:addi sp, sp, 16
@@ -116,8 +115,7 @@ define void @br_fcmp_oeq_alt(double %a, double %b) nounwind 
{
 ; RV64IFD-NEXT:fmv.d.x ft0, a1
 ; RV64IFD-NEXT:fmv.d.x ft1, a0
 ; RV64IFD-NEXT:feq.d a0, ft1, ft0
-; RV64IFD-NEXT:xori a0, a0, 1
-; RV64IFD-NEXT:beqz a0, .LBB2_2
+; RV64IFD-NEXT:bnez a0, .LBB2_2
 ; RV64IFD-NEXT:  # %bb.1: # %if.else
 ; RV64IFD-NEXT:ld ra, 8(sp) # 8-byte Folded Reload
 ; RV64IFD-NEXT:addi sp, sp, 16
@@ -460,8 +458,7 @@ define void @br_fcmp_ugt(double %a, double %b) nounwind {
 ; RV32IFD-NEXT:sw a1, 4(sp)
 ; RV32IFD-NEXT:fld ft1, 0(sp)
 ; RV32IFD-NEXT:fle.d a0, ft1, ft0
-; RV32IFD-NEXT:xori a0, a0, 1
-; RV32IFD-NEXT:bnez a0, .LBB10_2
+; RV32IFD-NEXT:beqz a0, .LBB10_2
 ; RV32IFD-NEXT:  # %bb.1: # %if.else
 ; RV32IFD-NEXT:lw ra, 12(sp) # 4-byte Folded Reload
 ; RV32IFD-NEXT:addi sp, sp, 16
@@ -476,8 +473,7 @@ define void @br_fcmp_ugt(double %a, double %b) nounwind {
 ; RV64IFD-NEXT:fmv.d.x ft0, a1
 ; RV64IFD-NEXT:fmv.d.x ft1, a0
 ; RV64IFD-NEXT:fle.d a0, ft1, ft0
-; RV64IFD-NEXT:xori a0, a0, 1
-; RV64IFD-NEXT:bnez a0, .LBB10_2
+; RV64IFD-NEXT:beqz a0, .LBB10_2
 ; RV64IFD-NEXT:  # %bb.1: # %if.else
 ; RV64IFD-NEXT:ld ra, 8(sp) # 8-byte Folded Reload
 ; RV64IFD-NEXT:addi sp, sp, 16
@@ -505,8 +501,7 @@ define void @br_fcmp_uge(double %a, double %b) nounwind {
 ; RV32IFD-NEXT:sw a1, 4(sp)
 ; RV32IFD-NEXT:fld ft1, 0(sp)
 ; RV32IFD-NEXT:flt.d a0, ft1, ft0
-; RV32IFD-NEXT:xori a0, a0, 1
-; RV32IFD-NEXT:bnez a0, .LBB11_2
+; RV32IFD-NEXT:beqz a0, .LBB11_2
 ; RV32IFD-NEXT:  # %bb.1: # %if.else
 ; RV32IFD-NEXT:lw ra, 12(sp) # 4-byte Folded Reload
 ; RV32IFD-NEXT:addi sp, sp, 16
@@ -521,8 +516,7 @@ define void @br_fcmp_uge(double %a, double %b) nounwind {
 ; RV64IFD-NEXT:fmv.d.x ft0, a1
 ; RV64IFD-NEXT:fmv.d.x ft1, a0
 ; RV64IFD-NEXT:flt.d a0, ft1, ft0
-; RV64IFD-NEXT:xori a0, a0, 1
-; RV64IFD-NEXT:bnez a0, .LBB11_2
+; RV64IFD-NEXT:beqz a0, .LBB11_2
 ; RV64IFD-NEXT:  # %bb.1: # %if.else
 ; RV64IFD-NEXT:ld ra, 8(sp) # 8-byte Folded Reload
 ; RV64IFD-NEXT:addi sp, sp, 16
@@ -550,8 +544,7 @@ 

[llvm-branch-commits] [lldb] b9993fc - DynamicRegisterInfo calculate offsets in separate function

2021-01-15 Thread Muhammad Omair Javaid via llvm-branch-commits

Author: Muhammad Omair Javaid
Date: 2021-01-15T16:21:18+05:00
New Revision: b9993fcbf53aa28ca2e7696a1855affeb558b51c

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

LOG: DynamicRegisterInfo calculate offsets in separate function

This patch pull offset calculation logic out of DynamicRegisterInfo::Finalize
into a separate function. We are going to call this function whenever we
update SVE register sizes.

Reviewed By: labath

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

Added: 


Modified: 
lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.h

Removed: 




diff  --git a/lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp 
b/lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
index 411db05da462..8b85c7805f5b 100644
--- a/lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
+++ b/lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
@@ -442,28 +442,6 @@ void DynamicRegisterInfo::Finalize(const ArchSpec ) {
 m_sets[set].registers = m_set_reg_nums[set].data();
   }
 
-  // We are going to create a map between remote (eRegisterKindProcessPlugin)
-  // and local (eRegisterKindLLDB) register numbers. This map will give us
-  // remote register numbers in increasing order for offset calculation.
-  std::map remote_to_local_regnum_map;
-  for (const auto  : m_regs)
-remote_to_local_regnum_map[reg.kinds[eRegisterKindProcessPlugin]] =
-reg.kinds[eRegisterKindLLDB];
-
-  // At this stage we manually calculate g/G packet offsets of all primary
-  // registers, only if target XML or qRegisterInfo packet did not send
-  // an offset explicitly.
-  uint32_t reg_offset = 0;
-  for (auto const _pair : remote_to_local_regnum_map) {
-if (m_regs[regnum_pair.second].byte_offset == LLDB_INVALID_INDEX32 &&
-m_regs[regnum_pair.second].value_regs == nullptr) {
-  m_regs[regnum_pair.second].byte_offset = reg_offset;
-
-  reg_offset = m_regs[regnum_pair.second].byte_offset +
-   m_regs[regnum_pair.second].byte_size;
-}
-  }
-
   // sort and unique all value registers and make sure each is terminated with
   // LLDB_INVALID_REGNUM
 
@@ -485,24 +463,10 @@ void DynamicRegisterInfo::Finalize(const ArchSpec ) {
   // Now update all value_regs with each register info as needed
   const size_t num_regs = m_regs.size();
   for (size_t i = 0; i < num_regs; ++i) {
-if (m_value_regs_map.find(i) != m_value_regs_map.end()) {
+if (m_value_regs_map.find(i) != m_value_regs_map.end())
   m_regs[i].value_regs = m_value_regs_map[i].data();
-  // Assign a valid offset to all pseudo registers if not assigned by stub.
-  // Pseudo registers with value_regs list populated will share same offset
-  // as that of their corresponding primary register in value_regs list.
-  if (m_regs[i].byte_offset == LLDB_INVALID_INDEX32) {
-uint32_t value_regnum = m_regs[i].value_regs[0];
-if (value_regnum != LLDB_INVALID_INDEX32)
-  m_regs[i].byte_offset =
-  GetRegisterInfoAtIndex(remote_to_local_regnum_map[value_regnum])
-  ->byte_offset;
-  }
-} else
+else
   m_regs[i].value_regs = nullptr;
-
-reg_offset = m_regs[i].byte_offset + m_regs[i].byte_size;
-if (m_reg_data_byte_size < reg_offset)
-  m_reg_data_byte_size = reg_offset;
   }
 
   // Expand all invalidation dependencies
@@ -648,6 +612,55 @@ void DynamicRegisterInfo::Finalize(const ArchSpec ) {
   break;
 }
   }
+
+  // At this stage call ConfigureOffsets to calculate register offsets for
+  // targets supporting dynamic offset calculation. It also calculates
+  // total byte size of register data.
+  ConfigureOffsets();
+}
+
+void DynamicRegisterInfo::ConfigureOffsets() {
+  // We are going to create a map between remote (eRegisterKindProcessPlugin)
+  // and local (eRegisterKindLLDB) register numbers. This map will give us
+  // remote register numbers in increasing order for offset calculation.
+  std::map remote_to_local_regnum_map;
+  for (const auto  : m_regs)
+remote_to_local_regnum_map[reg.kinds[eRegisterKindProcessPlugin]] =
+reg.kinds[eRegisterKindLLDB];
+
+  // At this stage we manually calculate g/G packet offsets of all primary
+  // registers, only if target XML or qRegisterInfo packet did not send
+  // an offset explicitly.
+  uint32_t reg_offset = 0;
+  for (auto const _pair : remote_to_local_regnum_map) {
+if (m_regs[regnum_pair.second].byte_offset == LLDB_INVALID_INDEX32 &&
+m_regs[regnum_pair.second].value_regs == nullptr) {
+  m_regs[regnum_pair.second].byte_offset = reg_offset;
+
+  reg_offset = m_regs[regnum_pair.second].byte_offset +
+  

[llvm-branch-commits] [lldb] 4fd7766 - [LLDB] Add per-thread register infos shared pointer in gdb-remote

2021-01-15 Thread Muhammad Omair Javaid via llvm-branch-commits

Author: Muhammad Omair Javaid
Date: 2021-01-15T16:11:17+05:00
New Revision: 4fd77668b2cc215f0605fe20bb989b90b29f4346

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

LOG: [LLDB] Add per-thread register infos shared pointer in gdb-remote

In gdb-remote process we have register infos defind as a refernce object of
GDBRemoteDynamicRegisterInfo class. In past register infos have remained
constant througout the life time of a process.

This has changed after AArch64 SVE support where register infos will have
per-thread configuration. SVE registers will have per-thread size and can
be updated while running. This patch aims to build up for that support by
changing GDBRemoteDynamicRegisterInfo reference to a shared pointer deinfed
per-thread.

Reviewed By: labath

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

Added: 


Modified: 
lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.h
lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h

Removed: 




diff  --git a/lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp 
b/lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
index 71e9b5ea4b2a..411db05da462 100644
--- a/lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
+++ b/lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
@@ -650,6 +650,8 @@ void DynamicRegisterInfo::Finalize(const ArchSpec ) {
   }
 }
 
+bool DynamicRegisterInfo::IsReconfigurable() { return m_is_reconfigurable; }
+
 size_t DynamicRegisterInfo::GetNumRegisters() const { return m_regs.size(); }
 
 size_t DynamicRegisterInfo::GetNumRegisterSets() const { return m_sets.size(); 
}

diff  --git a/lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.h 
b/lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.h
index d5e6f90832bf..0938b472c4ce 100644
--- a/lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.h
+++ b/lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.h
@@ -17,6 +17,10 @@
 #include "lldb/lldb-private.h"
 
 class DynamicRegisterInfo {
+protected:
+  DynamicRegisterInfo(DynamicRegisterInfo &) = default;
+  DynamicRegisterInfo =(DynamicRegisterInfo &) = default;
+
 public:
   DynamicRegisterInfo() = default;
 
@@ -25,9 +29,6 @@ class DynamicRegisterInfo {
 
   virtual ~DynamicRegisterInfo() = default;
 
-  DynamicRegisterInfo(DynamicRegisterInfo &) = delete;
-  void operator=(DynamicRegisterInfo &) = delete;
-
   DynamicRegisterInfo(DynamicRegisterInfo &);
   DynamicRegisterInfo =(DynamicRegisterInfo &);
 
@@ -63,6 +64,8 @@ class DynamicRegisterInfo {
 
   void Clear();
 
+  bool IsReconfigurable();
+
 protected:
   // Classes that inherit from DynamicRegisterInfo can see and modify these
   typedef std::vector reg_collection;
@@ -89,5 +92,6 @@ class DynamicRegisterInfo {
   size_t m_reg_data_byte_size = 0u; // The number of bytes required to store
 // all registers
   bool m_finalized = false;
+  bool m_is_reconfigurable = false;
 };
 #endif // LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_DYNAMICREGISTERINFO_H

diff  --git 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
index 1f31b45d0fa9..19bcac5dc4b7 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
@@ -31,19 +31,20 @@ using namespace lldb_private::process_gdb_remote;
 // GDBRemoteRegisterContext constructor
 GDBRemoteRegisterContext::GDBRemoteRegisterContext(
 ThreadGDBRemote , uint32_t concrete_frame_idx,
-GDBRemoteDynamicRegisterInfo _info, bool read_all_at_once,
+GDBRemoteDynamicRegisterInfoSP reg_info_sp, bool read_all_at_once,
 bool write_all_at_once)
-: RegisterContext(thread, concrete_frame_idx), m_reg_info(reg_info),
-  m_reg_valid(), m_reg_data(), m_read_all_at_once(read_all_at_once),
+: RegisterContext(thread, concrete_frame_idx),
+  m_reg_info_sp(std::move(reg_info_sp)), m_reg_valid(), m_reg_data(),
+  m_read_all_at_once(read_all_at_once),
   m_write_all_at_once(write_all_at_once) {
   // Resize our vector of bools to contain one bool for every register. We will
   // use these boolean values to know when a register value is valid in
   // m_reg_data.
-  m_reg_valid.resize(reg_info.GetNumRegisters());
+  

[llvm-branch-commits] [clang-tools-extra] 9cc221b - [clangd] exclude symbols from document outline which do not originate from the main file

2021-01-15 Thread Ilya Golovenko via llvm-branch-commits

Author: Ilya Golovenko
Date: 2021-01-15T13:23:12+03:00
New Revision: 9cc221b99becf20397d935981eeb48cba5be7faf

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

LOG: [clangd] exclude symbols from document outline which do not originate from 
the main file

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

Added: 


Modified: 
clang-tools-extra/clangd/FindSymbols.cpp
clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/FindSymbols.cpp 
b/clang-tools-extra/clangd/FindSymbols.cpp
index d6908f7ab5fb..0a10e3efb05c 100644
--- a/clang-tools-extra/clangd/FindSymbols.cpp
+++ b/clang-tools-extra/clangd/FindSymbols.cpp
@@ -247,6 +247,10 @@ class DocumentOutline {
   enum class VisitKind { No, OnlyDecl, OnlyChildren, DeclAndChildren };
 
   void traverseDecl(Decl *D, std::vector ) {
+// Skip symbols which do not originate from the main file.
+if (!isInsideMainFile(D->getLocation(), AST.getSourceManager()))
+  return;
+
 if (auto *Templ = llvm::dyn_cast(D)) {
   // TemplatedDecl might be null, e.g. concepts.
   if (auto *TD = Templ->getTemplatedDecl())

diff  --git a/clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp 
b/clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
index 43658284937e..e594ade4295e 100644
--- a/clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
+++ b/clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
@@ -523,11 +523,13 @@ TEST(DocumentSymbols, InHeaderFile) {
   }
   )cpp";
   TU.Code = R"cpp(
+  int i; // declaration to finish preamble
   #include "bar.h"
   int test() {
   }
   )cpp";
-  EXPECT_THAT(getSymbols(TU.build()), ElementsAre(WithName("test")));
+  EXPECT_THAT(getSymbols(TU.build()),
+  ElementsAre(WithName("i"), WithName("test")));
 }
 
 TEST(DocumentSymbols, Template) {



___
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] 45ef053 - [llvm-readobj][test] - Remove excessive YAML fields from tests.

2021-01-15 Thread Georgii Rymar via llvm-branch-commits

Author: Georgii Rymar
Date: 2021-01-15T12:46:39+03:00
New Revision: 45ef053bd70952d35e9bea58fc4af11d6e507ce2

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

LOG: [llvm-readobj][test] - Remove excessive YAML fields from tests.

This removes excessive YAML keys from `SHT_GNU_verdef` sections.
Those keys are set by default.

Differential revision: https://reviews.llvm.org/D94660

Added: 


Modified: 
llvm/test/tools/llvm-readobj/ELF/dyn-symbols.test
llvm/test/tools/llvm-readobj/ELF/verdef-invalid.test
llvm/test/tools/llvm-readobj/ELF/versioninfo.test

Removed: 




diff  --git a/llvm/test/tools/llvm-readobj/ELF/dyn-symbols.test 
b/llvm/test/tools/llvm-readobj/ELF/dyn-symbols.test
index d8ad0200316e..edb12d861862 100644
--- a/llvm/test/tools/llvm-readobj/ELF/dyn-symbols.test
+++ b/llvm/test/tools/llvm-readobj/ELF/dyn-symbols.test
@@ -308,16 +308,10 @@ Sections:
 AddressAlign: 0x4
 Info: 0x2
 Entries:
-  - Version:1
-Flags:  0
-VersionNdx: 2
-Hash:   0
+  - VersionNdx: 2
 Names:
   - Default
-  - Version:1
-Flags:  0
-VersionNdx: 3
-Hash:   0
+  - VersionNdx: 3
 Names:
   - NonDefault
 DynamicSymbols:

diff  --git a/llvm/test/tools/llvm-readobj/ELF/verdef-invalid.test 
b/llvm/test/tools/llvm-readobj/ELF/verdef-invalid.test
index aa9b7b86e227..e7c93efed1a5 100644
--- a/llvm/test/tools/llvm-readobj/ELF/verdef-invalid.test
+++ b/llvm/test/tools/llvm-readobj/ELF/verdef-invalid.test
@@ -107,11 +107,7 @@ Sections:
 Link:.dynstr
 Info:0x1
 Entries:
-  - Version:1
-Flags:  0
-VersionNdx: 0
-Hash:   0
-Names:
+  - Names:
   - FOO
 ShSize: 1
 DynamicSymbols:
@@ -137,11 +133,7 @@ Sections:
 Link:.dynstr
 Info:0x1
 Entries:
-  - Version:1
-Flags:  0
-VersionNdx: 0
-Hash:   0
-Names:
+  - Names:
   - FOO
 ShSize: 21
 DynamicSymbols:
@@ -181,11 +173,7 @@ Sections:
 Link:.strtab
 Info:0x1
 Entries:
-  - Version:1
-Flags:  0
-VersionNdx: 0
-Hash:   0
-Names:
+  - Names:
   - FOO
   - Name: .strtab
 Type: SHT_STRTAB
@@ -213,11 +201,7 @@ Sections:
 Link: .dynstr
 Info: 0x1
 Entries:
-  - Version:1
-Flags:  0
-VersionNdx: 0
-Hash:   0
-Names:
+  - Names:
   - FOO
 DynamicSymbols:
   - Name: foo
@@ -266,10 +250,7 @@ Sections:
 Link: .dynstr
 Info: 0x1
 Entries:
-  - Version:0xfefe
-Flags:  0
-VersionNdx: 0
-Hash:   0
+  - Version: 0xfefe
 Names: []
 DynamicSymbols:
   - Name: foo

diff  --git a/llvm/test/tools/llvm-readobj/ELF/versioninfo.test 
b/llvm/test/tools/llvm-readobj/ELF/versioninfo.test
index 071ad9a1a28f..38f1c6a02973 100644
--- a/llvm/test/tools/llvm-readobj/ELF/versioninfo.test
+++ b/llvm/test/tools/llvm-readobj/ELF/versioninfo.test
@@ -27,38 +27,23 @@ Sections:
 AddressAlign: 0x0004
 Info: 0x0006
 Entries:
-  - Version:1
-Flags:  0
-VersionNdx: 0
-Hash:   0
-Names:
+  - Names:
   - VERSION1
-  - Version:1
-Flags:  1
-VersionNdx: 0
-Hash:   0
+  - Flags: 1
 Names:
   - VERSION1
-  - Version:1
-Flags:  2
-VersionNdx: 0
-Hash:   0
+  - Flags: 2
 Names:
   - VERSION1
-  - Version:1
-Flags:  4
-VersionNdx: 0
-Hash:   0
+  - Flags: 4
 Names:
   - VERSION1
-  - Version:1
-Flags:  7
+  - Flags:  7
 VersionNdx: 2
 Hash:   175630257
 Names:
   - VERSION1
-  - Version:1
-Flags:  8
+  - Flags:  8
 VersionNdx: 3
 Hash:   175630258
 Names:



___
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] d9afe85 - [yaml2obj/obj2yaml] - Refine handling of SHT_GNU_verdef sections.

2021-01-15 Thread Georgii Rymar via llvm-branch-commits

Author: Georgii Rymar
Date: 2021-01-15T12:40:42+03:00
New Revision: d9afe8588e49f1a2779ab1fe7ff2ec39e8d080fd

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

LOG: [yaml2obj/obj2yaml] - Refine handling of SHT_GNU_verdef sections.

This patch:
1) Makes `Version`, `Flags`, `VersionNdx` and `Hash` fields to be `Optional<>`.
2) Disallows dumping version definitions that have `vd_version != 1`.
   `vd_version` identifies the version of the structure itself.
   
(https://refspecs.linuxfoundation.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-generic/symversion.html,
https://docs.oracle.com/cd/E19683-01/816-/chapter6-80869/index.html)
3) Stops dumping default values for `Version`, `Flags`, `VersionNdx` and `Hash` 
fields.
4) Refines testing.

Differential revision: https://reviews.llvm.org/D94659

Added: 


Modified: 
llvm/include/llvm/ObjectYAML/ELFYAML.h
llvm/lib/ObjectYAML/ELFEmitter.cpp
llvm/lib/ObjectYAML/ELFYAML.cpp
llvm/test/tools/obj2yaml/ELF/verdef-section.yaml
llvm/test/tools/yaml2obj/ELF/verdef-section.yaml
llvm/tools/obj2yaml/elf2yaml.cpp

Removed: 




diff  --git a/llvm/include/llvm/ObjectYAML/ELFYAML.h 
b/llvm/include/llvm/ObjectYAML/ELFYAML.h
index a289aab05b2c..c9e90527380e 100644
--- a/llvm/include/llvm/ObjectYAML/ELFYAML.h
+++ b/llvm/include/llvm/ObjectYAML/ELFYAML.h
@@ -522,10 +522,10 @@ struct SymverSection : Section {
 };
 
 struct VerdefEntry {
-  uint16_t Version;
-  uint16_t Flags;
-  uint16_t VersionNdx;
-  uint32_t Hash;
+  Optional Version;
+  Optional Flags;
+  Optional VersionNdx;
+  Optional Hash;
   std::vector VerNames;
 };
 

diff  --git a/llvm/lib/ObjectYAML/ELFEmitter.cpp 
b/llvm/lib/ObjectYAML/ELFEmitter.cpp
index ba0525c4a675..d4d61b22f1e1 100644
--- a/llvm/lib/ObjectYAML/ELFEmitter.cpp
+++ b/llvm/lib/ObjectYAML/ELFEmitter.cpp
@@ -1456,10 +1456,10 @@ void ELFState::writeSectionContent(Elf_Shdr 
,
 const ELFYAML::VerdefEntry  = (*Section.Entries)[I];
 
 Elf_Verdef VerDef;
-VerDef.vd_version = E.Version;
-VerDef.vd_flags = E.Flags;
-VerDef.vd_ndx = E.VersionNdx;
-VerDef.vd_hash = E.Hash;
+VerDef.vd_version = E.Version.getValueOr(1);
+VerDef.vd_flags = E.Flags.getValueOr(0);
+VerDef.vd_ndx = E.VersionNdx.getValueOr(0);
+VerDef.vd_hash = E.Hash.getValueOr(0);
 VerDef.vd_aux = sizeof(Elf_Verdef);
 VerDef.vd_cnt = E.VerNames.size();
 if (I == Section.Entries->size() - 1)

diff  --git a/llvm/lib/ObjectYAML/ELFYAML.cpp b/llvm/lib/ObjectYAML/ELFYAML.cpp
index 3a280b06336d..20b52723b1e8 100644
--- a/llvm/lib/ObjectYAML/ELFYAML.cpp
+++ b/llvm/lib/ObjectYAML/ELFYAML.cpp
@@ -1584,10 +1584,10 @@ void MappingTraits::mapping(IO 
,
   ELFYAML::VerdefEntry ) {
   assert(IO.getContext() && "The IO context is not initialized");
 
-  IO.mapRequired("Version", E.Version);
-  IO.mapRequired("Flags", E.Flags);
-  IO.mapRequired("VersionNdx", E.VersionNdx);
-  IO.mapRequired("Hash", E.Hash);
+  IO.mapOptional("Version", E.Version);
+  IO.mapOptional("Flags", E.Flags);
+  IO.mapOptional("VersionNdx", E.VersionNdx);
+  IO.mapOptional("Hash", E.Hash);
   IO.mapRequired("Names", E.VerNames);
 }
 

diff  --git a/llvm/test/tools/obj2yaml/ELF/verdef-section.yaml 
b/llvm/test/tools/obj2yaml/ELF/verdef-section.yaml
index 762b797ceb2b..cd6981c25df1 100644
--- a/llvm/test/tools/obj2yaml/ELF/verdef-section.yaml
+++ b/llvm/test/tools/obj2yaml/ELF/verdef-section.yaml
@@ -1,42 +1,37 @@
+## Check how we dump SHT_GNU_verdef sections.
+
 # RUN: yaml2obj %s -o %t
 # RUN: obj2yaml %t | FileCheck %s
 
-## Check we are able to yamalize SHT_GNU_verdef section.
-
-# CHECK:   - Name:.gnu.version_d
-# CHECK-NEXT: Type:SHT_GNU_verdef
-# CHECK-NEXT: Flags:   [ SHF_ALLOC ]
-# CHECK-NEXT: Address: 0x230
-# CHECK-NEXT: Link:.dynstr
-# CHECK-NEXT: AddressAlign:0x4
-# CHECK-NEXT: Info:0x4
-# CHECK-NEXT: Entries:
-# CHECK-NEXT:   - Version: 1
-# CHECK-NEXT: Flags:   1
-# CHECK-NEXT: VersionNdx:  1
-# CHECK-NEXT: Hash:170240160
-# CHECK-NEXT: Names:
-# CHECK-NEXT:   - dso.so.0
-# CHECK-NEXT:   - Version: 1
-# CHECK-NEXT: Flags:   2
-# CHECK-NEXT: VersionNdx:  2
-# CHECK-NEXT: Hash:108387921
-# CHECK-NEXT: Names:
-# CHECK-NEXT:   - VERSION_1
-# CHECK-NEXT:   - Version: 1
-# CHECK-NEXT: Flags:   3
-# CHECK-NEXT: VersionNdx:  3
-# CHECK-NEXT: Hash:108387922
-# CHECK-NEXT: Names:
-# CHECK-NEXT:   - VERSION_2
-# CHECK-NEXT:   - VERSION_3
+# CHECK:   - Name:  

[llvm-branch-commits] [llvm] 021ea78 - [llvm-nm] - Simplify the code in dumpSymbolNamesFromObject. NFC.

2021-01-15 Thread Georgii Rymar via llvm-branch-commits

Author: Georgii Rymar
Date: 2021-01-15T12:29:49+03:00
New Revision: 021ea78a97ed8f4796d92a61cdf62284def36f1e

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

LOG: [llvm-nm] - Simplify the code in dumpSymbolNamesFromObject. NFC.

It is possible to simplify the logic that extracts symbol names.

D94667 made the `NMSymbol::Name` to be `std::string`,
what allowed this simplification.

Differential revision: https://reviews.llvm.org/D94669

Added: 


Modified: 
llvm/tools/llvm-nm/llvm-nm.cpp

Removed: 




diff  --git a/llvm/tools/llvm-nm/llvm-nm.cpp b/llvm/tools/llvm-nm/llvm-nm.cpp
index 130201aac9dd..ccb54c3576fe 100644
--- a/llvm/tools/llvm-nm/llvm-nm.cpp
+++ b/llvm/tools/llvm-nm/llvm-nm.cpp
@@ -1698,8 +1698,7 @@ static void dumpSymbolNamesFromObject(SymbolicFile , 
bool printName,
 }
 Symbols = E->getDynamicSymbolIterators();
   }
-  std::string NameBuffer;
-  raw_string_ostream OS(NameBuffer);
+
   // If a "-s segname sectname" option was specified and this is a Mach-O
   // file get the section number for that section in this object file.
   unsigned int Nsect = 0;
@@ -1742,6 +1741,8 @@ static void dumpSymbolNamesFromObject(SymbolicFile , 
bool printName,
   }
   S.TypeName = getNMTypeName(Obj, Sym);
   S.TypeChar = getNMSectionTagAndName(Obj, Sym, S.SectionName);
+
+  raw_string_ostream OS(S.Name);
   if (Error E = Sym.printName(OS)) {
 if (MachO) {
   OS << "bad string index";
@@ -1749,20 +1750,11 @@ static void dumpSymbolNamesFromObject(SymbolicFile 
, bool printName,
 } else
   error(std::move(E), Obj.getFileName());
   }
-  OS << '\0';
   S.Sym = Sym;
   SymbolList.push_back(S);
 }
   }
 
-  OS.flush();
-  const char *P = NameBuffer.c_str();
-  unsigned I;
-  for (I = 0; I < SymbolList.size(); ++I) {
-SymbolList[I].Name = P;
-P += strlen(P) + 1;
-  }
-
   // If this is a Mach-O file where the nlist symbol table is out of sync
   // with the dyld export trie then look through exports and fake up symbols
   // for the ones that are missing (also done with the -add-dyldinfo flag).



___
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] bfb8f45 - [llvm-nm] - Move MachO specific logic out from the dumpSymbolNamesFromObject(). NFC.

2021-01-15 Thread Georgii Rymar via llvm-branch-commits

Author: Georgii Rymar
Date: 2021-01-15T12:18:37+03:00
New Revision: bfb8f45ef3f46102d290f11039faa82456c920ae

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

LOG: [llvm-nm] - Move MachO specific logic out from the 
dumpSymbolNamesFromObject(). NFC.

`dumpSymbolNamesFromObject` is the method that dumps symbol names.

It has 563 lines, mostly because of huge piece of MachO specific code.
In this patch I move it to separate helper method.

The new size of `dumpSymbolNamesFromObject` is 93 lines. With it it becomes
much easier to maintain it.

I had to change the type of 2 name fields to `std::string`, because MachO logic
uses temporarily buffer strings (e.g `ExportsNameBuffer`, `BindsNameBuffer` 
etc):

```
  std::string ExportsNameBuffer;
  raw_string_ostream EOS(ExportsNameBuffer);
```

these buffers were moved to `dumpSymbolsFromDLInfoMachO` by this patch and
invalidated after return. Technically, before this patch we had a situation
when local pointers (symbol names) were assigned to members of global static 
`SymbolList`,
what is dirty by itself.

Differential revision: https://reviews.llvm.org/D94667

Added: 


Modified: 
llvm/tools/llvm-nm/llvm-nm.cpp

Removed: 




diff  --git a/llvm/tools/llvm-nm/llvm-nm.cpp b/llvm/tools/llvm-nm/llvm-nm.cpp
index bbbf90db26f5..130201aac9dd 100644
--- a/llvm/tools/llvm-nm/llvm-nm.cpp
+++ b/llvm/tools/llvm-nm/llvm-nm.cpp
@@ -295,7 +295,7 @@ struct NMSymbol {
   uint64_t Address;
   uint64_t Size;
   char TypeChar;
-  StringRef Name;
+  std::string Name;
   StringRef SectionName;
   StringRef TypeName;
   BasicSymbolRef Sym;
@@ -309,7 +309,7 @@ struct NMSymbol {
   uint8_t NType;
   uint8_t NSect;
   uint16_t NDesc;
-  StringRef IndirectName;
+  std::string IndirectName;
 };
 } // anonymous namespace
 
@@ -815,7 +815,7 @@ static void sortAndPrintSymbolList(SymbolicFile , bool 
printName,
 
   for (const NMSymbol  : SymbolList) {
 uint32_t SymFlags;
-std::string Name = S.Name.str();
+std::string Name = S.Name;
 MachOObjectFile *MachO = dyn_cast();
 if (Demangle) {
   if (Optional Opt = demangle(S.Name, MachO))
@@ -1219,6 +1219,473 @@ static unsigned getNsectInMachO(MachOObjectFile , 
BasicSymbolRef Sym) {
   return (STE.n_type & MachO::N_TYPE) == MachO::N_SECT ? STE.n_sect : 0;
 }
 
+static void dumpSymbolsFromDLInfoMachO(MachOObjectFile ) {
+  size_t I = SymbolList.size();
+  std::string ExportsNameBuffer;
+  raw_string_ostream EOS(ExportsNameBuffer);
+  std::string BindsNameBuffer;
+  raw_string_ostream BOS(BindsNameBuffer);
+  std::string LazysNameBuffer;
+  raw_string_ostream LOS(LazysNameBuffer);
+  std::string WeaksNameBuffer;
+  raw_string_ostream WOS(WeaksNameBuffer);
+  std::string FunctionStartsNameBuffer;
+  raw_string_ostream FOS(FunctionStartsNameBuffer);
+
+  MachO::mach_header H;
+  MachO::mach_header_64 H_64;
+  uint32_t HFlags = 0;
+  if (MachO.is64Bit()) {
+H_64 = MachO.MachOObjectFile::getHeader64();
+HFlags = H_64.flags;
+  } else {
+H = MachO.MachOObjectFile::getHeader();
+HFlags = H.flags;
+  }
+  uint64_t BaseSegmentAddress = 0;
+  for (const auto  : MachO.load_commands()) {
+if (Command.C.cmd == MachO::LC_SEGMENT) {
+  MachO::segment_command Seg = MachO.getSegmentLoadCommand(Command);
+  if (Seg.fileoff == 0 && Seg.filesize != 0) {
+BaseSegmentAddress = Seg.vmaddr;
+break;
+  }
+} else if (Command.C.cmd == MachO::LC_SEGMENT_64) {
+  MachO::segment_command_64 Seg = MachO.getSegment64LoadCommand(Command);
+  if (Seg.fileoff == 0 && Seg.filesize != 0) {
+BaseSegmentAddress = Seg.vmaddr;
+break;
+  }
+}
+  }
+  if (DyldInfoOnly || AddDyldInfo ||
+  HFlags & MachO::MH_NLIST_OUTOFSYNC_WITH_DYLDINFO) {
+unsigned ExportsAdded = 0;
+Error Err = Error::success();
+for (const llvm::object::ExportEntry  : MachO.exports(Err)) {
+  bool found = false;
+  bool ReExport = false;
+  if (!DyldInfoOnly) {
+for (const NMSymbol  : SymbolList)
+  if (S.Address == Entry.address() + BaseSegmentAddress &&
+  S.Name == Entry.name()) {
+found = true;
+break;
+  }
+  }
+  if (!found) {
+NMSymbol S = {};
+S.Address = Entry.address() + BaseSegmentAddress;
+S.Size = 0;
+S.TypeChar = '\0';
+S.Name = Entry.name().str();
+// There is no symbol in the nlist symbol table for this so we set
+// Sym effectivly to null and the rest of code in here must test for
+// it and not do things like Sym.getFlags() for it.
+S.Sym = BasicSymbolRef();
+S.SymFlags = SymbolRef::SF_Global;
+S.Section = SectionRef();
+S.NType = 0;
+S.NSect = 0;
+S.NDesc = 0;
+

[llvm-branch-commits] [llvm] 104a9f9 - [Debuginfo][DW_OP_implicit_pointer] (1/7) Support for DW_OP_LLVM_implicit_pointer

2021-01-15 Thread Alok Kumar Sharma via llvm-branch-commits

Author: Alok Kumar Sharma
Date: 2021-01-15T14:45:04+05:30
New Revision: 104a9f99ccab9d6dbc07a70f569246c23feaf4c1

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

LOG: [Debuginfo][DW_OP_implicit_pointer] (1/7) Support for 
DW_OP_LLVM_implicit_pointer

New dwarf operator DW_OP_LLVM_implicit_pointer is introduced (present only in 
LLVM IR)
This operator is required as it is different than DWARF operator
DW_OP_implicit_pointer in representation and specification (number
and types of operands) and later can not be used as multiple level.

Reviewed By: aprantl

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

Added: 
llvm/test/DebugInfo/X86/LLVM_implicit_pointer.ll

Modified: 
llvm/docs/LangRef.rst
llvm/include/llvm/BinaryFormat/Dwarf.h
llvm/lib/BinaryFormat/Dwarf.cpp
llvm/lib/IR/DebugInfoMetadata.cpp

Removed: 




diff  --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index 5a4c652c3603..a6f6e8281a72 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -5284,6 +5284,33 @@ The current supported opcode vocabulary is limited:
   of the stack. This opcode can be used to calculate bounds of fortran assumed
   rank array which has rank known at run time and current dimension number is
   implicitly first element of the stack.
+- ``DW_OP_LLVM_implicit_pointer`` It specifies the dereferenced value. It can
+  be used to represent pointer variables which are optimized out but the value
+  it points to is known. This operator is required as it is 
diff erent than DWARF
+  operator DW_OP_implicit_pointer in representation and specification (number
+  and types of operands) and later can not be used as multiple level.
+
+.. code-block:: text
+
+IR for "*ptr = 4;"
+--
+call void @llvm.dbg.value(metadata i32 4, metadata !17, metadata !20)
+!17 = !DILocalVariable(name: "ptr1", scope: !12, file: !3, line: 5,
+   type: !18)
+!18 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !19, size: 64)
+!19 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!20 = !DIExpression(DW_OP_LLVM_implicit_pointer))
+
+IR for "**ptr = 4;"
+--
+call void @llvm.dbg.value(metadata i32 4, metadata !17, metadata !21)
+!17 = !DILocalVariable(name: "ptr1", scope: !12, file: !3, line: 5,
+   type: !18)
+!18 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !19, size: 64)
+!19 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !20, size: 64)
+!20 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!21 = !DIExpression(DW_OP_LLVM_implicit_pointer,
+DW_OP_LLVM_implicit_pointer))
 
 DWARF specifies three kinds of simple location descriptions: Register, memory,
 and implicit location descriptions.  Note that a location description is

diff  --git a/llvm/include/llvm/BinaryFormat/Dwarf.h 
b/llvm/include/llvm/BinaryFormat/Dwarf.h
index 75b8b2647b95..cafc5be686bc 100644
--- a/llvm/include/llvm/BinaryFormat/Dwarf.h
+++ b/llvm/include/llvm/BinaryFormat/Dwarf.h
@@ -120,10 +120,11 @@ enum LocationAtom {
 #include "llvm/BinaryFormat/Dwarf.def"
   DW_OP_lo_user = 0xe0,
   DW_OP_hi_user = 0xff,
-  DW_OP_LLVM_fragment = 0x1000,///< Only used in LLVM metadata.
-  DW_OP_LLVM_convert = 0x1001, ///< Only used in LLVM metadata.
-  DW_OP_LLVM_tag_offset = 0x1002,  ///< Only used in LLVM metadata.
-  DW_OP_LLVM_entry_value = 0x1003, ///< Only used in LLVM metadata.
+  DW_OP_LLVM_fragment = 0x1000, ///< Only used in LLVM metadata.
+  DW_OP_LLVM_convert = 0x1001,  ///< Only used in LLVM metadata.
+  DW_OP_LLVM_tag_offset = 0x1002,   ///< Only used in LLVM metadata.
+  DW_OP_LLVM_entry_value = 0x1003,  ///< Only used in LLVM metadata.
+  DW_OP_LLVM_implicit_pointer = 0x1004, ///< Only used in LLVM metadata.
 };
 
 enum TypeKind : uint8_t {

diff  --git a/llvm/lib/BinaryFormat/Dwarf.cpp b/llvm/lib/BinaryFormat/Dwarf.cpp
index 29028709d378..e4747369f3e3 100644
--- a/llvm/lib/BinaryFormat/Dwarf.cpp
+++ b/llvm/lib/BinaryFormat/Dwarf.cpp
@@ -151,6 +151,8 @@ StringRef llvm::dwarf::OperationEncodingString(unsigned 
Encoding) {
 return "DW_OP_LLVM_tag_offset";
   case DW_OP_LLVM_entry_value:
 return "DW_OP_LLVM_entry_value";
+  case DW_OP_LLVM_implicit_pointer:
+return "DW_OP_LLVM_implicit_pointer";
   }
 }
 
@@ -163,6 +165,7 @@ unsigned llvm::dwarf::getOperationEncoding(StringRef 
OperationEncodingString) {
   .Case("DW_OP_LLVM_fragment", DW_OP_LLVM_fragment)
   .Case("DW_OP_LLVM_tag_offset", DW_OP_LLVM_tag_offset)
   .Case("DW_OP_LLVM_entry_value", DW_OP_LLVM_entry_value)
+  .Case("DW_OP_LLVM_implicit_pointer", DW_OP_LLVM_implicit_pointer)
   .Default(0);
 }
 

diff  --git 

[llvm-branch-commits] [libcxx] 7803636 - [libcxx testing] Fix UB in tests for std::lock_guard

2021-01-15 Thread Igor Kudrin via llvm-branch-commits

Author: Igor Kudrin
Date: 2021-01-15T16:11:45+07:00
New Revision: 78036360573c35ea9e6a697d2eed92db893b4850

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

LOG: [libcxx testing] Fix UB in tests for std::lock_guard

If mutex::try_lock() is called in a thread that already owns the mutex,
the behavior is undefined. The patch fixes the issue by creating another
thread, where the call is allowed.

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

Added: 


Modified: 

libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/adopt_lock.pass.cpp

libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/mutex.pass.cpp

Removed: 




diff  --git 
a/libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/adopt_lock.pass.cpp
 
b/libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/adopt_lock.pass.cpp
index 5135dbcef816..db6a2e35f9c5 100644
--- 
a/libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/adopt_lock.pass.cpp
+++ 
b/libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/adopt_lock.pass.cpp
@@ -18,15 +18,21 @@
 #include 
 #include 
 
+#include "make_test_thread.h"
 #include "test_macros.h"
 
 std::mutex m;
 
+void do_try_lock() {
+  assert(m.try_lock() == false);
+}
+
 int main(int, char**) {
   {
 m.lock();
 std::lock_guard lg(m, std::adopt_lock);
-assert(m.try_lock() == false);
+std::thread t = support::make_test_thread(do_try_lock);
+t.join();
   }
 
   m.lock();

diff  --git 
a/libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/mutex.pass.cpp
 
b/libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/mutex.pass.cpp
index 0e096eabe4b6..5dcecd344c36 100644
--- 
a/libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/mutex.pass.cpp
+++ 
b/libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/mutex.pass.cpp
@@ -21,14 +21,20 @@
 #include 
 #include 
 
+#include "make_test_thread.h"
 #include "test_macros.h"
 
 std::mutex m;
 
+void do_try_lock() {
+  assert(m.try_lock() == false);
+}
+
 int main(int, char**) {
   {
 std::lock_guard lg(m);
-assert(m.try_lock() == false);
+std::thread t = support::make_test_thread(do_try_lock);
+t.join();
   }
 
   m.lock();



___
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] 89e84de - [AArch64][GlobalISel] Fix fallbacks introduced for G_SITOFP in 8f283cafddfa8d6d01a94b48cdc5d25817569e91

2021-01-15 Thread Amara Emerson via llvm-branch-commits

Author: Amara Emerson
Date: 2021-01-15T01:10:49-08:00
New Revision: 89e84dec1879417fb7eb96edaa55dac7eca204ab

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

LOG: [AArch64][GlobalISel] Fix fallbacks introduced for G_SITOFP in 
8f283cafddfa8d6d01a94b48cdc5d25817569e91

If we have an integer->fp convert that has differing sizes, e.g. s32 to s64,
then don't try to convert it to AArch64::G_SITOF since it won't select.

Added: 


Modified: 
llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
llvm/test/CodeGen/AArch64/GlobalISel/select-fp-casts.mir

Removed: 




diff  --git a/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp 
b/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
index 5dcb9b2d00da..797f33ce2ab4 100644
--- a/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
+++ b/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
@@ -1947,8 +1947,11 @@ bool 
AArch64InstructionSelector::preISelLower(MachineInstr ) {
 // Otherwise, it ends up matching an fpr/gpr variant and adding a 
cross-bank
 // copy.
 Register SrcReg = I.getOperand(1).getReg();
-if (MRI.getType(SrcReg).isVector())
+LLT SrcTy = MRI.getType(SrcReg);
+LLT DstTy = MRI.getType(I.getOperand(0).getReg());
+if (SrcTy.isVector() || SrcTy.getSizeInBits() != DstTy.getSizeInBits())
   return false;
+
 if (RBI.getRegBank(SrcReg, MRI, TRI)->getID() == AArch64::FPRRegBankID) {
   if (I.getOpcode() == TargetOpcode::G_SITOFP)
 I.setDesc(TII.get(AArch64::G_SITOF));

diff  --git a/llvm/test/CodeGen/AArch64/GlobalISel/select-fp-casts.mir 
b/llvm/test/CodeGen/AArch64/GlobalISel/select-fp-casts.mir
index aad71bd99f8f..4274f91dba49 100644
--- a/llvm/test/CodeGen/AArch64/GlobalISel/select-fp-casts.mir
+++ b/llvm/test/CodeGen/AArch64/GlobalISel/select-fp-casts.mir
@@ -327,6 +327,29 @@ body: |
 $d0 = COPY %1(s64)
 ...
 
+---
+name:sitofp_s64_s32_fpr_both
+legalized:   true
+regBankSelected: true
+
+registers:
+  - { id: 0, class: fpr }
+  - { id: 1, class: fpr }
+
+body: |
+  bb.0:
+liveins: $s0
+
+; CHECK-LABEL: name: sitofp_s64_s32_fpr
+; CHECK: [[COPY:%[0-9]+]]:fpr32 = COPY $s0
+; CHECK: [[COPY2:%[0-9]+]]:gpr32 = COPY [[COPY]]
+; CHECK: [[SCVTFUWDri:%[0-9]+]]:fpr64 = SCVTFUWDri [[COPY2]]
+; CHECK: $d0 = COPY [[SCVTFUWDri]]
+%0(s32) = COPY $s0
+%1(s64) = G_SITOFP %0
+$d0 = COPY %1(s64)
+...
+
 ---
 name:sitofp_s64_s64_fpr
 legalized:   true



___
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] 1185d3f - [llvm-readobj] - Fix the compilation with GCC < 7.0.

2021-01-15 Thread Georgii Rymar via llvm-branch-commits

Author: Georgii Rymar
Date: 2021-01-15T11:58:04+03:00
New Revision: 1185d3f43d2186fa9291fe7779abf48d9b962ef4

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

LOG: [llvm-readobj] - Fix the compilation with GCC < 7.0.

This addressed post commit comments for D93900.

GCC had an issue and requires placing a specialization of
`printUnwindInfo` to a namespace to compile:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56480

Added: 


Modified: 
llvm/tools/llvm-readobj/ELFDumper.cpp

Removed: 




diff  --git a/llvm/tools/llvm-readobj/ELFDumper.cpp 
b/llvm/tools/llvm-readobj/ELFDumper.cpp
index e03a3d1edc7e..9351338590ae 100644
--- a/llvm/tools/llvm-readobj/ELFDumper.cpp
+++ b/llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -2536,6 +2536,8 @@ template  void 
ELFDumper::printUnwindInfo() {
   Ctx.printUnwindInformation();
 }
 
+// The namespace is needed to fix the compilation with GCC older than 7.0+.
+namespace {
 template <> void ELFDumper::printUnwindInfo() {
   if (Obj.getHeader().e_machine == EM_ARM) {
 ARM::EHABI::PrinterContext Ctx(W, Obj, ObjF.getFileName(),
@@ -2545,6 +2547,7 @@ template <> void ELFDumper::printUnwindInfo() {
   DwarfCFIEH::PrinterContext Ctx(W, ObjF);
   Ctx.printUnwindInformation();
 }
+} // namespace
 
 template  void ELFDumper::printNeededLibraries() {
   ListScope D(W, "NeededLibraries");



___
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] [clang] 168be42 - [Clang] Mutate long-double math builtins into f128 under IEEE-quad

2021-01-15 Thread Qiu Chaofan via llvm-branch-commits

Author: Qiu Chaofan
Date: 2021-01-15T16:56:20+08:00
New Revision: 168be4208304e36d3bb156b5c413b340a391383e

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

LOG: [Clang] Mutate long-double math builtins into f128 under IEEE-quad

Under -mabi=ieeelongdouble on PowerPC, IEEE-quad floating point semantic
is used for long double. This patch mutates call to related builtins
into f128 version on PowerPC. And in theory, this should be applied to
other targets when their backend supports IEEE 128-bit style libcalls.

GCC already has these mutations except nansl, which is not available on
PowerPC along with other variants (nans, nansf).

Reviewed By: RKSimon, nemanjai

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

Added: 


Modified: 
clang/lib/CodeGen/CGBuiltin.cpp
clang/test/CodeGen/math-builtins-long.c

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 7fa4e4d270ad..25ebb67c2ab6 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -2107,6 +2107,78 @@ RValue CodeGenFunction::emitRotate(const CallExpr *E, 
bool IsRotateRight) {
   return RValue::get(Builder.CreateCall(F, { Src, Src, ShiftAmt }));
 }
 
+// Map math builtins for long-double to f128 version.
+static unsigned mutateLongDoubleBuiltin(unsigned BuiltinID) {
+  switch (BuiltinID) {
+#define MUTATE_LDBL(func) \
+  case Builtin::BI__builtin_##func##l: \
+return Builtin::BI__builtin_##func##f128;
+  MUTATE_LDBL(sqrt)
+  MUTATE_LDBL(cbrt)
+  MUTATE_LDBL(fabs)
+  MUTATE_LDBL(log)
+  MUTATE_LDBL(log2)
+  MUTATE_LDBL(log10)
+  MUTATE_LDBL(log1p)
+  MUTATE_LDBL(logb)
+  MUTATE_LDBL(exp)
+  MUTATE_LDBL(exp2)
+  MUTATE_LDBL(expm1)
+  MUTATE_LDBL(fdim)
+  MUTATE_LDBL(hypot)
+  MUTATE_LDBL(ilogb)
+  MUTATE_LDBL(pow)
+  MUTATE_LDBL(fmin)
+  MUTATE_LDBL(fmax)
+  MUTATE_LDBL(ceil)
+  MUTATE_LDBL(trunc)
+  MUTATE_LDBL(rint)
+  MUTATE_LDBL(nearbyint)
+  MUTATE_LDBL(round)
+  MUTATE_LDBL(floor)
+  MUTATE_LDBL(lround)
+  MUTATE_LDBL(llround)
+  MUTATE_LDBL(lrint)
+  MUTATE_LDBL(llrint)
+  MUTATE_LDBL(fmod)
+  MUTATE_LDBL(modf)
+  MUTATE_LDBL(nan)
+  MUTATE_LDBL(nans)
+  MUTATE_LDBL(inf)
+  MUTATE_LDBL(fma)
+  MUTATE_LDBL(sin)
+  MUTATE_LDBL(cos)
+  MUTATE_LDBL(tan)
+  MUTATE_LDBL(sinh)
+  MUTATE_LDBL(cosh)
+  MUTATE_LDBL(tanh)
+  MUTATE_LDBL(asin)
+  MUTATE_LDBL(acos)
+  MUTATE_LDBL(atan)
+  MUTATE_LDBL(asinh)
+  MUTATE_LDBL(acosh)
+  MUTATE_LDBL(atanh)
+  MUTATE_LDBL(atan2)
+  MUTATE_LDBL(erf)
+  MUTATE_LDBL(erfc)
+  MUTATE_LDBL(ldexp)
+  MUTATE_LDBL(frexp)
+  MUTATE_LDBL(huge_val)
+  MUTATE_LDBL(copysign)
+  MUTATE_LDBL(nextafter)
+  MUTATE_LDBL(nexttoward)
+  MUTATE_LDBL(remainder)
+  MUTATE_LDBL(remquo)
+  MUTATE_LDBL(scalbln)
+  MUTATE_LDBL(scalbn)
+  MUTATE_LDBL(tgamma)
+  MUTATE_LDBL(lgamma)
+#undef MUTATE_LDBL
+  default:
+return BuiltinID;
+  }
+}
+
 RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned 
BuiltinID,
 const CallExpr *E,
 ReturnValueSlot ReturnValue) {
@@ -2123,6 +2195,14 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
Result.Val.getFloat()));
   }
 
+  // If current long-double semantics is IEEE 128-bit, replace math builtins
+  // of long-double with f128 equivalent.
+  // TODO: This mutation should also be applied to other targets other than 
PPC,
+  // after backend supports IEEE 128-bit style libcalls.
+  if (getTarget().getTriple().isPPC64() &&
+  ().getLongDoubleFormat() == ::APFloat::IEEEquad())
+BuiltinID = mutateLongDoubleBuiltin(BuiltinID);
+
   // If the builtin has been declared explicitly with an assembler label,
   // disable the specialized emitting below. Ideally we should communicate the
   // rename in IR, or at least avoid generating the intrinsic calls that are

diff  --git a/clang/test/CodeGen/math-builtins-long.c 
b/clang/test/CodeGen/math-builtins-long.c
index bf7ebd31..f5cee75acad6 100644
--- a/clang/test/CodeGen/math-builtins-long.c
+++ b/clang/test/CodeGen/math-builtins-long.c
@@ -13,13 +13,13 @@ void foo(long double f, long double *l, int *i, const char 
*c) {
   // F80: call x86_fp80 @fmodl(x86_fp80 %{{.+}}, x86_fp80 %{{.+}})
   // PPC: call ppc_fp128 @fmodl(ppc_fp128 %{{.+}}, ppc_fp128 %{{.+}})
   // X86F128: call fp128 @fmodl(fp128 %{{.+}}, fp128 %{{.+}})
-  // PPCF128: call fp128 @fmodl(fp128 %{{.+}}, fp128 %{{.+}})
+  // PPCF128: call fp128 @fmodf128(fp128 %{{.+}}, fp128 %{{.+}})
   __builtin_fmodl(f,f);
 
   // F80: call x86_fp80 @atan2l(x86_fp80 %{{.+}}, x86_fp80 %{{.+}})
   // PPC: call ppc_fp128 @atan2l(ppc_fp128 %{{.+}}, ppc_fp128 %{{.+}})
   // X86F128: call fp128 @atan2l(fp128 %{{.+}}, 

[llvm-branch-commits] [llvm] 33be50d - Revert "Reapply "ADT: Fix reference invalidation in SmallVector::push_back and single-element insert""

2021-01-15 Thread Nikita Popov via llvm-branch-commits

Author: Nikita Popov
Date: 2021-01-15T09:28:42+01:00
New Revision: 33be50daa9ce1074c3b423a4ab27c70c0722113a

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

LOG: Revert "Reapply "ADT: Fix reference invalidation in SmallVector::push_back 
and single-element insert""

This reverts commit 260a856c2abcef49c7cb3bdcd999701db3e2af38.
This reverts commit 3043e5a5c33c4c871f4a1dfd621a8839f9a1f0b3.
This reverts commit 49142991a685bd427d7e877c29c77371dfb7634c.

This change had a larger than anticipated compile-time impact,
possibly because the small value optimization is not working as
intended. See D93779.

Added: 


Modified: 
llvm/include/llvm/ADT/SmallVector.h
llvm/unittests/ADT/SmallVectorTest.cpp

Removed: 




diff  --git a/llvm/include/llvm/ADT/SmallVector.h 
b/llvm/include/llvm/ADT/SmallVector.h
index b9c30abcb579..78d0848b1fcc 100644
--- a/llvm/include/llvm/ADT/SmallVector.h
+++ b/llvm/include/llvm/ADT/SmallVector.h
@@ -220,24 +220,6 @@ class SmallVectorTemplateCommon
   }
   void assertSafeToEmplace() {}
 
-  /// Reserve enough space to add one element, and return the updated element
-  /// pointer in case it was a reference to the storage.
-  template 
-  static const T *reserveForAndGetAddressImpl(U *This, const T , size_t N) 
{
-size_t NewSize = This->size() + N;
-if (LLVM_LIKELY(NewSize <= This->capacity()))
-  return 
-
-bool ReferencesStorage = false;
-int64_t Index = -1;
-if (LLVM_UNLIKELY(This->isReferenceToStorage())) {
-  ReferencesStorage = true;
-  Index =  - This->begin();
-}
-This->grow(NewSize);
-return ReferencesStorage ? This->begin() + Index : 
-  }
-
 public:
   using size_type = size_t;
   using 
diff erence_type = ptr
diff _t;
@@ -321,12 +303,7 @@ template ::value) &&
  (is_trivially_move_constructible::value) &&
  std::is_trivially_destructible::value>
 class SmallVectorTemplateBase : public SmallVectorTemplateCommon {
-  friend class SmallVectorTemplateCommon;
-
 protected:
-  static constexpr bool TakesParamByValue = false;
-  using ValueParamT = const T &;
-
   SmallVectorTemplateBase(size_t Size) : SmallVectorTemplateCommon(Size) {}
 
   static void destroy_range(T *S, T *E) {
@@ -356,31 +333,20 @@ class SmallVectorTemplateBase : public 
SmallVectorTemplateCommon {
   /// element, or MinSize more elements if specified.
   void grow(size_t MinSize = 0);
 
-  /// Reserve enough space to add one element, and return the updated element
-  /// pointer in case it was a reference to the storage.
-  const T *reserveForAndGetAddress(const T , size_t N = 1) {
-return this->reserveForAndGetAddressImpl(this, Elt, N);
-  }
-
-  /// Reserve enough space to add one element, and return the updated element
-  /// pointer in case it was a reference to the storage.
-  T *reserveForAndGetAddress(T , size_t N = 1) {
-return const_cast(this->reserveForAndGetAddressImpl(this, Elt, N));
-  }
-
-  static T &_value_param(T &) { return std::move(V); }
-  static const T _value_param(const T ) { return V; }
-
 public:
   void push_back(const T ) {
-const T *EltPtr = reserveForAndGetAddress(Elt);
-::new ((void *)this->end()) T(*EltPtr);
+this->assertSafeToAdd();
+if (LLVM_UNLIKELY(this->size() >= this->capacity()))
+  this->grow();
+::new ((void*) this->end()) T(Elt);
 this->set_size(this->size() + 1);
   }
 
   void push_back(T &) {
-T *EltPtr = reserveForAndGetAddress(Elt);
-::new ((void *)this->end()) T(::std::move(*EltPtr));
+this->assertSafeToAdd();
+if (LLVM_UNLIKELY(this->size() >= this->capacity()))
+  this->grow();
+::new ((void*) this->end()) T(::std::move(Elt));
 this->set_size(this->size() + 1);
   }
 
@@ -430,18 +396,7 @@ void SmallVectorTemplateBase::grow(size_t MinSize) {
 /// skipping destruction.
 template 
 class SmallVectorTemplateBase : public SmallVectorTemplateCommon {
-  friend class SmallVectorTemplateCommon;
-
 protected:
-  /// True if it's cheap enough to take parameters by value. Doing so avoids
-  /// overhead related to mitigations for reference invalidation.
-  static constexpr bool TakesParamByValue = sizeof(T) <= 2 * sizeof(void *);
-
-  /// Either const T& or T, depending on whether it's cheap enough to take
-  /// parameters by value.
-  using ValueParamT =
-  typename std::conditional::type;
-
   SmallVectorTemplateBase(size_t Size) : SmallVectorTemplateCommon(Size) {}
 
   // No need to do a destroy loop for POD's.
@@ -482,25 +437,12 @@ class SmallVectorTemplateBase : public 
SmallVectorTemplateCommon {
   /// least one more element or MinSize if specified.
   void grow(size_t MinSize = 0) { this->grow_pod(MinSize, sizeof(T)); }
 
-  /// Reserve enough space to add one 

[llvm-branch-commits] [lld] 38dfce7 - [WebAssembly] Add support for table linking to wasm-ld

2021-01-15 Thread Andy Wingo via llvm-branch-commits

Author: Andy Wingo
Date: 2021-01-15T09:21:52+01:00
New Revision: 38dfce706f796dc109ea495dd69a8cb4c8fa819d

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

LOG: [WebAssembly] Add support for table linking to wasm-ld

This patch adds support to wasm-ld for linking multiple table references
together, in a manner similar to wasm globals. The indirect function
table is synthesized as needed.

To manage the transitional period in which the compiler doesn't yet
produce TABLE_NUMBER relocations and doesn't residualize table symbols,
the linker will detect object files which have table imports or
definitions, but no table symbols. In that case it will synthesize
symbols for the defined and imported tables.

As a change, relocatable objects are now written with table symbols,
which can cause symbol renumbering in some of the tests. If no object
file requires an indirect function table, none will be written to the
file. Note that for legacy ObjFile inputs, this test is conservative: as
we don't have relocs for each use of the indirecy function table, we
just assume that any incoming indirect function table should be
propagated to the output.

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

Added: 


Modified: 
lld/test/wasm/alias.s
lld/test/wasm/init-fini.ll
lld/test/wasm/local-symbols.ll
lld/test/wasm/locals-duplicate.test
lld/test/wasm/pie.ll
lld/test/wasm/section-symbol-relocs.yaml
lld/test/wasm/shared.ll
lld/test/wasm/signature-mismatch.ll
lld/test/wasm/stack-pointer.ll
lld/test/wasm/weak-alias.ll
lld/wasm/Driver.cpp
lld/wasm/InputFiles.cpp
lld/wasm/InputFiles.h
lld/wasm/MarkLive.cpp
lld/wasm/SymbolTable.cpp
lld/wasm/SymbolTable.h
lld/wasm/Symbols.cpp
lld/wasm/Symbols.h
lld/wasm/SyntheticSections.cpp
lld/wasm/SyntheticSections.h
lld/wasm/Writer.cpp

Removed: 




diff  --git a/lld/test/wasm/alias.s b/lld/test/wasm/alias.s
index 6c99f69da8b8..b2ab45e98d95 100644
--- a/lld/test/wasm/alias.s
+++ b/lld/test/wasm/alias.s
@@ -22,14 +22,6 @@ _start:
 # CHECK-NEXT: ReturnTypes: []
 # CHECK-NEXT:   - Type:FUNCTION
 # CHECK-NEXT: FunctionTypes:   [ 0 ]
-# CHECK-NEXT:   - Type:TABLE
-# CHECK-NEXT: Tables:
-# CHECK-NEXT:   - Index:   0
-# CHECK-NEXT: ElemType:FUNCREF
-# CHECK-NEXT: Limits:
-# CHECK-NEXT:   Flags:   [ HAS_MAX ]
-# CHECK-NEXT:   Initial: 0x1
-# CHECK-NEXT:   Maximum: 0x1
 # CHECK-NEXT:   - Type:MEMORY
 # CHECK-NEXT: Memories:
 # CHECK-NEXT:   - Initial: 0x2

diff  --git a/lld/test/wasm/init-fini.ll b/lld/test/wasm/init-fini.ll
index 1e7644bc6d35..5631d58d68e5 100644
--- a/lld/test/wasm/init-fini.ll
+++ b/lld/test/wasm/init-fini.ll
@@ -139,15 +139,15 @@ entry:
 ; RELOC-NEXT:  InitFunctions [
 ; RELOC-NEXT:0 (priority=101)
 ; RELOC-NEXT:1 (priority=101)
-; RELOC-NEXT:14 (priority=101)
-; RELOC-NEXT:10 (priority=101)
-; RELOC-NEXT:20 (priority=101)
-; RELOC-NEXT:10 (priority=202)
-; RELOC-NEXT:22 (priority=202)
+; RELOC-NEXT:15 (priority=101)
+; RELOC-NEXT:11 (priority=101)
+; RELOC-NEXT:21 (priority=101)
+; RELOC-NEXT:11 (priority=202)
+; RELOC-NEXT:23 (priority=202)
 ; RELOC-NEXT:0 (priority=1001)
-; RELOC-NEXT:16 (priority=1001)
-; RELOC-NEXT:10 (priority=2002)
-; RELOC-NEXT:24 (priority=2002)
+; RELOC-NEXT:17 (priority=1001)
+; RELOC-NEXT:11 (priority=2002)
+; RELOC-NEXT:25 (priority=2002)
 ; RELOC-NEXT:9 (priority=4000)
-; RELOC-NEXT:18 (priority=4000)
+; RELOC-NEXT:19 (priority=4000)
 ; RELOC-NEXT:  ]

diff  --git a/lld/test/wasm/local-symbols.ll b/lld/test/wasm/local-symbols.ll
index 13c200d648e9..216aced9cf07 100644
--- a/lld/test/wasm/local-symbols.ll
+++ b/lld/test/wasm/local-symbols.ll
@@ -35,14 +35,6 @@ entry:
 ; CHECK-NEXT: ReturnTypes: []
 ; CHECK-NEXT:   - Type:FUNCTION
 ; CHECK-NEXT: FunctionTypes:   [ 0, 1 ]
-; CHECK-NEXT:   - Type:TABLE
-; CHECK-NEXT: Tables:
-; CHECK-NEXT:   - Index:   0
-; CHECK-NEXT: ElemType:FUNCREF
-; CHECK-NEXT: Limits:
-; CHECK-NEXT:   Flags:   [ HAS_MAX ]
-; CHECK-NEXT:   Initial: 0x1
-; CHECK-NEXT:   Maximum: 0x1
 ; CHECK-NEXT:   - Type:MEMORY
 ; CHECK-NEXT: Memories:
 ; CHECK-NEXT:   - Initial: 0x2

diff  --git a/lld/test/wasm/locals-duplicate.test 
b/lld/test/wasm/locals-duplicate.test
index 07abb7485381..cf9a148d4ab7 100644
--- a/lld/test/wasm/locals-duplicate.test
+++ b/lld/test/wasm/locals-duplicate.test
@@ -254,40 +254,40 @@
 ; RELOC-NEXT:   - Type:   

[llvm-branch-commits] [clang] 1a49944 - [clang][cli] NFC: Decrease the scope of ParseCodeGenArgs parameters

2021-01-15 Thread Jan Svoboda via llvm-branch-commits

Author: Jan Svoboda
Date: 2021-01-15T08:42:30+01:00
New Revision: 1a49944b59dbbfd62bd860b564919087f274a5bf

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

LOG: [clang][cli] NFC: Decrease the scope of ParseCodeGenArgs parameters

Instead of passing the whole `TargetOptions` and `FrontendOptions` to 
`ParseCodeGenArgs` give it only the necessary members.
This makes tracking the dependencies between various parsers and option groups 
easier.

Reviewed By: Bigcheese

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

Added: 


Modified: 
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index d80d1f79c692..6d5b4a84c233 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -405,6 +405,8 @@ static void FixupInvocation(CompilerInvocation ,
   llvm::Triple T(TargetOpts.Triple);
   llvm::Triple::ArchType Arch = T.getArch();
 
+  CodeGenOpts.CodeModel = TargetOpts.CodeModel;
+
   if (LangOpts.getExceptionHandling() != llvm::ExceptionHandling::None &&
   T.isWindowsMSVCEnvironment())
 Diags.Report(diag::err_fe_invalid_exception_model)
@@ -901,11 +903,9 @@ static void setPGOUseInstrumentor(CodeGenOptions ,
 }
 
 static bool ParseCodeGenArgs(CodeGenOptions , ArgList , InputKind IK,
- DiagnosticsEngine ,
- const TargetOptions ,
- const FrontendOptions ) {
+ DiagnosticsEngine , const llvm::Triple ,
+ const std::string ) {
   bool Success = true;
-  llvm::Triple Triple = llvm::Triple(TargetOpts.Triple);
 
   unsigned OptimizationLevel = getOptimizationLevel(Args, IK, Diags);
   // TODO: This could be done in Driver
@@ -964,7 +964,6 @@ static bool ParseCodeGenArgs(CodeGenOptions , ArgList 
, InputKind IK,
   llvm::Triple::arm, llvm::Triple::armeb, llvm::Triple::mips,
   llvm::Triple::mipsel, llvm::Triple::mips64, llvm::Triple::mips64el};
 
-  llvm::Triple T(TargetOpts.Triple);
   if (Opts.OptimizationLevel > 0 && Opts.hasReducedDebugInfo() &&
   llvm::is_contained(DebugEntryValueArchs, T.getArch()))
 Opts.EmitCallSiteInfo = true;
@@ -990,8 +989,6 @@ static bool ParseCodeGenArgs(CodeGenOptions , ArgList 
, InputKind IK,
   if (!Opts.ProfileInstrumentUsePath.empty())
 setPGOUseInstrumentor(Opts, Opts.ProfileInstrumentUsePath);
 
-  Opts.CodeModel = TargetOpts.CodeModel;
-
   if (const Arg *A = Args.getLastArg(OPT_ftime_report, OPT_ftime_report_EQ)) {
 Opts.TimePasses = true;
 
@@ -1036,8 +1033,8 @@ static bool ParseCodeGenArgs(CodeGenOptions , 
ArgList , InputKind IK,
   if (Arg *A = Args.getLastArg(OPT_save_temps_EQ))
 Opts.SaveTempsFilePrefix =
 llvm::StringSwitch(A->getValue())
-.Case("obj", FrontendOpts.OutputFile)
-.Default(llvm::sys::path::filename(FrontendOpts.OutputFile).str());
+.Case("obj", OutputFile)
+.Default(llvm::sys::path::filename(OutputFile).str());
 
   // The memory profile runtime appends the pid to make this name more unique.
   const char *MemProfileBasename = "memprof.profraw";
@@ -2937,11 +2934,11 @@ bool 
CompilerInvocation::CreateFromArgs(CompilerInvocation ,
   InputKind DashX = ParseFrontendArgs(Res.getFrontendOpts(), Args, Diags,
   LangOpts.IsHeaderFile);
   ParseTargetArgs(Res.getTargetOpts(), Args, Diags);
-  Success &= ParseCodeGenArgs(Res.getCodeGenOpts(), Args, DashX, Diags,
-  Res.getTargetOpts(), Res.getFrontendOpts());
+  llvm::Triple T(Res.getTargetOpts().Triple);
+  Success &= ParseCodeGenArgs(Res.getCodeGenOpts(), Args, DashX, Diags, T,
+  Res.getFrontendOpts().OutputFile);
   ParseHeaderSearchArgs(Res.getHeaderSearchOpts(), Args,
 Res.getFileSystemOpts().WorkingDir);
-  llvm::Triple T(Res.getTargetOpts().Triple);
   if (DashX.getFormat() == InputKind::Precompiled ||
   DashX.getLanguage() == Language::LLVM_IR) {
 // ObjCAAutoRefCount and Sanitize LangOpts are used to setup the



___
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] [clang] c495dfe - [clang][cli] NFC: Decrease the scope of ParseLangArgs parameters

2021-01-15 Thread Jan Svoboda via llvm-branch-commits

Author: Jan Svoboda
Date: 2021-01-15T08:41:50+01:00
New Revision: c495dfe0268bc2be8737725d657411baa1399e9d

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

LOG: [clang][cli] NFC: Decrease the scope of ParseLangArgs parameters

Instead of passing the whole `TargetOptions` and `PreprocessorOptions` to 
`ParseLangArgs` give it only the necessary members.
This makes tracking the dependencies between various parsers and option groups 
easier.

Reviewed By: Bigcheese

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

Added: 


Modified: 
clang/include/clang/Frontend/CompilerInvocation.h
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/include/clang/Frontend/CompilerInvocation.h 
b/clang/include/clang/Frontend/CompilerInvocation.h
index c723fc084c85..9f16c5077154 100644
--- a/clang/include/clang/Frontend/CompilerInvocation.h
+++ b/clang/include/clang/Frontend/CompilerInvocation.h
@@ -176,11 +176,12 @@ class CompilerInvocation : public CompilerInvocationBase {
   /// \param Opts - The LangOptions object to set up.
   /// \param IK - The input language.
   /// \param T - The target triple.
-  /// \param PPOpts - The PreprocessorOptions affected.
+  /// \param Includes - The affected list of included files.
   /// \param LangStd - The input language standard.
-  static void setLangDefaults(LangOptions , InputKind IK,
-   const llvm::Triple , PreprocessorOptions ,
-   LangStandard::Kind LangStd = 
LangStandard::lang_unspecified);
+  static void
+  setLangDefaults(LangOptions , InputKind IK, const llvm::Triple ,
+  std::vector ,
+  LangStandard::Kind LangStd = LangStandard::lang_unspecified);
 
   /// Retrieve a module hash string that is suitable for uniquely
   /// identifying the conditions under which the module was built.

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 6327723699d2..d80d1f79c692 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -1889,7 +1889,7 @@ static void ParseHeaderSearchArgs(HeaderSearchOptions 
, ArgList ,
 
 void CompilerInvocation::setLangDefaults(LangOptions , InputKind IK,
  const llvm::Triple ,
- PreprocessorOptions ,
+ std::vector ,
  LangStandard::Kind LangStd) {
   // Set some properties which depend solely on the input kind; it would be 
nice
   // to move these to the language standard, and have the driver resolve the
@@ -2000,9 +2000,9 @@ void CompilerInvocation::setLangDefaults(LangOptions 
, InputKind IK,
 if (Opts.IncludeDefaultHeader) {
   if (Opts.DeclareOpenCLBuiltins) {
 // Only include base header file for builtin types and constants.
-PPOpts.Includes.push_back("opencl-c-base.h");
+Includes.push_back("opencl-c-base.h");
   } else {
-PPOpts.Includes.push_back("opencl-c.h");
+Includes.push_back("opencl-c.h");
   }
 }
   }
@@ -2138,8 +2138,8 @@ static const StringRef GetInputKindName(InputKind IK) {
 }
 
 static void ParseLangArgs(LangOptions , ArgList , InputKind IK,
-  const TargetOptions ,
-  PreprocessorOptions ,
+  const llvm::Triple ,
+  std::vector ,
   DiagnosticsEngine ) {
   // FIXME: Cleanup per-file based stuff.
   LangStandard::Kind LangStd = LangStandard::lang_unspecified;
@@ -2212,8 +2212,7 @@ static void ParseLangArgs(LangOptions , ArgList 
, InputKind IK,
 
   Opts.SYCLIsDevice = Opts.SYCL && Args.hasArg(options::OPT_fsycl_is_device);
 
-  llvm::Triple T(TargetOpts.Triple);
-  CompilerInvocation::setLangDefaults(Opts, IK, T, PPOpts, LangStd);
+  CompilerInvocation::setLangDefaults(Opts, IK, T, Includes, LangStd);
 
   // -cl-strict-aliasing needs to emit diagnostic in the case where CL > 1.0.
   // This option should be deprecated for CL > 1.0 because
@@ -2490,7 +2489,6 @@ static void ParseLangArgs(LangOptions , ArgList 
, InputKind IK,
   Diags.Report(diag::err_drv_argument_not_allowed_with)
   << A->getSpelling() << "-fdefault-calling-conv";
 else {
-  llvm::Triple T(TargetOpts.Triple);
   if (T.getArch() != llvm::Triple::x86)
 Diags.Report(diag::err_drv_argument_not_allowed_with)
 << A->getSpelling() << T.getTriple();
@@ -2527,8 +2525,7 @@ static void ParseLangArgs(LangOptions , ArgList 
, InputKind IK,
   // Add unsupported host targets here:
   case llvm::Triple::nvptx:
   case llvm::Triple::nvptx64:
-