[llvm-branch-commits] [llvm] 0bf3d4b - [NFC][ARM][PhaseOrdering] Add one more test for D91800: LoopIdiom should be before IndVars

2020-11-25 Thread Roman Lebedev via llvm-branch-commits

Author: Roman Lebedev
Date: 2020-11-25T11:02:51+03:00
New Revision: 0bf3d4bc3121394c6153eda64b1a7086a70ec3b2

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

LOG: [NFC][ARM][PhaseOrdering] Add one more test for D91800: LoopIdiom should 
be before IndVars

Added: 
llvm/test/Transforms/PhaseOrdering/ARM/arm_fill_q7.ll
llvm/test/Transforms/PhaseOrdering/ARM/lit.local.cfg

Modified: 


Removed: 




diff  --git a/llvm/test/Transforms/PhaseOrdering/ARM/arm_fill_q7.ll 
b/llvm/test/Transforms/PhaseOrdering/ARM/arm_fill_q7.ll
new file mode 100644
index ..e82a1820f6e1
--- /dev/null
+++ b/llvm/test/Transforms/PhaseOrdering/ARM/arm_fill_q7.ll
@@ -0,0 +1,226 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -O3 -S| FileCheck 
-check-prefixes=ALL,OLDPM %s
+; RUN: opt < %s -passes='default' -aa-pipeline=default -S | FileCheck 
-check-prefixes=ALL,NEWPM %s
+
+target datalayout = "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64"
+target triple = "thumbv6m-none-none-eabi"
+
+; Not only should we be able to to form memsets here, the original loops
+; should be deleted, too.
+
+; Function Attrs: nounwind
+define dso_local void @arm_fill_q7(i8 signext %value, i8* %pDst, i32 
%blockSize) #0 {
+; OLDPM-LABEL: @arm_fill_q7(
+; OLDPM-NEXT:  entry:
+; OLDPM-NEXT:[[SHR:%.*]] = lshr i32 [[BLOCKSIZE:%.*]], 2
+; OLDPM-NEXT:[[CMP_NOT20:%.*]] = icmp eq i32 [[SHR]], 0
+; OLDPM-NEXT:br i1 [[CMP_NOT20]], label [[WHILE_END:%.*]], label 
[[WHILE_BODY_PREHEADER:%.*]]
+; OLDPM:   while.body.preheader:
+; OLDPM-NEXT:[[TMP0:%.*]] = and i32 [[BLOCKSIZE]], -4
+; OLDPM-NEXT:call void @llvm.memset.p0i8.i32(i8* align 1 [[PDST:%.*]], i8 
[[VALUE:%.*]], i32 [[TMP0]], i1 false)
+; OLDPM-NEXT:br label [[WHILE_BODY:%.*]]
+; OLDPM:   while.body:
+; OLDPM-NEXT:[[BLKCNT_022:%.*]] = phi i32 [ [[DEC:%.*]], [[WHILE_BODY]] ], 
[ [[SHR]], [[WHILE_BODY_PREHEADER]] ]
+; OLDPM-NEXT:[[PDST_ADDR_021:%.*]] = phi i8* [ [[ADD_PTR_I:%.*]], 
[[WHILE_BODY]] ], [ [[PDST]], [[WHILE_BODY_PREHEADER]] ]
+; OLDPM-NEXT:[[ADD_PTR_I]] = getelementptr inbounds i8, i8* 
[[PDST_ADDR_021]], i32 4
+; OLDPM-NEXT:[[DEC]] = add nsw i32 [[BLKCNT_022]], -1
+; OLDPM-NEXT:[[CMP_NOT:%.*]] = icmp eq i32 [[DEC]], 0
+; OLDPM-NEXT:br i1 [[CMP_NOT]], label [[WHILE_END]], label [[WHILE_BODY]], 
[[LOOP3:!llvm.loop !.*]]
+; OLDPM:   while.end:
+; OLDPM-NEXT:[[PDST_ADDR_0_LCSSA:%.*]] = phi i8* [ [[PDST]], [[ENTRY:%.*]] 
], [ [[ADD_PTR_I]], [[WHILE_BODY]] ]
+; OLDPM-NEXT:[[REM:%.*]] = and i32 [[BLOCKSIZE]], 3
+; OLDPM-NEXT:[[CMP14_NOT17:%.*]] = icmp eq i32 [[REM]], 0
+; OLDPM-NEXT:br i1 [[CMP14_NOT17]], label [[WHILE_END18:%.*]], label 
[[WHILE_BODY16_PREHEADER:%.*]]
+; OLDPM:   while.body16.preheader:
+; OLDPM-NEXT:call void @llvm.memset.p0i8.i32(i8* align 1 
[[PDST_ADDR_0_LCSSA]], i8 [[VALUE]], i32 [[REM]], i1 false)
+; OLDPM-NEXT:br label [[WHILE_END18]]
+; OLDPM:   while.end18:
+; OLDPM-NEXT:ret void
+;
+; NEWPM-LABEL: @arm_fill_q7(
+; NEWPM-NEXT:  entry:
+; NEWPM-NEXT:[[SHR:%.*]] = lshr i32 [[BLOCKSIZE:%.*]], 2
+; NEWPM-NEXT:[[CMP_NOT17:%.*]] = icmp eq i32 [[SHR]], 0
+; NEWPM-NEXT:br i1 [[CMP_NOT17]], label [[WHILE_END:%.*]], label 
[[WHILE_BODY_PREHEADER:%.*]]
+; NEWPM:   while.body.preheader:
+; NEWPM-NEXT:[[TMP0:%.*]] = and i32 [[BLOCKSIZE]], -4
+; NEWPM-NEXT:call void @llvm.memset.p0i8.i32(i8* align 1 [[PDST:%.*]], i8 
[[VALUE:%.*]], i32 [[TMP0]], i1 false)
+; NEWPM-NEXT:br label [[WHILE_BODY:%.*]]
+; NEWPM:   while.body:
+; NEWPM-NEXT:[[BLKCNT_019:%.*]] = phi i32 [ [[DEC:%.*]], [[WHILE_BODY]] ], 
[ [[SHR]], [[WHILE_BODY_PREHEADER]] ]
+; NEWPM-NEXT:[[PDST_ADDR_018:%.*]] = phi i8* [ [[ADD_PTR_I:%.*]], 
[[WHILE_BODY]] ], [ [[PDST]], [[WHILE_BODY_PREHEADER]] ]
+; NEWPM-NEXT:[[ADD_PTR_I]] = getelementptr inbounds i8, i8* 
[[PDST_ADDR_018]], i32 4
+; NEWPM-NEXT:[[DEC]] = add nsw i32 [[BLKCNT_019]], -1
+; NEWPM-NEXT:[[CMP_NOT:%.*]] = icmp eq i32 [[DEC]], 0
+; NEWPM-NEXT:br i1 [[CMP_NOT]], label [[WHILE_END]], label [[WHILE_BODY]], 
[[LOOP3:!llvm.loop !.*]]
+; NEWPM:   while.end:
+; NEWPM-NEXT:[[PDST_ADDR_0_LCSSA:%.*]] = phi i8* [ [[PDST]], [[ENTRY:%.*]] 
], [ [[ADD_PTR_I]], [[WHILE_BODY]] ]
+; NEWPM-NEXT:[[REM:%.*]] = and i32 [[BLOCKSIZE]], 3
+; NEWPM-NEXT:[[CMP14_NOT20:%.*]] = icmp eq i32 [[REM]], 0
+; NEWPM-NEXT:br i1 [[CMP14_NOT20]], label [[WHILE_END18:%.*]], label 
[[WHILE_BODY16_PREHEADER:%.*]]
+; NEWPM:   while.body16.preheader:
+; NEWPM-NEXT:call void @llvm.memset.p0i8.i32(i8* align 1 
[[PDST_ADDR_0_LCSSA]], i8 [[VALUE]], i32 [[REM]], i1 false)
+; NEWPM-NEXT:br label [[WHILE_END18]

[llvm-branch-commits] [llvm] ec0b927 - [llvm-readelf/obj] - Deduplicate the logic that prints notes. NFCI.

2020-11-25 Thread Georgii Rymar via llvm-branch-commits

Author: Georgii Rymar
Date: 2020-11-25T11:04:13+03:00
New Revision: ec0b927e4aa863dd610b97f3d6e996ca05475846

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

LOG: [llvm-readelf/obj] - Deduplicate the logic that prints notes. NFCI.

We have a similar logic for LLVM/GNU styles that can be deduplicated.
This will allow to replace `reportError` calls with `reportUniqueWarning`
calls in a single place.

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

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 d1a5aa7e0e5d..3676ee9724d3 100644
--- a/llvm/tools/llvm-readobj/ELFDumper.cpp
+++ b/llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -5541,6 +5541,54 @@ const StringRef getNoteTypeName(const typename 
ELFT::Note &Note,
   return FindNote(GenericNoteTypes);
 }
 
+template 
+static void printNotesHelper(
+const ELFDumper &Dumper,
+llvm::function_ref, typename ELFT::Off,
+typename ELFT::Addr)>
+StartNotesFn,
+llvm::function_ref ProcessNoteFn,
+llvm::function_ref FinishNotesFn = []() {}) {
+  const ELFFile &Obj = *Dumper.getElfObject().getELFFile();
+
+  ArrayRef Sections = cantFail(Obj.sections());
+  if (Obj.getHeader().e_type != ELF::ET_CORE && !Sections.empty()) {
+for (const typename ELFT::Shdr &S : Sections) {
+  if (S.sh_type != SHT_NOTE)
+continue;
+  StartNotesFn(expectedToOptional(Obj.getSectionName(S)), S.sh_offset,
+   S.sh_size);
+  Error Err = Error::success();
+  for (const typename ELFT::Note &Note : Obj.notes(S, Err))
+ProcessNoteFn(Note);
+  if (Err)
+reportError(std::move(Err), Dumper.getElfObject().getFileName());
+  FinishNotesFn();
+}
+return;
+  }
+
+  Expected> PhdrsOrErr = Obj.program_headers();
+  if (!PhdrsOrErr) {
+Dumper.reportUniqueWarning(createError(
+"unable to read program headers to locate the PT_NOTE segment: " +
+toString(PhdrsOrErr.takeError(;
+return;
+  }
+
+  for (const typename ELFT::Phdr &P : *PhdrsOrErr) {
+if (P.p_type != PT_NOTE)
+  continue;
+StartNotesFn(/*SecName=*/None, P.p_offset, P.p_filesz);
+Error Err = Error::success();
+for (const typename ELFT::Note Note : Obj.notes(P, Err))
+  ProcessNoteFn(Note);
+if (Err)
+  reportError(std::move(Err), Dumper.getElfObject().getFileName());
+FinishNotesFn();
+  }
+}
+
 template  void GNUStyle::printNotes() {
   auto PrintHeader = [&](Optional SecName,
  const typename ELFT::Off Offset,
@@ -5603,39 +5651,7 @@ template  void GNUStyle::printNotes() {
 }
   };
 
-  ArrayRef Sections = cantFail(this->Obj.sections());
-  if (this->Obj.getHeader().e_type != ELF::ET_CORE && !Sections.empty()) {
-for (const Elf_Shdr &S : Sections) {
-  if (S.sh_type != SHT_NOTE)
-continue;
-  PrintHeader(expectedToOptional(this->Obj.getSectionName(S)), S.sh_offset,
-  S.sh_size);
-  Error Err = Error::success();
-  for (const Elf_Note Note : this->Obj.notes(S, Err))
-ProcessNote(Note);
-  if (Err)
-reportError(std::move(Err), this->FileName);
-}
-  } else {
-Expected> PhdrsOrErr = this->Obj.program_headers();
-if (!PhdrsOrErr) {
-  this->reportUniqueWarning(createError(
-  "unable to read program headers to locate the PT_NOTE segment: " +
-  toString(PhdrsOrErr.takeError(;
-  return;
-}
-
-for (const Elf_Phdr &P : *PhdrsOrErr) {
-  if (P.p_type != PT_NOTE)
-continue;
-  PrintHeader(/*SecName=*/None, P.p_offset, P.p_filesz);
-  Error Err = Error::success();
-  for (const Elf_Note Note : this->Obj.notes(P, Err))
-ProcessNote(Note);
-  if (Err)
-reportError(std::move(Err), this->FileName);
-}
-  }
+  printNotesHelper(this->dumper(), PrintHeader, ProcessNote);
 }
 
 template  void GNUStyle::printELFLinkerOptions() {
@@ -6828,14 +6844,18 @@ static void printCoreNoteLLVMStyle(const CoreNote 
&Note, ScopedPrinter &W) {
 template  void LLVMStyle::printNotes() {
   ListScope L(W, "Notes");
 
-  auto PrintHeader = [&](Optional SecName,
- const typename ELFT::Off Offset,
- const typename ELFT::Addr Size) {
+  std::unique_ptr NoteScope;
+  auto StartNotes = [&](Optional SecName,
+const typename ELFT::Off Offset,
+const typename ELFT::Addr Size) {
+NoteScope = std::make_unique(W, "NoteSection");
 W.printString("Name", SecName ? *SecName : "");
 W.printHex("Offset", Offset);
 W.printHex("Size", Size);
   };
 
+  auto EndNotes = [&] { N

[llvm-branch-commits] [llvm] 00a6601 - [VPlan] Turn VPReductionRecipe into a VPValue

2020-11-25 Thread David Green via llvm-branch-commits

Author: David Green
Date: 2020-11-25T08:25:05Z
New Revision: 00a66011366c7b037d6680e6015524a41b761c34

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

LOG: [VPlan] Turn VPReductionRecipe into a VPValue

This converts the VPReductionRecipe into a VPValue, like other
VPRecipe's in preparation for traversing def-use chains. It also makes
it a VPUser, now storing the used VPValues as operands.

It doesn't yet change how the VPReductionRecipes are created. It will
need to call replaceAllUsesWith from the original recipe they replace,
but that is not done yet as VPWidenRecipe need to be created first.

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

Added: 


Modified: 
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
llvm/lib/Transforms/Vectorize/VPlan.cpp
llvm/lib/Transforms/Vectorize/VPlan.h
llvm/lib/Transforms/Vectorize/VPlanValue.h
llvm/test/Transforms/LoopVectorize/vplan-printing.ll

Removed: 




diff  --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp 
b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index e29a0a8bd666..35af7a445eef 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -8093,9 +8093,9 @@ void VPReductionRecipe::execute(VPTransformState &State) {
   assert(!State.Instance && "Reduction being replicated.");
   for (unsigned Part = 0; Part < State.UF; ++Part) {
 RecurrenceDescriptor::RecurrenceKind Kind = RdxDesc->getRecurrenceKind();
-Value *NewVecOp = State.get(VecOp, Part);
-if (CondOp) {
-  Value *NewCond = State.get(CondOp, Part);
+Value *NewVecOp = State.get(getVecOp(), Part);
+if (VPValue *Cond = getCondOp()) {
+  Value *NewCond = State.get(Cond, Part);
   VectorType *VecTy = cast(NewVecOp->getType());
   Constant *Iden = RecurrenceDescriptor::getRecurrenceIdentity(
   Kind, RdxDesc->getMinMaxRecurrenceKind(), VecTy->getElementType());
@@ -8106,7 +8106,7 @@ void VPReductionRecipe::execute(VPTransformState &State) {
 }
 Value *NewRed =
 createTargetReduction(State.Builder, TTI, *RdxDesc, NewVecOp, NoNaN);
-Value *PrevInChain = State.get(ChainOp, Part);
+Value *PrevInChain = State.get(getChainOp(), Part);
 Value *NextInChain;
 if (Kind == RecurrenceDescriptor::RK_IntegerMinMax ||
 Kind == RecurrenceDescriptor::RK_FloatMinMax) {
@@ -8115,9 +8115,10 @@ void VPReductionRecipe::execute(VPTransformState &State) 
{
  NewRed, PrevInChain);
 } else {
   NextInChain = State.Builder.CreateBinOp(
-  (Instruction::BinaryOps)I->getOpcode(), NewRed, PrevInChain);
+  (Instruction::BinaryOps)getUnderlyingInstr()->getOpcode(), NewRed,
+  PrevInChain);
 }
-State.ValueMap.setVectorValue(I, Part, NextInChain);
+State.set(this, getUnderlyingInstr(), NextInChain, Part);
   }
 }
 

diff  --git a/llvm/lib/Transforms/Vectorize/VPlan.cpp 
b/llvm/lib/Transforms/Vectorize/VPlan.cpp
index f7df8a4fb0e6..08ebafbf12cc 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlan.cpp
@@ -22,6 +22,7 @@
 #include "llvm/ADT/PostOrderIterator.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/Twine.h"
+#include "llvm/Analysis/IVDescriptors.h"
 #include "llvm/Analysis/LoopInfo.h"
 #include "llvm/IR/BasicBlock.h"
 #include "llvm/IR/CFG.h"
@@ -110,12 +111,16 @@ VPUser *VPRecipeBase::toVPUser() {
 return U;
   if (auto *U = dyn_cast(this))
 return U;
+  if (auto *U = dyn_cast(this))
+return U;
   return nullptr;
 }
 
 VPValue *VPRecipeBase::toVPValue() {
   if (auto *V = dyn_cast(this))
 return V;
+  if (auto *V = dyn_cast(this))
+return V;
   if (auto *V = dyn_cast(this))
 return V;
   if (auto *V = dyn_cast(this))
@@ -130,6 +135,8 @@ VPValue *VPRecipeBase::toVPValue() {
 const VPValue *VPRecipeBase::toVPValue() const {
   if (auto *V = dyn_cast(this))
 return V;
+  if (auto *V = dyn_cast(this))
+return V;
   if (auto *V = dyn_cast(this))
 return V;
   if (auto *V = dyn_cast(this))
@@ -932,13 +939,16 @@ void VPBlendRecipe::print(raw_ostream &O, const Twine 
&Indent,
 
 void VPReductionRecipe::print(raw_ostream &O, const Twine &Indent,
   VPSlotTracker &SlotTracker) const {
-  O << "\"REDUCE of" << *I << " as ";
-  ChainOp->printAsOperand(O, SlotTracker);
-  O << " + reduce(";
-  VecOp->printAsOperand(O, SlotTracker);
-  if (CondOp) {
+  O << "\"REDUCE ";
+  printAsOperand(O, SlotTracker);
+  O << " = ";
+  getChainOp()->printAsOperand(O, SlotTracker);
+  O << " + reduce." << 
Instruction::getOpcodeName(RdxDesc->getRecurrenceBinOp())
+<< " (";
+  getVecOp()->printAsOperand(O, SlotTracker);
+  if (getCondOp()) {
 O << ", ";
-CondOp->printAsOpe

[llvm-branch-commits] [llvm] e0c479c - [VPlan] Switch VPWidenRecipe to be a VPValue

2020-11-25 Thread David Green via llvm-branch-commits

Author: David Green
Date: 2020-11-25T08:25:06Z
New Revision: e0c479cd0e03279784925ece209ff53bdbb86cf8

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

LOG: [VPlan] Switch VPWidenRecipe to be a VPValue

Similar to other patches, this makes VPWidenRecipe a VPValue. Because of
the way it interacts with the reduction code it also slightly alters the
way that VPValues are registered, removing the up front NeedDef and
using getOrAddVPValue to create them on-demand if needed instead.

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

Added: 


Modified: 
llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
llvm/lib/Transforms/Vectorize/VPlan.cpp
llvm/lib/Transforms/Vectorize/VPlan.h
llvm/lib/Transforms/Vectorize/VPlanValue.h
llvm/test/Transforms/LoopVectorize/icmp-uniforms.ll
llvm/test/Transforms/LoopVectorize/vplan-printing.ll

Removed: 




diff  --git a/llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h 
b/llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h
index b3b744947c1f..ec88bebe684d 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h
@@ -292,8 +292,7 @@ class LoopVectorizationPlanner {
   /// Build a VPlan using VPRecipes according to the information gather by
   /// Legal. This method is only used for the legacy inner loop vectorizer.
   VPlanPtr buildVPlanWithVPRecipes(
-  VFRange &Range, SmallPtrSetImpl &NeedDef,
-  SmallPtrSetImpl &DeadInstructions,
+  VFRange &Range, SmallPtrSetImpl &DeadInstructions,
   const DenseMap &SinkAfter);
 
   /// Build VPlans for power-of-2 VF's between \p MinVF and \p MaxVF inclusive,

diff  --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp 
b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 35af7a445eef..97c9011d8086 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -461,7 +461,7 @@ class InnerLoopVectorizer {
   BasicBlock *createVectorizedLoopSkeleton();
 
   /// Widen a single instruction within the innermost loop.
-  void widenInstruction(Instruction &I, VPUser &Operands,
+  void widenInstruction(Instruction &I, VPValue *Def, VPUser &Operands,
 VPTransformState &State);
 
   /// Widen a single call instruction within the innermost loop.
@@ -4512,7 +4512,8 @@ static bool mayDivideByZero(Instruction &I) {
   return !CInt || CInt->isZero();
 }
 
-void InnerLoopVectorizer::widenInstruction(Instruction &I, VPUser &User,
+void InnerLoopVectorizer::widenInstruction(Instruction &I, VPValue *Def,
+   VPUser &User,
VPTransformState &State) {
   assert(!VF.isScalable() && "scalable vectors not yet supported.");
   switch (I.getOpcode()) {
@@ -4555,7 +4556,7 @@ void InnerLoopVectorizer::widenInstruction(Instruction 
&I, VPUser &User,
 VecOp->copyIRFlags(&I);
 
   // Use this vector value for all users of the original instruction.
-  VectorLoopValueMap.setVectorValue(&I, Part, V);
+  State.set(Def, &I, V, Part);
   addMetadata(V, &I);
 }
 
@@ -4579,7 +4580,7 @@ void InnerLoopVectorizer::widenInstruction(Instruction 
&I, VPUser &User,
   } else {
 C = Builder.CreateICmp(Cmp->getPredicate(), A, B);
   }
-  VectorLoopValueMap.setVectorValue(&I, Part, C);
+  State.set(Def, &I, C, Part);
   addMetadata(C, &I);
 }
 
@@ -4609,7 +4610,7 @@ void InnerLoopVectorizer::widenInstruction(Instruction 
&I, VPUser &User,
 for (unsigned Part = 0; Part < UF; ++Part) {
   Value *A = State.get(User.getOperand(0), Part);
   Value *Cast = Builder.CreateCast(CI->getOpcode(), A, DestTy);
-  VectorLoopValueMap.setVectorValue(&I, Part, Cast);
+  State.set(Def, &I, Cast, Part);
   addMetadata(Cast, &I);
 }
 break;
@@ -7262,7 +7263,7 @@ VPValue *VPRecipeBuilder::createEdgeMask(BasicBlock *Src, 
BasicBlock *Dst,
   if (!BI->isConditional() || BI->getSuccessor(0) == BI->getSuccessor(1))
 return EdgeMaskCache[Edge] = SrcMask;
 
-  VPValue *EdgeMask = Plan->getVPValue(BI->getCondition());
+  VPValue *EdgeMask = Plan->getOrAddVPValue(BI->getCondition());
   assert(EdgeMask && "No Edge Mask found for condition");
 
   if (BI->getSuccessor(0) != Dst)
@@ -7300,7 +7301,7 @@ VPValue *VPRecipeBuilder::createBlockInMask(BasicBlock 
*BB, VPlanPtr &Plan) {
 // Start by constructing the desired canonical IV.
 VPValue *IV = nullptr;
 if (Legal->getPrimaryInduction())
-  IV = Plan->getVPValue(Legal->getPrimaryInduction());
+  IV = Plan->getOrAddVPValue(Legal->getPrimaryInduction());
 else {
   auto IVR

[llvm-branch-commits] [llvm] ae7ac2d - [llvm-readobj] - An attempt to fix BB after D92018.

2020-11-25 Thread Georgii Rymar via llvm-branch-commits

Author: Georgii Rymar
Date: 2020-11-25T11:38:58+03:00
New Revision: ae7ac2d6654a18bd90db08a882c6ba91afee6ed9

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

LOG: [llvm-readobj] - An attempt to fix BB after D92018.

AVR and PPC64 bots reports link errors:
(http://lab.llvm.org:8011/#/builders/112/builds/1522)
(http://lab.llvm.org:8011/#/builders/52/builds/1764)

/tmp/cclOvLx0.s: Assembler messages:
/tmp/cclOvLx0.s:9223: Error: symbol 
`_ZN4llvm12function_refIFvvEE11callback_fnIUlvE2_EEvl' is already defined
/tmp/cclOvLx0.s:9227: Error: symbol 
`.L._ZN4llvm12function_refIFvvEE11callback_fnIUlvE2_EEvl' is already defined
/tmp/cclOvLx0.s:10272: Error: symbol 
`_ZN4llvm12function_refIFvvEE11callback_fnIUlvE2_EEvl' is already defined
/tmp/cclOvLx0.s:10276: Error: symbol 
`.L._ZN4llvm12function_refIFvvEE11callback_fnIUlvE2_EEvl' is already defined
/tmp/cclOvLx0.s:10285: Error: symbol 
`_ZN4llvm12function_refIFvvEE11callback_fnIUlvE2_EEvl' is already defined
/tmp/cclOvLx0.s:10289: Error: symbol 
`.L._ZN4llvm12function_refIFvvEE11callback_fnIUlvE2_EEvl' is already defined

/tmp/ccFJYr6I.s: Assembler messages:
/tmp/ccFJYr6I.s:6284: Error: symbol 
`_ZN4llvm12function_refIFvvEE11callback_fnIUlvE2_EEvl' is already defined
/tmp/ccFJYr6I.s:7053: Error: symbol 
`_ZN4llvm12function_refIFvvEE11callback_fnIUlvE2_EEvl' is already defined
/tmp/ccFJYr6I.s:7093: Error: symbol 
`_ZN4llvm12function_refIFvvEE11callback_fnIUlvE2_EEvl' is already defined

I *guess* the reason might be the default lambda argument. I've removed it.

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 3676ee9724d3..c5f506bb21f8 100644
--- a/llvm/tools/llvm-readobj/ELFDumper.cpp
+++ b/llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -5548,7 +5548,7 @@ static void printNotesHelper(
 typename ELFT::Addr)>
 StartNotesFn,
 llvm::function_ref ProcessNoteFn,
-llvm::function_ref FinishNotesFn = []() {}) {
+llvm::function_ref FinishNotesFn) {
   const ELFFile &Obj = *Dumper.getElfObject().getELFFile();
 
   ArrayRef Sections = cantFail(Obj.sections());
@@ -5651,7 +5651,7 @@ template  void GNUStyle::printNotes() {
 }
   };
 
-  printNotesHelper(this->dumper(), PrintHeader, ProcessNote);
+  printNotesHelper(this->dumper(), PrintHeader, ProcessNote, []() {});
 }
 
 template  void GNUStyle::printELFLinkerOptions() {



___
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] 3d2c681 - [clangd] Avoid type hierarchy crash on incomplete type

2020-11-25 Thread Nathan Ridge via llvm-branch-commits

Author: Nathan Ridge
Date: 2020-11-25T03:45:00-05:00
New Revision: 3d2c681f2835261599654c1b82dacdae05c9b4c4

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

LOG: [clangd] Avoid type hierarchy crash on incomplete type

Fixes https://github.com/clangd/clangd/issues/597

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

Added: 


Modified: 
clang-tools-extra/clangd/XRefs.cpp
clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/XRefs.cpp 
b/clang-tools-extra/clangd/XRefs.cpp
index 31e963cb853f..8a85507ff14c 100644
--- a/clang-tools-extra/clangd/XRefs.cpp
+++ b/clang-tools-extra/clangd/XRefs.cpp
@@ -1553,6 +1553,10 @@ std::vector typeParents(const 
CXXRecordDecl *CXXRD) {
   CXXRD = CTSD->getSpecializedTemplate()->getTemplatedDecl();
   }
 
+  // Can't query bases without a definition.
+  if (!CXXRD->hasDefinition())
+return Result;
+
   for (auto Base : CXXRD->bases()) {
 const CXXRecordDecl *ParentDecl = nullptr;
 

diff  --git a/clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp 
b/clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp
index 64831724d1be..08f936ce8b55 100644
--- a/clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp
+++ b/clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp
@@ -30,6 +30,7 @@ namespace {
 using ::testing::AllOf;
 using ::testing::ElementsAre;
 using ::testing::Field;
+using ::testing::IsEmpty;
 using ::testing::Matcher;
 using ::testing::UnorderedElementsAre;
 
@@ -318,6 +319,18 @@ struct Child3 : T {};
   EXPECT_THAT(typeParents(Child3), ElementsAre());
 }
 
+TEST(TypeParents, IncompleteClass) {
+  Annotations Source(R"cpp(
+class Incomplete;
+  )cpp");
+  TestTU TU = TestTU::withCode(Source.code());
+  auto AST = TU.build();
+
+  const CXXRecordDecl *Incomplete =
+  dyn_cast(&findDecl(AST, "Incomplete"));
+  EXPECT_THAT(typeParents(Incomplete), IsEmpty());
+}
+
 // Parts of getTypeHierarchy() are tested in more detail by the
 // FindRecordTypeAt.* and TypeParents.* tests above. This test exercises the
 // entire operation.



___
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] d8f22c7 - [SchedModels] Return earlier removed checks

2020-11-25 Thread Evgeny Leviant via llvm-branch-commits

Author: Evgeny Leviant
Date: 2020-11-25T12:07:35+03:00
New Revision: d8f22c77699fe8483cdd80e0936d68875ead5838

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

LOG: [SchedModels] Return earlier removed checks

It is possible that some write resource is variant in model A
and sequence in model B. Such case will trigger assertion in
getAllPredicates function.

Added: 


Modified: 
llvm/utils/TableGen/CodeGenSchedule.cpp

Removed: 




diff  --git a/llvm/utils/TableGen/CodeGenSchedule.cpp 
b/llvm/utils/TableGen/CodeGenSchedule.cpp
index 030e16b744a88..abb2420188116 100644
--- a/llvm/utils/TableGen/CodeGenSchedule.cpp
+++ b/llvm/utils/TableGen/CodeGenSchedule.cpp
@@ -1456,7 +1456,9 @@ static std::vector 
getAllPredicates(ArrayRef Variants,
   ArrayRef ProcIndices) {
   std::vector Preds;
   for (auto &Variant : Variants) {
-assert(Variant.VarOrSeqDef->isSubClassOf("SchedVar"));
+if (!Variant.VarOrSeqDef->isSubClassOf("SchedVar"))
+  continue;
+
 if (ProcIndices[0] && Variant.ProcIdx)
   if (!llvm::count(ProcIndices, Variant.ProcIdx))
 continue;
@@ -1532,9 +1534,11 @@ void PredTransitions::getIntersectingVariants(
 " Ensure only one SchedAlias exists per RW.");
   }
 }
-Record *PredDef = Variant.VarOrSeqDef->getValueAsDef("Predicate");
-if (mutuallyExclusive(PredDef, AllPreds, TransVec[TransIdx].PredTerm))
-  continue;
+if (Variant.VarOrSeqDef->isSubClassOf("SchedVar")) {
+  Record *PredDef = Variant.VarOrSeqDef->getValueAsDef("Predicate");
+  if (mutuallyExclusive(PredDef, AllPreds, TransVec[TransIdx].PredTerm))
+continue;
+}
 
 if (IntersectingVariants.empty()) {
   // The first variant builds on the existing transition.



___
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] 5edb90c - [obj2yaml] - Dump section offsets in some cases.

2020-11-25 Thread Georgii Rymar via llvm-branch-commits

Author: Georgii Rymar
Date: 2020-11-25T12:41:01+03:00
New Revision: 5edb90c927131b9153da98634241ef74419a3b4d

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

LOG: [obj2yaml] - Dump section offsets in some cases.

Currently we never dump the `sh_offset` key.
Though it sometimes an important information.

To reduce the noise this patch implements the following logic:
1) The "Offset" key for the first section is always emitted.
2) If we can derive the offset for a next section naturally,
   then the "Offset" key is omitted.

By "naturally" I mean that section[X] offset is expected to be:
```
offsetOf(section[X]) == alignTo(section[X - 1].sh_offset + section[X - 
1].sh_size, section[X].sh_addralign)
```

So, when it has the expected value, we omit it from the output.

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

Added: 
llvm/test/tools/obj2yaml/ELF/offset.yaml

Modified: 
llvm/include/llvm/ObjectYAML/ELFYAML.h
llvm/lib/ObjectYAML/ELFEmitter.cpp
llvm/test/Object/obj2yaml.test
llvm/tools/obj2yaml/elf2yaml.cpp

Removed: 




diff  --git a/llvm/include/llvm/ObjectYAML/ELFYAML.h 
b/llvm/include/llvm/ObjectYAML/ELFYAML.h
index 058d78d4f4fd..9015fb680b60 100644
--- a/llvm/include/llvm/ObjectYAML/ELFYAML.h
+++ b/llvm/include/llvm/ObjectYAML/ELFYAML.h
@@ -658,6 +658,9 @@ struct Object {
   unsigned getMachine() const;
 };
 
+bool shouldAllocateFileSpace(ArrayRef Phdrs,
+ const NoBitsSection &S);
+
 } // end namespace ELFYAML
 } // end namespace llvm
 

diff  --git a/llvm/lib/ObjectYAML/ELFEmitter.cpp 
b/llvm/lib/ObjectYAML/ELFEmitter.cpp
index b31b7681adad..b8386bd46be2 100644
--- a/llvm/lib/ObjectYAML/ELFEmitter.cpp
+++ b/llvm/lib/ObjectYAML/ELFEmitter.cpp
@@ -1135,8 +1135,8 @@ void 
ELFState::setProgramHeaderLayout(std::vector &PHeaders,
   }
 }
 
-static bool shouldAllocateFileSpace(ArrayRef Phdrs,
-const ELFYAML::NoBitsSection &S) {
+bool llvm::ELFYAML::shouldAllocateFileSpace(
+ArrayRef Phdrs, const ELFYAML::NoBitsSection &S) {
   for (const ELFYAML::ProgramHeader &PH : Phdrs) {
 auto It = llvm::find_if(
 PH.Chunks, [&](ELFYAML::Chunk *C) { return C->Name == S.Name; });

diff  --git a/llvm/test/Object/obj2yaml.test b/llvm/test/Object/obj2yaml.test
index ea6194dee9a6..840440406456 100644
--- a/llvm/test/Object/obj2yaml.test
+++ b/llvm/test/Object/obj2yaml.test
@@ -362,6 +362,7 @@
 # ELF-MIPSEL-NEXT: Type:SHT_REL
 # ELF-MIPSEL-NEXT: Link:.symtab
 # ELF-MIPSEL-NEXT: AddressAlign:0x4
+# ELF-MIPSEL-NEXT: Offset:  0x434
 # ELF-MIPSEL-NEXT: Info:.text
 # ELF-MIPSEL-NEXT: Relocations:
 # ELF-MIPSEL-NEXT:   - Symbol:  _gp_disp
@@ -385,6 +386,7 @@
 # ELF-MIPSEL-NEXT: Type:SHT_PROGBITS
 # ELF-MIPSEL-NEXT: Flags:   [ SHF_WRITE, SHF_ALLOC ]
 # ELF-MIPSEL-NEXT: AddressAlign:0x4
+# ELF-MIPSEL-NEXT: Offset:  0x80
 # ELF-MIPSEL-NEXT:   - Name:.bss
 # ELF-MIPSEL-NEXT: Type:SHT_NOBITS
 # ELF-MIPSEL-NEXT: Flags:   [ SHF_WRITE, SHF_ALLOC ]
@@ -482,6 +484,7 @@
 # ELF-MIPS64EL-NEXT: Type:SHT_RELA
 # ELF-MIPS64EL-NEXT: Link:.symtab
 # ELF-MIPS64EL-NEXT: AddressAlign:0x8
+# ELF-MIPS64EL-NEXT: Offset:  0x410
 # ELF-MIPS64EL-NEXT: Info:.data
 # ELF-MIPS64EL-NEXT: Relocations:
 # ELF-MIPS64EL-NEXT:   - Symbol:  zed
@@ -490,6 +493,7 @@
 # ELF-MIPS64EL-NEXT: Type:SHT_NOBITS
 # ELF-MIPS64EL-NEXT: Flags:   [ SHF_WRITE, SHF_ALLOC ]
 # ELF-MIPS64EL-NEXT: AddressAlign:0x10
+# ELF-MIPS64EL-NEXT: Offset:  0x50
 # ELF-MIPS64EL-NEXT:   - Name:.MIPS.options
 # ELF-MIPS64EL-NEXT: Type:SHT_MIPS_OPTIONS
 # ELF-MIPS64EL-NEXT: Flags:   [ SHF_ALLOC, SHF_MIPS_NOSTRIP ]

diff  --git a/llvm/test/tools/obj2yaml/ELF/offset.yaml 
b/llvm/test/tools/obj2yaml/ELF/offset.yaml
new file mode 100644
index ..417c92aed1f8
--- /dev/null
+++ b/llvm/test/tools/obj2yaml/ELF/offset.yaml
@@ -0,0 +1,260 @@
+## Check how the "Offset" field is dumped by obj2yaml.
+## For each section we calulate the expected offset.
+## When it does not match the actual offset, we emit the "Offset" key.
+
+# RUN: yaml2obj %s -o %t1.o
+# RUN: obj2yaml %t1.o | FileCheck %s --check-prefix=BASIC
+
+# BASIC:  --- !ELF
+# BASIC-NEXT: FileHeader:
+# BASIC-NEXT:   Class: ELFCLASS64
+# BASIC-NEXT:   Data:  ELFDATA2LSB
+# BASIC-NEXT:   Type:  ET_REL
+# BASIC-NEXT: Sections:
+# BASIC-NEXT:   - Name: .foo1
+# BASIC-NEXT: Type: SHT_PROGBITS
+# BASIC-NEXT: Content:  '00'
+# BASIC-NEXT:   - Name:   

[llvm-branch-commits] [clang-tools-extra] fb6f425 - [clangd] Add metrics for invalid name.

2020-11-25 Thread Haojian Wu via llvm-branch-commits

Author: Haojian Wu
Date: 2020-11-25T10:50:43+01:00
New Revision: fb6f425d1b06480f4e61109852b1761cc15c81c1

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

LOG: [clangd] Add metrics for invalid name.

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

Added: 


Modified: 
clang-tools-extra/clangd/refactor/Rename.cpp
clang-tools-extra/clangd/unittests/RenameTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/refactor/Rename.cpp 
b/clang-tools-extra/clangd/refactor/Rename.cpp
index e7924b4add09..78aaa9930cd4 100644
--- a/clang-tools-extra/clangd/refactor/Rename.cpp
+++ b/clang-tools-extra/clangd/refactor/Rename.cpp
@@ -341,6 +341,15 @@ struct InvalidName {
   Kind K;
   std::string Details;
 };
+std::string toString(InvalidName::Kind K) {
+  switch (K) {
+  case InvalidName::Keywords:
+return "Keywords";
+  case InvalidName::Conflict:
+return "Conflict";
+  }
+  llvm_unreachable("unhandled InvalidName kind");
+}
 
 llvm::Error makeError(InvalidName Reason) {
   auto Message = [](InvalidName Reason) {
@@ -361,18 +370,25 @@ llvm::Error makeError(InvalidName Reason) {
 llvm::Optional checkName(const NamedDecl &RenameDecl,
   llvm::StringRef NewName) {
   trace::Span Tracer("CheckName");
+  static constexpr trace::Metric InvalidNameMetric(
+  "rename_name_invalid", trace::Metric::Counter, "invalid_kind");
   auto &ASTCtx = RenameDecl.getASTContext();
+  llvm::Optional Result;
   if (isKeyword(NewName, ASTCtx.getLangOpts()))
-return InvalidName{InvalidName::Keywords, NewName.str()};
-  // Name conflict detection.
-  // Function conflicts are subtle (overloading), so ignore them.
-  if (RenameDecl.getKind() != Decl::Function) {
-if (auto *Conflict = lookupSiblingWithName(ASTCtx, RenameDecl, NewName))
-  return InvalidName{
-  InvalidName::Conflict,
-  Conflict->getLocation().printToString(ASTCtx.getSourceManager())};
+Result = InvalidName{InvalidName::Keywords, NewName.str()};
+  else {
+// Name conflict detection.
+// Function conflicts are subtle (overloading), so ignore them.
+if (RenameDecl.getKind() != Decl::Function) {
+  if (auto *Conflict = lookupSiblingWithName(ASTCtx, RenameDecl, NewName))
+Result = InvalidName{
+InvalidName::Conflict,
+Conflict->getLocation().printToString(ASTCtx.getSourceManager())};
+}
   }
-  return llvm::None;
+  if (Result)
+InvalidNameMetric.record(1, toString(Result->K));
+  return Result;
 }
 
 // AST-based rename, it renames all occurrences in the main file.

diff  --git a/clang-tools-extra/clangd/unittests/RenameTests.cpp 
b/clang-tools-extra/clangd/unittests/RenameTests.cpp
index 68a6a666a895..d109b5139b2e 100644
--- a/clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ b/clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -1031,6 +1031,7 @@ TEST(RenameTest, PrepareRename) {
   EXPECT_THAT(FooCC.ranges(),
   testing::UnorderedElementsAreArray(Results->LocalChanges));
 
+  trace::TestTracer Tracer;
   // Name validation.
   Results =
   runPrepareRename(Server, FooCCPath, FooCC.point(),
@@ -1038,6 +1039,8 @@ TEST(RenameTest, PrepareRename) {
   EXPECT_FALSE(Results);
   EXPECT_THAT(llvm::toString(Results.takeError()),
   testing::HasSubstr("keyword"));
+  EXPECT_THAT(Tracer.takeMetric("rename_name_invalid", "Keywords"),
+  ElementsAre(1));
 
   // Single-file rename on global symbols, we should report an error.
   Results = runPrepareRename(Server, FooCCPath, FooCC.point(),



___
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] fee910e - [libObject, llvm-readelf] - Stop describing a section/segment in `notes_begin()`.

2020-11-25 Thread Georgii Rymar via llvm-branch-commits

Author: Georgii Rymar
Date: 2020-11-25T12:51:40+03:00
New Revision: fee910e522c997d7606f31148e01bcf67f3f94d1

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

LOG: [libObject,llvm-readelf] - Stop describing a section/segment in 
`notes_begin()`.

`notes_begin()` is used for iterating over notes. This API in some cases might 
print
section type and index. At the same time during iterating, the 
`Elf_Note_Iterator`
might omit it as it doesn't have this info.

Because of above we might have the redundant duplication of information in 
warnings:
(See D92021).

```
warning: '[[FILE]]': unable to read notes from the SHT_NOTE section with index 
1: SHT_NOTE section [index 1] has invalid offset (0x40) or size (0x)
```

This change stops reporting section index/type in Object/ELF.h/notes_begin().
(FTR, this was introduced by me for llvm-readobj in D64470).
Instead we can describe sections/program headers on the caller side.

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

Added: 


Modified: 
llvm/include/llvm/Object/ELF.h
llvm/test/tools/llvm-readobj/ELF/gnu-notes.test
llvm/tools/llvm-readobj/ELFDumper.cpp

Removed: 




diff  --git a/llvm/include/llvm/Object/ELF.h b/llvm/include/llvm/Object/ELF.h
index 7ebe6869c7b5..d47c8f7809fe 100644
--- a/llvm/include/llvm/Object/ELF.h
+++ b/llvm/include/llvm/Object/ELF.h
@@ -238,9 +238,9 @@ class ELFFile {
 assert(Phdr.p_type == ELF::PT_NOTE && "Phdr is not of type PT_NOTE");
 ErrorAsOutParameter ErrAsOutParam(&Err);
 if (Phdr.p_offset + Phdr.p_filesz > getBufSize()) {
-  Err = createError("PT_NOTE header has invalid offset (0x" +
-Twine::utohexstr(Phdr.p_offset) + ") or size (0x" +
-Twine::utohexstr(Phdr.p_filesz) + ")");
+  Err =
+  createError("invalid offset (0x" + Twine::utohexstr(Phdr.p_offset) +
+  ") or size (0x" + Twine::utohexstr(Phdr.p_filesz) + ")");
   return Elf_Note_Iterator(Err);
 }
 return Elf_Note_Iterator(base() + Phdr.p_offset, Phdr.p_filesz, Err);
@@ -257,10 +257,9 @@ class ELFFile {
 assert(Shdr.sh_type == ELF::SHT_NOTE && "Shdr is not of type SHT_NOTE");
 ErrorAsOutParameter ErrAsOutParam(&Err);
 if (Shdr.sh_offset + Shdr.sh_size > getBufSize()) {
-  Err = createError("SHT_NOTE section " + getSecIndexForError(*this, Shdr) 
+
-" has invalid offset (0x" +
-Twine::utohexstr(Shdr.sh_offset) + ") or size (0x" +
-Twine::utohexstr(Shdr.sh_size) + ")");
+  Err =
+  createError("invalid offset (0x" + Twine::utohexstr(Shdr.sh_offset) +
+  ") or size (0x" + Twine::utohexstr(Shdr.sh_size) + ")");
   return Elf_Note_Iterator(Err);
 }
 return Elf_Note_Iterator(base() + Shdr.sh_offset, Shdr.sh_size, Err);

diff  --git a/llvm/test/tools/llvm-readobj/ELF/gnu-notes.test 
b/llvm/test/tools/llvm-readobj/ELF/gnu-notes.test
index 04430577daaf..530a4a87293b 100644
--- a/llvm/test/tools/llvm-readobj/ELF/gnu-notes.test
+++ b/llvm/test/tools/llvm-readobj/ELF/gnu-notes.test
@@ -116,7 +116,7 @@ ProgramHeaders:
 # RUN: not llvm-readelf --notes %t2.so 2>&1 | FileCheck -DFILE=%t2.so %s 
--check-prefix=ERR1
 # RUN: not llvm-readobj --notes %t2.so 2>&1 | FileCheck -DFILE=%t2.so %s 
--check-prefix=ERR1
 
-# ERR1: error: '[[FILE]]': SHT_NOTE section [index 1] has invalid offset 
(0x) or size (0x0)
+# ERR1: error: '[[FILE]]': unable to read notes from the SHT_NOTE section with 
index 1: invalid offset (0x) or size (0x0)
 
 --- !ELF
 FileHeader:
@@ -137,7 +137,7 @@ Sections:
 # RUN: not llvm-readelf --notes %t3.so 2>&1 | FileCheck -DFILE=%t3.so %s 
--check-prefix=ERR2
 # RUN: not llvm-readobj --notes %t3.so 2>&1 | FileCheck -DFILE=%t3.so %s 
--check-prefix=ERR2
 
-# ERR2: error: '[[FILE]]': SHT_NOTE section [index 1] has invalid offset 
(0x40) or size (0x)
+# ERR2: error: '[[FILE]]': unable to read notes from the SHT_NOTE section with 
index 1: invalid offset (0x40) or size (0x)
 
 ## Test tools report an error if a note program header has an invalid offset 
that
 ## goes past the end of file.
@@ -146,7 +146,7 @@ Sections:
 # RUN: not llvm-readelf --notes %t4.so 2>&1 | FileCheck -DFILE=%t4.so %s 
--check-prefix=ERR3
 # RUN: not llvm-readobj --notes %t4.so 2>&1 | FileCheck -DFILE=%t4.so %s 
--check-prefix=ERR3
 
-# ERR3: error: '[[FILE]]': PT_NOTE header has invalid offset (0x) or 
size (0x0)
+# ERR3: error: '[[FILE]]': unable to read notes from the PT_NOTE segment: 
invalid offset (0x) or size (0x0)
 
 --- !ELF
 FileHeader:
@@ -165,7 +165,7 @@ ProgramHeaders:
 # RUN: not llvm-readelf --notes %t5.so 2>&1 | FileCheck -DFILE=%t5.so  %s 
--check-prefix=ERR4
 

[llvm-branch-commits] [llvm] d2b71ea - [ORC] Cast to const void* to silence a GCC warning. NFC.

2020-11-25 Thread Martin Storsjö via llvm-branch-commits

Author: Martin Storsjö
Date: 2020-11-25T12:10:53+02:00
New Revision: d2b71ea03d9c250453a90ad01ea1a4f8b0566b5d

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

LOG: [ORC] Cast to const void* to silence a GCC warning. NFC.

Added: 


Modified: 
llvm/include/llvm/ExecutionEngine/Orc/OrcRPCTargetProcessControl.h

Removed: 




diff  --git 
a/llvm/include/llvm/ExecutionEngine/Orc/OrcRPCTargetProcessControl.h 
b/llvm/include/llvm/ExecutionEngine/Orc/OrcRPCTargetProcessControl.h
index b498661021ae..0bc209120ce7 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/OrcRPCTargetProcessControl.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/OrcRPCTargetProcessControl.h
@@ -94,7 +94,7 @@ class OrcRPCTPCJITLinkMemoryManager : public 
jitlink::JITLinkMemoryManager {
  << " bytes to " << ((Prot & orcrpctpc::WPF_Read) ? 'R' : '-')
  << ((Prot & orcrpctpc::WPF_Write) ? 'W' : '-')
  << ((Prot & orcrpctpc::WPF_Exec) ? 'X' : '-')
- << " segment: local " << (void *)B.Buffer.data()
+ << " segment: local " << (const void *)B.Buffer.data()
  << " -> target " << formatv("{0:x16}", B.Address) << "\n";
 }
   });



___
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] df54f50 - [ORC] Remove a superfluous semicolon, silencing GCC warnings. NFC.

2020-11-25 Thread Martin Storsjö via llvm-branch-commits

Author: Martin Storsjö
Date: 2020-11-25T12:10:53+02:00
New Revision: df54f50437db99bd489d0782422c3c55900e6347

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

LOG: [ORC] Remove a superfluous semicolon, silencing GCC warnings. NFC.

Added: 


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

Removed: 




diff  --git a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp 
b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
index 4e899cf2d156..1ba5259988f5 100644
--- a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
+++ b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
@@ -733,7 +733,7 @@ Error LLVMJITLinkRemoteTargetProcessControl::disconnect() {
   });
   ListenerThread.join();
   return joinErrors(std::move(Err), F.get());
-};
+}
 
 class PhonyExternalsGenerator : public DefinitionGenerator {
 public:



___
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] e592dde - [clang][SVE] Activate macro `__ARM_FEATURE_SVE_VECTOR_OPERATORS`.

2020-11-25 Thread Francesco Petrogalli via llvm-branch-commits

Author: Francesco Petrogalli
Date: 2020-11-25T10:16:43Z
New Revision: e592dde6889b5119eb2794a30aca57c3760cab67

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

LOG: [clang][SVE] Activate macro `__ARM_FEATURE_SVE_VECTOR_OPERATORS`.

The macro is emitted when wargeting SVE code generation with the additional 
command line option `-msve-vector-bits=`.

The behavior implied by the macro is described in sections "3.7.3.3. Behavior 
specific to SVE vectors" of the SVE ACLE (Version 00bet6) that can be found at 
https://developer.arm.com/documentation/100987/latest

Reviewed By: rengolin, rsandifo-arm

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

Added: 
clang/test/CodeGen/aarch64-sve-acle-__ARM_FEATURE_SVE_VECTOR_OPERATORS.c
clang/test/CodeGen/aarch64-sve-acle-__ARM_FEATURE_SVE_VECTOR_OPERATORS.cpp

Modified: 
clang/lib/Basic/Targets/AArch64.cpp
clang/test/Preprocessor/aarch64-target-features.c

Removed: 




diff  --git a/clang/lib/Basic/Targets/AArch64.cpp 
b/clang/lib/Basic/Targets/AArch64.cpp
index 8e0fc5fa621e..37f0212b7001 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -377,8 +377,10 @@ void AArch64TargetInfo::getTargetDefines(const LangOptions 
&Opts,
   Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4");
   Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8");
 
-  if (Opts.ArmSveVectorBits)
+  if (Opts.ArmSveVectorBits) {
 Builder.defineMacro("__ARM_FEATURE_SVE_BITS", 
Twine(Opts.ArmSveVectorBits));
+Builder.defineMacro("__ARM_FEATURE_SVE_VECTOR_OPERATORS");
+  }
 }
 
 ArrayRef AArch64TargetInfo::getTargetBuiltins() const {

diff  --git 
a/clang/test/CodeGen/aarch64-sve-acle-__ARM_FEATURE_SVE_VECTOR_OPERATORS.c 
b/clang/test/CodeGen/aarch64-sve-acle-__ARM_FEATURE_SVE_VECTOR_OPERATORS.c
new file mode 100644
index ..fed7708c6893
--- /dev/null
+++ b/clang/test/CodeGen/aarch64-sve-acle-__ARM_FEATURE_SVE_VECTOR_OPERATORS.c
@@ -0,0 +1,117 @@
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve 
-fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s 
-msve-vector-bits=128  | FileCheck %s -D#VBITS=128  --check-prefixes=CHECK128
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve 
-fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s 
-msve-vector-bits=256  | FileCheck %s -D#VBITS=256  
--check-prefixes=CHECK,CHECK256
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve 
-fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s 
-msve-vector-bits=512  | FileCheck %s -D#VBITS=512  
--check-prefixes=CHECK,CHECK512
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve 
-fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s 
-msve-vector-bits=1024 | FileCheck %s -D#VBITS=1024 
--check-prefixes=CHECK,CHECK1024
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve 
-fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s 
-msve-vector-bits=2048 | FileCheck %s -D#VBITS=2048 
--check-prefixes=CHECK,CHECK2048
+// REQUIRES: aarch64-registered-target
+
+// Examples taken from section "3.7.3.3 Behavior specific to SVE
+// vectors" of the SVE ACLE (Version 00bet6) that can be found at
+// https://developer.arm.com/documentation/100987/latest
+//
+// Example has been expanded to work with mutiple values of
+// -msve-vector-bits.
+
+#include 
+
+// Page 27, item 1
+#if __ARM_FEATURE_SVE_BITS == 256 && __ARM_FEATURE_SVE_VECTOR_OPERATORS
+// CHECK256-LABEL: @x256 = local_unnamed_addr global <4 x i64> , align 16
+typedef svint64_t vec256 __attribute__((arm_sve_vector_bits(256)));
+vec256 x256 = {0, 1, 2, 3};
+#endif
+
+#if __ARM_FEATURE_SVE_BITS == 512 && __ARM_FEATURE_SVE_VECTOR_OPERATORS
+// CHECK512-LABEL: @x512 = local_unnamed_addr global <8 x i64> , align 16
+typedef svint64_t vec512 __attribute__((arm_sve_vector_bits(512)));
+vec512 x512 = {0, 1, 2, 3, 3 , 2 , 1, 0};
+#endif
+
+#if __ARM_FEATURE_SVE_BITS == 1024 && __ARM_FEATURE_SVE_VECTOR_OPERATORS
+// CHECK1024-LABEL: @x1024 = local_unnamed_addr global <16 x i64> , align 16
+typedef svint64_t vec1024 __attribute__((arm_sve_vector_bits(1024)));
+vec1024 x1024 = {0, 1, 2, 3, 3 , 2 , 1, 0, 0, 1, 2, 3, 3 , 2 , 1, 0};
+#endif
+
+#if __ARM_FEATURE_SVE_BITS == 2048 && __ARM_FEATURE_SVE_VECTOR_OPERATORS
+// CHECK2048-LABEL: @x2048 = local_unnamed_addr global <32 x i64> , align 16
+typedef svint64_t vec2048 __attribute__((arm_sve_vector_bits(2048)));
+vec2048 x2048 = {0, 1, 2, 3, 3 , 2 , 1, 0, 0, 1, 2, 3, 3 , 2 , 1, 0,
+ 0, 1, 2, 3, 3 , 2 , 1, 0, 0, 1, 2, 3, 3 , 2 , 1, 0};
+#endif
+
+// Page 27, item 2. We can not change the ABI of existing vector
+// t

[llvm-branch-commits] [clang] 633cae3 - [OpenCL] Move kernel arg type tests into one file

2020-11-25 Thread Sven van Haastregt via llvm-branch-commits

Author: Sven van Haastregt
Date: 2020-11-25T10:20:30Z
New Revision: 633cae30599cc5ec99f679079499a1f2ca4d3af3

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

LOG: [OpenCL] Move kernel arg type tests into one file

Keep all kernel parameter type diagnostic tests in
invalid-kernel-parameters.cl .

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

Added: 


Modified: 
clang/test/SemaOpenCL/invalid-kernel-parameters.cl
clang/test/SemaOpenCL/invalid-kernel.cl

Removed: 




diff  --git a/clang/test/SemaOpenCL/invalid-kernel-parameters.cl 
b/clang/test/SemaOpenCL/invalid-kernel-parameters.cl
index 48de39d0f87e..26859ee62cae 100644
--- a/clang/test/SemaOpenCL/invalid-kernel-parameters.cl
+++ b/clang/test/SemaOpenCL/invalid-kernel-parameters.cl
@@ -1,9 +1,21 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s -triple spir-unknown-unknown
+// RUN: %clang_cc1 -fsyntax-only -verify %s -triple spir-unknown-unknown 
-cl-std=CL2.0
 
 kernel void half_arg(half x) { } // expected-error{{declaring function 
parameter of type '__private half' is not allowed; did you forget * ?}}
 
 #pragma OPENCL EXTENSION cl_khr_fp16 : enable
 
+// expected-error@+1{{kernel parameter cannot be declared as a pointer to a 
pointer}}
+kernel void no_ptrptr(global int * global *i) { }
+
+// expected-error@+1{{pointer arguments to kernel functions must reside in 
'__global', '__constant' or '__local' address space}}
+__kernel void no_privateptr(__private int *i) { }
+
+// expected-error@+1{{pointer arguments to kernel functions must reside in 
'__global', '__constant' or '__local' address space}}
+__kernel void no_privatearray(__private int i[]) { }
+
+// expected-error@+1{{pointer arguments to kernel functions must reside in 
'__global', '__constant' or '__local' address space}}
+__kernel void no_addrsp_ptr(int *ptr) { }
 
 // Disallowed: parameters with type
 // bool, half, size_t, ptr
diff _t, intptr_t, and uintptr_t
@@ -65,14 +77,14 @@ kernel void image_in_struct_arg(FooImage2D arg) { } // 
expected-error{{struct ke
 
 typedef struct Foo // expected-note{{within field of type 'Foo' declared here}}
 {
-  int* ptrField; // expected-note{{field of illegal pointer type '__private 
int *' declared here}}
+  int* ptrField; // expected-note-re{{field of illegal pointer type 
'__{{private|generic}} int *' declared here}}
 } Foo;
 
 kernel void pointer_in_struct_arg(Foo arg) { } // expected-error{{struct 
kernel parameters may not contain pointers}}
 
 typedef union FooUnion // expected-note{{within field of type 'FooUnion' 
declared here}}
 {
-  int* ptrField; // expected-note{{field of illegal pointer type '__private 
int *' declared here}}
+  int* ptrField; // expected-note-re{{field of illegal pointer type 
'__{{private|generic}} int *' declared here}}
 } FooUnion;
 
 kernel void pointer_in_union_arg(FooUnion arg) { }// expected-error{{union 
kernel parameters may not contain pointers}}
@@ -82,7 +94,7 @@ typedef struct NestedPointer // expected-note 2 {{within 
field of type 'NestedPo
   int x;
   struct InnerNestedPointer
   {
-int* ptrField; // expected-note 3 {{field of illegal pointer type 
'__private int *' declared here}}
+int* ptrField; // expected-note-re 3 {{field of illegal pointer type 
'__{{private|generic}} int *' declared here}}
   } inner; // expected-note 3 {{within field of type 'struct 
InnerNestedPointer' declared here}}
 } NestedPointer;
 
@@ -96,7 +108,7 @@ struct NestedPointerComplex // expected-note{{within field 
of type 'NestedPointe
   struct InnerNestedPointerComplex
   {
 int innerFoo;
-int* innerPtrField; // expected-note{{field of illegal pointer type 
'__private int *' declared here}}
+int* innerPtrField; // expected-note-re{{field of illegal pointer type 
'__{{private|generic}} int *' declared here}}
   } inner; // expected-note{{within field of type 'struct 
InnerNestedPointerComplex' declared here}}
 
   float y;
@@ -167,8 +179,7 @@ kernel void pointer_in_nested_struct_arg_2(struct Valid 
valid, struct NestedPoin
 
 struct ArrayOfPtr // expected-note{{within field of type 'ArrayOfPtr' declared 
here}}
 {
-  float *arr[3]; // expected-note{{field of illegal type '__private float 
*[3]' declared here}}
- // expected-note@-1{{field of illegal type '__private float 
*[3]' declared here}}
+  float *arr[3]; // expected-note-re 2{{field of illegal type 
'__{{private|generic}} float *[3]' declared here}}
 };
 kernel void array_of_ptr(struct ArrayOfPtr arr) {} // expected-error{{struct 
kernel parameters may not contain pointers}}
 

diff  --git a/clang/test/SemaOpenCL/invalid-kernel.cl 
b/clang/test/SemaOpenCL/invalid-kernel.cl
index 031f6061a3b9..fd9cd6def00e 100644
--- a/clang/test/SemaOpenCL/invalid-kernel.cl
+++ b/clang/test/SemaOpenCL/invalid-k

[llvm-branch-commits] [clang-tools-extra] 0cb3869 - [clangd] Fix a tsan failure.

2020-11-25 Thread Haojian Wu via llvm-branch-commits

Author: Haojian Wu
Date: 2020-11-25T11:47:44+01:00
New Revision: 0cb38699a09d859dd40da0e4216b6066c63035f6

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

LOG: [clangd] Fix a tsan failure.

Tracer must be set up before calling any clangd-specific functions.

Added: 


Modified: 
clang-tools-extra/clangd/unittests/RenameTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/unittests/RenameTests.cpp 
b/clang-tools-extra/clangd/unittests/RenameTests.cpp
index d109b5139b2e..c67339ff2be4 100644
--- a/clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ b/clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -1016,6 +1016,7 @@ TEST(RenameTest, PrepareRename) {
   auto ServerOpts = ClangdServer::optsForTest();
   ServerOpts.BuildDynamicSymbolIndex = true;
 
+  trace::TestTracer Tracer;
   MockCompilationDatabase CDB;
   ClangdServer Server(CDB, FS, ServerOpts);
   runAddDocument(Server, FooHPath, FooH.code());
@@ -1031,7 +1032,6 @@ TEST(RenameTest, PrepareRename) {
   EXPECT_THAT(FooCC.ranges(),
   testing::UnorderedElementsAreArray(Results->LocalChanges));
 
-  trace::TestTracer Tracer;
   // Name validation.
   Results =
   runPrepareRename(Server, FooCCPath, FooCC.point(),



___
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] ad5b83d - [VPlan] Add VPReductionSC to VPUser::classof, unify VPValue IDs.

2020-11-25 Thread Florian Hahn via llvm-branch-commits

Author: Florian Hahn
Date: 2020-11-25T11:08:25Z
New Revision: ad5b83ddcf45372f61b9602038006a2ec58dab4a

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

LOG: [VPlan] Add VPReductionSC to VPUser::classof, unify VPValue IDs.

This is a follow-up to 00a66011366c7b037d6680e6015524a41b761c34 to make
isa work and unifies the VPValue ID names, by making
sure they all consistently start with VPV*.

Added: 


Modified: 
llvm/lib/Transforms/Vectorize/VPlan.h
llvm/lib/Transforms/Vectorize/VPlanValue.h
llvm/unittests/Transforms/Vectorize/VPlanTest.cpp

Removed: 




diff  --git a/llvm/lib/Transforms/Vectorize/VPlan.h 
b/llvm/lib/Transforms/Vectorize/VPlan.h
index fb7117b4ca8c..28595b9ec408 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.h
+++ b/llvm/lib/Transforms/Vectorize/VPlan.h
@@ -726,6 +726,7 @@ inline bool VPUser::classof(const VPRecipeBase *Recipe) {
  Recipe->getVPRecipeID() == VPRecipeBase::VPBlendSC ||
  Recipe->getVPRecipeID() == VPRecipeBase::VPInterleaveSC ||
  Recipe->getVPRecipeID() == VPRecipeBase::VPReplicateSC ||
+ Recipe->getVPRecipeID() == VPRecipeBase::VPReductionSC ||
  Recipe->getVPRecipeID() == VPRecipeBase::VPBranchOnMaskSC ||
  Recipe->getVPRecipeID() == VPRecipeBase::VPWidenMemoryInstructionSC;
 }
@@ -760,7 +761,7 @@ class VPInstruction : public VPUser, public VPValue, public 
VPRecipeBase {
 
 public:
   VPInstruction(unsigned Opcode, ArrayRef Operands)
-  : VPUser(Operands), VPValue(VPValue::VPInstructionSC),
+  : VPUser(Operands), VPValue(VPValue::VPVInstructionSC),
 VPRecipeBase(VPRecipeBase::VPInstructionSC), Opcode(Opcode) {}
 
   VPInstruction(unsigned Opcode, std::initializer_list Operands)
@@ -768,7 +769,7 @@ class VPInstruction : public VPUser, public VPValue, public 
VPRecipeBase {
 
   /// Method to support type inquiry through isa, cast, and dyn_cast.
   static inline bool classof(const VPValue *V) {
-return V->getVPValueID() == VPValue::VPInstructionSC;
+return V->getVPValueID() == VPValue::VPVInstructionSC;
   }
 
   VPInstruction *clone() const {
@@ -832,7 +833,7 @@ class VPWidenRecipe : public VPRecipeBase, public VPValue, 
public VPUser {
 public:
   template 
   VPWidenRecipe(Instruction &I, iterator_range Operands)
-  : VPRecipeBase(VPRecipeBase::VPWidenSC), VPValue(VPValue::VPWidenSC, &I),
+  : VPRecipeBase(VPRecipeBase::VPWidenSC), VPValue(VPValue::VPVWidenSC, 
&I),
 VPUser(Operands) {}
 
   ~VPWidenRecipe() override = default;
@@ -842,7 +843,7 @@ class VPWidenRecipe : public VPRecipeBase, public VPValue, 
public VPUser {
 return V->getVPRecipeID() == VPRecipeBase::VPWidenSC;
   }
   static inline bool classof(const VPValue *V) {
-return V->getVPValueID() == VPValue::VPWidenSC;
+return V->getVPValueID() == VPValue::VPVWidenSC;
   }
 
   /// Produce widened copies of all Ingredients.
@@ -1086,7 +1087,7 @@ class VPReductionRecipe : public VPRecipeBase, public 
VPValue, public VPUser {
 VPValue *VecOp, VPValue *CondOp, bool NoNaN,
 const TargetTransformInfo *TTI)
   : VPRecipeBase(VPRecipeBase::VPReductionSC),
-VPValue(VPValue::VPReductionSC, I), VPUser({ChainOp, VecOp}),
+VPValue(VPValue::VPVReductionSC, I), VPUser({ChainOp, VecOp}),
 RdxDesc(R), NoNaN(NoNaN), TTI(TTI) {
 if (CondOp)
   addOperand(CondOp);
@@ -1096,7 +1097,7 @@ class VPReductionRecipe : public VPRecipeBase, public 
VPValue, public VPUser {
 
   /// Method to support type inquiry through isa, cast, and dyn_cast.
   static inline bool classof(const VPValue *V) {
-return V->getVPValueID() == VPValue::VPReductionSC;
+return V->getVPValueID() == VPValue::VPVReductionSC;
   }
   static inline bool classof(const VPRecipeBase *V) {
 return V->getVPRecipeID() == VPRecipeBase::VPReductionSC;
@@ -1257,14 +1258,14 @@ class VPWidenMemoryInstructionRecipe : public 
VPRecipeBase,
 public:
   VPWidenMemoryInstructionRecipe(LoadInst &Load, VPValue *Addr, VPValue *Mask)
   : VPRecipeBase(VPWidenMemoryInstructionSC),
-VPValue(VPValue::VPMemoryInstructionSC, &Load), VPUser({Addr}) {
+VPValue(VPValue::VPVMemoryInstructionSC, &Load), VPUser({Addr}) {
 setMask(Mask);
   }
 
   VPWidenMemoryInstructionRecipe(StoreInst &Store, VPValue *Addr,
  VPValue *StoredValue, VPValue *Mask)
   : VPRecipeBase(VPWidenMemoryInstructionSC),
-VPValue(VPValue::VPMemoryInstructionSC, &Store),
+VPValue(VPValue::VPVMemoryInstructionSC, &Store),
 VPUser({Addr, StoredValue}) {
 setMask(Mask);
   }

diff  --git a/llvm/lib/Transforms/Vectorize/VPlanValue.h 
b/llvm/lib/Transforms/Vectorize/VPlanValue.h
index 0bc40112c9c5..9561abd10b5b 100644
---

[llvm-branch-commits] [clang-tools-extra] d95db16 - [clangd] Extract common file-caching logic from ConfigProvider.

2020-11-25 Thread Sam McCall via llvm-branch-commits

Author: Sam McCall
Date: 2020-11-25T12:09:13+01:00
New Revision: d95db1693cbf80b9de58a94b50178fddd62c3e15

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

LOG: [clangd] Extract common file-caching logic from ConfigProvider.

The plan is to use this to use this for .clang-format, .clang-tidy, and
compile_commands.json. (Currently the former two are reparsed every
time, and the latter is cached forever and changes are never seen).

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

Added: 
clang-tools-extra/clangd/support/FileCache.cpp
clang-tools-extra/clangd/support/FileCache.h
clang-tools-extra/clangd/unittests/support/FileCacheTests.cpp

Modified: 
clang-tools-extra/clangd/ConfigProvider.cpp
clang-tools-extra/clangd/ConfigProvider.h
clang-tools-extra/clangd/support/CMakeLists.txt
clang-tools-extra/clangd/unittests/ConfigProviderTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/ConfigProvider.cpp 
b/clang-tools-extra/clangd/ConfigProvider.cpp
index 5a00ec5048c0..e020ec04d1d2 100644
--- a/clang-tools-extra/clangd/ConfigProvider.cpp
+++ b/clang-tools-extra/clangd/ConfigProvider.cpp
@@ -9,6 +9,7 @@
 #include "ConfigProvider.h"
 #include "Config.h"
 #include "ConfigFragment.h"
+#include "support/FileCache.h"
 #include "support/ThreadsafeFS.h"
 #include "support/Trace.h"
 #include "llvm/ADT/ScopeExit.h"
@@ -24,89 +25,28 @@ namespace clangd {
 namespace config {
 
 // Threadsafe cache around reading a YAML config file from disk.
-class FileConfigCache {
-  std::mutex Mu;
-  std::chrono::steady_clock::time_point ValidTime = {};
-  llvm::SmallVector CachedValue;
-  llvm::sys::TimePoint<> MTime = {};
-  unsigned Size = -1;
-
-  // Called once we are sure we want to read the file.
-  // REQUIRES: Cache keys are set. Mutex must be held.
-  void fillCacheFromDisk(llvm::vfs::FileSystem &FS, DiagnosticCallback DC) {
-CachedValue.clear();
-
-auto Buf = FS.getBufferForFile(Path);
-// If we failed to read (but stat succeeded), don't cache failure.
-if (!Buf) {
-  Size = -1;
-  MTime = {};
-  return;
-}
-
-// If file changed between stat and open, we don't know its mtime.
-// For simplicity, don't cache the value in this case (use a bad key).
-if (Buf->get()->getBufferSize() != Size) {
-  Size = -1;
-  MTime = {};
-}
-
-// Finally parse and compile the actual fragments.
-for (auto &Fragment :
- Fragment::parseYAML(Buf->get()->getBuffer(), Path, DC)) {
-  Fragment.Source.Directory = Directory;
-  CachedValue.push_back(std::move(Fragment).compile(DC));
-}
-  }
-
-public:
-  // Must be set before the cache is used. Not a constructor param to allow
-  // computing ancestor-relative paths to be deferred.
-  std::string Path;
-  // Directory associated with this fragment.
+class FileConfigCache : public FileCache {
+  mutable llvm::SmallVector CachedValue;
   std::string Directory;
 
-  // Retrieves up-to-date config fragments from disk.
-  // A cached result may be reused if the mtime and size are unchanged.
-  // (But several concurrent read()s can miss the cache after a single change).
-  // Future performance ideas:
-  // - allow caches to be reused based on short elapsed walltime
-  // - allow latency-sensitive operations to skip revalidating the cache
-  void read(const ThreadsafeFS &TFS, DiagnosticCallback DC,
-llvm::Optional FreshTime,
-std::vector &Out) {
-std::lock_guard Lock(Mu);
-// We're going to update the cache and return whatever's in it.
-auto Return = llvm::make_scope_exit(
-[&] { llvm::copy(CachedValue, std::back_inserter(Out)); });
-
-// Return any sufficiently recent result without doing any further work.
-if (FreshTime && ValidTime >= FreshTime)
-  return;
-
-// Ensure we bump the ValidTime at the end to allow for reuse.
-auto MarkTime = llvm::make_scope_exit(
-[&] { ValidTime = std::chrono::steady_clock::now(); });
-
-// Stat is cheaper than opening the file, it's usually unchanged.
-assert(llvm::sys::path::is_absolute(Path));
-auto FS = TFS.view(/*CWD=*/llvm::None);
-auto Stat = FS->status(Path);
-// If there's no file, the result is empty. Ensure we have an invalid key.
-if (!Stat || !Stat->isRegularFile()) {
-  MTime = {};
-  Size = -1;
-  CachedValue.clear();
-  return;
-}
-// If the modified-time and size match, assume the content does too.
-if (Size == Stat->getSize() && MTime == Stat->getLastModificationTime())
-  return;
-
-// OK, the file has actually changed. Update cache key, compute new value.
-Size = Stat->getSize();
-MTime = Stat->getLastModificationTime();
-fillCacheFromDisk(*FS, DC);
+public:
+  Fil

[llvm-branch-commits] [llvm] 1c3451c - [gn build] Port d95db1693cb

2020-11-25 Thread LLVM GN Syncbot via llvm-branch-commits

Author: LLVM GN Syncbot
Date: 2020-11-25T11:13:15Z
New Revision: 1c3451c665f9deacb55a4bf38c038096fc93d094

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

LOG: [gn build] Port d95db1693cb

Added: 


Modified: 
llvm/utils/gn/secondary/clang-tools-extra/clangd/support/BUILD.gn

Removed: 




diff  --git a/llvm/utils/gn/secondary/clang-tools-extra/clangd/support/BUILD.gn 
b/llvm/utils/gn/secondary/clang-tools-extra/clangd/support/BUILD.gn
index 06a063fcbf60..07d4e1e062e9 100644
--- a/llvm/utils/gn/secondary/clang-tools-extra/clangd/support/BUILD.gn
+++ b/llvm/utils/gn/secondary/clang-tools-extra/clangd/support/BUILD.gn
@@ -11,6 +11,7 @@ static_library("support") {
   sources = [
 "Cancellation.cpp",
 "Context.cpp",
+"FileCache.cpp",
 "Logger.cpp",
 "Markup.cpp",
 "MemoryTree.cpp",



___
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] 603d40d - [SVE][CodeGen] Add a DAG combine to extend mscatter indices

2020-11-25 Thread Kerry McLaughlin via llvm-branch-commits

Author: Kerry McLaughlin
Date: 2020-11-25T11:18:22Z
New Revision: 603d40da9d532ab4706e32c07aba339e180ed865

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

LOG: [SVE][CodeGen] Add a DAG combine to extend mscatter indices

This patch adds a target-specific DAG combine for mscatter to promote indices
with element types i8 or i16 before legalisation, plus various tests with 
illegal types.

Reviewed By: sdesmalen

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

Added: 
llvm/test/CodeGen/AArch64/sve-masked-scatter-legalise.ll

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 b92eb1d0e4f6..e4c20cc4e6e3 100644
--- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -835,6 +835,8 @@ AArch64TargetLowering::AArch64TargetLowering(const 
TargetMachine &TM,
   if (Subtarget->supportsAddressTopByteIgnored())
 setTargetDAGCombine(ISD::LOAD);
 
+  setTargetDAGCombine(ISD::MSCATTER);
+
   setTargetDAGCombine(ISD::MUL);
 
   setTargetDAGCombine(ISD::SELECT);
@@ -13944,6 +13946,44 @@ static SDValue performSTORECombine(SDNode *N,
   return SDValue();
 }
 
+static SDValue performMSCATTERCombine(SDNode *N,
+  TargetLowering::DAGCombinerInfo &DCI,
+  SelectionDAG &DAG) {
+  MaskedScatterSDNode *MSC = cast(N);
+  assert(MSC && "Can only combine scatter store nodes");
+
+  SDLoc DL(MSC);
+  SDValue Chain = MSC->getChain();
+  SDValue Scale = MSC->getScale();
+  SDValue Index = MSC->getIndex();
+  SDValue Data = MSC->getValue();
+  SDValue Mask = MSC->getMask();
+  SDValue BasePtr = MSC->getBasePtr();
+  ISD::MemIndexType IndexType = MSC->getIndexType();
+
+  EVT IdxVT = Index.getValueType();
+
+  if (DCI.isBeforeLegalize()) {
+// SVE gather/scatter requires indices of i32/i64. Promote anything smaller
+// prior to legalisation so the result can be split if required.
+if ((IdxVT.getVectorElementType() == MVT::i8) ||
+(IdxVT.getVectorElementType() == MVT::i16)) {
+  EVT NewIdxVT = IdxVT.changeVectorElementType(MVT::i32);
+  if (MSC->isIndexSigned())
+Index = DAG.getNode(ISD::SIGN_EXTEND, DL, NewIdxVT, Index);
+  else
+Index = DAG.getNode(ISD::ZERO_EXTEND, DL, NewIdxVT, Index);
+
+  SDValue Ops[] = { Chain, Data, Mask, BasePtr, Index, Scale };
+  return DAG.getMaskedScatter(DAG.getVTList(MVT::Other),
+  MSC->getMemoryVT(), DL, Ops,
+  MSC->getMemOperand(), IndexType,
+  MSC->isTruncatingStore());
+}
+  }
+
+  return SDValue();
+}
 
 /// Target-specific DAG combine function for NEON load/store intrinsics
 /// to merge base address updates.
@@ -15136,6 +15176,8 @@ SDValue AArch64TargetLowering::PerformDAGCombine(SDNode 
*N,
 break;
   case ISD::STORE:
 return performSTORECombine(N, DCI, DAG, Subtarget);
+  case ISD::MSCATTER:
+return performMSCATTERCombine(N, DCI, DAG);
   case AArch64ISD::BRCOND:
 return performBRCONDCombine(N, DCI, DAG);
   case AArch64ISD::TBNZ:

diff  --git a/llvm/test/CodeGen/AArch64/sve-masked-scatter-legalise.ll 
b/llvm/test/CodeGen/AArch64/sve-masked-scatter-legalise.ll
new file mode 100644
index ..c3746a61d875
--- /dev/null
+++ b/llvm/test/CodeGen/AArch64/sve-masked-scatter-legalise.ll
@@ -0,0 +1,59 @@
+; RUN: llc -mtriple=aarch64--linux-gnu -mattr=+sve < %s | FileCheck %s
+
+; Tests that exercise various type legalisation scenarios for ISD::MSCATTER.
+
+; Code generate the scenario where the offset vector type is illegal.
+define void @masked_scatter_nxv16i8( %data, i8* %base, 
 %offsets,  %mask) {
+; CHECK-LABEL: masked_scatter_nxv16i8:
+; CHECK-DAG: st1b { {{z[0-9]+}}.s }, {{p[0-9]+}}, [x0, {{z[0-9]+}}.s, sxtw]
+; CHECK-DAG: st1b { {{z[0-9]+}}.s }, {{p[0-9]+}}, [x0, {{z[0-9]+}}.s, sxtw]
+; CHECK-DAG: st1b { {{z[0-9]+}}.s }, {{p[0-9]+}}, [x0, {{z[0-9]+}}.s, sxtw]
+; CHECK-DAG: st1b { {{z[0-9]+}}.s }, {{p[0-9]+}}, [x0, {{z[0-9]+}}.s, sxtw]
+; CHECK: ret
+  %ptrs = getelementptr i8, i8* %base,  %offsets
+  call void @llvm.masked.scatter.nxv16i8( %data,  %ptrs, i32 1,  %mask)
+  ret void
+}
+
+define void @masked_scatter_nxv8i16( %data, i16* %base, 
 %offsets,  %mask) {
+; CHECK-LABEL: masked_scatter_nxv8i16
+; CHECK-DAG: st1h { {{z[0-9]+}}.s }, {{p[0-9]+}}, [x0, {{z[0-9]+}}.s, sxtw #1]
+; CHECK-DAG: st1h { {{z[0-9]+}}.s }, {{p[0-9]+}}, [x0, {{z[0-9]+}}.s, sxtw #1]
+; CHECK: ret
+  %ptrs = getelementptr i16, i16* %base,  %offsets
+  call void @llvm.masked.scatter.nxv8i16( %data,  %ptrs, i32 1,  %mask)
+  ret void
+}
+
+def

[llvm-branch-commits] [llvm] 7e7106d - DetectDeadLanes.cpp - remove unused headers. NFCI.

2020-11-25 Thread Simon Pilgrim via llvm-branch-commits

Author: Simon Pilgrim
Date: 2020-11-25T11:38:28Z
New Revision: 7e7106d10425369e61a1cbe5b131b7aad57f700f

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

LOG: DetectDeadLanes.cpp - remove unused headers. NFCI.

Added: 


Modified: 
llvm/lib/CodeGen/DetectDeadLanes.cpp

Removed: 




diff  --git a/llvm/lib/CodeGen/DetectDeadLanes.cpp 
b/llvm/lib/CodeGen/DetectDeadLanes.cpp
index 6d5306c1dc0c7..03fe5f155291a 100644
--- a/llvm/lib/CodeGen/DetectDeadLanes.cpp
+++ b/llvm/lib/CodeGen/DetectDeadLanes.cpp
@@ -25,11 +25,7 @@
 //
 
//===--===//
 
-#include 
-#include 
-
 #include "llvm/ADT/BitVector.h"
-#include "llvm/ADT/SetVector.h"
 #include "llvm/CodeGen/MachineFunctionPass.h"
 #include "llvm/CodeGen/MachineRegisterInfo.h"
 #include "llvm/CodeGen/Passes.h"
@@ -40,6 +36,7 @@
 #include "llvm/PassRegistry.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/raw_ostream.h"
+#include 
 
 using namespace llvm;
 



___
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] 6d56823 - SemaExpr.cpp - use castAs<> instead of getAs<> as we dereference the pointer directly. NFCI.

2020-11-25 Thread Simon Pilgrim via llvm-branch-commits

Author: Simon Pilgrim
Date: 2020-11-25T11:38:29Z
New Revision: 6d56823116820962984cdd535cbed1191be696c9

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

LOG: SemaExpr.cpp - use castAs<> instead of getAs<> as we dereference the 
pointer directly. NFCI.

castAs<> will assert the correct cast type instead of just returning null, 
which we then try to dereference immediately.

Added: 


Modified: 
clang/lib/Sema/SemaExpr.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 5580cdf13691..859caed8fd86 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -15166,10 +15166,10 @@ void Sema::ActOnBlockArguments(SourceLocation 
CaretLoc, Declarator &ParamInfo,
   CurBlock->TheDecl->setSignatureAsWritten(Sig);
   CurBlock->FunctionType = T;
 
-  const FunctionType *Fn = T->getAs();
+  const auto *Fn = T->castAs();
   QualType RetTy = Fn->getReturnType();
   bool isVariadic =
-(isa(Fn) && cast(Fn)->isVariadic());
+  (isa(Fn) && 
cast(Fn)->isVariadic());
 
   CurBlock->TheDecl->setIsVariadic(isVariadic);
 



___
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] eb7ea5a - CGCall.cpp - use castAs<> instead of getAs<> as we dereference the pointer directly. NFCI.

2020-11-25 Thread Simon Pilgrim via llvm-branch-commits

Author: Simon Pilgrim
Date: 2020-11-25T11:38:29Z
New Revision: eb7ea5aa1ac6030b7bc94c5f2fb42de675cd392f

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

LOG: CGCall.cpp - use castAs<> instead of getAs<> as we dereference the pointer 
directly. NFCI.

castAs<> will assert the correct cast type instead of just returning null, 
which we then try to dereference immediately in the setUsedBits call.

Added: 


Modified: 
clang/lib/CodeGen/CGCall.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 2558dd42fac1..78740018d416 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -3153,7 +3153,7 @@ llvm::Value 
*CodeGenFunction::EmitCMSEClearRecord(llvm::Value *Src,
   const llvm::DataLayout &DataLayout = CGM.getDataLayout();
   int Size = DataLayout.getTypeStoreSize(ITy);
   SmallVector Bits(Size);
-  setUsedBits(CGM, QTy->getAs(), 0, Bits);
+  setUsedBits(CGM, QTy->castAs(), 0, Bits);
 
   int CharWidth = CGM.getContext().getCharWidth();
   uint64_t Mask =
@@ -3170,7 +3170,7 @@ llvm::Value 
*CodeGenFunction::EmitCMSEClearRecord(llvm::Value *Src,
   const llvm::DataLayout &DataLayout = CGM.getDataLayout();
   int Size = DataLayout.getTypeStoreSize(ATy);
   SmallVector Bits(Size);
-  setUsedBits(CGM, QTy->getAs(), 0, Bits);
+  setUsedBits(CGM, QTy->castAs(), 0, Bits);
 
   // Clear each element of the LLVM array.
   int CharWidth = CGM.getContext().getCharWidth();



___
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] 9d996c0 - TargetInfo.cpp - use castAs<> instead of getAs<> as we dereference the pointer directly. NFCI.

2020-11-25 Thread Simon Pilgrim via llvm-branch-commits

Author: Simon Pilgrim
Date: 2020-11-25T11:38:29Z
New Revision: 9d996c01aad5371ccf3790ce937b1cc85d1b07ab

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

LOG: TargetInfo.cpp - use castAs<> instead of getAs<> as we dereference the 
pointer directly. NFCI.

castAs<> will assert the correct cast type instead of just returning null, 
which we then try to dereference immediately.

Added: 


Modified: 
clang/lib/CodeGen/TargetInfo.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/TargetInfo.cpp 
b/clang/lib/CodeGen/TargetInfo.cpp
index 64240b1bde20..06b24c0384d8 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -10394,7 +10394,7 @@ void RISCVABIInfo::computeInfo(CGFunctionInfo &FI) 
const {
   if (!IsRetIndirect && RetTy->isScalarType() &&
   getContext().getTypeSize(RetTy) > (2 * XLen)) {
 if (RetTy->isComplexType() && FLen) {
-  QualType EltTy = RetTy->getAs()->getElementType();
+  QualType EltTy = RetTy->castAs()->getElementType();
   IsRetIndirect = getContext().getTypeSize(EltTy) > FLen;
 } else {
   // This is a normal scalar > 2*XLen, such as fp128 on RV32.



___
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] 88bb265 - SemaExpr.cpp - use castAs<> instead of getAs<> as we dereference the pointer directly. NFCI.

2020-11-25 Thread Simon Pilgrim via llvm-branch-commits

Author: Simon Pilgrim
Date: 2020-11-25T11:38:30Z
New Revision: 88bb2656708050bdb012c9046b3e30f3975f9949

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

LOG: SemaExpr.cpp - use castAs<> instead of getAs<> as we dereference the 
pointer directly. NFCI.

castAs<> will assert the correct cast type instead of just returning null, 
which we then try to dereference immediately.

Added: 


Modified: 
clang/lib/Sema/SemaExpr.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 859caed8fd86..d25d91223826 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -3778,8 +3778,7 @@ ExprResult Sema::ActOnNumericConstant(const Token &Tok, 
Scope *UDLScope) {
 
 if (Ty == Context.DoubleTy) {
   if (getLangOpts().SinglePrecisionConstants) {
-const BuiltinType *BTy = Ty->getAs();
-if (BTy->getKind() != BuiltinType::Float) {
+if (Ty->castAs()->getKind() != BuiltinType::Float) {
   Res = ImpCastExprToType(Res, Context.FloatTy, CK_FloatingCast).get();
 }
   } else if (getLangOpts().OpenCL &&



___
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] 2b66918 - [ARM][AArch64] Adding Neoverse N2 CPU support

2020-11-25 Thread Mark Murray via llvm-branch-commits

Author: Mark Murray
Date: 2020-11-25T11:42:54Z
New Revision: 2b6691894ab671706051a6d7ef54571546c20d3b

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

LOG: [ARM][AArch64] Adding Neoverse N2 CPU support

Add support for the Neoverse N2 CPU to the ARM and AArch64 backends.

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

Added: 


Modified: 
clang/test/Driver/aarch64-cpus.c
clang/test/Driver/arm-cortex-cpus.c
llvm/include/llvm/Support/AArch64TargetParser.def
llvm/include/llvm/Support/ARMTargetParser.def
llvm/lib/Support/Host.cpp
llvm/lib/Target/AArch64/AArch64.td
llvm/lib/Target/AArch64/AArch64Subtarget.cpp
llvm/lib/Target/AArch64/AArch64Subtarget.h
llvm/lib/Target/ARM/ARM.td
llvm/lib/Target/ARM/ARMSubtarget.cpp
llvm/lib/Target/ARM/ARMSubtarget.h
llvm/test/CodeGen/AArch64/cpus.ll
llvm/test/CodeGen/AArch64/neon-dot-product.ll
llvm/test/CodeGen/AArch64/remat.ll
llvm/test/MC/AArch64/armv8.2a-dotprod.s
llvm/test/MC/AArch64/armv8.3a-rcpc.s
llvm/test/MC/AArch64/armv8.5a-ssbs.s
llvm/test/MC/ARM/armv8.2a-dotprod-a32.s
llvm/test/MC/ARM/armv8.2a-dotprod-t32.s
llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt
llvm/unittests/Support/TargetParserTest.cpp

Removed: 




diff  --git a/clang/test/Driver/aarch64-cpus.c 
b/clang/test/Driver/aarch64-cpus.c
index 139746823660..131a57940b4c 100644
--- a/clang/test/Driver/aarch64-cpus.c
+++ b/clang/test/Driver/aarch64-cpus.c
@@ -752,6 +752,9 @@
 // RUN: %clang -target aarch64 -march=armv8-a+ras -### -c %s 2>&1 | FileCheck 
-check-prefix=V8ARAS -check-prefix=GENERIC %s
 // V8ARAS: "-target-feature" "+ras"
 
+// RUN: %clang -target aarch64 -mcpu=neoverse-n2 -### -c %s 2>&1 | FileCheck 
-check-prefix=NEOVERSE-N2 %s
+// NEOVERSE-N2: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"neoverse-n2"
+
 // == Check whether -march accepts mixed-case values.
 // RUN: %clang -target aarch64_be -march=ARMV8.1A -### -c %s 2>&1 | FileCheck 
-check-prefix=GENERICV81A-BE %s
 // RUN: %clang -target aarch64_be -march=ARMV8.1-A -### -c %s 2>&1 | FileCheck 
-check-prefix=GENERICV81A-BE %s

diff  --git a/clang/test/Driver/arm-cortex-cpus.c 
b/clang/test/Driver/arm-cortex-cpus.c
index 5df872358a7a..a312ccfda5a1 100644
--- a/clang/test/Driver/arm-cortex-cpus.c
+++ b/clang/test/Driver/arm-cortex-cpus.c
@@ -879,6 +879,9 @@
 // RUN: %clang -target arm -mcpu=cortex-m55 -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-CORTEX-M55 %s
 // CHECK-CORTEX-M55:  "-cc1"{{.*}} "-triple" "thumbv8.1m.main-{{.*}} 
"-target-cpu" "cortex-m55"
 
+// RUN: %clang -target arm -mcpu=neoverse-n2 -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-NEOVERSE-N2 %s
+// CHECK-NEOVERSE-N2: "-cc1"{{.*}} "-triple" "armv8.5a-{{.*}}" "-target-cpu" 
"neoverse-n2"
+
 // == Check whether -mcpu accepts mixed-case values.
 // RUN: %clang -target arm-linux-gnueabi -mcpu=Cortex-a5 -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-CASE-INSENSITIVE-CPUV7A %s
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-A7 -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-CASE-INSENSITIVE-CPUV7A %s

diff  --git a/llvm/include/llvm/Support/AArch64TargetParser.def 
b/llvm/include/llvm/Support/AArch64TargetParser.def
index cbf0d5d079dd..7625f5a6f6ab 100644
--- a/llvm/include/llvm/Support/AArch64TargetParser.def
+++ b/llvm/include/llvm/Support/AArch64TargetParser.def
@@ -150,6 +150,11 @@ AARCH64_CPU_NAME("neoverse-n1", ARMV8_2A, 
FK_CRYPTO_NEON_FP_ARMV8, false,
  (AArch64::AEK_DOTPROD | AArch64::AEK_FP16 |
   AArch64::AEK_PROFILE | AArch64::AEK_RAS | AArch64::AEK_RCPC |
   AArch64::AEK_SSBS))
+AARCH64_CPU_NAME("neoverse-n2", ARMV8_5A, FK_CRYPTO_NEON_FP_ARMV8, false,
+ (AArch64::AEK_BF16 | AArch64::AEK_DOTPROD | AArch64::AEK_FP16 
|
+  AArch64::AEK_I8MM | AArch64::AEK_MTE | AArch64::AEK_RAS |
+  AArch64::AEK_RCPC | AArch64::AEK_SB | AArch64::AEK_SSBS |
+  AArch64::AEK_SVE | AArch64::AEK_SVE2 | 
AArch64::AEK_SVE2BITPERM))
 AARCH64_CPU_NAME("neoverse-v1", ARMV8_4A, FK_CRYPTO_NEON_FP_ARMV8, false,
  (AArch64::AEK_RAS | AArch64::AEK_SVE | AArch64::AEK_SSBS |
   AArch64::AEK_RCPC | AArch64::AEK_FP16 | AArch64::AEK_BF16 |

diff  --git a/llvm/include/llvm/Support/ARMTargetParser.def 
b/llvm/include/llvm/Support/ARMTargetParser.def
index 35c94fd5bce0..75ab539762db 100644
--- a/llvm/include/llvm/Support/ARMTargetParser.def
+++ b/llvm/include/llvm/Support/ARMTargetParser.def
@@ -300,6 +300,9 @@ ARM_CPU_NAME("cortex-x1", ARMV8_2A, 
FK_CRYPTO_NEON_FP_ARMV8, false,
  (ARM::AEK_FP16 | ARM::AEK_DOTPROD))
 ARM_CPU_NAME("neoverse-n1", ARMV8_2A, FK_CRYPTO_NEON_FP_ARMV8, false,

[llvm-branch-commits] [clang-tools-extra] a38d13e - [clangd] Use TimePoint<> instead of system_clock::time_point, it does matter after all.

2020-11-25 Thread Sam McCall via llvm-branch-commits

Author: Sam McCall
Date: 2020-11-25T12:49:24+01:00
New Revision: a38d13ed3635bfdd35226e8d8d0661a42bcd35c6

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

LOG: [clangd] Use TimePoint<> instead of system_clock::time_point, it does 
matter after all.

Added: 


Modified: 
clang-tools-extra/clangd/support/FileCache.h

Removed: 




diff  --git a/clang-tools-extra/clangd/support/FileCache.h 
b/clang-tools-extra/clangd/support/FileCache.h
index 75782e9ae021..ffc5deb7442b 100644
--- a/clang-tools-extra/clangd/support/FileCache.h
+++ b/clang-tools-extra/clangd/support/FileCache.h
@@ -71,7 +71,7 @@ class FileCache {
   // Time when the cache was known valid (reflected disk state).
   mutable std::chrono::steady_clock::time_point ValidTime;
   // Filesystem metadata corresponding to the currently cached data.
-  mutable std::chrono::system_clock::time_point ModifiedTime;
+  mutable llvm::sys::TimePoint<> ModifiedTime;
   mutable uint64_t Size;
 };
 



___
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] eb9b063 - [libc++] P1645 constexpr for

2020-11-25 Thread Mark de Wever via llvm-branch-commits

Author: Mark de Wever
Date: 2020-11-25T13:19:32+01:00
New Revision: eb9b063539c34d0d4dd14e8516eeb77bb8b9e4bd

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

LOG: [libc++] P1645 constexpr for 

Implements P1645: constexpr for  algorithms

Reviewed By: ldionne, #libc

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

Added: 


Modified: 
libcxx/docs/FeatureTestMacroTable.rst
libcxx/include/numeric
libcxx/include/version

libcxx/test/std/language.support/support.limits/support.limits.general/numeric.version.pass.cpp

libcxx/test/std/language.support/support.limits/support.limits.general/version.version.pass.cpp
libcxx/test/std/numerics/numeric.ops/accumulate/accumulate.pass.cpp
libcxx/test/std/numerics/numeric.ops/accumulate/accumulate_op.pass.cpp

libcxx/test/std/numerics/numeric.ops/adjacent.difference/adjacent_difference.pass.cpp

libcxx/test/std/numerics/numeric.ops/adjacent.difference/adjacent_difference_op.pass.cpp
libcxx/test/std/numerics/numeric.ops/exclusive.scan/exclusive_scan.pass.cpp

libcxx/test/std/numerics/numeric.ops/exclusive.scan/exclusive_scan_init_op.pass.cpp
libcxx/test/std/numerics/numeric.ops/inclusive.scan/inclusive_scan.pass.cpp

libcxx/test/std/numerics/numeric.ops/inclusive.scan/inclusive_scan_op.pass.cpp

libcxx/test/std/numerics/numeric.ops/inclusive.scan/inclusive_scan_op_init.pass.cpp
libcxx/test/std/numerics/numeric.ops/inner.product/inner_product.pass.cpp

libcxx/test/std/numerics/numeric.ops/inner.product/inner_product_comp.pass.cpp
libcxx/test/std/numerics/numeric.ops/numeric.iota/iota.pass.cpp
libcxx/test/std/numerics/numeric.ops/partial.sum/partial_sum.pass.cpp
libcxx/test/std/numerics/numeric.ops/partial.sum/partial_sum_op.pass.cpp
libcxx/test/std/numerics/numeric.ops/reduce/reduce.pass.cpp
libcxx/test/std/numerics/numeric.ops/reduce/reduce_init.pass.cpp
libcxx/test/std/numerics/numeric.ops/reduce/reduce_init_op.pass.cpp

libcxx/test/std/numerics/numeric.ops/transform.exclusive.scan/transform_exclusive_scan_init_bop_uop.pass.cpp

libcxx/test/std/numerics/numeric.ops/transform.inclusive.scan/transform_inclusive_scan_bop_uop.pass.cpp

libcxx/test/std/numerics/numeric.ops/transform.inclusive.scan/transform_inclusive_scan_bop_uop_init.pass.cpp

libcxx/test/std/numerics/numeric.ops/transform.reduce/transform_reduce_iter_iter_init_bop_uop.pass.cpp

libcxx/test/std/numerics/numeric.ops/transform.reduce/transform_reduce_iter_iter_iter_init.pass.cpp

libcxx/test/std/numerics/numeric.ops/transform.reduce/transform_reduce_iter_iter_iter_init_op_op.pass.cpp
libcxx/utils/generate_feature_test_macro_components.py
libcxx/www/cxx2a_status.html

Removed: 




diff  --git a/libcxx/docs/FeatureTestMacroTable.rst 
b/libcxx/docs/FeatureTestMacroTable.rst
index 637a4849e471..aa60a033edc3 100644
--- a/libcxx/docs/FeatureTestMacroTable.rst
+++ b/libcxx/docs/FeatureTestMacroTable.rst
@@ -196,6 +196,8 @@ Status
 - -
 ``__cpp_lib_constexpr_misc``  *unimplemented*
 - -
+``__cpp_lib_constexpr_numeric``   ``201911L``
+- -
 ``__cpp_lib_constexpr_swap_algorithms``   *unimplemented*
 - -
 ``__cpp_lib_constexpr_utility``   ``201811L``

diff  --git a/libcxx/include/numeric b/libcxx/include/numeric
index 50070ded8fed..ce4fc5f55347 100644
--- a/libcxx/include/numeric
+++ b/libcxx/include/numeric
@@ -17,115 +17,116 @@ namespace std
 {
 
 template 
-T
+constexpr T  // constexpr since C++20
 accumulate(InputIterator first, InputIterator last, T init);
 
 template 
-T
+constexpr T  // constexpr since C++20
 accumulate(InputIterator first, InputIterator last, T init, 
BinaryOperation binary_op);
 
 template
-typename iterator_traits::value_type
+constexpr typename iterator_traits::value_type  // 
constexpr since C++20
 reduce(InputIterator first, InputIterator last);  // C++17
 
 template
-T
+constexpr T  // constexpr since C++20
 reduce(InputIterator first, InputIterator last, T init);  // C++17
 
 template
-T
+constexpr T  // constexpr since C++20
 reduce(InputIterator first, InputIterator last, T init, BinaryOperation 
binary_op);  // C++17
 
 template 
-T
+constexpr T  // constexpr since C++20
 inner_product(InputIterator1 first1, InputIterator1 last1, InputIterator2 
first2, T init);
 
 template 
-T
+constexpr T  // constexpr since C++20

[llvm-branch-commits] [llvm] ce322fb - [llvm-readelf/obj] - Stop using `reportError` when dumping notes.

2020-11-25 Thread Georgii Rymar via llvm-branch-commits

Author: Georgii Rymar
Date: 2020-11-25T15:22:56+03:00
New Revision: ce322fb0b8973134f9e0f8f38e99f7051d24acb8

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

LOG: [llvm-readelf/obj] - Stop using `reportError` when dumping notes.

This starts using `reportUniqueWarnings` instead of `reportError`
in the code that is responsible for dumping notes.

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

Added: 


Modified: 
llvm/test/tools/llvm-readobj/ELF/gnu-notes.test
llvm/tools/llvm-readobj/ELFDumper.cpp

Removed: 




diff  --git a/llvm/test/tools/llvm-readobj/ELF/gnu-notes.test 
b/llvm/test/tools/llvm-readobj/ELF/gnu-notes.test
index 530a4a87293b..4a5cb1a38473 100644
--- a/llvm/test/tools/llvm-readobj/ELF/gnu-notes.test
+++ b/llvm/test/tools/llvm-readobj/ELF/gnu-notes.test
@@ -113,10 +113,22 @@ ProgramHeaders:
 ## that goes past the end of file.
 
 # RUN: yaml2obj --docnum=2 -DSHOFFSET=0x %s -o %t2.so
-# RUN: not llvm-readelf --notes %t2.so 2>&1 | FileCheck -DFILE=%t2.so %s 
--check-prefix=ERR1
-# RUN: not llvm-readobj --notes %t2.so 2>&1 | FileCheck -DFILE=%t2.so %s 
--check-prefix=ERR1
-
-# ERR1: error: '[[FILE]]': unable to read notes from the SHT_NOTE section with 
index 1: invalid offset (0x) or size (0x0)
+# RUN: llvm-readelf --notes %t2.so 2>&1 | FileCheck -DFILE=%t2.so %s 
--check-prefix=ERR1-GNU
+# RUN: llvm-readobj --notes %t2.so 2>&1 | FileCheck -DFILE=%t2.so %s 
--check-prefix=ERR1-LLVM
+
+# ERR1-GNU:  Displaying notes found in: .note
+# ERR1-GNU-NEXT:   OwnerData sizeDescription
+# ERR1-GNU-NEXT: warning: '[[FILE]]': unable to read notes from the SHT_NOTE 
section with index 1: invalid offset (0x) or size (0x0)
+# ERR1-GNU-NOT: {{.}}
+
+# ERR1-LLVM:  Notes [
+# ERR1-LLVM-NEXT:   NoteSection {
+# ERR1-LLVM-NEXT: Name:   .note
+# ERR1-LLVM-NEXT: Offset: 0x
+# ERR1-LLVM-NEXT: Size:   0x0
+# ERR1-LLVM-NEXT: warning: '[[FILE]]': unable to read notes from the SHT_NOTE 
section with index 1: invalid offset (0x) or size (0x0)
+# ERR1-LLVM-NEXT:   }
+# ERR1-LLVM-NEXT: ]
 
 --- !ELF
 FileHeader:
@@ -134,19 +146,43 @@ Sections:
 ## that goes past the end of file.
 
 # RUN: yaml2obj --docnum=2 -DSHSIZE=0x %s -o %t3.so
-# RUN: not llvm-readelf --notes %t3.so 2>&1 | FileCheck -DFILE=%t3.so %s 
--check-prefix=ERR2
-# RUN: not llvm-readobj --notes %t3.so 2>&1 | FileCheck -DFILE=%t3.so %s 
--check-prefix=ERR2
-
-# ERR2: error: '[[FILE]]': unable to read notes from the SHT_NOTE section with 
index 1: invalid offset (0x40) or size (0x)
+# RUN: llvm-readelf --notes %t3.so 2>&1 | FileCheck -DFILE=%t3.so %s 
--check-prefix=ERR2-GNU
+# RUN: llvm-readobj --notes %t3.so 2>&1 | FileCheck -DFILE=%t3.so %s 
--check-prefix=ERR2-LLVM
+
+# ERR2-GNU:  Displaying notes found in: .note
+# ERR2-GNU-NEXT:   OwnerData sizeDescription
+# ERR2-GNU-NEXT: warning: '[[FILE]]': unable to read notes from the SHT_NOTE 
section with index 1: invalid offset (0x40) or size (0x)
+# ERR2-GNU-NOT: {{.}}
+
+# ERR2-LLVM:  Notes [
+# ERR2-LLVM-NEXT:   NoteSection {
+# ERR2-LLVM-NEXT: Name: .note
+# ERR2-LLVM-NEXT: Offset: 0x40
+# ERR2-LLVM-NEXT: Size: 0x
+# ERR2-LLVM-NEXT: warning: '[[FILE]]': unable to read notes from the SHT_NOTE 
section with index 1: invalid offset (0x40) or size (0x)
+# ERR2-LLVM-NEXT:   }
+# ERR2-LLVM-NEXT: ]
 
 ## Test tools report an error if a note program header has an invalid offset 
that
 ## goes past the end of file.
 
 # RUN: yaml2obj --docnum=3 -DPHOFFSET=0x %s -o %t4.so
-# RUN: not llvm-readelf --notes %t4.so 2>&1 | FileCheck -DFILE=%t4.so %s 
--check-prefix=ERR3
-# RUN: not llvm-readobj --notes %t4.so 2>&1 | FileCheck -DFILE=%t4.so %s 
--check-prefix=ERR3
-
-# ERR3: error: '[[FILE]]': unable to read notes from the PT_NOTE segment: 
invalid offset (0x) or size (0x0)
+# RUN: llvm-readelf --notes %t4.so 2>&1 | FileCheck -DFILE=%t4.so %s 
--check-prefix=ERR3-GNU
+# RUN: llvm-readobj --notes %t4.so 2>&1 | FileCheck -DFILE=%t4.so %s 
--check-prefix=ERR3-LLVM
+
+# ERR3-GNU:  Displaying notes found at file offset 0x with length 
0x:
+# ERR3-GNU-NEXT:   OwnerData sizeDescription
+# ERR3-GNU-NEXT: warning: '[[FILE]]': unable to read notes from the PT_NOTE 
segment with index 1: invalid offset (0x) or size (0x0)
+# ERR3-GNU-NOT: {{.}}
+
+# ERR3-LLVM:  Notes [
+# ERR3-LLVM-NEXT:   NoteSection {
+# ERR3-LLVM-NEXT: Name: 
+# ERR3-LLVM-NEXT: Offset: 0x
+# ERR3-LLVM-NEXT: Size: 0x0
+# ERR3-LLVM-NEXT: warning: '[[FILE]]': unable to read notes from the PT_NOTE 
segment with index 1: invalid offset (0x) or size (0x0)
+# ERR3-LLVM-NE

[llvm-branch-commits] [clang-tools-extra] ed242da - Fix a typo in the documentation to unbreak the sphinx builder.

2020-11-25 Thread Aaron Ballman via llvm-branch-commits

Author: Aaron Ballman
Date: 2020-11-25T07:34:08-05:00
New Revision: ed242da0ffa28493d8a5ee6b80ecbe2441ca48a7

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

LOG: Fix a typo in the documentation to unbreak the sphinx builder.

Added: 


Modified: 
clang-tools-extra/docs/clang-tidy/checks/readability-identifier-naming.rst

Removed: 




diff  --git 
a/clang-tools-extra/docs/clang-tidy/checks/readability-identifier-naming.rst 
b/clang-tools-extra/docs/clang-tidy/checks/readability-identifier-naming.rst
index b744d21b6ff8..68c0abfcbdf6 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/readability-identifier-naming.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/readability-identifier-naming.rst
@@ -680,7 +680,7 @@ After:
 When defined, the check will ensure enumeration names will add the
 prefixed with the given value (regardless of casing).
 
-.. option:: EnumConstantIgnoredRegexp
+.. option:: EnumIgnoredRegexp
 
 Identifier naming checks won't be enforced for enumeration names
 matching this regular expression.



___
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] ecabb39 - Revert "[libc++] P1645 constexpr for "

2020-11-25 Thread Mark de Wever via llvm-branch-commits

Author: Mark de Wever
Date: 2020-11-25T13:46:08+01:00
New Revision: ecabb39ca11cba3d78a4134dfafd3bc0ee0473f4

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

LOG: Revert "[libc++] P1645 constexpr for "

This reverts commit eb9b063539c34d0d4dd14e8516eeb77bb8b9e4bd.

The commit fails to build on build bots using LLVM 8.

Added: 


Modified: 
libcxx/docs/FeatureTestMacroTable.rst
libcxx/include/numeric
libcxx/include/version

libcxx/test/std/language.support/support.limits/support.limits.general/numeric.version.pass.cpp

libcxx/test/std/language.support/support.limits/support.limits.general/version.version.pass.cpp
libcxx/test/std/numerics/numeric.ops/accumulate/accumulate.pass.cpp
libcxx/test/std/numerics/numeric.ops/accumulate/accumulate_op.pass.cpp

libcxx/test/std/numerics/numeric.ops/adjacent.difference/adjacent_difference.pass.cpp

libcxx/test/std/numerics/numeric.ops/adjacent.difference/adjacent_difference_op.pass.cpp
libcxx/test/std/numerics/numeric.ops/exclusive.scan/exclusive_scan.pass.cpp

libcxx/test/std/numerics/numeric.ops/exclusive.scan/exclusive_scan_init_op.pass.cpp
libcxx/test/std/numerics/numeric.ops/inclusive.scan/inclusive_scan.pass.cpp

libcxx/test/std/numerics/numeric.ops/inclusive.scan/inclusive_scan_op.pass.cpp

libcxx/test/std/numerics/numeric.ops/inclusive.scan/inclusive_scan_op_init.pass.cpp
libcxx/test/std/numerics/numeric.ops/inner.product/inner_product.pass.cpp

libcxx/test/std/numerics/numeric.ops/inner.product/inner_product_comp.pass.cpp
libcxx/test/std/numerics/numeric.ops/numeric.iota/iota.pass.cpp
libcxx/test/std/numerics/numeric.ops/partial.sum/partial_sum.pass.cpp
libcxx/test/std/numerics/numeric.ops/partial.sum/partial_sum_op.pass.cpp
libcxx/test/std/numerics/numeric.ops/reduce/reduce.pass.cpp
libcxx/test/std/numerics/numeric.ops/reduce/reduce_init.pass.cpp
libcxx/test/std/numerics/numeric.ops/reduce/reduce_init_op.pass.cpp

libcxx/test/std/numerics/numeric.ops/transform.exclusive.scan/transform_exclusive_scan_init_bop_uop.pass.cpp

libcxx/test/std/numerics/numeric.ops/transform.inclusive.scan/transform_inclusive_scan_bop_uop.pass.cpp

libcxx/test/std/numerics/numeric.ops/transform.inclusive.scan/transform_inclusive_scan_bop_uop_init.pass.cpp

libcxx/test/std/numerics/numeric.ops/transform.reduce/transform_reduce_iter_iter_init_bop_uop.pass.cpp

libcxx/test/std/numerics/numeric.ops/transform.reduce/transform_reduce_iter_iter_iter_init.pass.cpp

libcxx/test/std/numerics/numeric.ops/transform.reduce/transform_reduce_iter_iter_iter_init_op_op.pass.cpp
libcxx/utils/generate_feature_test_macro_components.py
libcxx/www/cxx2a_status.html

Removed: 




diff  --git a/libcxx/docs/FeatureTestMacroTable.rst 
b/libcxx/docs/FeatureTestMacroTable.rst
index aa60a033edc3..637a4849e471 100644
--- a/libcxx/docs/FeatureTestMacroTable.rst
+++ b/libcxx/docs/FeatureTestMacroTable.rst
@@ -196,8 +196,6 @@ Status
 - -
 ``__cpp_lib_constexpr_misc``  *unimplemented*
 - -
-``__cpp_lib_constexpr_numeric``   ``201911L``
-- -
 ``__cpp_lib_constexpr_swap_algorithms``   *unimplemented*
 - -
 ``__cpp_lib_constexpr_utility``   ``201811L``

diff  --git a/libcxx/include/numeric b/libcxx/include/numeric
index ce4fc5f55347..50070ded8fed 100644
--- a/libcxx/include/numeric
+++ b/libcxx/include/numeric
@@ -17,116 +17,115 @@ namespace std
 {
 
 template 
-constexpr T  // constexpr since C++20
+T
 accumulate(InputIterator first, InputIterator last, T init);
 
 template 
-constexpr T  // constexpr since C++20
+T
 accumulate(InputIterator first, InputIterator last, T init, 
BinaryOperation binary_op);
 
 template
-constexpr typename iterator_traits::value_type  // 
constexpr since C++20
+typename iterator_traits::value_type
 reduce(InputIterator first, InputIterator last);  // C++17
 
 template
-constexpr T  // constexpr since C++20
+T
 reduce(InputIterator first, InputIterator last, T init);  // C++17
 
 template
-constexpr T  // constexpr since C++20
+T
 reduce(InputIterator first, InputIterator last, T init, BinaryOperation 
binary_op);  // C++17
 
 template 
-constexpr T  // constexpr since C++20
+T
 inner_product(InputIterator1 first1, InputIterator1 last1, InputIterator2 
first2, T init);
 
 template 
-constexpr T  // constexpr since C++20
+T
   

[llvm-branch-commits] [llvm] 1ba4b82 - [LAA] NFC: Rename [get]MaxSafeRegisterWidth -> [get]MaxSafeVectorWidthInBits

2020-11-25 Thread Cullen Rhodes via llvm-branch-commits

Author: Cullen Rhodes
Date: 2020-11-25T13:06:26Z
New Revision: 1ba4b82f67e2267b156fb77e7d0c0f43e88e9103

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

LOG: [LAA] NFC: Rename [get]MaxSafeRegisterWidth -> 
[get]MaxSafeVectorWidthInBits

MaxSafeRegisterWidth is a misnomer since it actually returns the maximum
safe vector width. Register suggests it relates directly to a physical
register where it could be a vector spanning one or more physical
registers.

Reviewed By: sdesmalen

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

Added: 


Modified: 
llvm/include/llvm/Analysis/LoopAccessAnalysis.h
llvm/include/llvm/Transforms/Vectorize/LoopVectorizationLegality.h
llvm/lib/Analysis/LoopAccessAnalysis.cpp
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Removed: 




diff  --git a/llvm/include/llvm/Analysis/LoopAccessAnalysis.h 
b/llvm/include/llvm/Analysis/LoopAccessAnalysis.h
index 663b9c9935db..5ee98f308878 100644
--- a/llvm/include/llvm/Analysis/LoopAccessAnalysis.h
+++ b/llvm/include/llvm/Analysis/LoopAccessAnalysis.h
@@ -171,7 +171,8 @@ class MemoryDepChecker {
 
   MemoryDepChecker(PredicatedScalarEvolution &PSE, const Loop *L)
   : PSE(PSE), InnermostLoop(L), AccessIdx(0), MaxSafeDepDistBytes(0),
-MaxSafeRegisterWidth(-1U), FoundNonConstantDistanceDependence(false),
+MaxSafeVectorWidthInBits(-1U),
+FoundNonConstantDistanceDependence(false),
 Status(VectorizationSafetyStatus::Safe), RecordDependences(true) {}
 
   /// Register the location (instructions are given increasing numbers)
@@ -210,7 +211,9 @@ class MemoryDepChecker {
 
   /// Return the number of elements that are safe to operate on
   /// simultaneously, multiplied by the size of the element in bits.
-  uint64_t getMaxSafeRegisterWidth() const { return MaxSafeRegisterWidth; }
+  uint64_t getMaxSafeVectorWidthInBits() const {
+return MaxSafeVectorWidthInBits;
+  }
 
   /// In same cases when the dependency check fails we can still
   /// vectorize the loop with a dynamic array access check.
@@ -275,7 +278,7 @@ class MemoryDepChecker {
   /// operate on simultaneously, multiplied by the size of the element in bits.
   /// The size of the element is taken from the memory access that is most
   /// restrictive.
-  uint64_t MaxSafeRegisterWidth;
+  uint64_t MaxSafeVectorWidthInBits;
 
   /// If we see a non-constant dependence distance we can still try to
   /// vectorize this loop with runtime checks.

diff  --git 
a/llvm/include/llvm/Transforms/Vectorize/LoopVectorizationLegality.h 
b/llvm/include/llvm/Transforms/Vectorize/LoopVectorizationLegality.h
index ae8d545d6112..2be9ef10ac4f 100644
--- a/llvm/include/llvm/Transforms/Vectorize/LoopVectorizationLegality.h
+++ b/llvm/include/llvm/Transforms/Vectorize/LoopVectorizationLegality.h
@@ -311,8 +311,8 @@ class LoopVectorizationLegality {
 
   unsigned getMaxSafeDepDistBytes() { return LAI->getMaxSafeDepDistBytes(); }
 
-  uint64_t getMaxSafeRegisterWidth() const {
-return LAI->getDepChecker().getMaxSafeRegisterWidth();
+  uint64_t getMaxSafeVectorWidthInBits() const {
+return LAI->getDepChecker().getMaxSafeVectorWidthInBits();
   }
 
   bool hasStride(Value *V) { return LAI->hasStride(V); }

diff  --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp 
b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
index 78f63c63cb40..19a8ea23b70b 100644
--- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp
+++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
@@ -1654,7 +1654,7 @@ MemoryDepChecker::isDependent(const MemAccessInfo &A, 
unsigned AIdx,
   LLVM_DEBUG(dbgs() << "LAA: Positive distance " << Val.getSExtValue()
 << " with max VF = " << MaxVF << '\n');
   uint64_t MaxVFInBits = MaxVF * TypeByteSize * 8;
-  MaxSafeRegisterWidth = std::min(MaxSafeRegisterWidth, MaxVFInBits);
+  MaxSafeVectorWidthInBits = std::min(MaxSafeVectorWidthInBits, MaxVFInBits);
   return Dependence::BackwardVectorizable;
 }
 

diff  --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp 
b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 97c9011d8086..c9d6a6199476 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -5369,9 +5369,9 @@ LoopVectorizationCostModel::computeFeasibleMaxVF(unsigned 
ConstTripCount) {
   // It is computed by MaxVF * sizeOf(type) * 8, where type is taken from
   // the memory accesses that is most restrictive (involved in the smallest
   // dependence distance).
-  unsigned MaxSafeRegisterWidth = Legal->getMaxSafeRegisterWidth();
+  unsigned MaxSafeVectorWidthInBits = Legal->getMaxSafeVectorWidthInBits();
 
-  WidestRegister = std::min(WidestRegister, MaxSafeRegisterWidth);
+  WidestRegister = std::min(WidestRegister, MaxSafeVectorWidthInBits);
 
  

[llvm-branch-commits] [clang-tools-extra] f697050 - [clangd] PopulateSwitch: disable on dependent enums.

2020-11-25 Thread Adam Czachorowski via llvm-branch-commits

Author: Adam Czachorowski
Date: 2020-11-25T14:12:29+01:00
New Revision: f6970503d291b7cae70fe583bed392387f93f9e4

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

LOG: [clangd] PopulateSwitch: disable on dependent enums.

If the enum is a dependent type, we would crash somewhere in
getIntWidth(). -Wswitch diagnostic doesn't work on dependent enums
either.

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

Added: 


Modified: 
clang-tools-extra/clangd/refactor/tweaks/PopulateSwitch.cpp
clang-tools-extra/clangd/unittests/TweakTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/refactor/tweaks/PopulateSwitch.cpp 
b/clang-tools-extra/clangd/refactor/tweaks/PopulateSwitch.cpp
index 852888f6a043..bae80cdecf59 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/PopulateSwitch.cpp
+++ b/clang-tools-extra/clangd/refactor/tweaks/PopulateSwitch.cpp
@@ -126,7 +126,7 @@ bool PopulateSwitch::prepare(const Selection &Sel) {
 return false;
 
   EnumD = EnumT->getDecl();
-  if (!EnumD)
+  if (!EnumD || EnumD->isDependentType())
 return false;
 
   // We trigger if there are any values in the enum that aren't covered by the

diff  --git a/clang-tools-extra/clangd/unittests/TweakTests.cpp 
b/clang-tools-extra/clangd/unittests/TweakTests.cpp
index fd815d2c4c27..4a2360dda739 100644
--- a/clang-tools-extra/clangd/unittests/TweakTests.cpp
+++ b/clang-tools-extra/clangd/unittests/TweakTests.cpp
@@ -3084,6 +3084,12 @@ TEST_F(PopulateSwitchTest, Test) {
   R""(enum Enum {A,B,b=B}; ^switch (A) {case A:case B:break;})"",
   "unavailable",
   },
+  {
+  // Enum is dependent type
+  File,
+  R""(template void f() {enum Enum {A}; ^switch (A) {}})"",
+  "unavailable",
+  },
   };
 
   for (const auto &Case : Cases) {



___
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] bbf8a9c - [libc++] ADL-proof by adding _VSTD:: qualification on calls.

2020-11-25 Thread Arthur O'Dwyer via llvm-branch-commits

Author: Arthur O'Dwyer
Date: 2020-11-25T09:19:37-05:00
New Revision: bbf8a9ca3ffedb7059194086bac490b6171cc474

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

LOG: [libc++] ADL-proof  by adding _VSTD:: qualification on calls.

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

Added: 
libcxx/test/std/utilities/variant/variant.visit/robust_against_adl.pass.cpp

Modified: 
libcxx/include/variant

Removed: 




diff  --git a/libcxx/include/variant b/libcxx/include/variant
index cb92a69d14d1..3621f2c68f52 100644
--- a/libcxx/include/variant
+++ b/libcxx/include/variant
@@ -491,7 +491,7 @@ private:
 template 
 inline _LIBCPP_INLINE_VISIBILITY
 static constexpr decltype(auto) __dispatch(_Fp __f, _Vs... __vs) {
-return __invoke_constexpr(
+return _VSTD::__invoke_constexpr(
 static_cast<_Fp>(__f),
 __access::__base::__get_alt<_Is>(static_cast<_Vs>(__vs))...);
 }
@@ -599,7 +599,7 @@ private:
   __std_visit_exhaustive_visitor_check<
   _Visitor,
   decltype((_VSTD::forward<_Alts>(__alts).__value))...>();
-  return __invoke_constexpr(_VSTD::forward<_Visitor>(__visitor),
+  return _VSTD::__invoke_constexpr(_VSTD::forward<_Visitor>(__visitor),
 _VSTD::forward<_Alts>(__alts).__value...);
 }
 _Visitor&& __visitor;

diff  --git 
a/libcxx/test/std/utilities/variant/variant.visit/robust_against_adl.pass.cpp 
b/libcxx/test/std/utilities/variant/variant.visit/robust_against_adl.pass.cpp
new file mode 100644
index ..af3cd759dbef
--- /dev/null
+++ 
b/libcxx/test/std/utilities/variant/variant.visit/robust_against_adl.pass.cpp
@@ -0,0 +1,46 @@
+// -*- C++ -*-
+//===--===//
+//
+// 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
+//
+//===--===//
+
+// UNSUPPORTED: c++03, c++11, c++14
+
+// Throwing bad_variant_access is supported starting in macosx10.13
+// XFAIL: with_system_cxx_lib=macosx10.12 && !no-exceptions
+// XFAIL: with_system_cxx_lib=macosx10.11 && !no-exceptions
+// XFAIL: with_system_cxx_lib=macosx10.10 && !no-exceptions
+// XFAIL: with_system_cxx_lib=macosx10.9 && !no-exceptions
+
+// 
+// template 
+// constexpr see below visit(Visitor&& vis, Variants&&... vars);
+
+#include 
+
+#include "test_macros.h"
+
+struct Incomplete;
+template struct Holder { T t; };
+
+constexpr bool test(bool do_it)
+{
+if (do_it) {
+std::variant*, int> v = nullptr;
+std::visit([](auto){}, v);
+std::visit([](auto) -> Holder* { return nullptr; }, v);
+}
+return true;
+}
+
+int main(int, char**)
+{
+test(true);
+#if TEST_STD_VER > 17
+static_assert(test(true));
+#endif
+return 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] [libc] d899f99 - Fix case mismatch between definition and declaration

2020-11-25 Thread Guillaume Chatelet via llvm-branch-commits

Author: Guillaume Chatelet
Date: 2020-11-25T14:23:31Z
New Revision: d899f9970e51cb80114abdc4efb5c0d9ce435f80

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

LOG: Fix case mismatch between definition and declaration

Added: 


Modified: 
libc/benchmarks/MemorySizeDistributions.cpp

Removed: 




diff  --git a/libc/benchmarks/MemorySizeDistributions.cpp 
b/libc/benchmarks/MemorySizeDistributions.cpp
index 02c3d6414a66..02c8103d6980 100644
--- a/libc/benchmarks/MemorySizeDistributions.cpp
+++ b/libc/benchmarks/MemorySizeDistributions.cpp
@@ -28,7 +28,7 @@ static constexpr double kMemsetGoogleQ[] = {0, 0, 0.0043, 
0.0055, 0.0033, 0.0025
 static constexpr double kMemsetGoogleU[] = {0.1064, 0.0986, 0.0201, 0.0042, 
0.1506, 0.0276, 0.0028, 0.0033, 0.3233, 0.1282, 0.011, 0.0035, 0.0015, 0.0019, 
0.0005, 0.0007, 0.0143, 0.0152, 0.0005, 0.0146, 0.0013, 0.0001, 0.0001, 0.0067, 
0.0054, 0, 0.0001, 0, 0.0006, 0, 0.0002, 0.0062, 0.0005, 0, 0, 0, 0.0004, 0, 0, 
0.0001, 0.0003, 0, 0.0001, 0, 0.0001, 0.0001, 0, 0.0021, 0.0002, 0, 0, 0.0001, 
0.0001, 0.0001, 0, 0, 0.0001, 0.0001, 0, 0.0001, 0.0001, 0, 0.0001, 0, 0.0092, 
0, 0, 0, 0.0002, 0, 0, 0, 0.007, 0, 0, 0, 0, 0, 0, 0.0015, 0.0001, 0.0001, 0, 
0, 0.0001, 0, 0, 0, 0.0001, 0, 0, 0.0001, 0, 0, 0, 0.0001, 0.0001, 0, 0, 
0.0001, 0, 0, 0, 0, 0.0001, 0.0001, 0.0053, 0, 0.0001, 0, 0, 0, 0.0002, 0, 0, 
0, 0.0001, 0, 0, 0.0001, 0, 0, 0, 0.0001, 0, 0, 0, 0, 0.0001, 0, 0, 0, 0.0001, 
0, 0, 0, 0.0001, 0, 0, 0, 0, 0.0001, 0, 0.0012, 0.0001, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0.0001, 0, 0, 0, 0, 0, 0.0001, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0.0001, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0.0001, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.0001, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0.0001, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.0001, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0.0003, 0.0001, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0.0002, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0.0001, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.0001, 
0, 0, 0, 0, 0, 0, 0, 0.0006, 0, 0, 0, 0, 0, 0, 0, 0.0001, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0.0001, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0.0001, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.0001, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0.0001, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.0136, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.0002, 0, 0, 0, 0, 0, 0, 0, 0, 0.0001, 0, 0, 
0, 0, 0, 0, 0, 0.0002, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.0001, 0, 
0, 0, 0, 0, 0, 0, 0.0002, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.0001, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.0001};
 // clang-format on
 
-ArrayRef GetMemcpySizeDistributions() {
+ArrayRef getMemcpySizeDistributions() {
   static constexpr MemorySizeDistribution kDistributions[] = {
   {"memcpy Google A", kMemcpyGoogleA}, {"memcpy Google B", kMemcpyGoogleB},
   {"memcpy Google D", kMemcpyGoogleD}, {"memcpy Google L", kMemcpyGoogleL},
@@ -39,7 +39,7 @@ ArrayRef GetMemcpySizeDistributions() 
{
   return kDistributions;
 }
 
-ArrayRef GetMemsetSizeDistributions() {
+ArrayRef getMemsetSizeDistributions() {
   static constexpr MemorySizeDistribution kDistributions[] = {
   {"memset Google B", kMemsetGoogleB},
   {"memset Google D", kMemsetGoogleD},
@@ -49,7 +49,7 @@ ArrayRef GetMemsetSizeDistributions() 
{
   return kDistributions;
 }
 
-ArrayRef GetMemcmpSizeDistributions() {
+ArrayRef getMemcmpSizeDistributions() {
   static constexpr MemorySizeDistribution kDistributions[] = {
   {"memcmp Google A", kMemcmpGoogleA}, {"memcmp Google B", kMemcmpGoogleB},
   {"memcmp Google D", kMemcmpGoogleD}, {"memcmp Google L", kMemcmpGoogleL},



___
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] 209e59d - [libc++] Mark a few tests as unsupported on gcc-7.

2020-11-25 Thread Marek Kurdej via llvm-branch-commits

Author: Marek Kurdej
Date: 2020-11-25T14:14:30+01:00
New Revision: 209e59d7b2b94e1809060e762a825ae8eb437272

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

LOG: [libc++] Mark a few tests as unsupported on gcc-7.

Added: 


Modified: 

libcxx/test/std/strings/basic.string/string.cons/string_view_deduction.fail.cpp

libcxx/test/std/strings/basic.string/string.cons/string_view_size_size_deduction.fail.cpp

Removed: 




diff  --git 
a/libcxx/test/std/strings/basic.string/string.cons/string_view_deduction.fail.cpp
 
b/libcxx/test/std/strings/basic.string/string.cons/string_view_deduction.fail.cpp
index 1fa2ee0efb1b..aa4c4559696c 100644
--- 
a/libcxx/test/std/strings/basic.string/string.cons/string_view_deduction.fail.cpp
+++ 
b/libcxx/test/std/strings/basic.string/string.cons/string_view_deduction.fail.cpp
@@ -8,6 +8,7 @@
 
 // 
 // UNSUPPORTED: c++03, c++11, c++14
+// UNSUPPORTED: gcc-7
 // XFAIL: libcpp-no-deduction-guides
 
 // template

diff  --git 
a/libcxx/test/std/strings/basic.string/string.cons/string_view_size_size_deduction.fail.cpp
 
b/libcxx/test/std/strings/basic.string/string.cons/string_view_size_size_deduction.fail.cpp
index 07c9002b5b7d..d7a8868977c8 100644
--- 
a/libcxx/test/std/strings/basic.string/string.cons/string_view_size_size_deduction.fail.cpp
+++ 
b/libcxx/test/std/strings/basic.string/string.cons/string_view_size_size_deduction.fail.cpp
@@ -8,6 +8,7 @@
 
 // 
 // UNSUPPORTED: c++03, c++11, c++14
+// UNSUPPORTED: gcc-7
 // XFAIL: libcpp-no-deduction-guides
 
 // 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] [libcxx] b2b21a2 - Fix gcc warnings: -Wsign-compare, -Wparentheses.

2020-11-25 Thread Marek Kurdej via llvm-branch-commits

Author: Marek Kurdej
Date: 2020-11-25T14:38:54+01:00
New Revision: b2b21a20e7bf72117bd3fe5895012016172da213

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

LOG: Fix gcc warnings: -Wsign-compare, -Wparentheses.

Added: 


Modified: 
libcxx/test/std/experimental/simd/simd.access/default.pass.cpp
libcxx/test/support/filesystem_test_helper.h

Removed: 




diff  --git a/libcxx/test/std/experimental/simd/simd.access/default.pass.cpp 
b/libcxx/test/std/experimental/simd/simd.access/default.pass.cpp
index 1bc1500ea6a7..2ca5ec4482bf 100644
--- a/libcxx/test/std/experimental/simd/simd.access/default.pass.cpp
+++ b/libcxx/test/std/experimental/simd/simd.access/default.pass.cpp
@@ -40,12 +40,12 @@ void test_access() {
 assert(a[0] % b[0] == 42 % 4);
 assert(a[0] << b[0] == (42 << 4));
 assert(a[0] >> b[0] == (42 >> 4));
-assert(a[0] < b[0] == false);
-assert(a[0] <= b[0] == false);
-assert(a[0] > b[0] == true);
-assert(a[0] >= b[0] == true);
-assert(a[0] == b[0] == false);
-assert(a[0] != b[0] == true);
+assert((a[0] < b[0]) == false);
+assert((a[0] <= b[0]) == false);
+assert((a[0] > b[0]) == true);
+assert((a[0] >= b[0]) == true);
+assert((a[0] == b[0]) == false);
+assert((a[0] != b[0]) == true);
 assert((a[0] & b[0]) == (42 & 4));
 assert((a[0] | b[0]) == (42 | 4));
 assert((a[0] ^ b[0]) == (42 ^ 4));
@@ -198,12 +198,12 @@ void test_access() {
 assert(a[0] % b[0] == 42 % 4);
 assert(a[0] << b[0] == (42 << 4));
 assert(a[0] >> b[0] == (42 >> 4));
-assert(a[0] < b[0] == false);
-assert(a[0] <= b[0] == false);
-assert(a[0] > b[0] == true);
-assert(a[0] >= b[0] == true);
-assert(a[0] == b[0] == false);
-assert(a[0] != b[0] == true);
+assert((a[0] < b[0]) == false);
+assert((a[0] <= b[0]) == false);
+assert((a[0] > b[0]) == true);
+assert((a[0] >= b[0]) == true);
+assert((a[0] == b[0]) == false);
+assert((a[0] != b[0]) == true);
 assert((a[0] & b[0]) == (42 & 4));
 assert((a[0] | b[0]) == (42 | 4));
 assert((a[0] ^ b[0]) == (42 ^ 4));

diff  --git a/libcxx/test/support/filesystem_test_helper.h 
b/libcxx/test/support/filesystem_test_helper.h
index 840c6aa3ce51..ad7ade3a1a58 100644
--- a/libcxx/test/support/filesystem_test_helper.h
+++ b/libcxx/test/support/filesystem_test_helper.h
@@ -184,7 +184,9 @@ struct scoped_test_env
 
 filename = sanitize_path(std::move(filename));
 
-if (size > std::numeric_limits::max()) {
+if (size >
+static_cast::type>(
+std::numeric_limits::max())) {
 fprintf(stderr, "create_file(%s, %ju) too large\n",
 filename.c_str(), size);
 abort();



___
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] [libcxxabi] 8334bca - [libc++abi] Fix gcc warnings: -Wpragmas.

2020-11-25 Thread Marek Kurdej via llvm-branch-commits

Author: Marek Kurdej
Date: 2020-11-25T14:59:17+01:00
New Revision: 8334bcac61c8b63a1f8e047cc7b56ab087548816

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

LOG: [libc++abi] Fix gcc warnings: -Wpragmas.

Added: 


Modified: 
libcxxabi/test/dynamic_cast.pass.cpp
libcxxabi/test/dynamic_cast3.pass.cpp
libcxxabi/test/dynamic_cast5.pass.cpp
libcxxabi/test/unwind_06.pass.cpp

Removed: 




diff  --git a/libcxxabi/test/dynamic_cast.pass.cpp 
b/libcxxabi/test/dynamic_cast.pass.cpp
index 49ecddb4177b..69f5dc3aa8b6 100644
--- a/libcxxabi/test/dynamic_cast.pass.cpp
+++ b/libcxxabi/test/dynamic_cast.pass.cpp
@@ -12,7 +12,7 @@
 // bases.
 #if defined(__clang__)
 #   pragma clang diagnostic ignored "-Winaccessible-base"
-#elif defined(__GNUC__)
+#elif defined(__GNUC__) && (__GNUC__ >= 10)
 #   pragma GCC diagnostic ignored "-Winaccessible-base"
 #endif
 

diff  --git a/libcxxabi/test/dynamic_cast3.pass.cpp 
b/libcxxabi/test/dynamic_cast3.pass.cpp
index 9c25cac865b9..2eefafa2b42b 100644
--- a/libcxxabi/test/dynamic_cast3.pass.cpp
+++ b/libcxxabi/test/dynamic_cast3.pass.cpp
@@ -13,7 +13,7 @@
 // bases.
 #if defined(__clang__)
 #   pragma clang diagnostic ignored "-Winaccessible-base"
-#elif defined(__GNUC__)
+#elif defined(__GNUC__) && (__GNUC__ >= 10)
 #   pragma GCC diagnostic ignored "-Winaccessible-base"
 #endif
 

diff  --git a/libcxxabi/test/dynamic_cast5.pass.cpp 
b/libcxxabi/test/dynamic_cast5.pass.cpp
index 0a9689c23d6b..7fdf106aae5b 100644
--- a/libcxxabi/test/dynamic_cast5.pass.cpp
+++ b/libcxxabi/test/dynamic_cast5.pass.cpp
@@ -13,7 +13,7 @@
 // bases.
 #if defined(__clang__)
 #   pragma clang diagnostic ignored "-Winaccessible-base"
-#elif defined(__GNUC__)
+#elif defined(__GNUC__) && (__GNUC__ >= 10)
 #   pragma GCC diagnostic ignored "-Winaccessible-base"
 #endif
 

diff  --git a/libcxxabi/test/unwind_06.pass.cpp 
b/libcxxabi/test/unwind_06.pass.cpp
index 0c34c4949376..f8e9f8953aa9 100644
--- a/libcxxabi/test/unwind_06.pass.cpp
+++ b/libcxxabi/test/unwind_06.pass.cpp
@@ -14,7 +14,7 @@
 #include 
 
 // Suppress diagnostics about deprecated volatile operations
-#if defined(__GNUC__) && !defined(__clang__)
+#if defined(__GNUC__) && (__GNUC__ >= 10) && !defined(__clang__)
 # pragma GCC diagnostic ignored "-Wvolatile"
 #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] [libcxxabi] 7a0bc89 - [libc++abi] Mark a few tests as XFAIL on gcc-7, gcc-8, gcc-9 (they were probably never tested anyway, gcc-10 passes them).

2020-11-25 Thread Marek Kurdej via llvm-branch-commits

Author: Marek Kurdej
Date: 2020-11-25T15:21:20+01:00
New Revision: 7a0bc898f599b92dc6bfd596cdfa50cf58a5d9c9

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

LOG: [libc++abi] Mark a few tests as XFAIL on gcc-7, gcc-8, gcc-9 (they were 
probably never tested anyway, gcc-10 passes them).

Added: 


Modified: 
libcxxabi/test/dynamic_cast.pass.cpp
libcxxabi/test/dynamic_cast3.pass.cpp
libcxxabi/test/dynamic_cast5.pass.cpp

Removed: 




diff  --git a/libcxxabi/test/dynamic_cast.pass.cpp 
b/libcxxabi/test/dynamic_cast.pass.cpp
index 69f5dc3aa8b6..c1a5980d552b 100644
--- a/libcxxabi/test/dynamic_cast.pass.cpp
+++ b/libcxxabi/test/dynamic_cast.pass.cpp
@@ -6,6 +6,8 @@
 //
 
//===--===//
 
+// XFAIL: gcc-7, gcc-8, gcc-9
+
 #include 
 
 // This test explicitly tests dynamic cast with types that have inaccessible

diff  --git a/libcxxabi/test/dynamic_cast3.pass.cpp 
b/libcxxabi/test/dynamic_cast3.pass.cpp
index 2eefafa2b42b..2364f4c1b5bd 100644
--- a/libcxxabi/test/dynamic_cast3.pass.cpp
+++ b/libcxxabi/test/dynamic_cast3.pass.cpp
@@ -6,6 +6,8 @@
 //
 
//===--===//
 
+// XFAIL: gcc-7, gcc-8, gcc-9
+
 #include 
 #include "support/timer.h"
 

diff  --git a/libcxxabi/test/dynamic_cast5.pass.cpp 
b/libcxxabi/test/dynamic_cast5.pass.cpp
index 7fdf106aae5b..357bb804766e 100644
--- a/libcxxabi/test/dynamic_cast5.pass.cpp
+++ b/libcxxabi/test/dynamic_cast5.pass.cpp
@@ -6,6 +6,8 @@
 //
 
//===--===//
 
+// XFAIL: gcc-7, gcc-8, gcc-9
+
 #include 
 #include "support/timer.h"
 



___
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] 6588592 - [PowerPC] Regenerate vec_select.ll tests and add <1 x i128> test case

2020-11-25 Thread Simon Pilgrim via llvm-branch-commits

Author: Simon Pilgrim
Date: 2020-11-25T14:28:16Z
New Revision: 6588592684ff0ec455570e576f8351a36e4ead3a

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

LOG: [PowerPC] Regenerate vec_select.ll tests and add <1 x i128> test case

Added: 


Modified: 
llvm/test/CodeGen/PowerPC/vec_select.ll

Removed: 




diff  --git a/llvm/test/CodeGen/PowerPC/vec_select.ll 
b/llvm/test/CodeGen/PowerPC/vec_select.ll
index 3b4f390611d4..2a839675b2a8 100644
--- a/llvm/test/CodeGen/PowerPC/vec_select.ll
+++ b/llvm/test/CodeGen/PowerPC/vec_select.ll
@@ -1,100 +1,178 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
 ; RUN: llc -verify-machineinstrs -ppc-vsr-nums-as-vr -ppc-asm-full-reg-names < 
%s -mtriple=powerpc64-linux-gnu -mcpu=pwr8 -mattr=+vsx | FileCheck %s 
-check-prefix=CHECK-VSX
-; RUN: llc -verify-machineinstrs -ppc-vsr-nums-as-vr -ppc-asm-full-reg-names < 
%s -mtriple=powerpc64-linux-gnu -mcpu=pwr8 -mattr=-vsx | FileCheck %s 
-check-prefix=CHECK-NOVSX
+; RUN: llc -verify-machineinstrs -ppc-vsr-nums-as-vr -ppc-asm-full-reg-names < 
%s -mtriple=powerpc64-linux-gnu -mcpu=pwr8 -mattr=-vsx | FileCheck %s 
-check-prefixes=CHECK-NOVSX,CHECK-NOVSX-BE
 ; RUN: llc -verify-machineinstrs -ppc-vsr-nums-as-vr -ppc-asm-full-reg-names < 
%s -mtriple=powerpc64le-linux-gnu -mcpu=pwr8 -mattr=+vsx | FileCheck %s 
-check-prefix=CHECK-VSX
-; RUN: llc -verify-machineinstrs -ppc-vsr-nums-as-vr -ppc-asm-full-reg-names < 
%s -mtriple=powerpc64le-linux-gnu -mcpu=pwr8 -mattr=-vsx | FileCheck %s 
-check-prefix=CHECK-NOVSX
+; RUN: llc -verify-machineinstrs -ppc-vsr-nums-as-vr -ppc-asm-full-reg-names < 
%s -mtriple=powerpc64le-linux-gnu -mcpu=pwr8 -mattr=-vsx | FileCheck %s 
-check-prefixes=CHECK-NOVSX,CHECK-NOVSX-LE
 
 define <4 x float> @test1(<4 x float> %a, <4 x float> %b, <4 x float> %c, <4 x 
float> %d) {
+; CHECK-VSX-LABEL: test1:
+; CHECK-VSX:   # %bb.0: # %entry
+; CHECK-VSX-NEXT:xvcmpeqsp vs0, v4, v5
+; CHECK-VSX-NEXT:xxsel v2, v3, v2, vs0
+; CHECK-VSX-NEXT:blr
+;
+; CHECK-NOVSX-LABEL: test1:
+; CHECK-NOVSX:   # %bb.0: # %entry
+; CHECK-NOVSX-NEXT:vcmpeqfp v4, v4, v5
+; CHECK-NOVSX-NEXT:vsel v2, v3, v2, v4
+; CHECK-NOVSX-NEXT:blr
 entry:
   %m = fcmp oeq <4 x float> %c, %d
   %v = select <4 x i1> %m, <4 x float> %a, <4 x float> %b
   ret <4 x float> %v
 }
-; CHECK-VSX-LABLE: test1
-; CHECK-VSX: xvcmpeqsp [[REG1:(vs|v)[0-9]+]], v4, v5
-; CHECK-VSX: xxsel v2, v3, v2, [[REG1]]
-; CHECK-VSX: blr
-
-; CHECK-NOVSX-LABLE: test1
-; CHECK-NOVSX: vcmpeqfp v[[REG1:[0-9]+]], v4, v5
-; CHECK-NOVSX: vsel v2, v3, v2, v[[REG1]]
-; CHECK-NOVSX: blr
 
 define <2 x double> @test2(<2 x double> %a, <2 x double> %b, <2 x double> %c, 
<2 x double> %d) {
+; CHECK-VSX-LABEL: test2:
+; CHECK-VSX:   # %bb.0: # %entry
+; CHECK-VSX-NEXT:xvcmpeqdp v4, v4, v5
+; CHECK-VSX-NEXT:xxsel v2, v3, v2, v4
+; CHECK-VSX-NEXT:blr
+;
+; CHECK-NOVSX-LABEL: test2:
+; CHECK-NOVSX:   # %bb.0: # %entry
+; CHECK-NOVSX-NEXT:fcmpu cr0, f5, f7
+; CHECK-NOVSX-NEXT:beq cr0, .LBB1_2
+; CHECK-NOVSX-NEXT:  # %bb.1: # %entry
+; CHECK-NOVSX-NEXT:fmr f1, f3
+; CHECK-NOVSX-NEXT:  .LBB1_2: # %entry
+; CHECK-NOVSX-NEXT:fcmpu cr0, f6, f8
+; CHECK-NOVSX-NEXT:beqlr cr0
+; CHECK-NOVSX-NEXT:  # %bb.3: # %entry
+; CHECK-NOVSX-NEXT:fmr f2, f4
+; CHECK-NOVSX-NEXT:blr
 entry:
   %m = fcmp oeq <2 x double> %c, %d
   %v = select <2 x i1> %m, <2 x double> %a, <2 x double> %b
   ret <2 x double> %v
 }
-; CHECK-VSX-LABLE: test2
-; CHECK-VSX: xvcmpeqdp [[REG1:(vs|v)[0-9]+]], v4, v5
-; CHECK-VSX: xxsel v2, v3, v2, [[REG1]]
-; CHECK-VSX: blr
-
-; CHECK-NOVSX-LABLE: test2
-; CHECK-NOVSX: fcmp
-; CHECK-NOVSX: fcmp
-; CHECK-NOVSX: blr
 
 define <16 x i8> @test3(<16 x i8> %a, <16 x i8> %b, <16 x i8> %c, <16 x i8> 
%d) {
+; CHECK-VSX-LABEL: test3:
+; CHECK-VSX:   # %bb.0: # %entry
+; CHECK-VSX-NEXT:vcmpequb v4, v4, v5
+; CHECK-VSX-NEXT:xxsel v2, v3, v2, v4
+; CHECK-VSX-NEXT:blr
+;
+; CHECK-NOVSX-LABEL: test3:
+; CHECK-NOVSX:   # %bb.0: # %entry
+; CHECK-NOVSX-NEXT:vcmpequb v4, v4, v5
+; CHECK-NOVSX-NEXT:vsel v2, v3, v2, v4
+; CHECK-NOVSX-NEXT:blr
 entry:
   %m = icmp eq <16 x i8> %c, %d
   %v = select <16 x i1> %m, <16 x i8> %a, <16 x i8> %b
   ret <16 x i8> %v
 }
-; CHECK-VSX-LABLE: test3
-; CHECK-VSX: vcmpequb v[[REG1:[0-9]+]], v4, v5
-; CHECK-VSX: xxsel v2, v3, v2, v[[REG1]]
-; CHECK-VSX: blr
-
-; CHECK-NOVSX-LABLE: test3
-; CHECK-NOVSX: vcmpequb v[[REG1:[0-9]+]], v4, v5
-; CHECK-NOVSX: vsel v2, v3, v2, v[[REG1]]
-; CHECK-NOVSX: blr
 
 define <8 x i16> @test4(<8 x i16> %a, <8 x i16> %b, <8 x i16> %c, <8 x i16> 
%d) {
+; CHECK-VSX-LABEL: test4:
+; CHECK-VSX:   # %bb.0: # %entry
+; CHECK-VSX-NEXT:vcmpequh v4, v4, v5
+; CHECK-VSX-NEXT:xxs

[llvm-branch-commits] [llvm] 0637dfe - [DAG] Legalize abs(x) -> smax(x, sub(0, x)) iff smax/sub are legal

2020-11-25 Thread Simon Pilgrim via llvm-branch-commits

Author: Simon Pilgrim
Date: 2020-11-25T15:03:03Z
New Revision: 0637dfe88b02a68f27fbad16ea47b26f91a47c61

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

LOG: [DAG] Legalize abs(x) -> smax(x,sub(0,x)) iff smax/sub are legal

If smax() is legal, this is likely to result in smaller codegen expansion for 
abs(x) than the xor(add,ashr) method.

This is also what PowerPC has been doing for its abs implementation, so it lets 
us get rid of a load of custom lowering code there (and which was never updated 
when they added smax lowering).

Alive2: https://alive2.llvm.org/ce/z/xRk3cD

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

Added: 


Modified: 
llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
llvm/lib/Target/PowerPC/PPCISelLowering.cpp
llvm/lib/Target/PowerPC/PPCISelLowering.h
llvm/test/CodeGen/X86/abs.ll
llvm/test/CodeGen/X86/combine-abs.ll
llvm/test/CodeGen/X86/viabs.ll

Removed: 




diff  --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp 
b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
index 93df88b3f6d7..0b1c25764549 100644
--- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
@@ -6822,6 +6822,14 @@ bool TargetLowering::expandABS(SDNode *N, SDValue 
&Result,
   EVT ShVT = getShiftAmountTy(VT, DAG.getDataLayout());
   SDValue Op = N->getOperand(0);
 
+  // abs(x) -> smax(x,sub(0,x))
+  if (isOperationLegal(ISD::SUB, VT) && isOperationLegal(ISD::SMAX, VT)) {
+SDValue Zero = DAG.getConstant(0, dl, VT);
+Result = DAG.getNode(ISD::SMAX, dl, VT, Op,
+ DAG.getNode(ISD::SUB, dl, VT, Zero, Op));
+return true;
+  }
+
   // Only expand vector types if we have the appropriate vector operations.
   if (VT.isVector() && (!isOperationLegalOrCustom(ISD::SRA, VT) ||
 !isOperationLegalOrCustom(ISD::ADD, VT) ||

diff  --git a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp 
b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
index d19fbd477d77..1f3ef3efa2c2 100644
--- a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -806,9 +806,6 @@ PPCTargetLowering::PPCTargetLowering(const PPCTargetMachine 
&TM,
   setOperationAction(ISD::UMIN, MVT::v2i64, Expand);
 }
 
-for (auto VT : {MVT::v2i64, MVT::v4i32, MVT::v8i16, MVT::v16i8})
-  setOperationAction(ISD::ABS, VT, Custom);
-
 // We can custom expand all VECTOR_SHUFFLEs to VPERM, others we can handle
 // with merges, splats, etc.
 setOperationAction(ISD::VECTOR_SHUFFLE, MVT::v16i8, Custom);
@@ -841,11 +838,6 @@ PPCTargetLowering::PPCTargetLowering(const 
PPCTargetMachine &TM,
 setOperationAction(ISD::FTRUNC, MVT::v4f32, Legal);
 setOperationAction(ISD::FNEARBYINT, MVT::v4f32, Legal);
 
-// Without hasP8Altivec set, v2i64 SMAX isn't available.
-// But ABS custom lowering requires SMAX support.
-if (!Subtarget.hasP8Altivec())
-  setOperationAction(ISD::ABS, MVT::v2i64, Expand);
-
 // Custom lowering ROTL v1i128 to VECTOR_SHUFFLE v16i8.
 setOperationAction(ISD::ROTL, MVT::v1i128, Custom);
 // With hasAltivec set, we can lower ISD::ROTL to vrl(b|h|w).
@@ -10886,44 +10878,6 @@ SDValue PPCTargetLowering::LowerMUL(SDValue Op, 
SelectionDAG &DAG) const {
   }
 }
 
-SDValue PPCTargetLowering::LowerABS(SDValue Op, SelectionDAG &DAG) const {
-
-  assert(Op.getOpcode() == ISD::ABS && "Should only be called for ISD::ABS");
-
-  EVT VT = Op.getValueType();
-  assert(VT.isVector() &&
- "Only set vector abs as custom, scalar abs shouldn't reach here!");
-  assert((VT == MVT::v2i64 || VT == MVT::v4i32 || VT == MVT::v8i16 ||
-  VT == MVT::v16i8) &&
- "Unexpected vector element type!");
-  assert((VT != MVT::v2i64 || Subtarget.hasP8Altivec()) &&
- "Current subtarget doesn't support smax v2i64!");
-
-  // For vector abs, it can be lowered to:
-  // abs x
-  // ==>
-  // y = -x
-  // smax(x, y)
-
-  SDLoc dl(Op);
-  SDValue X = Op.getOperand(0);
-  SDValue Zero = DAG.getConstant(0, dl, VT);
-  SDValue Y = DAG.getNode(ISD::SUB, dl, VT, Zero, X);
-
-  // SMAX patch https://reviews.llvm.org/D47332
-  // hasn't landed yet, so use intrinsic first here.
-  // TODO: Should use SMAX directly once SMAX patch landed
-  Intrinsic::ID BifID = Intrinsic::ppc_altivec_vmaxsw;
-  if (VT == MVT::v2i64)
-BifID = Intrinsic::ppc_altivec_vmaxsd;
-  else if (VT == MVT::v8i16)
-BifID = Intrinsic::ppc_altivec_vmaxsh;
-  else if (VT == MVT::v16i8)
-BifID = Intrinsic::ppc_altivec_vmaxsb;
-
-  return BuildIntrinsicOp(BifID, X, Y, DAG, dl, VT);
-}
-
 // Custom lowering for fpext vf32 to v2f64
 SDValue PPCTargetLowering::LowerFP_EXTEND(SDValue Op, SelectionDAG &DAG) const 
{
 
@@ -11059,7 +11013,6 @@ SDVa

[llvm-branch-commits] [flang] e73d8c7 - [flang][openacc] Semantic check for cache directive

2020-11-25 Thread via llvm-branch-commits

Author: Valentin Clement
Date: 2020-11-25T10:28:14-05:00
New Revision: e73d8c793a5028b8ba93b9b9a82d059760c3ec4d

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

LOG: [flang][openacc] Semantic check for cache directive

Add semantic check for the cache directive. According to section 2.10 from the 
specification:
A var in a cache directive must be a single array element or a simple subarray.

Reviewed By: kiranchandramohan

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

Added: 


Modified: 
flang/lib/Semantics/check-acc-structure.cpp
flang/lib/Semantics/check-acc-structure.h
flang/lib/Semantics/resolve-directives.cpp
flang/test/Semantics/acc-clause-validity.f90

Removed: 




diff  --git a/flang/lib/Semantics/check-acc-structure.cpp 
b/flang/lib/Semantics/check-acc-structure.cpp
index 8c05b585dda5..edcb41eae0c5 100644
--- a/flang/lib/Semantics/check-acc-structure.cpp
+++ b/flang/lib/Semantics/check-acc-structure.cpp
@@ -238,6 +238,15 @@ void AccStructureChecker::Leave(const 
parser::OpenACCAtomicConstruct &x) {
   dirContext_.pop_back();
 }
 
+void AccStructureChecker::Enter(const parser::OpenACCCacheConstruct &x) {
+  const auto &verbatim = std::get(x.t);
+  PushContextAndClauseSets(verbatim.source, llvm::acc::Directive::ACCD_cache);
+  SetContextDirectiveSource(verbatim.source);
+}
+void AccStructureChecker::Leave(const parser::OpenACCCacheConstruct &x) {
+  dirContext_.pop_back();
+}
+
 // Clause checkers
 CHECK_REQ_SCALAR_INT_CONSTANT_CLAUSE(Collapse, ACCC_collapse)
 

diff  --git a/flang/lib/Semantics/check-acc-structure.h 
b/flang/lib/Semantics/check-acc-structure.h
index 04c08b14598c..e2ea3899c98b 100644
--- a/flang/lib/Semantics/check-acc-structure.h
+++ b/flang/lib/Semantics/check-acc-structure.h
@@ -59,6 +59,8 @@ class AccStructureChecker
   void Leave(const parser::OpenACCWaitConstruct &);
   void Enter(const parser::OpenACCAtomicConstruct &);
   void Leave(const parser::OpenACCAtomicConstruct &);
+  void Enter(const parser::OpenACCCacheConstruct &);
+  void Leave(const parser::OpenACCCacheConstruct &);
 
   // Clauses
   void Leave(const parser::AccClauseList &);

diff  --git a/flang/lib/Semantics/resolve-directives.cpp 
b/flang/lib/Semantics/resolve-directives.cpp
index 65606d119dc4..f34cb69beca9 100644
--- a/flang/lib/Semantics/resolve-directives.cpp
+++ b/flang/lib/Semantics/resolve-directives.cpp
@@ -140,6 +140,9 @@ class AccAttributeVisitor : 
DirectiveAttributeVisitor {
 GetContext().withinConstruct = true;
   }
 
+  bool Pre(const parser::OpenACCCacheConstruct &);
+  void Post(const parser::OpenACCCacheConstruct &) { PopContext(); }
+
   void Post(const parser::AccDefaultClause &);
 
   bool Pre(const parser::AccClause::Copy &x) {
@@ -209,6 +212,7 @@ class AccAttributeVisitor : 
DirectiveAttributeVisitor {
   Symbol *DeclareOrMarkOtherAccessEntity(Symbol &, Symbol::Flag);
   void CheckMultipleAppearances(
   const parser::Name &, const Symbol &, Symbol::Flag);
+  void AllowOnlyArrayAndSubArray(const parser::AccObjectList &objectList);
 };
 
 // Data-sharing and Data-mapping attributes for data-refs in OpenMP construct
@@ -450,7 +454,6 @@ bool AccAttributeVisitor::Pre(const 
parser::OpenACCLoopConstruct &x) {
 bool AccAttributeVisitor::Pre(const parser::OpenACCStandaloneConstruct &x) {
   const auto &standaloneDir{std::get(x.t)};
   switch (standaloneDir.v) {
-  case llvm::acc::Directive::ACCD_cache:
   case llvm::acc::Directive::ACCD_enter_data:
   case llvm::acc::Directive::ACCD_exit_data:
   case llvm::acc::Directive::ACCD_init:
@@ -483,6 +486,64 @@ bool AccAttributeVisitor::Pre(const 
parser::OpenACCCombinedConstruct &x) {
   return true;
 }
 
+static bool IsLastNameArray(const parser::Designator &designator) {
+  const auto &name{GetLastName(designator)};
+  const evaluate::DataRef dataRef{*(name.symbol)};
+  return std::visit(
+  common::visitors{
+  [](const evaluate::SymbolRef &ref) { return ref->Rank() > 0; },
+  [](const evaluate::ArrayRef &aref) {
+return aref.base().IsSymbol() ||
+aref.base().GetComponent().base().Rank() == 0;
+  },
+  [](const auto &) { return false; },
+  },
+  dataRef.u);
+}
+
+void AccAttributeVisitor::AllowOnlyArrayAndSubArray(
+const parser::AccObjectList &objectList) {
+  for (const auto &accObject : objectList.v) {
+std::visit(
+common::visitors{
+[&](const parser::Designator &designator) {
+  if (!IsLastNameArray(designator))
+context_.Say(designator.source,
+"Only array element or subarray are allowed in %s 
directive"_err_en_US,
+parser::ToUpperCaseLetters(
+llvm::acc::getOpenACCDirectiveName(
+ 

[llvm-branch-commits] [llvm] edd6756 - [AMDGPU] Emit stack frame size in metadata

2020-11-25 Thread Sebastian Neubauer via llvm-branch-commits

Author: Sebastian Neubauer
Date: 2020-11-25T16:30:02+01:00
New Revision: edd675643d5ff49e6ea01af2a2a9b40498b3226c

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

LOG: [AMDGPU] Emit stack frame size in metadata

Add .shader_functions to pal metadata, which contains the stack frame
size for all non-entry-point functions.

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

Added: 


Modified: 
llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.h
llvm/lib/Target/AMDGPU/Utils/AMDGPUPALMetadata.cpp
llvm/lib/Target/AMDGPU/Utils/AMDGPUPALMetadata.h
llvm/test/CodeGen/AMDGPU/amdpal-callable.ll

Removed: 




diff  --git a/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp 
b/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
index fc785902843c..8148d0487802 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
@@ -456,9 +456,12 @@ bool 
AMDGPUAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
 Info = analyzeResourceUsage(MF);
   }
 
-  if (STM.isAmdPalOS() && MFI->isEntryFunction())
-EmitPALMetadata(MF, CurrentProgramInfo);
-  else if (!STM.isAmdHsaOS()) {
+  if (STM.isAmdPalOS()) {
+if (MFI->isEntryFunction())
+  EmitPALMetadata(MF, CurrentProgramInfo);
+else
+  emitPALFunctionMetadata(MF);
+  } else if (!STM.isAmdHsaOS()) {
 EmitProgramInfoSI(MF, CurrentProgramInfo);
   }
 
@@ -1260,6 +1263,12 @@ void AMDGPUAsmPrinter::EmitPALMetadata(const 
MachineFunction &MF,
 MD->setWave32(MF.getFunction().getCallingConv());
 }
 
+void AMDGPUAsmPrinter::emitPALFunctionMetadata(const MachineFunction &MF) {
+  auto *MD = getTargetStreamer()->getPALMetadata();
+  const MachineFrameInfo &MFI = MF.getFrameInfo();
+  MD->setStackFrameSize(MF, MFI.getStackSize());
+}
+
 // This is supposed to be log2(Size)
 static amd_element_byte_size_t getElementByteSizeValue(unsigned Size) {
   switch (Size) {

diff  --git a/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.h 
b/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.h
index 54e8338ab4b0..907ff2bfc162 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.h
+++ b/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.h
@@ -78,6 +78,7 @@ class AMDGPUAsmPrinter final : public AsmPrinter {
  const SIProgramInfo &KernelInfo);
   void EmitPALMetadata(const MachineFunction &MF,
const SIProgramInfo &KernelInfo);
+  void emitPALFunctionMetadata(const MachineFunction &MF);
   void emitCommonFunctionComments(uint32_t NumVGPR,
   Optional NumAGPR,
   uint32_t TotalNumVGPR,

diff  --git a/llvm/lib/Target/AMDGPU/Utils/AMDGPUPALMetadata.cpp 
b/llvm/lib/Target/AMDGPU/Utils/AMDGPUPALMetadata.cpp
index 85cba165770f..efabab90422f 100644
--- a/llvm/lib/Target/AMDGPU/Utils/AMDGPUPALMetadata.cpp
+++ b/llvm/lib/Target/AMDGPU/Utils/AMDGPUPALMetadata.cpp
@@ -238,6 +238,14 @@ void AMDGPUPALMetadata::setScratchSize(CallingConv::ID CC, 
unsigned Val) {
   getHwStage(CC)[".scratch_memory_size"] = MsgPackDoc.getNode(Val);
 }
 
+// Set the scratch size in the metadata.
+void AMDGPUPALMetadata::setStackFrameSize(const MachineFunction &MF,
+  unsigned Val) {
+  auto Node = MsgPackDoc.getMapNode();
+  Node[".stack_frame_size_in_bytes"] = MsgPackDoc.getNode(Val);
+  getShaderFunctions()[MF.getFunction().getName()] = Node;
+}
+
 // Set the hardware register bit in PAL metadata to enable wave32 on the
 // shader of the given calling convention.
 void AMDGPUPALMetadata::setWave32(unsigned CC) {
@@ -721,6 +729,24 @@ msgpack::MapDocNode AMDGPUPALMetadata::getRegisters() {
   return Registers.getMap();
 }
 
+// Reference (create if necessary) the node for the shader functions map.
+msgpack::DocNode &AMDGPUPALMetadata::refShaderFunctions() {
+  auto &N =
+  MsgPackDoc.getRoot()
+  .getMap(/*Convert=*/true)[MsgPackDoc.getNode("amdpal.pipelines")]
+  .getArray(/*Convert=*/true)[0]
+  .getMap(/*Convert=*/true)[MsgPackDoc.getNode(".shader_functions")];
+  N.getMap(/*Convert=*/true);
+  return N;
+}
+
+// Get (create if necessary) the shader functions map.
+msgpack::MapDocNode AMDGPUPALMetadata::getShaderFunctions() {
+  if (ShaderFunctions.isEmpty())
+ShaderFunctions = refShaderFunctions();
+  return ShaderFunctions.getMap();
+}
+
 // Return the PAL metadata hardware shader stage name.
 static const char *getStageName(CallingConv::ID CC) {
   switch (CC) {

diff  --git a/llvm/lib/Target/AMDGPU/Utils/AMDGPUPALMetadata.h 
b/llvm/lib/Target/AMDGPU/Utils/AMDGPUPALMetadata.h
index b089f295364c..3b1767bb1f64 100644
--- a/llvm/lib/Target/AMDGPU/Utils/AMDGPUPALMetadata.h
+++ b/llvm/lib/Target/AMDGPU/Utils/AMDGPUPALMetadata.h
@@ -15,6 +1

[llvm-branch-commits] [lld] 1933c9d - [WebAssembly] Factor out WasmTableType in binary format

2020-11-25 Thread Sam Clegg via llvm-branch-commits

Author: Andy Wingo
Date: 2020-11-25T08:00:08-08:00
New Revision: 1933c9d41a08cfc4c5c0ae80eedf466b5ae7ef01

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

LOG: [WebAssembly] Factor out WasmTableType in binary format

This commit factors out a WasmTableType definition from WasmTable, as is
the case for WasmGlobal and other data types.  Also add support for
extracting the SymbolName for a table from the linking section's symbol
table.

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

Added: 


Modified: 
lld/wasm/SyntheticSections.cpp
lld/wasm/WriterUtils.cpp
lld/wasm/WriterUtils.h
llvm/include/llvm/BinaryFormat/Wasm.h
llvm/lib/MC/WasmObjectWriter.cpp
llvm/lib/Object/WasmObjectFile.cpp
llvm/tools/obj2yaml/wasm2yaml.cpp

Removed: 




diff  --git a/lld/wasm/SyntheticSections.cpp b/lld/wasm/SyntheticSections.cpp
index 407eb8084d0e..3e0581cbcfc4 100644
--- a/lld/wasm/SyntheticSections.cpp
+++ b/lld/wasm/SyntheticSections.cpp
@@ -223,7 +223,7 @@ void TableSection::writeBody() {
 limits = {0, tableSize, 0};
   else
 limits = {WASM_LIMITS_FLAG_HAS_MAX, tableSize, tableSize};
-  writeTableType(os, WasmTable{0, WASM_TYPE_FUNCREF, limits});
+  writeTableType(os, WasmTableType{WASM_TYPE_FUNCREF, limits});
 }
 
 void MemorySection::writeBody() {

diff  --git a/lld/wasm/WriterUtils.cpp b/lld/wasm/WriterUtils.cpp
index cd221855a12b..81fcee4e68fe 100644
--- a/lld/wasm/WriterUtils.cpp
+++ b/lld/wasm/WriterUtils.cpp
@@ -195,7 +195,7 @@ void writeEvent(raw_ostream &os, const WasmEvent &event) {
   writeEventType(os, event.Type);
 }
 
-void writeTableType(raw_ostream &os, const llvm::wasm::WasmTable &type) {
+void writeTableType(raw_ostream &os, const WasmTableType &type) {
   writeU8(os, WASM_TYPE_FUNCREF, "table type");
   writeLimits(os, type.Limits);
 }

diff  --git a/lld/wasm/WriterUtils.h b/lld/wasm/WriterUtils.h
index 86df768af5c6..98f5ab1fbf3b 100644
--- a/lld/wasm/WriterUtils.h
+++ b/lld/wasm/WriterUtils.h
@@ -54,7 +54,7 @@ void writeEventType(raw_ostream &os, const 
llvm::wasm::WasmEventType &type);
 
 void writeEvent(raw_ostream &os, const llvm::wasm::WasmEvent &event);
 
-void writeTableType(raw_ostream &os, const llvm::wasm::WasmTable &type);
+void writeTableType(raw_ostream &os, const llvm::wasm::WasmTableType &type);
 
 void writeImport(raw_ostream &os, const llvm::wasm::WasmImport &import);
 

diff  --git a/llvm/include/llvm/BinaryFormat/Wasm.h 
b/llvm/include/llvm/BinaryFormat/Wasm.h
index f1441c7e0794..adcd9d364431 100644
--- a/llvm/include/llvm/BinaryFormat/Wasm.h
+++ b/llvm/include/llvm/BinaryFormat/Wasm.h
@@ -67,12 +67,17 @@ struct WasmLimits {
   uint64_t Maximum;
 };
 
-struct WasmTable {
-  uint32_t Index;
+struct WasmTableType {
   uint8_t ElemType;
   WasmLimits Limits;
 };
 
+struct WasmTable {
+  uint32_t Index;
+  WasmTableType Type;
+  StringRef SymbolName; // from the "linking" section
+};
+
 struct WasmInitExpr {
   uint8_t Opcode;
   union {
@@ -115,7 +120,7 @@ struct WasmImport {
   union {
 uint32_t SigIndex;
 WasmGlobalType Global;
-WasmTable Table;
+WasmTableType Table;
 WasmLimits Memory;
 WasmEventType Event;
   };

diff  --git a/llvm/lib/MC/WasmObjectWriter.cpp 
b/llvm/lib/MC/WasmObjectWriter.cpp
index 0cf6e310ae32..029b776fd774 100644
--- a/llvm/lib/MC/WasmObjectWriter.cpp
+++ b/llvm/lib/MC/WasmObjectWriter.cpp
@@ -848,11 +848,11 @@ void 
WasmObjectWriter::writeTableSection(ArrayRef Tables) {
 
   encodeULEB128(Tables.size(), W->OS);
   for (const wasm::WasmTable &Table : Tables) {
-encodeULEB128(Table.ElemType, W->OS);
-encodeULEB128(Table.Limits.Flags, W->OS);
-encodeULEB128(Table.Limits.Initial, W->OS);
-if (Table.Limits.Flags & wasm::WASM_LIMITS_FLAG_HAS_MAX)
-  encodeULEB128(Table.Limits.Maximum, W->OS);
+encodeULEB128(Table.Type.ElemType, W->OS);
+encodeULEB128(Table.Type.Limits.Flags, W->OS);
+encodeULEB128(Table.Type.Limits.Initial, W->OS);
+if (Table.Type.Limits.Flags & wasm::WASM_LIMITS_FLAG_HAS_MAX)
+  encodeULEB128(Table.Type.Limits.Maximum, W->OS);
   }
   endSection(Section);
 }
@@ -1527,10 +1527,10 @@ uint64_t WasmObjectWriter::writeOneObject(MCAssembler 
&Asm,
   if (WS.isDefined()) {
 assert(WasmIndices.count(&WS) == 0);
 wasm::WasmTable Table;
-Table.ElemType = static_cast(WS.getTableType());
 Table.Index = NumTableImports + Tables.size();
+Table.Type.ElemType = static_cast(WS.getTableType());
 // FIXME: Work on custom limits is ongoing
-Table.Limits = {wasm::WASM_LIMITS_FLAG_NONE, 0, 0};
+Table.Type.Limits = {wasm::WASM_LIMITS_FLAG_NONE, 0, 0};
 
 WasmIndices[&WS] = Table.Index;
 Tables.push_back(Table);

diff  --git a/llvm/lib/Object/WasmObjectFile.cpp 

[llvm-branch-commits] [llvm] a8d7451 - [PassManager] Run Induction Variable Simplification pass *after* Recognize loop idioms pass, not before

2020-11-25 Thread Roman Lebedev via llvm-branch-commits

Author: Roman Lebedev
Date: 2020-11-25T19:20:07+03:00
New Revision: a8d74517dcff42d3300aa144820b2772c1560a96

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

LOG: [PassManager] Run Induction Variable Simplification pass *after* Recognize 
loop idioms pass, not before

Currently, `-indvars` runs first, and then immediately after `-loop-idiom` does.
I'm not really sure if `-loop-idiom` requires `-indvars` to run beforehand,
but i'm *very* sure that `-indvars` requires `-loop-idiom` to run afterwards,
as it can be seen in the phase-ordering test.

LoopIdiom runs on two types of loops: countable ones, and uncountable ones.
For uncountable ones, IndVars obviously didn't make any change to them,
since they are uncountable, so for them the order should be irrelevant.
For countable ones, well, they should have been countable before IndVars
for IndVars to make any change to them, and since SCEV is used on them,
it shouldn't matter if IndVars have already canonicalized them.
So i don't really see why we'd want the current ordering.

Should this cause issues, it will give us a reproducer test case
that shows flaws in this logic, and we then could adjust accordingly.

While this is quite likely beneficial in-the-wild already,
it's a required part for the full motivational pattern
behind `left-shift-until-bittest` loop idiom (D91038).

Reviewed By: dmgreen

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

Added: 


Modified: 
llvm/lib/Passes/PassBuilder.cpp
llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
llvm/test/CodeGen/AMDGPU/opt-pipeline.ll
llvm/test/Other/new-pm-defaults.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/Other/opt-O2-pipeline.ll
llvm/test/Other/opt-O3-pipeline-enable-matrix.ll
llvm/test/Other/opt-O3-pipeline.ll
llvm/test/Other/opt-Os-pipeline.ll
llvm/test/Transforms/PhaseOrdering/ARM/arm_fill_q7.ll
llvm/test/Transforms/PhaseOrdering/X86/loop-idiom-vs-indvars.ll

Removed: 




diff  --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp
index af3eae47d242..2a9b0c1e4f6b 100644
--- a/llvm/lib/Passes/PassBuilder.cpp
+++ b/llvm/lib/Passes/PassBuilder.cpp
@@ -521,8 +521,8 @@ 
PassBuilder::buildO1FunctionSimplificationPipeline(OptimizationLevel Level,
 
   if (EnableLoopFlatten)
 FPM.addPass(LoopFlattenPass());
-  LPM2.addPass(IndVarSimplifyPass());
   LPM2.addPass(LoopIdiomRecognizePass());
+  LPM2.addPass(IndVarSimplifyPass());
 
   for (auto &C : LateLoopOptimizationsEPCallbacks)
 C(LPM2, Level);
@@ -682,8 +682,8 @@ 
PassBuilder::buildFunctionSimplificationPipeline(OptimizationLevel Level,
   // TODO: Investigate promotion cap for O1.
   LPM1.addPass(LICMPass(PTO.LicmMssaOptCap, PTO.LicmMssaNoAccForPromotionCap));
   LPM1.addPass(SimpleLoopUnswitchPass());
-  LPM2.addPass(IndVarSimplifyPass());
   LPM2.addPass(LoopIdiomRecognizePass());
+  LPM2.addPass(IndVarSimplifyPass());
 
   for (auto &C : LateLoopOptimizationsEPCallbacks)
 C(LPM2, Level);
@@ -712,7 +712,7 @@ 
PassBuilder::buildFunctionSimplificationPipeline(OptimizationLevel Level,
   DebugLogging));
   FPM.addPass(SimplifyCFGPass());
   FPM.addPass(InstCombinePass());
-  // The loop passes in LPM2 (IndVarSimplifyPass, LoopIdiomRecognizePass,
+  // The loop passes in LPM2 (LoopIdiomRecognizePass, IndVarSimplifyPass,
   // LoopDeletionPass and LoopFullUnrollPass) do not preserve MemorySSA.
   // *All* loop passes must preserve it, in order to be able to use it.
   FPM.addPass(createFunctionToLoopPassAdaptor(

diff  --git a/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp 
b/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
index f05fc36c182a..e03015f8b0aa 100644
--- a/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
+++ b/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
@@ -445,8 +445,8 @@ void PassManagerBuilder::addFunctionSimplificationPasses(
 MPM.add(createLoopFlattenPass()); // Flatten loops
 MPM.add(createLoopSimplifyCFGPass());
   }
-  MPM.add(createIndVarSimplifyPass());// Canonicalize indvars
   MPM.add(createLoopIdiomPass()); // Recognize idioms like memset.
+  MPM.add(createIndVarSimplifyPass());// Canonicalize indvars
   addExtensionsToPM(EP_LateLoopOptimizations, MPM);
   MPM.add(createLoopDeletionPass());  // Delete dead loops
 

diff  --git a/llvm/test/CodeGen/AMDGPU/opt-pipeline.ll 
b/llvm/test/CodeGen/AMDGPU/opt-pipeline.ll
index 55461ea5b66e..2184a80b6782 100644
--- a/llvm/test/CodeGen/AMDGPU/opt-pipeline.ll
+++ b/llvm/test/CodeGen/AM

[llvm-branch-commits] [llvm] feac819 - [MC][WebAssembly] Only emit indirect function table import if needed

2020-11-25 Thread Sam Clegg via llvm-branch-commits

Author: Andy Wingo
Date: 2020-11-25T08:38:43-08:00
New Revision: feac819e50b2b62eeafdf1a7e6ecaa725d7bf08d

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

LOG: [MC][WebAssembly] Only emit indirect function table import if needed

The indirect function table, synthesized by the linker, is needed if and
only if there are TABLE_INDEX relocs.

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

Added: 


Modified: 
llvm/include/llvm/MC/MCSymbolWasm.h
llvm/include/llvm/Object/Wasm.h
llvm/lib/MC/WasmObjectWriter.cpp
llvm/lib/Object/WasmObjectFile.cpp
llvm/test/MC/WebAssembly/assembler-binary.ll
llvm/test/MC/WebAssembly/comdat.ll
llvm/test/MC/WebAssembly/custom-sections.ll
llvm/test/MC/WebAssembly/data-section.s
llvm/test/MC/WebAssembly/event-section.ll
llvm/test/MC/WebAssembly/external-func-address.ll
llvm/test/MC/WebAssembly/global-ctor-dtor.ll
llvm/test/MC/WebAssembly/reloc-pic.s
llvm/test/MC/WebAssembly/tables.s
llvm/test/MC/WebAssembly/type-index.s
llvm/test/MC/WebAssembly/wasm64.s

Removed: 




diff  --git a/llvm/include/llvm/MC/MCSymbolWasm.h 
b/llvm/include/llvm/MC/MCSymbolWasm.h
index 52ff9f933f92..ae512fd27be2 100644
--- a/llvm/include/llvm/MC/MCSymbolWasm.h
+++ b/llvm/include/llvm/MC/MCSymbolWasm.h
@@ -96,6 +96,15 @@ class MCSymbolWasm : public MCSymbol {
   StringRef getExportName() const { return ExportName.getValue(); }
   void setExportName(StringRef Name) { ExportName = Name; }
 
+  bool isFunctionTable() const {
+return isTable() && hasTableType() &&
+   getTableType() == wasm::ValType::FUNCREF;
+  }
+  void setFunctionTable() {
+setType(wasm::WASM_SYMBOL_TYPE_TABLE);
+setTableType(wasm::ValType::FUNCREF);
+  }
+
   void setUsedInGOT() const { IsUsedInGOT = true; }
   bool isUsedInGOT() const { return IsUsedInGOT; }
 
@@ -111,8 +120,9 @@ class MCSymbolWasm : public MCSymbol {
   }
   void setGlobalType(wasm::WasmGlobalType GT) { GlobalType = GT; }
 
-  const wasm::ValType &getTableType() const {
-assert(TableType.hasValue());
+  bool hasTableType() const { return TableType.hasValue(); }
+  wasm::ValType getTableType() const {
+assert(hasTableType());
 return TableType.getValue();
   }
   void setTableType(wasm::ValType TT) { TableType = TT; }

diff  --git a/llvm/include/llvm/Object/Wasm.h b/llvm/include/llvm/Object/Wasm.h
index 72e4403a45cb..e5091f5a8552 100644
--- a/llvm/include/llvm/Object/Wasm.h
+++ b/llvm/include/llvm/Object/Wasm.h
@@ -299,6 +299,7 @@ class WasmObjectFile : public ObjectFile {
   uint32_t DataSection = 0;
   uint32_t EventSection = 0;
   uint32_t GlobalSection = 0;
+  uint32_t TableSection = 0;
 };
 
 class WasmSectionOrderChecker {

diff  --git a/llvm/lib/MC/WasmObjectWriter.cpp 
b/llvm/lib/MC/WasmObjectWriter.cpp
index 029b776fd774..a05d4c993089 100644
--- a/llvm/lib/MC/WasmObjectWriter.cpp
+++ b/llvm/lib/MC/WasmObjectWriter.cpp
@@ -40,8 +40,8 @@ using namespace llvm;
 
 namespace {
 
-// Went we ceate the indirect function table we start at 1, so that there is
-// and emtpy slot at 0 and therefore calling a null function pointer will trap.
+// When we create the indirect function table we start at 1, so that there is
+// and empty slot at 0 and therefore calling a null function pointer will trap.
 static const uint32_t InitialTableOffset = 1;
 
 // For patching purposes, we need to remember where each section starts, both
@@ -218,9 +218,7 @@ class WasmObjectWriter : public MCObjectWriter {
   SmallVector DataSegments;
   unsigned NumFunctionImports = 0;
   unsigned NumGlobalImports = 0;
-  // NumTableImports is initialized to 1 to account for the hardcoded import of
-  // __indirect_function_table
-  unsigned NumTableImports = 1;
+  unsigned NumTableImports = 0;
   unsigned NumEventImports = 0;
   uint32_t SectionCount = 0;
 
@@ -270,7 +268,7 @@ class WasmObjectWriter : public MCObjectWriter {
 SectionFunctions.clear();
 NumFunctionImports = 0;
 NumGlobalImports = 0;
-NumTableImports = 1;
+NumTableImports = 0;
 MCObjectWriter::reset();
   }
 
@@ -497,6 +495,29 @@ void WasmObjectWriter::recordRelocation(MCAssembler &Asm,
 SymA = cast(SectionSymbol);
   }
 
+  if (Type == wasm::R_WASM_TABLE_INDEX_REL_SLEB ||
+  Type == wasm::R_WASM_TABLE_INDEX_SLEB ||
+  Type == wasm::R_WASM_TABLE_INDEX_SLEB64 ||
+  Type == wasm::R_WASM_TABLE_INDEX_I32 ||
+  Type == wasm::R_WASM_TABLE_INDEX_I64) {
+// TABLE_INDEX relocs implicitly use the default indirect function table.
+auto TableName = "__indirect_function_table";
+MCSymbolWasm *Sym = 
cast_or_null(Ctx.lookupSymbol(TableName));
+if (Sym) {
+  if (!Sym->isFunctionTable())
+Ctx.reportError(
+Fixup.getLoc(),
+"symbol '__indire

[llvm-branch-commits] [llvm] ba74fa2 - [AMDGPU] Actually fully update opt-pipeline.ll test to account for -loop-idiom vs -indvars switch

2020-11-25 Thread Roman Lebedev via llvm-branch-commits

Author: Roman Lebedev
Date: 2020-11-25T19:39:32+03:00
New Revision: ba74fa244f4ca1b7ec187271fc145a968890441f

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

LOG: [AMDGPU] Actually fully update opt-pipeline.ll test to account for 
-loop-idiom vs -indvars switch

Added: 


Modified: 
llvm/test/CodeGen/AMDGPU/opt-pipeline.ll

Removed: 




diff  --git a/llvm/test/CodeGen/AMDGPU/opt-pipeline.ll 
b/llvm/test/CodeGen/AMDGPU/opt-pipeline.ll
index 2184a80b6782..8a8ce1e0c185 100644
--- a/llvm/test/CodeGen/AMDGPU/opt-pipeline.ll
+++ b/llvm/test/CodeGen/AMDGPU/opt-pipeline.ll
@@ -487,8 +487,8 @@
 ; GCN-O2-NEXT:   Loop-Closed SSA Form Pass
 ; GCN-O2-NEXT:   Scalar Evolution Analysis
 ; GCN-O2-NEXT:   Loop Pass Manager
-; GCN-O2-NEXT: Induction Variable Simplification
 ; GCN-O2-NEXT: Recognize loop idioms
+; GCN-O2-NEXT: Induction Variable Simplification
 ; GCN-O2-NEXT: Delete dead loops
 ; GCN-O2-NEXT: Unroll loops
 ; GCN-O2-NEXT:   SROA
@@ -851,8 +851,8 @@
 ; GCN-O3-NEXT:   Loop-Closed SSA Form Pass
 ; GCN-O3-NEXT:   Scalar Evolution Analysis
 ; GCN-O3-NEXT:   Loop Pass Manager
-; GCN-O3-NEXT: Induction Variable Simplification
 ; GCN-O3-NEXT: Recognize loop idioms
+; GCN-O3-NEXT: Induction Variable Simplification
 ; GCN-O3-NEXT: Delete dead loops
 ; GCN-O3-NEXT: Unroll loops
 ; GCN-O3-NEXT:   SROA



___
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] 572d183 - [ELF] Add TargetInfo::adjustGotPcExpr for `R_GOT_PC` relaxations. NFC

2020-11-25 Thread Fangrui Song via llvm-branch-commits

Author: Fangrui Song
Date: 2020-11-25T08:43:26-08:00
New Revision: 572d18397cf0d8808ec85f9bd51471cd80266c27

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

LOG: [ELF] Add TargetInfo::adjustGotPcExpr for `R_GOT_PC` relaxations. NFC

With this change, `TargetInfo::adjustRelaxExpr` is only related to TLS
relaxations and a subsequent clean-up can delete the `data` parameter.

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

Added: 


Modified: 
lld/ELF/Arch/PPC64.cpp
lld/ELF/Arch/X86_64.cpp
lld/ELF/Relocations.cpp
lld/ELF/Target.cpp
lld/ELF/Target.h

Removed: 




diff  --git a/lld/ELF/Arch/PPC64.cpp b/lld/ELF/Arch/PPC64.cpp
index 8a3de2b3cbb2..a18cf9591125 100644
--- a/lld/ELF/Arch/PPC64.cpp
+++ b/lld/ELF/Arch/PPC64.cpp
@@ -384,6 +384,8 @@ class PPC64 final : public TargetInfo {
   bool inBranchRange(RelType type, uint64_t src, uint64_t dst) const override;
   RelExpr adjustRelaxExpr(RelType type, const uint8_t *data,
   RelExpr expr) const override;
+  RelExpr adjustGotPcExpr(RelType type, int64_t addend,
+  const uint8_t *loc) const override;
   void relaxGot(uint8_t *loc, const Relocation &rel,
 uint64_t val) const override;
   void relaxTlsGdToIe(uint8_t *loc, const Relocation &rel,
@@ -1392,20 +1394,23 @@ bool PPC64::inBranchRange(RelType type, uint64_t src, 
uint64_t dst) const {
 
 RelExpr PPC64::adjustRelaxExpr(RelType type, const uint8_t *data,
RelExpr expr) const {
+  if (type != R_PPC64_GOT_TLSGD_PCREL34 && expr == R_RELAX_TLS_GD_TO_IE)
+return R_RELAX_TLS_GD_TO_IE_GOT_OFF;
+  if (expr == R_RELAX_TLS_LD_TO_LE)
+return R_RELAX_TLS_LD_TO_LE_ABS;
+  return expr;
+}
+
+RelExpr PPC64::adjustGotPcExpr(RelType type, int64_t addend,
+   const uint8_t *loc) const {
   if ((type == R_PPC64_GOT_PCREL34 || type == R_PPC64_PCREL_OPT) &&
   config->pcRelOptimize) {
 // It only makes sense to optimize pld since paddi means that the address
 // of the object in the GOT is required rather than the object itself.
-assert(data && "Expecting an instruction encoding here");
-if ((readPrefixedInstruction(data) & 0xfc00) == 0xe400)
+if ((readPrefixedInstruction(loc) & 0xfc00) == 0xe400)
   return R_PPC64_RELAX_GOT_PC;
   }
-
-  if (type != R_PPC64_GOT_TLSGD_PCREL34 && expr == R_RELAX_TLS_GD_TO_IE)
-return R_RELAX_TLS_GD_TO_IE_GOT_OFF;
-  if (expr == R_RELAX_TLS_LD_TO_LE)
-return R_RELAX_TLS_LD_TO_LE_ABS;
-  return expr;
+  return R_GOT_PC;
 }
 
 // Reference: 3.7.4.1 of the 64-bit ELF V2 abi supplement.

diff  --git a/lld/ELF/Arch/X86_64.cpp b/lld/ELF/Arch/X86_64.cpp
index 93fd8ecb7c8e..618922844238 100644
--- a/lld/ELF/Arch/X86_64.cpp
+++ b/lld/ELF/Arch/X86_64.cpp
@@ -40,8 +40,8 @@ class X86_64 : public TargetInfo {
   void applyJumpInstrMod(uint8_t *loc, JumpModType type,
  unsigned size) const override;
 
-  RelExpr adjustRelaxExpr(RelType type, const uint8_t *data,
-  RelExpr expr) const override;
+  RelExpr adjustGotPcExpr(RelType type, int64_t addend,
+  const uint8_t *loc) const override;
   void relaxGot(uint8_t *loc, const Relocation &rel,
 uint64_t val) const override;
   void relaxTlsGdToIe(uint8_t *loc, const Relocation &rel,
@@ -728,12 +728,12 @@ void X86_64::relocate(uint8_t *loc, const Relocation 
&rel, uint64_t val) const {
   }
 }
 
-RelExpr X86_64::adjustRelaxExpr(RelType type, const uint8_t *data,
-RelExpr relExpr) const {
+RelExpr X86_64::adjustGotPcExpr(RelType type, int64_t addend,
+const uint8_t *loc) const {
   if (type != R_X86_64_GOTPCRELX && type != R_X86_64_REX_GOTPCRELX)
-return relExpr;
-  const uint8_t op = data[-2];
-  const uint8_t modRm = data[-1];
+return R_GOT_PC;
+  const uint8_t op = loc[-2];
+  const uint8_t modRm = loc[-1];
 
   // FIXME: When PIC is disabled and foo is defined locally in the
   // lower 32 bit address space, memory operand in mov can be converted into
@@ -748,11 +748,11 @@ RelExpr X86_64::adjustRelaxExpr(RelType type, const 
uint8_t *data,
 
   // We don't support test/binop instructions without a REX prefix.
   if (type == R_X86_64_GOTPCRELX)
-return relExpr;
+return R_GOT_PC;
 
   // Relaxation of test, adc, add, and, cmp, or, sbb, sub, xor.
   // If PIC then no relaxation is available.
-  return config->isPic ? relExpr : R_RELAX_GOT_PC_NOPIC;
+  return config->isPic ? R_GOT_PC : R_RELAX_GOT_PC_NOPIC;
 }
 
 // A subset of relaxations can only be applied for no-PIC. This method

diff  --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp
index abb21f1d7274..115

[llvm-branch-commits] [llvm] 06654a5 - [SVE] Fix TypeSize warning in RuntimePointerChecking::insert

2020-11-25 Thread Joe Ellis via llvm-branch-commits

Author: Joe Ellis
Date: 2020-11-25T16:59:03Z
New Revision: 06654a5348bfc510208514a30c552f4f2c4c0ee7

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

LOG: [SVE] Fix TypeSize warning in RuntimePointerChecking::insert

The TypeSize warning would occur because RuntimePointerChecking::insert
was not scalable vector aware. The fix is to use
ScalarEvolution::getSizeOfExpr to grab the size of types.

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

Added: 
llvm/test/Analysis/LoopAccessAnalysis/memcheck-store-vs-alloc-size.ll

llvm/test/Analysis/LoopAccessAnalysis/runtime-pointer-checking-insert-typesize.ll

Modified: 
llvm/include/llvm/Analysis/ScalarEvolution.h
llvm/lib/Analysis/LoopAccessAnalysis.cpp
llvm/lib/Analysis/ScalarEvolution.cpp

Removed: 




diff  --git a/llvm/include/llvm/Analysis/ScalarEvolution.h 
b/llvm/include/llvm/Analysis/ScalarEvolution.h
index 9c19ec986444..a7a24f086fbe 100644
--- a/llvm/include/llvm/Analysis/ScalarEvolution.h
+++ b/llvm/include/llvm/Analysis/ScalarEvolution.h
@@ -600,9 +600,17 @@ class ScalarEvolution {
 return getConstant(Ty, -1, /*isSigned=*/true);
   }
 
-  /// Return an expression for sizeof AllocTy that is type IntTy
+  /// Return an expression for sizeof ScalableTy that is type IntTy, where
+  /// ScalableTy is a scalable vector type.
+  const SCEV *getSizeOfScalableVectorExpr(Type *IntTy,
+  ScalableVectorType *ScalableTy);
+
+  /// Return an expression for the alloc size of AllocTy that is type IntTy
   const SCEV *getSizeOfExpr(Type *IntTy, Type *AllocTy);
 
+  /// Return an expression for the store size of StoreTy that is type IntTy
+  const SCEV *getStoreSizeOfExpr(Type *IntTy, Type *StoreTy);
+
   /// Return an expression for offsetof on the given field with type IntTy
   const SCEV *getOffsetOfExpr(Type *IntTy, StructType *STy, unsigned FieldNo);
 

diff  --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp 
b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
index 19a8ea23b70b..d37c07801b2e 100644
--- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp
+++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
@@ -224,9 +224,9 @@ void RuntimePointerChecking::insert(Loop *Lp, Value *Ptr, 
bool WritePtr,
 }
 // Add the size of the pointed element to ScEnd.
 auto &DL = Lp->getHeader()->getModule()->getDataLayout();
-unsigned EltSize =
-DL.getTypeStoreSizeInBits(Ptr->getType()->getPointerElementType()) / 8;
-const SCEV *EltSizeSCEV = SE->getConstant(ScEnd->getType(), EltSize);
+Type *IdxTy = DL.getIndexType(Ptr->getType());
+const SCEV *EltSizeSCEV =
+SE->getStoreSizeOfExpr(IdxTy, Ptr->getType()->getPointerElementType());
 ScEnd = SE->getAddExpr(ScEnd, EltSizeSCEV);
   }
 

diff  --git a/llvm/lib/Analysis/ScalarEvolution.cpp 
b/llvm/lib/Analysis/ScalarEvolution.cpp
index 5f77f4aa05c2..5a7f1b94a4e8 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -3660,28 +3660,42 @@ const SCEV 
*ScalarEvolution::getUMinExpr(SmallVectorImpl &Ops) {
   return getMinMaxExpr(scUMinExpr, Ops);
 }
 
+const SCEV *
+ScalarEvolution::getSizeOfScalableVectorExpr(Type *IntTy,
+ ScalableVectorType *ScalableTy) {
+  Constant *NullPtr = Constant::getNullValue(ScalableTy->getPointerTo());
+  Constant *One = ConstantInt::get(IntTy, 1);
+  Constant *GEP = ConstantExpr::getGetElementPtr(ScalableTy, NullPtr, One);
+  // Note that the expression we created is the final expression, we don't
+  // want to simplify it any further Also, if we call a normal getSCEV(),
+  // we'll end up in an endless recursion. So just create an SCEVUnknown.
+  return getUnknown(ConstantExpr::getPtrToInt(GEP, IntTy));
+}
+
 const SCEV *ScalarEvolution::getSizeOfExpr(Type *IntTy, Type *AllocTy) {
-  if (isa(AllocTy)) {
-Constant *NullPtr = Constant::getNullValue(AllocTy->getPointerTo());
-Constant *One = ConstantInt::get(IntTy, 1);
-Constant *GEP = ConstantExpr::getGetElementPtr(AllocTy, NullPtr, One);
-// Note that the expression we created is the final expression, we don't
-// want to simplify it any further Also, if we call a normal getSCEV(),
-// we'll end up in an endless recursion. So just create an SCEVUnknown.
-return getUnknown(ConstantExpr::getPtrToInt(GEP, IntTy));
-  }
-  // We can bypass creating a target-independent
-  // constant expression and then folding it back into a ConstantInt.
-  // This is just a compile-time optimization.
+  if (auto *ScalableAllocTy = dyn_cast(AllocTy))
+return getSizeOfScalableVectorExpr(IntTy, ScalableAllocTy);
+  // We can bypass creating a target-independent constant expression and then
+  // folding it back into a ConstantInt. This is just a compile

[llvm-branch-commits] [lld] 50564ca - [ELF] Rename adjustRelaxExpr to adjustTlsExpr and delete the unused `data` parameter. NFC

2020-11-25 Thread Fangrui Song via llvm-branch-commits

Author: Fangrui Song
Date: 2020-11-25T09:00:55-08:00
New Revision: 50564ca075431f65c64abb97c01596c964a4cda0

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

LOG: [ELF] Rename adjustRelaxExpr to adjustTlsExpr and delete the unused `data` 
parameter. NFC

Reviewed By: psmith

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

Added: 


Modified: 
lld/ELF/Arch/AArch64.cpp
lld/ELF/Arch/PPC.cpp
lld/ELF/Arch/PPC64.cpp
lld/ELF/Arch/X86.cpp
lld/ELF/Relocations.cpp
lld/ELF/Target.cpp
lld/ELF/Target.h

Removed: 




diff  --git a/lld/ELF/Arch/AArch64.cpp b/lld/ELF/Arch/AArch64.cpp
index 637046e90bbd..e61251903059 100644
--- a/lld/ELF/Arch/AArch64.cpp
+++ b/lld/ELF/Arch/AArch64.cpp
@@ -46,8 +46,7 @@ class AArch64 : public TargetInfo {
   bool usesOnlyLowPageBits(RelType type) const override;
   void relocate(uint8_t *loc, const Relocation &rel,
 uint64_t val) const override;
-  RelExpr adjustRelaxExpr(RelType type, const uint8_t *data,
-  RelExpr expr) const override;
+  RelExpr adjustTlsExpr(RelType type, RelExpr expr) const override;
   void relaxTlsGdToLe(uint8_t *loc, const Relocation &rel,
   uint64_t val) const override;
   void relaxTlsGdToIe(uint8_t *loc, const Relocation &rel,
@@ -159,8 +158,7 @@ RelExpr AArch64::getRelExpr(RelType type, const Symbol &s,
   }
 }
 
-RelExpr AArch64::adjustRelaxExpr(RelType type, const uint8_t *data,
- RelExpr expr) const {
+RelExpr AArch64::adjustTlsExpr(RelType type, RelExpr expr) const {
   if (expr == R_RELAX_TLS_GD_TO_IE) {
 if (type == R_AARCH64_TLSDESC_ADR_PAGE21)
   return R_AARCH64_RELAX_TLS_GD_TO_IE_PAGE_PC;

diff  --git a/lld/ELF/Arch/PPC.cpp b/lld/ELF/Arch/PPC.cpp
index a004cf74ddd8..88a1b2143b8e 100644
--- a/lld/ELF/Arch/PPC.cpp
+++ b/lld/ELF/Arch/PPC.cpp
@@ -45,8 +45,7 @@ class PPC final : public TargetInfo {
   bool inBranchRange(RelType type, uint64_t src, uint64_t dst) const override;
   void relocate(uint8_t *loc, const Relocation &rel,
 uint64_t val) const override;
-  RelExpr adjustRelaxExpr(RelType type, const uint8_t *data,
-  RelExpr expr) const override;
+  RelExpr adjustTlsExpr(RelType type, RelExpr expr) const override;
   int getTlsGdRelaxSkip(RelType type) const override;
   void relaxTlsGdToIe(uint8_t *loc, const Relocation &rel,
   uint64_t val) const override;
@@ -360,8 +359,7 @@ void PPC::relocate(uint8_t *loc, const Relocation &rel, 
uint64_t val) const {
   }
 }
 
-RelExpr PPC::adjustRelaxExpr(RelType type, const uint8_t *data,
- RelExpr expr) const {
+RelExpr PPC::adjustTlsExpr(RelType type, RelExpr expr) const {
   if (expr == R_RELAX_TLS_GD_TO_IE)
 return R_RELAX_TLS_GD_TO_IE_GOT_OFF;
   if (expr == R_RELAX_TLS_LD_TO_LE)

diff  --git a/lld/ELF/Arch/PPC64.cpp b/lld/ELF/Arch/PPC64.cpp
index a18cf9591125..65652b1c471f 100644
--- a/lld/ELF/Arch/PPC64.cpp
+++ b/lld/ELF/Arch/PPC64.cpp
@@ -382,8 +382,7 @@ class PPC64 final : public TargetInfo {
   int64_t a) const override;
   uint32_t getThunkSectionSpacing() const override;
   bool inBranchRange(RelType type, uint64_t src, uint64_t dst) const override;
-  RelExpr adjustRelaxExpr(RelType type, const uint8_t *data,
-  RelExpr expr) const override;
+  RelExpr adjustTlsExpr(RelType type, RelExpr expr) const override;
   RelExpr adjustGotPcExpr(RelType type, int64_t addend,
   const uint8_t *loc) const override;
   void relaxGot(uint8_t *loc, const Relocation &rel,
@@ -1392,8 +1391,7 @@ bool PPC64::inBranchRange(RelType type, uint64_t src, 
uint64_t dst) const {
   llvm_unreachable("unsupported relocation type used in branch");
 }
 
-RelExpr PPC64::adjustRelaxExpr(RelType type, const uint8_t *data,
-   RelExpr expr) const {
+RelExpr PPC64::adjustTlsExpr(RelType type, RelExpr expr) const {
   if (type != R_PPC64_GOT_TLSGD_PCREL34 && expr == R_RELAX_TLS_GD_TO_IE)
 return R_RELAX_TLS_GD_TO_IE_GOT_OFF;
   if (expr == R_RELAX_TLS_LD_TO_LE)

diff  --git a/lld/ELF/Arch/X86.cpp b/lld/ELF/Arch/X86.cpp
index 8c8824d53cce..1e10bd3e685a 100644
--- a/lld/ELF/Arch/X86.cpp
+++ b/lld/ELF/Arch/X86.cpp
@@ -37,8 +37,7 @@ class X86 : public TargetInfo {
   void relocate(uint8_t *loc, const Relocation &rel,
 uint64_t val) const override;
 
-  RelExpr adjustRelaxExpr(RelType type, const uint8_t *data,
-  RelExpr expr) const override;
+  RelExpr adjustTlsExpr(RelType type, RelExpr expr) const override;
   void relaxTlsGdToIe(uint8_t *loc, const Relocation &rel,
   uint64_t val) const override;
   void relaxTlsGdToLe(uint8_t

[llvm-branch-commits] [clang] dc96cc3 - [clang][test] Fix prefix operator++ signature in iterators

2020-11-25 Thread Endre Fülöp via llvm-branch-commits

Author: Endre Fülöp
Date: 2020-11-25T18:05:11+01:00
New Revision: dc96cc33c13e1e38382118c25bf26de480eb2b12

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

LOG: [clang][test] Fix prefix operator++ signature in iterators

Prefix operator++ should return the iterator incremented by reference.

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

Added: 


Modified: 
clang/test/Analysis/Inputs/system-header-simulator-cxx.h

Removed: 




diff  --git a/clang/test/Analysis/Inputs/system-header-simulator-cxx.h 
b/clang/test/Analysis/Inputs/system-header-simulator-cxx.h
index f2b148cbc692..87984d02c2f6 100644
--- a/clang/test/Analysis/Inputs/system-header-simulator-cxx.h
+++ b/clang/test/Analysis/Inputs/system-header-simulator-cxx.h
@@ -46,7 +46,7 @@ template  struct 
__vector_iterator {
 
   __vector_iterator(const Ptr p = 0) : ptr(p) {}
   __vector_iterator(const iterator &rhs): ptr(rhs.base()) {}
-  __vector_iterator operator++() { ++ ptr; return *this; }
+  __vector_iterator& operator++() { ++ ptr; return *this; }
   __vector_iterator operator++(int) {
 auto tmp = *this;
 ++ ptr;
@@ -109,7 +109,7 @@ template  struct 
__deque_iterator {
 
   __deque_iterator(const Ptr p = 0) : ptr(p) {}
   __deque_iterator(const iterator &rhs): ptr(rhs.base()) {}
-  __deque_iterator operator++() { ++ ptr; return *this; }
+  __deque_iterator& operator++() { ++ ptr; return *this; }
   __deque_iterator operator++(int) {
 auto tmp = *this;
 ++ ptr;
@@ -169,7 +169,7 @@ template  struct 
__list_iterator {
 
   __list_iterator(T* it = 0) : item(it) {}
   __list_iterator(const iterator &rhs): item(rhs.item) {}
-  __list_iterator operator++() { item = item->next; return *this; 
}
+  __list_iterator& operator++() { item = item->next; return 
*this; }
   __list_iterator operator++(int) {
 auto tmp = *this;
 item = item->next;
@@ -212,7 +212,7 @@ template  struct 
__fwdl_iterator {
 
   __fwdl_iterator(T* it = 0) : item(it) {}
   __fwdl_iterator(const iterator &rhs): item(rhs.item) {}
-  __fwdl_iterator operator++() { item = item->next; return *this; 
}
+  __fwdl_iterator& operator++() { item = item->next; return 
*this; }
   __fwdl_iterator operator++(int) {
 auto tmp = *this;
 item = item->next;
@@ -1079,7 +1079,7 @@ template<
 class iterator {
 public:
   iterator(Key *key): ptr(key) {}
-  iterator operator++() { ++ptr; return *this; }
+  iterator& operator++() { ++ptr; return *this; }
   bool operator!=(const iterator &other) const { return ptr != other.ptr; }
   const Key &operator*() const { return *ptr; }
 private:
@@ -1104,7 +1104,7 @@ template<
 class iterator {
 public:
   iterator(Key *key): ptr(key) {}
-  iterator operator++() { ++ptr; return *this; }
+  iterator& operator++() { ++ptr; return *this; }
   bool operator!=(const iterator &other) const { return ptr != other.ptr; }
   const Key &operator*() const { return *ptr; }
 private:



___
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] 9595a7f - [gn build] Download prebuilt mac-arm64 binary now that it exists

2020-11-25 Thread Nico Weber via llvm-branch-commits

Author: Nico Weber
Date: 2020-11-25T12:08:48-05:00
New Revision: 9595a7ff55b6f3bf316ae182390fc74da65dda51

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

LOG: [gn build] Download prebuilt mac-arm64 binary now that it exists

Sadly requires an ugly workaround for an ugly bug, but still nicer than
building locally.

Added: 


Modified: 
llvm/utils/gn/get.py

Removed: 




diff  --git a/llvm/utils/gn/get.py b/llvm/utils/gn/get.py
index f778ab931bba..bb185c187783 100755
--- a/llvm/utils/gn/get.py
+++ b/llvm/utils/gn/get.py
@@ -47,21 +47,15 @@ def main():
 if not platform:
 print('no prebuilt binary for', sys.platform)
 return 1
-if platform == 'mac-arm64':
-print('no prebuilt mac-arm64 binaries yet. build it yourself with:')
-print('  rm -rf /tmp/gn &&')
-print('  pushd /tmp && git clone https://gn.googlesource.com/gn &&')
-print('  cd gn && build/gen.py && ninja -C out gn && popd &&')
-print('  mkdir -p llvm/utils/gn/bin/mac-arm64 &&')
-print('  cp /tmp/gn/out/gn llvm/utils/gn/bin/mac-arm64')
-return 1
-
 dirname = os.path.join(os.path.dirname(__file__), 'bin', platform)
 if not os.path.exists(dirname):
 os.makedirs(dirname)
 
 url = 'https://chrome-infra-packages.appspot.com/dl/gn/gn/%s/+/latest'
 gn = 'gn' + ('.exe' if sys.platform == 'win32' else '')
+if platform == 'mac-arm64': # For https://openradar.appspot.com/FB8914243
+try: os.remove(os.path.join(dirname, gn))
+except OSError: pass
 download_and_unpack(url % platform, dirname, gn)
 set_executable_bit(os.path.join(dirname, gn))
 



___
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] [openmp] b281a05 - [OpenMP][OMPT] Implement verbose tool loading

2020-11-25 Thread Joachim Protze via llvm-branch-commits

Author: Isabel Thärigen
Date: 2020-11-25T18:17:44+01:00
New Revision: b281a05dacb485d3c3c9cc7f7f5e8fb858ac67bc

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

LOG: [OpenMP][OMPT] Implement verbose tool loading

OpenMP 5.1 introduces the new env variable
OMP_TOOL_VERBOSE_INIT=(disabled|stdout|stderr|) to enable verbose
loading and initialization of OMPT tools.
This env variable helps to understand the cause when loading of a tool fails
(e.g., undefined symbols or dependency not in LD_LIBRARY_PATH)
Output of OMP_TOOL_VERBOSE_INIT is added for OMP_DISPLAY_ENV

Tests for this patch are integrated into the different existing tool loading
tests, making these tests more verbose. An Archer specific verbose test is
integrated into an existing Archer test.

Patch prepared by: Isabel Thärigen

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

Added: 


Modified: 
openmp/runtime/src/kmp_settings.cpp
openmp/runtime/src/ompt-general.cpp
openmp/runtime/test/ompt/loadtool/tool_available/tool_available.c

openmp/runtime/test/ompt/loadtool/tool_available_search/tool_available_search.c
openmp/runtime/test/ompt/loadtool/tool_not_available/tool_not_available.c
openmp/tools/archer/tests/parallel/parallel-simple.c

Removed: 




diff  --git a/openmp/runtime/src/kmp_settings.cpp 
b/openmp/runtime/src/kmp_settings.cpp
index 5745cbba585f..9ae6b31cacc8 100644
--- a/openmp/runtime/src/kmp_settings.cpp
+++ b/openmp/runtime/src/kmp_settings.cpp
@@ -4695,6 +4695,27 @@ static void 
__kmp_stg_print_omp_tool_libraries(kmp_str_buf_t *buffer,
   }
 } // __kmp_stg_print_omp_tool_libraries
 
+static char *__kmp_tool_verbose_init = NULL;
+
+static void __kmp_stg_parse_omp_tool_verbose_init(char const *name,
+  char const *value, void 
*data) {
+  __kmp_stg_parse_str(name, value, &__kmp_tool_verbose_init);
+} // __kmp_stg_parse_omp_tool_libraries
+
+static void __kmp_stg_print_omp_tool_verbose_init(kmp_str_buf_t *buffer,
+  char const *name, void 
*data) {
+  if (__kmp_tool_verbose_init)
+__kmp_stg_print_str(buffer, name, __kmp_tool_libraries);
+  else {
+if (__kmp_env_format) {
+  KMP_STR_BUF_PRINT_NAME;
+} else {
+  __kmp_str_buf_print(buffer, "   %s", name);
+}
+__kmp_str_buf_print(buffer, ": %s\n", KMP_I18N_STR(NotDefined));
+  }
+} // __kmp_stg_print_omp_tool_verbose_init
+
 #endif
 
 // Table.
@@ -4937,6 +4958,8 @@ static kmp_setting_t __kmp_stg_table[] = {
  0},
 {"OMP_TOOL_LIBRARIES", __kmp_stg_parse_omp_tool_libraries,
  __kmp_stg_print_omp_tool_libraries, NULL, 0, 0},
+{"OMP_TOOL_VERBOSE_INIT", __kmp_stg_parse_omp_tool_verbose_init,
+ __kmp_stg_print_omp_tool_verbose_init, NULL, 0, 0},
 #endif
 
 {"", NULL, NULL, NULL, 0, 0}}; // settings

diff  --git a/openmp/runtime/src/ompt-general.cpp 
b/openmp/runtime/src/ompt-general.cpp
index 22eac2ebf7b8..36bd6b55f33a 100644
--- a/openmp/runtime/src/ompt-general.cpp
+++ b/openmp/runtime/src/ompt-general.cpp
@@ -45,6 +45,20 @@
 #define OMPT_STR_MATCH(haystack, needle) (!strcasecmp(haystack, needle))
 #endif
 
+// prints for an enabled OMP_TOOL_VERBOSE_INIT.
+// In the future a prefix could be added in the first define, the second define
+// omits the prefix to allow for continued lines. Example: "PREFIX: Start
+// tool... Success." instead of "PREFIX: Start tool... PREFIX: Success."
+#define OMPT_VERBOSE_INIT_PRINT(...)   
\
+  if (verbose_init)
\
+  fprintf(verbose_file, __VA_ARGS__)
+#define OMPT_VERBOSE_INIT_CONTINUED_PRINT(...) 
\
+  if (verbose_init)
\
+  fprintf(verbose_file, __VA_ARGS__)
+
+static FILE *verbose_file;
+static int verbose_init;
+
 /*
  * types
  /
@@ -230,6 +244,9 @@ ompt_try_start_tool(unsigned int omp_version, const char 
*runtime_version) {
   const char *sep = ":";
 #endif
 
+  OMPT_VERBOSE_INIT_PRINT("- START LOGGING OF TOOL REGISTRATION -\n");
+  OMPT_VERBOSE_INIT_PRINT("Search for OMP tool in current address space... ");
+
 #if KMP_OS_DARWIN
   // Try in the current address space
   ret = ompt_tool_darwin(omp_version, runtime_version);
@@ -240,50 +257,114 @@ ompt_try_start_tool(unsigned int omp_version, const char 
*runtime_version) {
 #else
 #error Activation of OMPT is not supported on this platform.
 #endif
-  if (ret)
+  if (ret) {
+OMPT_VERBOSE_INIT_CONTINUED_PRINT("Sucess.\n");
+OMPT_VERBOSE_INIT_PRINT(
+  

[llvm-branch-commits] [openmp] 6d3b816 - [OpenMP][OMPT] Introduce a guard to handle OMPT return address

2020-11-25 Thread Joachim Protze via llvm-branch-commits

Author: Joachim Protze
Date: 2020-11-25T18:17:44+01:00
New Revision: 6d3b81664a4b79b32ed2c2f46b21ab0dca9029cc

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

LOG: [OpenMP][OMPT] Introduce a guard to handle OMPT return address

This is an alternative approach to address inconsistencies pointed out in: 
D90078
This patch makes sure that the return address is reset, when leaving the scope.
In some cases, I had to move the macro out of an if-statement to have it in the
right scope, in some cases I added an additional block to restrict the scope.

This patch does not handle inconsistencies, which might occur if the return
address is still set when we call into the application.

Test case (repeated_calls.c) provided by @hbae

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

Added: 
openmp/runtime/test/ompt/parallel/repeated_calls.c

Modified: 
openmp/runtime/src/kmp_csupport.cpp
openmp/runtime/src/kmp_gsupport.cpp
openmp/runtime/src/ompt-specific.h

Removed: 




diff  --git a/openmp/runtime/src/kmp_csupport.cpp 
b/openmp/runtime/src/kmp_csupport.cpp
index 119386c49843..1a8db51a667b 100644
--- a/openmp/runtime/src/kmp_csupport.cpp
+++ b/openmp/runtime/src/kmp_csupport.cpp
@@ -297,8 +297,8 @@ void __kmpc_fork_call(ident_t *loc, kmp_int32 argc, 
kmpc_micro microtask, ...) {
 parent_team->t.t_implicit_task_taskdata[tid].ompt_task_info.frame);
   }
   ompt_frame->enter_frame.ptr = OMPT_GET_FRAME_ADDRESS(0);
-  OMPT_STORE_RETURN_ADDRESS(gtid);
 }
+OMPT_STORE_RETURN_ADDRESS(gtid);
 #endif
 
 #if INCLUDE_SSC_MARKS
@@ -713,8 +713,8 @@ void __kmpc_barrier(ident_t *loc, kmp_int32 global_tid) {
 __ompt_get_task_info_internal(0, NULL, NULL, &ompt_frame, NULL, NULL);
 if (ompt_frame->enter_frame.ptr == NULL)
   ompt_frame->enter_frame.ptr = OMPT_GET_FRAME_ADDRESS(0);
-OMPT_STORE_RETURN_ADDRESS(global_tid);
   }
+  OMPT_STORE_RETURN_ADDRESS(global_tid);
 #endif
   __kmp_threads[global_tid]->th.th_ident = loc;
   // TODO: explicit barrier_wait_id:
@@ -851,8 +851,8 @@ void __kmpc_ordered(ident_t *loc, kmp_int32 gtid) {
   kmp_team_t *team;
   ompt_wait_id_t lck;
   void *codeptr_ra;
+  OMPT_STORE_RETURN_ADDRESS(gtid);
   if (ompt_enabled.enabled) {
-OMPT_STORE_RETURN_ADDRESS(gtid);
 team = __kmp_team_from_gtid(gtid);
 lck = (ompt_wait_id_t)(uintptr_t)&team->t.t_ordered.dt.t_value;
 /* OMPT state update */
@@ -1607,8 +1607,8 @@ kmp_int32 __kmpc_barrier_master(ident_t *loc, kmp_int32 
global_tid) {
 __ompt_get_task_info_internal(0, NULL, NULL, &ompt_frame, NULL, NULL);
 if (ompt_frame->enter_frame.ptr == NULL)
   ompt_frame->enter_frame.ptr = OMPT_GET_FRAME_ADDRESS(0);
-OMPT_STORE_RETURN_ADDRESS(global_tid);
   }
+  OMPT_STORE_RETURN_ADDRESS(global_tid);
 #endif
 #if USE_ITT_NOTIFY
   __kmp_threads[global_tid]->th.th_ident = loc;
@@ -1671,8 +1671,8 @@ kmp_int32 __kmpc_barrier_master_nowait(ident_t *loc, 
kmp_int32 global_tid) {
 __ompt_get_task_info_internal(0, NULL, NULL, &ompt_frame, NULL, NULL);
 if (ompt_frame->enter_frame.ptr == NULL)
   ompt_frame->enter_frame.ptr = OMPT_GET_FRAME_ADDRESS(0);
-OMPT_STORE_RETURN_ADDRESS(global_tid);
   }
+  OMPT_STORE_RETURN_ADDRESS(global_tid);
 #endif
 #if USE_ITT_NOTIFY
   __kmp_threads[global_tid]->th.th_ident = loc;
@@ -2069,8 +2069,8 @@ void __kmpc_copyprivate(ident_t *loc, kmp_int32 gtid, 
size_t cpy_size,
 __ompt_get_task_info_internal(0, NULL, NULL, &ompt_frame, NULL, NULL);
 if (ompt_frame->enter_frame.ptr == NULL)
   ompt_frame->enter_frame.ptr = OMPT_GET_FRAME_ADDRESS(0);
-OMPT_STORE_RETURN_ADDRESS(gtid);
   }
+  OMPT_STORE_RETURN_ADDRESS(gtid);
 #endif
 /* This barrier is not a barrier region boundary */
 #if USE_ITT_NOTIFY
@@ -2083,11 +2083,9 @@ void __kmpc_copyprivate(ident_t *loc, kmp_int32 gtid, 
size_t cpy_size,
 
 // Consider next barrier a user-visible barrier for barrier region boundaries
 // Nesting checks are already handled by the single construct checks
-
+  {
 #if OMPT_SUPPORT
-  if (ompt_enabled.enabled) {
 OMPT_STORE_RETURN_ADDRESS(gtid);
-  }
 #endif
 #if USE_ITT_NOTIFY
   __kmp_threads[gtid]->th.th_ident = loc; // TODO: check if it is needed (e.g.
@@ -2099,6 +2097,7 @@ void __kmpc_copyprivate(ident_t *loc, kmp_int32 gtid, 
size_t cpy_size,
 ompt_frame->enter_frame = ompt_data_none;
   }
 #endif
+  }
 }
 
 /* -- 
*/
@@ -3462,8 +3461,8 @@ __kmpc_reduce_nowait(ident_t *loc, kmp_int32 global_tid, 
kmp_int32 num_vars,
   __ompt_get_task_info_internal(0, NULL, NULL, &ompt_frame, NULL, NULL);
   if (ompt_frame->enter_frame.ptr == NULL)
 ompt_frame->enter_frame.ptr = OMPT_GET_FRAME_ADDRESS(0);
-  OMPT_STORE_RETURN_AD

[llvm-branch-commits] [openmp] 9e3e332 - [OpenMP] libomp: fix non-X86, non-AARCH64 builds

2020-11-25 Thread via llvm-branch-commits

Author: AndreyChurbanov
Date: 2020-11-25T20:40:23+03:00
New Revision: 9e3e332d273b80b5167ac35f8dcfa7178e45c5e9

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

LOG: [OpenMP] libomp: fix non-X86, non-AARCH64 builds

Commit https://reviews.llvm.org/rG7b5254223acbf2ef9cd278070c5a84ab278d7e5f
broke the build for some architectures, because macro KMP_PREFIX_UNDERSCORE
was defined only for x86, x86_64 and aarch64. This patch defines it for other
architectures (as a no-op).

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

Added: 


Modified: 
openmp/runtime/src/z_Linux_asm.S

Removed: 




diff  --git a/openmp/runtime/src/z_Linux_asm.S 
b/openmp/runtime/src/z_Linux_asm.S
index 272999ddb9af0..b4a45c1ac6f5b 100644
--- a/openmp/runtime/src/z_Linux_asm.S
+++ b/openmp/runtime/src/z_Linux_asm.S
@@ -1737,6 +1737,9 @@ __kmp_unnamed_critical_addr:
 #endif /* KMP_ARCH_ARM */
 
 #if KMP_ARCH_PPC64 || KMP_ARCH_AARCH64 || KMP_ARCH_MIPS64 || KMP_ARCH_RISCV64
+#ifndef KMP_PREFIX_UNDERSCORE
+# define KMP_PREFIX_UNDERSCORE(x) x
+#endif
 .data
 .comm .gomp_critical_user_,32,8
 .data



___
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] c557f54 - [Flang][Docs] Update call information and add two more calls

2020-11-25 Thread Johannes Doerfert via llvm-branch-commits

Author: Johannes Doerfert
Date: 2020-11-25T11:52:35-06:00
New Revision: c557f549ba049131e444dd17dc326988158677ef

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

LOG: [Flang][Docs] Update call information and add two more calls

Call information have been updated and the OpenMP in LLVM as well as
Classic Flang call have been added.

Added: 


Modified: 
flang/docs/GettingInvolved.md

Removed: 




diff  --git a/flang/docs/GettingInvolved.md b/flang/docs/GettingInvolved.md
index a244fbcee56a..c8dbbf106fac 100644
--- a/flang/docs/GettingInvolved.md
+++ b/flang/docs/GettingInvolved.md
@@ -52,21 +52,36 @@ To understand the status of various developments in Flang 
please join the respec
 ### Flang Community Technical Biweekly Call
 
 -   Technical topics call.
--   Join [Flang Community Technical Biweekly 
Call](https://bluejeans.com/625064848?src=join_info)
+-   Join [Flang Community Technical Biweekly 
Call](https://bluejeans.com/284530575)
 -   Time: On Mondays 8:30 Pacific Time, on the weeks alternating with regular 
Flang Community Biweekly Call.
 -   The agenda is in this [Google 
Doc](https://docs.google.com/document/d/1Z2U5UAtJ-Dag5wlMaLaW1KRmNgENNAYynJqLW2j2AZQ/).
 
 ### LLVM Alias Analysis Technical Call
 
 -   For people working on improvements to LLVM alias analysis.
--   Join [LLVM Alias Analysis Technical 
Call](https://bluejeans.com/101176001?src=join_info)
+-   Join [LLVM Alias Analysis Technical Call](https://bluejeans.com/316886064)
 -   Time: Tuesdays 10:00 AM Pacific Time, every 4 weeks.
 -   The agenda is in this [Google 
Doc](https://docs.google.com/document/d/1ybwEKDVtIbhIhK50qYtwKsL50K-NvB6LfuBsfepBZ9Y/).
 
-### OpenMP Technical Call
+### OpenMP in Flang Technical Call
 
 -   Development updates on OpenMP and OpenACC in the Flang Project.
--   Join [OpenMP Technical Call](https://bit.ly/39eQW3o)
+-   Join [OpenMP in Flang Technical Call](https://bit.ly/39eQW3o)
 -   Time: Weekly call on every Thursdays 8:00 AM Pacific time.
 -   Meeting minutes are 
[here](https://docs.google.com/document/d/1yA-MeJf6RYY-ZXpdol0t7YoDoqtwAyBhFLr5thu5pFI).
 -   Status tracking 
[page](https://docs.google.com/spreadsheets/d/1FvHPuSkGbl4mQZRAwCIndvQx9dQboffiD-xD0oqxgU0/edit#gid=0).
+
+### OpenMP in LLVM Technical Call
+
+-   Development updates on OpenMP (and OpenACC) in the LLVM Project, including 
Clang, optimization, and runtime work.
+-   Join [OpenMP in LLVM Technical 
Call](https://bluejeans.com/544112769//webrtc)
+-   Time: Weekly call on every Wednesday 7:00 AM Pacific time.
+-   Meeting minutes are 
[here](https://docs.google.com/document/d/1Tz8WFN13n7yJ-SCE0Qjqf9LmjGUw0dWO9Ts1ss4YOdg/edit).
+-   Status tracking [page](https://openmp.llvm.org/docs).
+
+### Classic Flang Biweekly Technical Call
+
+-   For people working on Classic Flang, the original Flang Fortran 2003/2008 
compiler.
+-   Join [Classic Flang Biweekly Technical 
Call](https://teams.microsoft.com/l/meetup-join/19%3ameeting_YjM5YjlmNGEtMjA0MS00MTRlLTg5ZjUtOTM1ZGIxOTU2NWQy%40thread.v2)
+-   The call is held every other Wednesday in the same week as the LLVM Flang 
Technical call (alternate week with the Flang Community Biweekly call).
+-   The agenda is available 
[here](https://docs.google.com/document/d/1-OuiKx4d7O6eLEJDBDKSRnSiUO2rgRR-c2Ga4AkrzOI)



___
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] [openmp] 227c8ff - [OpenMP][Docs] Add more content, call coordinates, FAQ entries, links

2020-11-25 Thread Johannes Doerfert via llvm-branch-commits

Author: Johannes Doerfert
Date: 2020-11-25T11:52:35-06:00
New Revision: 227c8ff189c3861c11f6e80c31274c5fa28a2ee9

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

LOG: [OpenMP][Docs] Add more content, call coordinates, FAQ entries, links

Added: 


Modified: 
openmp/docs/SupportAndFAQ.rst
openmp/docs/design/Overview.rst
openmp/docs/design/Runtimes.rst
openmp/docs/index.rst
openmp/docs/optimizations/OpenMPOpt.rst
openmp/docs/optimizations/OpenMPUnawareOptimizations.rst

Removed: 




diff  --git a/openmp/docs/SupportAndFAQ.rst b/openmp/docs/SupportAndFAQ.rst
index 545dd89189c8..6b8f0d2f72b0 100644
--- a/openmp/docs/SupportAndFAQ.rst
+++ b/openmp/docs/SupportAndFAQ.rst
@@ -1,4 +1,93 @@
-Support And FAQ
-===
+Support, Getting Involved, and FAQ
+==
 
+Please do not hesitate to reach out to us via openmp-...@lists.llvm.org or join
+one of our :ref:`regular calls `. Some common questions are answered in
+the :ref:`faq`.
 
+.. _calls:
+
+Calls
+-
+
+OpenMP in LLVM Technical Call
+^
+
+-   Development updates on OpenMP (and OpenACC) in the LLVM Project, including 
Clang, optimization, and runtime work.
+-   Join `OpenMP in LLVM Technical Call 
`__.
+-   Time: Weekly call on every Wednesday 7:00 AM Pacific time.
+-   Meeting minutes are `here 
`__.
+-   Status tracking `page `__.
+
+
+OpenMP in Flang Technical Call
+^^
+-   Development updates on OpenMP and OpenACC in the Flang Project.
+-   Join `OpenMP in Flang Technical Call `_
+-   Time: Weekly call on every Thursdays 8:00 AM Pacific time.
+-   Meeting minutes are `here 
`__.
+-   Status tracking `page 
`__.
+
+
+.. _faq:
+
+FAQ
+---
+
+.. note::
+   The FAQ is a work in progress and most of the expected content is not
+   yet available. While you can expect changes, we always welcome feedback and
+   additions. Please contact, e.g., through ``openmp-...@lists.llvm.org``.
+
+
+Q: How to contribute a patch to the webpage or any other part?
+^^
+
+All patches go through the regular `LLVM review process
+`_.
+
+
+.. _build_offload_capable_compiler:
+
+Q: How to build an OpenMP offload capable compiler?
+^^^
+
+To build an *effective* OpenMP offload capable compiler we recommend a two
+stage build. The first stage Clang does not require to be offload capable but
+all backends that are targeted by OpenMP need to be enabled. By default, Clang
+will be build with all backends enabled. This initial (stage 1) Clang is used
+to create a second Clang compiler that is offload capable as well as the
+:ref:`device runtime libraries ` that will be linked into the
+offloaded code to provide OpenMP runtime support on the device.
+
+Generic information about building LLVM is available `here
+`__. The CMake options for the
+second stage Clang should include:
+
+- `LIBOMPTARGET_NVPTX_CUDA_COMPILER=$STAGE1/bin/clang` to use the stage one
+  compiler for the device runtime compilation.
+- `LIBOMPTARGET_NVPTX_ENABLE_BCLIB=ON` to enable efficient device runtimes in
+  bitcode format.
+
+If your build machine is not the target machine or automatic detection of the
+available GPUs failed, you should also set:
+
+- `CLANG_OPENMP_NVPTX_DEFAULT_ARCH=sm_XX` where `XX` is the architecture of 
your GPU, e.g, 80.
+- `LIBOMPTARGET_NVPTX_COMPUTE_CAPABILITIES=YY` where `YY` is the numeric 
compute capacity of your GPU, e.g., 75.
+
+.. note::
+  The compiler that generates the offload code should be the same (version) as
+  the compiler that build the OpenMP device runtimes. The OpenMP host runtime
+  can be build by a 
diff erent compiler.
+
+.. _advanced_builds: https://llvm.org//docs/AdvancedBuilds.html
+
+
+
+Q: Does OpenMP offloading support work in pre-packaged LLVM releases?
+^
+For now, the answer is most likely *no*. Please see 
:ref:`build_offload_capable_compiler`.
+
+Q: Does OpenMP offloading support work in packages distributed as part of my 
OS?
+
+For now, the answer is most likely *no*. Please see 
:ref:`build_offload_capable

[llvm-branch-commits] [llvm] c26e869 - [RISCV] Custom type legalize i32 fshl/fshr on RV64 with Zbt.

2020-11-25 Thread Craig Topper via llvm-branch-commits

Author: Craig Topper
Date: 2020-11-25T10:01:47-08:00
New Revision: c26e8697d71eea5fa08944a2db039a2187abf27c

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

LOG: [RISCV] Custom type legalize i32 fshl/fshr on RV64 with Zbt.

This adds custom opcodes for FSLW/FSRW so we can type legalize
fshl/fshr without needing to match a sign_extend_inreg.

I've used the operand order from fshl/fshr to make the isel
pattern similar to the non-W form. It was also hard to decide
another order since the register instruction has the shift amount
as the second operand, but the immediate instruction has it as
the third operand.

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

Added: 


Modified: 
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
llvm/lib/Target/RISCV/RISCVISelLowering.h
llvm/lib/Target/RISCV/RISCVInstrInfoB.td
llvm/test/CodeGen/RISCV/rv64Zbt.ll

Removed: 




diff  --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp 
b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index 15bd35e72e9a..854e0f4162b2 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -181,6 +181,11 @@ RISCVTargetLowering::RISCVTargetLowering(const 
TargetMachine &TM,
   if (Subtarget.hasStdExtZbt()) {
 setOperationAction(ISD::FSHL, XLenVT, Legal);
 setOperationAction(ISD::FSHR, XLenVT, Legal);
+
+if (Subtarget.is64Bit()) {
+  setOperationAction(ISD::FSHL, MVT::i32, Custom);
+  setOperationAction(ISD::FSHR, MVT::i32, Custom);
+}
   }
 
   ISD::CondCode FPCCToExtend[] = {
@@ -1091,6 +1096,26 @@ void RISCVTargetLowering::ReplaceNodeResults(SDNode *N,
 Results.push_back(DAG.getNode(ISD::TRUNCATE, DL, MVT::i32, GREVIW));
 break;
   }
+  case ISD::FSHL:
+  case ISD::FSHR: {
+assert(N->getValueType(0) == MVT::i32 && Subtarget.is64Bit() &&
+   Subtarget.hasStdExtZbt() && "Unexpected custom legalisation");
+SDValue NewOp0 =
+DAG.getNode(ISD::ANY_EXTEND, DL, MVT::i64, N->getOperand(0));
+SDValue NewOp1 =
+DAG.getNode(ISD::ANY_EXTEND, DL, MVT::i64, N->getOperand(1));
+SDValue NewOp2 =
+DAG.getNode(ISD::ANY_EXTEND, DL, MVT::i64, N->getOperand(2));
+// FSLW/FSRW take a 6 bit shift amount but i32 FSHL/FSHR only use 5 bits.
+// Mask the shift amount to 5 bits.
+NewOp2 = DAG.getNode(ISD::AND, DL, MVT::i64, NewOp2,
+ DAG.getConstant(0x1f, DL, MVT::i64));
+unsigned Opc =
+N->getOpcode() == ISD::FSHL ? RISCVISD::FSLW : RISCVISD::FSRW;
+SDValue NewOp = DAG.getNode(Opc, DL, MVT::i64, NewOp0, NewOp1, NewOp2);
+Results.push_back(DAG.getNode(ISD::TRUNCATE, DL, MVT::i32, NewOp));
+break;
+  }
   }
 }
 
@@ -1322,6 +1347,24 @@ SDValue RISCVTargetLowering::PerformDAGCombine(SDNode *N,
 }
 break;
   }
+  case RISCVISD::FSLW:
+  case RISCVISD::FSRW: {
+// Only the lower 32 bits of Values and lower 6 bits of shift amount are
+// read.
+SDValue Op0 = N->getOperand(0);
+SDValue Op1 = N->getOperand(1);
+SDValue ShAmt = N->getOperand(2);
+APInt OpMask = APInt::getLowBitsSet(Op0.getValueSizeInBits(), 32);
+APInt ShAmtMask = APInt::getLowBitsSet(ShAmt.getValueSizeInBits(), 6);
+if (SimplifyDemandedBits(Op0, OpMask, DCI) ||
+SimplifyDemandedBits(Op1, OpMask, DCI) ||
+SimplifyDemandedBits(ShAmt, ShAmtMask, DCI)) {
+  if (N->getOpcode() != ISD::DELETED_NODE)
+DCI.AddToWorklist(N);
+  return SDValue(N, 0);
+}
+break;
+  }
   case RISCVISD::GREVIW:
   case RISCVISD::GORCIW: {
 // Only the lower 32 bits of the first operand are read
@@ -1454,6 +1497,8 @@ unsigned 
RISCVTargetLowering::ComputeNumSignBitsForTargetNode(
   case RISCVISD::RORW:
   case RISCVISD::GREVIW:
   case RISCVISD::GORCIW:
+  case RISCVISD::FSLW:
+  case RISCVISD::FSRW:
 // TODO: As the result is sign-extended, this is conservatively correct. A
 // more precise answer could be calculated for SRAW depending on known
 // bits in the shift amount.
@@ -2951,6 +2996,8 @@ const char 
*RISCVTargetLowering::getTargetNodeName(unsigned Opcode) const {
   NODE_NAME_CASE(REMUW)
   NODE_NAME_CASE(ROLW)
   NODE_NAME_CASE(RORW)
+  NODE_NAME_CASE(FSLW)
+  NODE_NAME_CASE(FSRW)
   NODE_NAME_CASE(FMV_W_X_RV64)
   NODE_NAME_CASE(FMV_X_ANYEXTW_RV64)
   NODE_NAME_CASE(READ_CYCLE_WIDE)

diff  --git a/llvm/lib/Target/RISCV/RISCVISelLowering.h 
b/llvm/lib/Target/RISCV/RISCVISelLowering.h
index 46c91ed78479..39aa360860bc 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.h
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.h
@@ -46,6 +46,10 @@ enum NodeType : unsigned {
   // instructions.
   ROLW,
   RORW,
+  // RV64IB funnel shifts, with the semantics of the named RISC-V instructions,
+  // but the same operand order 

[llvm-branch-commits] [llvm] 9c86c5e - [DAG] Legalize abs(x) -> umin(x, sub(0, x)) iff umin/sub are legal

2020-11-25 Thread Simon Pilgrim via llvm-branch-commits

Author: Simon Pilgrim
Date: 2020-11-25T18:06:02Z
New Revision: 9c86c5e8add23a29fb19f7c0ac366a2063a5073a

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

LOG: [DAG] Legalize abs(x) -> umin(x,sub(0,x)) iff umin/sub are legal

If umin() is legal, this is likely to result in smaller codegen expansion for 
abs(x) than the xor(add,ashr) method.

Followup to D92095

Alive2: https://alive2.llvm.org/ce/z/8nuX6s  https://alive2.llvm.org/ce/z/q2hB9w

Added: 


Modified: 
llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
llvm/test/CodeGen/X86/abs.ll
llvm/test/CodeGen/X86/combine-abs.ll
llvm/test/CodeGen/X86/viabs.ll

Removed: 




diff  --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp 
b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
index 0b1c25764549..3464fe87d99f 100644
--- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
@@ -6830,6 +6830,14 @@ bool TargetLowering::expandABS(SDNode *N, SDValue 
&Result,
 return true;
   }
 
+  // abs(x) -> umin(x,sub(0,x))
+  if (isOperationLegal(ISD::SUB, VT) && isOperationLegal(ISD::UMIN, VT)) {
+SDValue Zero = DAG.getConstant(0, dl, VT);
+Result = DAG.getNode(ISD::UMIN, dl, VT, Op,
+ DAG.getNode(ISD::SUB, dl, VT, Zero, Op));
+return true;
+  }
+
   // Only expand vector types if we have the appropriate vector operations.
   if (VT.isVector() && (!isOperationLegalOrCustom(ISD::SRA, VT) ||
 !isOperationLegalOrCustom(ISD::ADD, VT) ||

diff  --git a/llvm/test/CodeGen/X86/abs.ll b/llvm/test/CodeGen/X86/abs.ll
index 942f09f9341b..0bbc785034a2 100644
--- a/llvm/test/CodeGen/X86/abs.ll
+++ b/llvm/test/CodeGen/X86/abs.ll
@@ -474,9 +474,8 @@ define <16 x i8> @test_v16i8(<16 x i8> %a) nounwind {
 ; SSE-LABEL: test_v16i8:
 ; SSE:   # %bb.0:
 ; SSE-NEXT:pxor %xmm1, %xmm1
-; SSE-NEXT:pcmpgtb %xmm0, %xmm1
-; SSE-NEXT:paddb %xmm1, %xmm0
-; SSE-NEXT:pxor %xmm1, %xmm0
+; SSE-NEXT:psubb %xmm0, %xmm1
+; SSE-NEXT:pminub %xmm1, %xmm0
 ; SSE-NEXT:retq
 ;
 ; AVX-LABEL: test_v16i8:

diff  --git a/llvm/test/CodeGen/X86/combine-abs.ll 
b/llvm/test/CodeGen/X86/combine-abs.ll
index da59da48a919..4ff9fef148fa 100644
--- a/llvm/test/CodeGen/X86/combine-abs.ll
+++ b/llvm/test/CodeGen/X86/combine-abs.ll
@@ -81,12 +81,10 @@ define <32 x i8> @combine_v32i8_abs_abs(<32 x i8> %a) {
 ; SSE2:   # %bb.0:
 ; SSE2-NEXT:pxor %xmm2, %xmm2
 ; SSE2-NEXT:pxor %xmm3, %xmm3
-; SSE2-NEXT:pcmpgtb %xmm0, %xmm3
-; SSE2-NEXT:paddb %xmm3, %xmm0
-; SSE2-NEXT:pxor %xmm3, %xmm0
-; SSE2-NEXT:pcmpgtb %xmm1, %xmm2
-; SSE2-NEXT:paddb %xmm2, %xmm1
-; SSE2-NEXT:pxor %xmm2, %xmm1
+; SSE2-NEXT:psubb %xmm0, %xmm3
+; SSE2-NEXT:pminub %xmm3, %xmm0
+; SSE2-NEXT:psubb %xmm1, %xmm2
+; SSE2-NEXT:pminub %xmm2, %xmm1
 ; SSE2-NEXT:retq
 ;
 ; SSE42-LABEL: combine_v32i8_abs_abs:

diff  --git a/llvm/test/CodeGen/X86/viabs.ll b/llvm/test/CodeGen/X86/viabs.ll
index 873dea24ecdd..405d9eaa2c83 100644
--- a/llvm/test/CodeGen/X86/viabs.ll
+++ b/llvm/test/CodeGen/X86/viabs.ll
@@ -132,9 +132,8 @@ define <16 x i8> @test_abs_lt_v16i8(<16 x i8> %a) nounwind {
 ; SSE2-LABEL: test_abs_lt_v16i8:
 ; SSE2:   # %bb.0:
 ; SSE2-NEXT:pxor %xmm1, %xmm1
-; SSE2-NEXT:pcmpgtb %xmm0, %xmm1
-; SSE2-NEXT:paddb %xmm1, %xmm0
-; SSE2-NEXT:pxor %xmm1, %xmm0
+; SSE2-NEXT:psubb %xmm0, %xmm1
+; SSE2-NEXT:pminub %xmm1, %xmm0
 ; SSE2-NEXT:retq
 ;
 ; SSSE3-LABEL: test_abs_lt_v16i8:
@@ -363,12 +362,10 @@ define <32 x i8> @test_abs_lt_v32i8(<32 x i8> %a) 
nounwind {
 ; SSE2:   # %bb.0:
 ; SSE2-NEXT:pxor %xmm2, %xmm2
 ; SSE2-NEXT:pxor %xmm3, %xmm3
-; SSE2-NEXT:pcmpgtb %xmm0, %xmm3
-; SSE2-NEXT:paddb %xmm3, %xmm0
-; SSE2-NEXT:pxor %xmm3, %xmm0
-; SSE2-NEXT:pcmpgtb %xmm1, %xmm2
-; SSE2-NEXT:paddb %xmm2, %xmm1
-; SSE2-NEXT:pxor %xmm2, %xmm1
+; SSE2-NEXT:psubb %xmm0, %xmm3
+; SSE2-NEXT:pminub %xmm3, %xmm0
+; SSE2-NEXT:psubb %xmm1, %xmm2
+; SSE2-NEXT:pminub %xmm2, %xmm1
 ; SSE2-NEXT:retq
 ;
 ; SSSE3-LABEL: test_abs_lt_v32i8:
@@ -874,20 +871,16 @@ define <64 x i8> @test_abs_lt_v64i8(<64 x i8> %a) 
nounwind {
 ; SSE2:   # %bb.0:
 ; SSE2-NEXT:pxor %xmm4, %xmm4
 ; SSE2-NEXT:pxor %xmm5, %xmm5
-; SSE2-NEXT:pcmpgtb %xmm0, %xmm5
-; SSE2-NEXT:paddb %xmm5, %xmm0
-; SSE2-NEXT:pxor %xmm5, %xmm0
+; SSE2-NEXT:psubb %xmm0, %xmm5
+; SSE2-NEXT:pminub %xmm5, %xmm0
 ; SSE2-NEXT:pxor %xmm5, %xmm5
-; SSE2-NEXT:pcmpgtb %xmm1, %xmm5
-; SSE2-NEXT:paddb %xmm5, %xmm1
-; SSE2-NEXT:pxor %xmm5, %xmm1
+; SSE2-NEXT:psubb %xmm1, %xmm5
+; SSE2-NEXT:pminub %xmm5, %xmm1
 ; SSE2-NEXT:pxor %xmm5, %xmm5
-; SSE2-NEXT:pcmpgtb %xmm2, %x

[llvm-branch-commits] [clang-tools-extra] 73fdd99 - [clangd] Implement clang-tidy options from config

2020-11-25 Thread Nathan James via llvm-branch-commits

Author: Nathan James
Date: 2020-11-25T18:35:35Z
New Revision: 73fdd998701cce3aa6c4d8d2a73ab97351a0313b

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

LOG: [clangd] Implement clang-tidy options from config

Added some new ClangTidyOptionsProvider like classes designed for clangd work 
flow.
These providers are designed to source the options on the worker thread but in 
a thread safe manner.
This is done through making the options getter take a pointer to the filesystem 
used by the worker thread which natuarally is from a ThreadsafeFS.
Internal caching in the providers is also guarded.

The providers don't inherit from `ClangTidyOptionsProvider` instead they share 
a base class which is able to create a provider for the `ClangTidyContext` 
using a specific FileSystem.
This approach means one provider can be used for multiple contexts even though 
`ClangTidyContext` owns its provider.

Depends on D90531

Reviewed By: sammccall

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

Added: 
clang-tools-extra/clangd/TidyProvider.cpp
clang-tools-extra/clangd/TidyProvider.h

Modified: 
clang-tools-extra/clangd/CMakeLists.txt
clang-tools-extra/clangd/ClangdServer.cpp
clang-tools-extra/clangd/ClangdServer.h
clang-tools-extra/clangd/Compiler.h
clang-tools-extra/clangd/ParsedAST.cpp
clang-tools-extra/clangd/tool/Check.cpp
clang-tools-extra/clangd/tool/ClangdMain.cpp
clang-tools-extra/clangd/unittests/ClangdTests.cpp
clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
clang-tools-extra/clangd/unittests/TestTU.cpp
clang-tools-extra/clangd/unittests/TestTU.h

Removed: 




diff  --git a/clang-tools-extra/clangd/CMakeLists.txt 
b/clang-tools-extra/clangd/CMakeLists.txt
index 2ce5d31e623e..919457f216c1 100644
--- a/clang-tools-extra/clangd/CMakeLists.txt
+++ b/clang-tools-extra/clangd/CMakeLists.txt
@@ -81,6 +81,7 @@ add_clang_library(clangDaemon
   SemanticSelection.cpp
   SourceCode.cpp
   QueryDriverDatabase.cpp
+  TidyProvider.cpp
   TUScheduler.cpp
   URI.cpp
   XRefs.cpp

diff  --git a/clang-tools-extra/clangd/ClangdServer.cpp 
b/clang-tools-extra/clangd/ClangdServer.cpp
index 502078c776db..aa19a9485e17 100644
--- a/clang-tools-extra/clangd/ClangdServer.cpp
+++ b/clang-tools-extra/clangd/ClangdServer.cpp
@@ -114,40 +114,6 @@ struct UpdateIndexCallbacks : public ParsingCallbacks {
   bool TheiaSemanticHighlighting;
 };
 
-// Set of clang-tidy checks that don't work well in clangd, either due to
-// crashes or false positives.
-// Returns a clang-tidy filter string: -check1,-check2.
-llvm::StringRef getUnusableTidyChecks() {
-  static const std::string FalsePositives =
-  llvm::join_items(", ",
-   // Check relies on seeing ifndef/define/endif 
directives,
-   // clangd doesn't replay those when using a preamble.
-   "-llvm-header-guard");
-  static const std::string CrashingChecks =
-  llvm::join_items(", ",
-   // Check can choke on invalid (intermediate) c++ code,
-   // which is often the case when clangd tries to build an
-   // AST.
-   "-bugprone-use-after-move");
-  static const std::string UnusableTidyChecks =
-  llvm::join_items(", ", FalsePositives, CrashingChecks);
-  return UnusableTidyChecks;
-}
-
-// Returns a clang-tidy options string: check1,check2.
-llvm::StringRef getDefaultTidyChecks() {
-  // These default checks are chosen for:
-  //  - low false-positive rate
-  //  - providing a lot of value
-  //  - being reasonably efficient
-  static const std::string DefaultChecks = llvm::join_items(
-  ",", "readability-misleading-indentation", "readability-deleted-default",
-  "bugprone-integer-division", "bugprone-sizeof-expression",
-  "bugprone-suspicious-missing-comma", "bugprone-unused-raii",
-  "bugprone-unused-return-value", "misc-unused-using-decls",
-  "misc-unused-alias-decls", "misc-definitions-in-headers");
-  return DefaultChecks;
-}
 } // namespace
 
 ClangdServer::Options ClangdServer::optsForTest() {
@@ -178,7 +144,7 @@ ClangdServer::ClangdServer(const GlobalCompilationDatabase 
&CDB,
  ? new FileIndex(Opts.HeavyweightDynamicSymbolIndex,
  Opts.CollectMainFileRefs)
  : nullptr),
-  GetClangTidyOptions(Opts.GetClangTidyOptions),
+  ClangTidyProvider(Opts.ClangTidyProvider),
   SuggestMissingIncludes(Opts.SuggestMissingIncludes),
   BuildRecoveryAST(Opts.BuildRecoveryAST),
   PreserveRecoveryASTType(Opts.PreserveRecoveryASTType),
@@ -236,20 +202,6 @@ void ClangdServer::addDocument(PathRef Fi

[llvm-branch-commits] [llvm] 54038ee - [gn build] Port 73fdd998701

2020-11-25 Thread LLVM GN Syncbot via llvm-branch-commits

Author: LLVM GN Syncbot
Date: 2020-11-25T18:35:53Z
New Revision: 54038eeef4ac922059db32403c63ca79822f291d

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

LOG: [gn build] Port 73fdd998701

Added: 


Modified: 
llvm/utils/gn/secondary/clang-tools-extra/clangd/BUILD.gn

Removed: 




diff  --git a/llvm/utils/gn/secondary/clang-tools-extra/clangd/BUILD.gn 
b/llvm/utils/gn/secondary/clang-tools-extra/clangd/BUILD.gn
index 8ca0b9460b46..908dce6a12e5 100644
--- a/llvm/utils/gn/secondary/clang-tools-extra/clangd/BUILD.gn
+++ b/llvm/utils/gn/secondary/clang-tools-extra/clangd/BUILD.gn
@@ -104,6 +104,7 @@ static_library("clangd") {
 "SemanticSelection.cpp",
 "SourceCode.cpp",
 "TUScheduler.cpp",
+"TidyProvider.cpp",
 "URI.cpp",
 "XRefs.cpp",
 "index/Background.cpp",



___
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] 385a27d - [CostModel][X86] Refresh ISD::ABS costs

2020-11-25 Thread Simon Pilgrim via llvm-branch-commits

Author: Simon Pilgrim
Date: 2020-11-25T18:40:19Z
New Revision: 385a27d6cdaddbb99da5518da3cb6713d9677df3

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

LOG: [CostModel][X86] Refresh ISD::ABS costs

Update costs now that D92095 and D92102 have tweaked the SSE2 implementation

The SSE42 BLENDVPD cost can actually be used on SSE41 as we don't attempt to 
generate PCMPGT anymore

Add scalar i16/i32/i64 costs as we can do this cheaply with CMOV

Added: 


Modified: 
llvm/lib/Target/X86/X86TargetTransformInfo.cpp
llvm/test/Analysis/CostModel/X86/abs.ll

Removed: 




diff  --git a/llvm/lib/Target/X86/X86TargetTransformInfo.cpp 
b/llvm/lib/Target/X86/X86TargetTransformInfo.cpp
index 2c35f74ab95e..770317a9a8b5 100644
--- a/llvm/lib/Target/X86/X86TargetTransformInfo.cpp
+++ b/llvm/lib/Target/X86/X86TargetTransformInfo.cpp
@@ -2483,7 +2483,7 @@ int X86TTIImpl::getTypeBasedIntrinsicInstrCost(
 { ISD::FSQRT,  MVT::v4f64,  28 }, // Haswell from http://www.agner.org/
   };
   static const CostTblEntry AVX1CostTbl[] = {
-{ ISD::ABS,MVT::v4i64,   6 }, // VBLENDVPD(X,VPSUBQ(0,X),X)
+{ ISD::ABS,MVT::v4i64,   5 }, // VBLENDVPD(X,VPSUBQ(0,X),X)
 { ISD::ABS,MVT::v8i32,   3 },
 { ISD::ABS,MVT::v16i16,  3 },
 { ISD::ABS,MVT::v32i8,   3 },
@@ -2554,13 +2554,13 @@ int X86TTIImpl::getTypeBasedIntrinsicInstrCost(
 { ISD::FSQRT, MVT::v2f64, 70 }, // sqrtpd
   };
   static const CostTblEntry SSE42CostTbl[] = {
-{ ISD::ABS,MVT::v2i64,   3 }, // BLENDVPD(X,PSUBQ(0,X),X)
 { ISD::USUBSAT,MVT::v4i32,   2 }, // pmaxud + psubd
 { ISD::UADDSAT,MVT::v4i32,   3 }, // not + pminud + paddd
 { ISD::FSQRT,  MVT::f32,18 }, // Nehalem from http://www.agner.org/
 { ISD::FSQRT,  MVT::v4f32,  18 }, // Nehalem from http://www.agner.org/
   };
   static const CostTblEntry SSE41CostTbl[] = {
+{ ISD::ABS,MVT::v2i64,   2 }, // BLENDVPD(X,PSUBQ(0,X),X)
 { ISD::SMAX,   MVT::v4i32,   1 },
 { ISD::SMAX,   MVT::v16i8,   1 },
 { ISD::SMIN,   MVT::v4i32,   1 },
@@ -2597,8 +2597,8 @@ int X86TTIImpl::getTypeBasedIntrinsicInstrCost(
   static const CostTblEntry SSE2CostTbl[] = {
 { ISD::ABS,MVT::v2i64,   4 },
 { ISD::ABS,MVT::v4i32,   3 },
-{ ISD::ABS,MVT::v8i16,   3 },
-{ ISD::ABS,MVT::v16i8,   3 },
+{ ISD::ABS,MVT::v8i16,   2 },
+{ ISD::ABS,MVT::v16i8,   2 },
 { ISD::BITREVERSE, MVT::v2i64,  29 },
 { ISD::BITREVERSE, MVT::v4i32,  27 },
 { ISD::BITREVERSE, MVT::v8i16,  27 },
@@ -2668,6 +2668,7 @@ int X86TTIImpl::getTypeBasedIntrinsicInstrCost(
 { ISD::CTPOP,  MVT::i8,  1 },
   };
   static const CostTblEntry X64CostTbl[] = { // 64-bit targets
+{ ISD::ABS,MVT::i64, 2 }, // SUB+CMOV
 { ISD::BITREVERSE, MVT::i64,14 },
 { ISD::CTLZ,   MVT::i64, 4 }, // BSR+XOR or BSR+XOR+CMOV
 { ISD::CTTZ,   MVT::i64, 3 }, // TEST+BSF+CMOV/BRANCH
@@ -2677,6 +2678,8 @@ int X86TTIImpl::getTypeBasedIntrinsicInstrCost(
 { ISD::UMULO,  MVT::i64, 2 }, // mulq + seto
   };
   static const CostTblEntry X86CostTbl[] = { // 32 or 64-bit targets
+{ ISD::ABS,MVT::i32, 2 }, // SUB+CMOV
+{ ISD::ABS,MVT::i16, 2 }, // SUB+CMOV
 { ISD::BITREVERSE, MVT::i32,14 },
 { ISD::BITREVERSE, MVT::i16,14 },
 { ISD::BITREVERSE, MVT::i8, 11 },

diff  --git a/llvm/test/Analysis/CostModel/X86/abs.ll 
b/llvm/test/Analysis/CostModel/X86/abs.ll
index 636160201342..dbfcb20779dc 100644
--- a/llvm/test/Analysis/CostModel/X86/abs.ll
+++ b/llvm/test/Analysis/CostModel/X86/abs.ll
@@ -14,42 +14,42 @@
 
 define void @cost_abs_i64(i64 %a64, <2 x i64> %a128, <4 x i64> %a256, <8 x 
i64> %a512) {
 ; SSE2-LABEL: 'cost_abs_i64'
-; SSE2-NEXT:  Cost Model: Found an estimated cost of 3 for instruction: %I64 = 
call i64 @llvm.abs.i64(i64 %a64, i1 false)
+; SSE2-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %I64 = 
call i64 @llvm.abs.i64(i64 %a64, i1 false)
 ; SSE2-NEXT:  Cost Model: Found an estimated cost of 4 for instruction: %V2I64 
= call <2 x i64> @llvm.abs.v2i64(<2 x i64> %a128, i1 false)
 ; SSE2-NEXT:  Cost Model: Found an estimated cost of 8 for instruction: %V4I64 
= call <4 x i64> @llvm.abs.v4i64(<4 x i64> %a256, i1 false)
 ; SSE2-NEXT:  Cost Model: Found an estimated cost of 16 for instruction: 
%V8I64 = call <8 x i64> @llvm.abs.v8i64(<8 x i64> %a512, i1 false)
 ; SSE2-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret 
void
 ;
 ; SSSE3-LABEL: 'cost_abs_i64'
-; SSSE3-NEXT:  Cost Model: Found an estimated cost of 3 for instruction: %I64 
= call i64 @llvm.abs.i64(i64 %a64, i1 false)
+; SSSE3-NEXT:  

[llvm-branch-commits] [llvm] dc35368 - Remove static function unused after cf1c774.

2020-11-25 Thread Paul Robinson via llvm-branch-commits

Author: Paul Robinson
Date: 2020-11-25T13:43:06-05:00
New Revision: dc35368ccf17a7dca0874ace7490cc3836fb063f

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

LOG: Remove static function unused after cf1c774.

Caused some -Werror bot failures.

Added: 


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

Removed: 




diff  --git a/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp 
b/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
index 3d935bb0077e..2d3ec0a0367f 100644
--- a/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
@@ -223,21 +223,6 @@ void FastISel::flushLocalValueMap() {
   LastFlushPoint = FuncInfo.InsertPt;
 }
 
-static bool isTerminatingEHLabel(MachineBasicBlock *MBB, MachineInstr &MI) {
-  // Ignore non-EH labels.
-  if (!MI.isEHLabel())
-return false;
-
-  // Any EH label outside a landing pad must be for an invoke. Consider it a
-  // terminator.
-  if (!MBB->isEHPad())
-return true;
-
-  // If this is a landingpad, the first non-phi instruction will be an 
EH_LABEL.
-  // Don't consider that label to be a terminator.
-  return MI.getIterator() != MBB->getFirstNonPHI();
-}
-
 bool FastISel::hasTrivialKill(const Value *V) {
   // Don't consider constants or arguments to have trivial kills.
   const Instruction *I = dyn_cast(V);



___
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] 5654a3d - [RISCV] Add test cases showing that we don't recognize the select form of NABS in SelectionDAGBuilder so we end up with branches. NFC

2020-11-25 Thread Craig Topper via llvm-branch-commits

Author: Craig Topper
Date: 2020-11-25T10:45:39-08:00
New Revision: 5654a3dd0add58984e2c3247c70946d2ae0175f6

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

LOG: [RISCV] Add test cases showing that we don't recognize the select form of 
NABS in SelectionDAGBuilder so we end up with branches. NFC

There's a FIXME that it should produce (sub 0, (abs)).

Added: 


Modified: 
llvm/test/CodeGen/RISCV/neg-abs.ll

Removed: 




diff  --git a/llvm/test/CodeGen/RISCV/neg-abs.ll 
b/llvm/test/CodeGen/RISCV/neg-abs.ll
index 2171a1d24a281..10290a0f8b894 100644
--- a/llvm/test/CodeGen/RISCV/neg-abs.ll
+++ b/llvm/test/CodeGen/RISCV/neg-abs.ll
@@ -24,6 +24,29 @@ define i32 @neg_abs32(i32 %x) {
   ret i32 %neg
 }
 
+define i32 @select_neg_abs32(i32 %x) {
+; RV32-LABEL: select_neg_abs32:
+; RV32:   # %bb.0:
+; RV32-NEXT:bltz a0, .LBB1_2
+; RV32-NEXT:  # %bb.1:
+; RV32-NEXT:neg a0, a0
+; RV32-NEXT:  .LBB1_2:
+; RV32-NEXT:ret
+;
+; RV64-LABEL: select_neg_abs32:
+; RV64:   # %bb.0:
+; RV64-NEXT:sext.w a1, a0
+; RV64-NEXT:bltz a1, .LBB1_2
+; RV64-NEXT:  # %bb.1:
+; RV64-NEXT:negw a0, a0
+; RV64-NEXT:  .LBB1_2:
+; RV64-NEXT:ret
+  %1 = icmp slt i32 %x, 0
+  %2 = sub nsw i32 0, %x
+  %3 = select i1 %1, i32 %x, i32 %2
+  ret i32 %3
+}
+
 define i64 @neg_abs64(i64 %x) {
 ; RV32-LABEL: neg_abs64:
 ; RV32:   # %bb.0:
@@ -46,3 +69,29 @@ define i64 @neg_abs64(i64 %x) {
   %neg = sub nsw i64 0, %abs
   ret i64 %neg
 }
+
+define i64 @select_neg_abs64(i64 %x) {
+; RV32-LABEL: select_neg_abs64:
+; RV32:   # %bb.0:
+; RV32-NEXT:bltz a1, .LBB3_2
+; RV32-NEXT:  # %bb.1:
+; RV32-NEXT:snez a2, a0
+; RV32-NEXT:add a1, a1, a2
+; RV32-NEXT:neg a1, a1
+; RV32-NEXT:neg a0, a0
+; RV32-NEXT:  .LBB3_2:
+; RV32-NEXT:ret
+;
+; RV64-LABEL: select_neg_abs64:
+; RV64:   # %bb.0:
+; RV64-NEXT:bltz a0, .LBB3_2
+; RV64-NEXT:  # %bb.1:
+; RV64-NEXT:neg a0, a0
+; RV64-NEXT:  .LBB3_2:
+; RV64-NEXT:ret
+  %1 = icmp slt i64 %x, 0
+  %2 = sub nsw i64 0, %x
+  %3 = select i1 %1, i64 %x, i64 %2
+  ret i64 %3
+}
+



___
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] a015635 - [Hexagon] Add support for ISD::SMAX/SMIN/UMAX/UMIN instead of custom dag patterns

2020-11-25 Thread Simon Pilgrim via llvm-branch-commits

Author: Simon Pilgrim
Date: 2020-11-25T19:02:17Z
New Revision: a0156356296b54dc071405332a517695b1881bc1

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

LOG: [Hexagon] Add support for ISD::SMAX/SMIN/UMAX/UMIN instead of custom dag 
patterns

This should handle the basic integer min/max handling - the HVX ops are still 
TODO.

This is some necessary cleanup work for min/max ops to eventually help us move 
the add/sub sat patterns into DAGCombine - D91876.

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

Added: 


Modified: 
llvm/lib/Target/Hexagon/HexagonISelLowering.cpp
llvm/lib/Target/Hexagon/HexagonPatterns.td
llvm/test/CodeGen/Hexagon/isel-minmax-v64bit.ll

Removed: 




diff  --git a/llvm/lib/Target/Hexagon/HexagonISelLowering.cpp 
b/llvm/lib/Target/Hexagon/HexagonISelLowering.cpp
index b2fc79215c1e..b60758a8be8a 100644
--- a/llvm/lib/Target/Hexagon/HexagonISelLowering.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonISelLowering.cpp
@@ -1517,8 +1517,11 @@ HexagonTargetLowering::HexagonTargetLowering(const 
TargetMachine &TM,
 setMinimumJumpTableEntries(std::numeric_limits::max());
   setOperationAction(ISD::BR_JT, MVT::Other, Expand);
 
-  setOperationAction(ISD::ABS, MVT::i32, Legal);
-  setOperationAction(ISD::ABS, MVT::i64, Legal);
+  for (unsigned LegalIntOp :
+   {ISD::ABS, ISD::SMIN, ISD::SMAX, ISD::UMIN, ISD::UMAX}) {
+setOperationAction(LegalIntOp, MVT::i32, Legal);
+setOperationAction(LegalIntOp, MVT::i64, Legal);
+  }
 
   // Hexagon has A4_addp_c and A4_subp_c that take and generate a carry bit,
   // but they only operate on i64.
@@ -1683,6 +1686,13 @@ HexagonTargetLowering::HexagonTargetLowering(const 
TargetMachine &TM,
   setOperationAction(ISD::SPLAT_VECTOR, NativeVT, Legal);
   }
 
+  for (MVT VT : {MVT::v8i8, MVT::v4i16, MVT::v2i32}) {
+setOperationAction(ISD::SMIN, VT, Legal);
+setOperationAction(ISD::SMAX, VT, Legal);
+setOperationAction(ISD::UMIN, VT, Legal);
+setOperationAction(ISD::UMAX, VT, Legal);
+  }
+
   // Custom lower unaligned loads.
   // Also, for both loads and stores, verify the alignment of the address
   // in case it is a compile-time constant. This is a usability feature to

diff  --git a/llvm/lib/Target/Hexagon/HexagonPatterns.td 
b/llvm/lib/Target/Hexagon/HexagonPatterns.td
index 348cef29c305..fa91f7a31b14 100644
--- a/llvm/lib/Target/Hexagon/HexagonPatterns.td
+++ b/llvm/lib/Target/Hexagon/HexagonPatterns.td
@@ -366,12 +366,14 @@ multiclass NopCast_pat {
   def: Pat<(Ty2 (bitconvert (Ty1 RC:$Val))), (Ty2 RC:$Val)>;
 }
 
-
 // Frags for commonly used SDNodes.
 def Add: pf2;def And: pf2;def Sra: pf2;
 def Sub: pf2;def Or:  pf2; def Srl: pf2;
 def Mul: pf2;def Xor: pf2;def Shl: pf2;
 
+def Smin: pf2;  def Smax: pf2;
+def Umin: pf2;  def Umax: pf2;
+
 def Rol: pf2;
 
 // --(1) Immediate ---
@@ -924,25 +926,14 @@ let AddedComplexity = 200 in {
   defm: SelMinMax16_pats;
 }
 
-let AddedComplexity = 200 in {
-  defm: MinMax_pats;
-  defm: MinMax_pats;
-  defm: MinMax_pats;
-  defm: MinMax_pats;
-  defm: MinMax_pats;
-  defm: MinMax_pats;
-  defm: MinMax_pats;
-  defm: MinMax_pats;
-
-  defm: MinMax_pats;
-  defm: MinMax_pats;
-  defm: MinMax_pats;
-  defm: MinMax_pats;
-  defm: MinMax_pats;
-  defm: MinMax_pats;
-  defm: MinMax_pats;
-  defm: MinMax_pats;
-}
+def: OpR_RR_pat;
+def: OpR_RR_pat;
+def: OpR_RR_pat;
+def: OpR_RR_pat;
+def: OpR_RR_pat;
+def: OpR_RR_pat;
+def: OpR_RR_pat;
+def: OpR_RR_pat;
 
 let AddedComplexity = 100 in {
   defm: MinMax_pats;
@@ -958,18 +949,20 @@ let AddedComplexity = 100, Predicates = [HasV67] in {
   defm: MinMax_pats;
 }
 
-defm: MinMax_pats;
-defm: MinMax_pats;
-defm: MinMax_pats;
-defm: MinMax_pats;
-defm: MinMax_pats;
-defm: MinMax_pats;
-defm: MinMax_pats;
-defm: MinMax_pats;
-defm: MinMax_pats;
-defm: MinMax_pats;
-defm: MinMax_pats;
-defm: MinMax_pats;
+def: OpR_RR_pat;
+def: OpR_RR_pat;
+def: OpR_RR_pat;
+def: OpR_RR_pat;
+
+def: OpR_RR_pat;
+def: OpR_RR_pat;
+def: OpR_RR_pat;
+def: OpR_RR_pat;
+
+def: OpR_RR_pat;
+def: OpR_RR_pat;
+def: OpR_RR_pat;
+def: OpR_RR_pat;
 
 // --(7) Insert/extract --
 //

diff  --git a/llvm/test/CodeGen/Hexagon/isel-minmax-v64bit.ll 
b/llvm/test/CodeGen/Hexagon/isel-minmax-v64bit.ll
index 53dec510a865..d175d8dd295c 100644
--- a/llvm/test/CodeGen/Hexagon/isel-minmax-v64bit.ll
+++ b/llvm/test/CodeGen/Hexagon/isel-minmax-v64bit.ll
@@ -3,7 +3,7 @@
 ; min
 
 ; CHECK-LABEL: test_00:
-; CHECK: r1:0 = vminb(r3:2,r1:0)
+; CHECK: r1:0 = vminb(r1:0,r3:2)
 define <8 x i8> @test_00(<8 x i8> %a0, <8 x i8> %a1) #0 {
   %v0 = icmp slt <8 x i8> %a0, %a1
   %v1 = select <8 x i1> %v0, <8 x i8> %a0, <8 x i8> %a1
@@ -19,7 +1

[llvm-branch-commits] [clang] 3bd0672 - [MS] Fix double evaluation of MSVC builtin arguments

2020-11-25 Thread Reid Kleckner via llvm-branch-commits

Author: Reid Kleckner
Date: 2020-11-25T11:55:01-08:00
New Revision: 3bd06727267184223464f11d4e2470048ac40cb1

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

LOG: [MS] Fix double evaluation of MSVC builtin arguments

This code got quite twisted because we consider some MSVC builtins to be
target agnostic, and some to be target specific. Target specific
intrinsics have a pattern of doing up-front argument evaluation, while
general intrinsics do not evaluate their arguments up front. As we tried
to share codepaths between the target-specific and target-agnostic
handling, we ended up doing double evaluation.

Instead, have each target handle MSVC intrinsics consistently before up
front argument evaluation. This requires passing less data around and is
more consistent with target independent intrinsic handling.

See D50979 for past examples of this bug. I noticed this while looking
into adding some more intrinsics.

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

Added: 


Modified: 
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/CodeGen/CodeGenFunction.h
clang/test/CodeGen/ms-intrinsics.c

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index e98ec3e35e37..b2bfc3c84322 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -1011,16 +1011,342 @@ enum class CodeGenFunction::MSVCIntrin {
   __fastfail,
 };
 
+static Optional
+translateArmToMsvcIntrin(unsigned BuiltinID) {
+  using MSVCIntrin = CodeGenFunction::MSVCIntrin;
+  switch (BuiltinID) {
+  default:
+return None;
+  case ARM::BI_BitScanForward:
+  case ARM::BI_BitScanForward64:
+return MSVCIntrin::_BitScanForward;
+  case ARM::BI_BitScanReverse:
+  case ARM::BI_BitScanReverse64:
+return MSVCIntrin::_BitScanReverse;
+  case ARM::BI_InterlockedAnd64:
+return MSVCIntrin::_InterlockedAnd;
+  case ARM::BI_InterlockedExchange64:
+return MSVCIntrin::_InterlockedExchange;
+  case ARM::BI_InterlockedExchangeAdd64:
+return MSVCIntrin::_InterlockedExchangeAdd;
+  case ARM::BI_InterlockedExchangeSub64:
+return MSVCIntrin::_InterlockedExchangeSub;
+  case ARM::BI_InterlockedOr64:
+return MSVCIntrin::_InterlockedOr;
+  case ARM::BI_InterlockedXor64:
+return MSVCIntrin::_InterlockedXor;
+  case ARM::BI_InterlockedDecrement64:
+return MSVCIntrin::_InterlockedDecrement;
+  case ARM::BI_InterlockedIncrement64:
+return MSVCIntrin::_InterlockedIncrement;
+  case ARM::BI_InterlockedExchangeAdd8_acq:
+  case ARM::BI_InterlockedExchangeAdd16_acq:
+  case ARM::BI_InterlockedExchangeAdd_acq:
+  case ARM::BI_InterlockedExchangeAdd64_acq:
+return MSVCIntrin::_InterlockedExchangeAdd_acq;
+  case ARM::BI_InterlockedExchangeAdd8_rel:
+  case ARM::BI_InterlockedExchangeAdd16_rel:
+  case ARM::BI_InterlockedExchangeAdd_rel:
+  case ARM::BI_InterlockedExchangeAdd64_rel:
+return MSVCIntrin::_InterlockedExchangeAdd_rel;
+  case ARM::BI_InterlockedExchangeAdd8_nf:
+  case ARM::BI_InterlockedExchangeAdd16_nf:
+  case ARM::BI_InterlockedExchangeAdd_nf:
+  case ARM::BI_InterlockedExchangeAdd64_nf:
+return MSVCIntrin::_InterlockedExchangeAdd_nf;
+  case ARM::BI_InterlockedExchange8_acq:
+  case ARM::BI_InterlockedExchange16_acq:
+  case ARM::BI_InterlockedExchange_acq:
+  case ARM::BI_InterlockedExchange64_acq:
+return MSVCIntrin::_InterlockedExchange_acq;
+  case ARM::BI_InterlockedExchange8_rel:
+  case ARM::BI_InterlockedExchange16_rel:
+  case ARM::BI_InterlockedExchange_rel:
+  case ARM::BI_InterlockedExchange64_rel:
+return MSVCIntrin::_InterlockedExchange_rel;
+  case ARM::BI_InterlockedExchange8_nf:
+  case ARM::BI_InterlockedExchange16_nf:
+  case ARM::BI_InterlockedExchange_nf:
+  case ARM::BI_InterlockedExchange64_nf:
+return MSVCIntrin::_InterlockedExchange_nf;
+  case ARM::BI_InterlockedCompareExchange8_acq:
+  case ARM::BI_InterlockedCompareExchange16_acq:
+  case ARM::BI_InterlockedCompareExchange_acq:
+  case ARM::BI_InterlockedCompareExchange64_acq:
+return MSVCIntrin::_InterlockedCompareExchange_acq;
+  case ARM::BI_InterlockedCompareExchange8_rel:
+  case ARM::BI_InterlockedCompareExchange16_rel:
+  case ARM::BI_InterlockedCompareExchange_rel:
+  case ARM::BI_InterlockedCompareExchange64_rel:
+return MSVCIntrin::_InterlockedCompareExchange_rel;
+  case ARM::BI_InterlockedCompareExchange8_nf:
+  case ARM::BI_InterlockedCompareExchange16_nf:
+  case ARM::BI_InterlockedCompareExchange_nf:
+  case ARM::BI_InterlockedCompareExchange64_nf:
+return MSVCIntrin::_InterlockedCompareExchange_nf;
+  case ARM::BI_InterlockedOr8_acq:
+  case ARM::BI_InterlockedOr16_acq:
+  case ARM::BI_InterlockedOr_acq:
+  case ARM::BI_InterlockedOr64_acq:
+return MSVCIntrin::_InterlockedOr_acq;
+  case AR

[llvm-branch-commits] [clang] 1e843a9 - [MS] Add more 128bit cmpxchg intrinsics for AArch64

2020-11-25 Thread Reid Kleckner via llvm-branch-commits

Author: Reid Kleckner
Date: 2020-11-25T12:07:28-08:00
New Revision: 1e843a987d847da48aaf41801b79cfb364937e8f

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

LOG: [MS] Add more 128bit cmpxchg intrinsics for AArch64

The MSVC STL for requires this on ARM64.
Requested in https://llvm.org/pr47099

Depends on D92061

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

Added: 


Modified: 
clang/include/clang/Basic/BuiltinsAArch64.def
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/Headers/intrin.h
clang/test/CodeGen/ms-intrinsics.c

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsAArch64.def 
b/clang/include/clang/Basic/BuiltinsAArch64.def
index f07c567053de..c684105908de 100644
--- a/clang/include/clang/Basic/BuiltinsAArch64.def
+++ b/clang/include/clang/Basic/BuiltinsAArch64.def
@@ -153,6 +153,11 @@ TARGET_HEADER_BUILTIN(_InterlockedCompareExchange64_acq, 
"LLiLLiD*LLiLLi", "nh",
 TARGET_HEADER_BUILTIN(_InterlockedCompareExchange64_nf,  "LLiLLiD*LLiLLi", 
"nh", "intrin.h", ALL_MS_LANGUAGES, "")
 TARGET_HEADER_BUILTIN(_InterlockedCompareExchange64_rel, "LLiLLiD*LLiLLi", 
"nh", "intrin.h", ALL_MS_LANGUAGES, "")
 
+TARGET_HEADER_BUILTIN(_InterlockedCompareExchange128,"UcLLiD*LLiLLiLLi*", 
"nh", "intrin.h", ALL_MS_LANGUAGES, "")
+TARGET_HEADER_BUILTIN(_InterlockedCompareExchange128_acq,"UcLLiD*LLiLLiLLi*", 
"nh", "intrin.h", ALL_MS_LANGUAGES, "")
+TARGET_HEADER_BUILTIN(_InterlockedCompareExchange128_nf ,"UcLLiD*LLiLLiLLi*", 
"nh", "intrin.h", ALL_MS_LANGUAGES, "")
+TARGET_HEADER_BUILTIN(_InterlockedCompareExchange128_rel,"UcLLiD*LLiLLiLLi*", 
"nh", "intrin.h", ALL_MS_LANGUAGES, "")
+
 TARGET_HEADER_BUILTIN(_InterlockedOr8_acq,  "ccD*c",   "nh", "intrin.h", 
ALL_MS_LANGUAGES, "")
 TARGET_HEADER_BUILTIN(_InterlockedOr8_nf,   "ccD*c",   "nh", "intrin.h", 
ALL_MS_LANGUAGES, "")
 TARGET_HEADER_BUILTIN(_InterlockedOr8_rel,  "ccD*c",   "nh", "intrin.h", 
ALL_MS_LANGUAGES, "")

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index b2bfc3c84322..828d66f83de9 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -304,6 +304,10 @@ Value *EmitAtomicCmpXchgForMSIntrin(CodeGenFunction &CGF, 
const CallExpr *E,
  AtomicOrdering::Monotonic :
  SuccessOrdering;
 
+  // The atomic instruction is marked volatile for consistency with MSVC. This
+  // blocks the few atomics optimizations that LLVM has. If we want to optimize
+  // _Interlocked* operations in the future, we will have to remove the 
volatile
+  // marker.
   auto *Result = CGF.Builder.CreateAtomicCmpXchg(
Destination, Comparand, Exchange,
SuccessOrdering, FailureOrdering);
@@ -311,6 +315,68 @@ Value *EmitAtomicCmpXchgForMSIntrin(CodeGenFunction &CGF, 
const CallExpr *E,
   return CGF.Builder.CreateExtractValue(Result, 0);
 }
 
+// 64-bit Microsoft platforms support 128 bit cmpxchg operations. They are
+// prototyped like this:
+//
+// unsigned char _InterlockedCompareExchange128...(
+// __int64 volatile * _Destination,
+// __int64 _ExchangeHigh,
+// __int64 _ExchangeLow,
+// __int64 * _ComparandResult);
+static Value *EmitAtomicCmpXchg128ForMSIntrin(CodeGenFunction &CGF,
+  const CallExpr *E,
+  AtomicOrdering SuccessOrdering) {
+  assert(E->getNumArgs() == 4);
+  llvm::Value *Destination = CGF.EmitScalarExpr(E->getArg(0));
+  llvm::Value *ExchangeHigh = CGF.EmitScalarExpr(E->getArg(1));
+  llvm::Value *ExchangeLow = CGF.EmitScalarExpr(E->getArg(2));
+  llvm::Value *ComparandPtr = CGF.EmitScalarExpr(E->getArg(3));
+
+  assert(Destination->getType()->isPointerTy());
+  assert(!ExchangeHigh->getType()->isPointerTy());
+  assert(!ExchangeLow->getType()->isPointerTy());
+  assert(ComparandPtr->getType()->isPointerTy());
+
+  // For Release ordering, the failure ordering should be Monotonic.
+  auto FailureOrdering = SuccessOrdering == AtomicOrdering::Release
+ ? AtomicOrdering::Monotonic
+ : SuccessOrdering;
+
+  // Convert to i128 pointers and values.
+  llvm::Type *Int128Ty = llvm::IntegerType::get(CGF.getLLVMContext(), 128);
+  llvm::Type *Int128PtrTy = Int128Ty->getPointerTo();
+  Destination = CGF.Builder.CreateBitCast(Destination, Int128PtrTy);
+  Address ComparandResult(CGF.Builder.CreateBitCast(ComparandPtr, Int128PtrTy),
+  CGF.getContext().toCharUnitsFromBits(128));
+
+  // (((i128)hi) << 64) | ((i128)lo)
+  ExchangeHigh = CGF.Builder.CreateZExt(ExchangeHigh, Int128Ty);
+  ExchangeLow = CGF.Builder.CreateZExt(ExchangeLow, Int128Ty);
+  ExchangeHigh =
+  CGF.Bu

[llvm-branch-commits] [mlir] 9ffba19 - [MLIR][Affine] Add custom builders for AffineVectorLoadOp/AffineVectorStoreOp

2020-11-25 Thread Frank Laub via llvm-branch-commits

Author: Frank Laub
Date: 2020-11-25T20:22:56Z
New Revision: 9ffba19e86ce234d7289b31b4a7b78cd8878f159

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

LOG: [MLIR][Affine] Add custom builders for 
AffineVectorLoadOp/AffineVectorStoreOp

Adding missing custom builders for AffineVectorLoadOp & AffineVectorStoreOp. In 
practice, it is difficult to correctly construct these ops without these 
builders (because the AffineMap is not included at construction time).

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

Added: 


Modified: 
mlir/include/mlir/Dialect/Affine/IR/AffineOps.td
mlir/lib/Dialect/Affine/IR/AffineOps.cpp

Removed: 




diff  --git a/mlir/include/mlir/Dialect/Affine/IR/AffineOps.td 
b/mlir/include/mlir/Dialect/Affine/IR/AffineOps.td
index e2fffc4ab591..5b1180889072 100644
--- a/mlir/include/mlir/Dialect/Affine/IR/AffineOps.td
+++ b/mlir/include/mlir/Dialect/Affine/IR/AffineOps.td
@@ -910,6 +910,18 @@ def AffineVectorLoadOp : AffineLoadOpBase<"vector_load"> {
 
   let results = (outs AnyVector:$result);
 
+  let builders = [
+/// Builds an affine vector load op with the specified map and operands.
+OpBuilderDAG<(ins "VectorType":$resultType, "AffineMap":$map,
+  "ValueRange":$operands)>,
+/// Builds an affine vector load op with an identity map and operands.
+OpBuilderDAG<(ins "VectorType":$resultType, "Value":$memref,
+  CArg<"ValueRange", "{}">:$indices)>,
+/// Builds an affine vector load op with the specified map and its 
operands.
+OpBuilderDAG<(ins "VectorType":$resultType, "Value":$memref,
+  "AffineMap":$map, "ValueRange":$mapOperands)>
+  ];
+
   let extraClassDeclaration = extraClassDeclarationBase # [{
 VectorType getVectorType() {
   return result().getType().cast();
@@ -964,6 +976,14 @@ def AffineVectorStoreOp : 
AffineStoreOpBase<"vector_store"> {
   [MemWrite]>:$memref,
   Variadic:$indices);
 
+  let skipDefaultBuilders = 1;
+  let builders = [
+OpBuilderDAG<(ins "Value":$valueToStore, "Value":$memref,
+  "ValueRange":$indices)>,
+OpBuilderDAG<(ins "Value":$valueToStore, "Value":$memref, "AffineMap":$map,
+  "ValueRange":$mapOperands)>
+  ];
+
   let extraClassDeclaration = extraClassDeclarationBase # [{
 VectorType getVectorType() {
   return value().getType().cast();

diff  --git a/mlir/lib/Dialect/Affine/IR/AffineOps.cpp 
b/mlir/lib/Dialect/Affine/IR/AffineOps.cpp
index 299569602ea1..b83807475f34 100644
--- a/mlir/lib/Dialect/Affine/IR/AffineOps.cpp
+++ b/mlir/lib/Dialect/Affine/IR/AffineOps.cpp
@@ -2088,7 +2088,7 @@ void AffineLoadOp::build(OpBuilder &builder, 
OperationState &result,
 void AffineLoadOp::build(OpBuilder &builder, OperationState &result,
  Value memref, ValueRange indices) {
   auto memrefType = memref.getType().cast();
-  auto rank = memrefType.getRank();
+  int64_t rank = memrefType.getRank();
   // Create identity map for memrefs with at least one dimension or () -> ()
   // for zero-dimensional memrefs.
   auto map =
@@ -2202,7 +2202,7 @@ void AffineStoreOp::build(OpBuilder &builder, 
OperationState &result,
   Value valueToStore, Value memref,
   ValueRange indices) {
   auto memrefType = memref.getType().cast();
-  auto rank = memrefType.getRank();
+  int64_t rank = memrefType.getRank();
   // Create identity map for memrefs with at least one dimension or () -> ()
   // for zero-dimensional memrefs.
   auto map =
@@ -2902,6 +2902,38 @@ static LogicalResult verify(AffineYieldOp op) {
 // AffineVectorLoadOp
 
//===--===//
 
+void AffineVectorLoadOp::build(OpBuilder &builder, OperationState &result,
+   VectorType resultType, AffineMap map,
+   ValueRange operands) {
+  assert(operands.size() == 1 + map.getNumInputs() && "inconsistent operands");
+  result.addOperands(operands);
+  if (map)
+result.addAttribute(getMapAttrName(), AffineMapAttr::get(map));
+  result.types.push_back(resultType);
+}
+
+void AffineVectorLoadOp::build(OpBuilder &builder, OperationState &result,
+   VectorType resultType, Value memref,
+   AffineMap map, ValueRange mapOperands) {
+  assert(map.getNumInputs() == mapOperands.size() && "inconsistent index 
info");
+  result.addOperands(memref);
+  result.addOperands(mapOperands);
+  result.addAttribute(getMapAttrName(), AffineMapAttr::get(map));
+  result.types.push_back(resultType);
+}
+
+void AffineVectorLoadOp::build(OpBuilder &builder, OperationState &result,
+   VectorType resultType, Value memref,
+   ValueRan

[llvm-branch-commits] [clang-tools-extra] cbf336a - [clangd] Track deprecation of 'member' semantic token type in LSP.

2020-11-25 Thread Sam McCall via llvm-branch-commits

Author: Sam McCall
Date: 2020-11-25T21:31:46+01:00
New Revision: cbf336ad76cd619495b213e8364acaccb7a7c0d6

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

LOG: [clangd] Track deprecation of 'member' semantic token type in LSP.

Added: 


Modified: 
clang-tools-extra/clangd/SemanticHighlighting.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/SemanticHighlighting.cpp 
b/clang-tools-extra/clangd/SemanticHighlighting.cpp
index 1a78e7a8c0da..44d74f387dd1 100644
--- a/clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ b/clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -556,12 +556,11 @@ llvm::StringRef toSemanticTokenType(HighlightingKind 
Kind) {
   case HighlightingKind::Function:
 return "function";
   case HighlightingKind::Method:
-return "member";
+return "method";
   case HighlightingKind::StaticMethod:
-// FIXME: better function/member with static modifier?
+// FIXME: better method with static modifier?
 return "function";
   case HighlightingKind::Field:
-// Not "member": https://github.com/clangd/vscode-clangd/issues/105
 return "property";
   case HighlightingKind::Class:
 return "class";



___
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] [libcxxabi] a78aaa1 - [libc++] Factor out common logic for calling aligned allocation

2020-11-25 Thread Louis Dionne via llvm-branch-commits

Author: Louis Dionne
Date: 2020-11-25T15:44:50-05:00
New Revision: a78aaa1ad51214b2e04f41762e76bb43067ea1fd

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

LOG: [libc++] Factor out common logic for calling aligned allocation

There were a couple of places where we needed to call the underlying
platform's aligned allocation/deallocation function. Instead of having
the same logic all over the place, extract the logic into a pair of
helper functions __libcpp_aligned_alloc and __libcpp_aligned_free.

The code in libcxxabi/src/fallback_malloc.cpp looks like it could be
simplified after this change -- I purposefully did not simplify it
further to keep this change as straightforward as possible, since it
is touching very important parts of the library.

Also, the changes in libcxx/src/new.cpp and libcxxabi/src/stdlib_new_delete.cpp
are basically the same -- I just kept both source files in sync.

The underlying reason for this refactoring is to make it easier to support
platforms that provide aligned allocation through C11's aligned_alloc
function instead of posix_memalign. After this change, we'll only have
to add support for that in a single place.

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

Added: 


Modified: 
libcxx/include/new
libcxx/src/new.cpp
libcxxabi/src/fallback_malloc.cpp
libcxxabi/src/stdlib_new_delete.cpp

Removed: 




diff  --git a/libcxx/include/new b/libcxx/include/new
index 66747b04d4d7..8b17003b7b87 100644
--- a/libcxx/include/new
+++ b/libcxx/include/new
@@ -88,13 +88,11 @@ void  operator delete[](void* ptr, void*) noexcept;
 
 #include <__config>
 #include <__availability>
+#include 
+#include 
 #include 
 #include 
-#include 
 #include 
-#ifdef _LIBCPP_NO_EXCEPTIONS
-#include 
-#endif
 
 #if defined(_LIBCPP_ABI_VCRUNTIME)
 #include 
@@ -303,6 +301,36 @@ inline _LIBCPP_INLINE_VISIBILITY void 
__libcpp_deallocate_unsized(void* __ptr, s
 #endif
 }
 
+#if !defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION)
+// Low-level helpers to call the aligned allocation and deallocation functions
+// on the target platform. This is used to implement libc++'s own memory
+// allocation routines -- if you need to allocate memory inside the library,
+// chances are that you want to use `__libcpp_allocate` instead.
+//
+// Returns the allocated memory, or `nullptr` on failure.
+inline _LIBCPP_INLINE_VISIBILITY
+void* __libcpp_aligned_alloc(std::size_t __alignment, std::size_t __size) {
+#if defined(_LIBCPP_MSVCRT_LIKE)
+  return ::_aligned_malloc(__size, __alignment);
+#else
+  void* __result = nullptr;
+  ::posix_memalign(&__result, __alignment, __size);
+  // If posix_memalign fails, __result is unmodified so we still return 
`nullptr`.
+  return __result;
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+void __libcpp_aligned_free(void* __ptr) {
+#if defined(_LIBCPP_MSVCRT_LIKE)
+  ::_aligned_free(__ptr);
+#else
+  ::free(__ptr);
+#endif
+}
+#endif // !_LIBCPP_HAS_NO_ALIGNED_ALLOCATION
+
+
 template 
 _LIBCPP_NODISCARD_AFTER_CXX17 inline
 _LIBCPP_CONSTEXPR _Tp* __launder(_Tp* __p) _NOEXCEPT

diff  --git a/libcxx/src/new.cpp b/libcxx/src/new.cpp
index ec60ca64815f..57f948fbb052 100644
--- a/libcxx/src/new.cpp
+++ b/libcxx/src/new.cpp
@@ -179,15 +179,16 @@ operator new(std::size_t size, std::align_val_t 
alignment) _THROW_BAD_ALLOC
 size = 1;
 if (static_cast(alignment) < sizeof(void*))
   alignment = std::align_val_t(sizeof(void*));
+
+// Try allocating memory. If allocation fails and there is a new_handler,
+// call it to try free up memory, and try again until it succeeds, or until
+// the new_handler decides to terminate.
+//
+// If allocation fails and there is no new_handler, we throw bad_alloc
+// (or return nullptr if exceptions are disabled).
 void* p;
-#if defined(_LIBCPP_MSVCRT_LIKE)
-while ((p = _aligned_malloc(size, static_cast(alignment))) == 
nullptr)
-#else
-while (::posix_memalign(&p, static_cast(alignment), size) != 0)
-#endif
+while ((p = 
std::__libcpp_aligned_alloc(static_cast(alignment), size)) == 
nullptr)
 {
-// If posix_memalign fails and there is a new_handler,
-// call it to try free up memory.
 std::new_handler nh = std::get_new_handler();
 if (nh)
 nh();
@@ -195,7 +196,6 @@ operator new(std::size_t size, std::align_val_t alignment) 
_THROW_BAD_ALLOC
 #ifndef _LIBCPP_NO_EXCEPTIONS
 throw std::bad_alloc();
 #else
-p = nullptr; // posix_memalign doesn't initialize 'p' on failure
 break;
 #endif
 }
@@ -252,12 +252,9 @@ _LIBCPP_WEAK
 void
 operator delete(void* ptr, std::align_val_t) _NOEXCEPT
 {
-if (ptr)
-#if defined(_LIBCPP_MSVCRT_LIKE)
-::_aligned_free(ptr);
-#else
- 

[llvm-branch-commits] [llvm] 751b0d9 - [RISCV] Make SMIN/SMAX/UMIN/UMAX legal with Zbb extension.

2020-11-25 Thread Craig Topper via llvm-branch-commits

Author: Craig Topper
Date: 2020-11-25T12:48:43-08:00
New Revision: 751b0d970e757aef055fb6e1a981a7c44185aa80

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

LOG: [RISCV] Make SMIN/SMAX/UMIN/UMAX legal with Zbb extension.

This is the logically correct thing to do. But it generates worse
code for i32 umin/umax on the rv64 due to type legalize requesting
zext even though the arguments are sext. Maybe we can teach type
legalizer to use sext for umin/umax for RISCV.

It's also producing possibly worse code on i64 on RV32 since we
still end up with selects that become branches. But this seems
like something we could improve in type legalization or DAG combine.

Hopefully this makes D92095 work for RISCV with Zbb.

Added: 


Modified: 
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
llvm/lib/Target/RISCV/RISCVInstrInfoB.td
llvm/test/CodeGen/RISCV/rv32Zbb.ll
llvm/test/CodeGen/RISCV/rv64Zbb.ll

Removed: 




diff  --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp 
b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index 854e0f4162b2..c182a34c0c9a 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -172,7 +172,12 @@ RISCVTargetLowering::RISCVTargetLowering(const 
TargetMachine &TM,
 setOperationAction(ISD::BSWAP, XLenVT, Expand);
   }
 
-  if (!Subtarget.hasStdExtZbb()) {
+  if (Subtarget.hasStdExtZbb()) {
+setOperationAction(ISD::SMIN, XLenVT, Legal);
+setOperationAction(ISD::SMAX, XLenVT, Legal);
+setOperationAction(ISD::UMIN, XLenVT, Legal);
+setOperationAction(ISD::UMAX, XLenVT, Legal);
+  } else {
 setOperationAction(ISD::CTTZ, XLenVT, Expand);
 setOperationAction(ISD::CTLZ, XLenVT, Expand);
 setOperationAction(ISD::CTPOP, XLenVT, Expand);

diff  --git a/llvm/lib/Target/RISCV/RISCVInstrInfoB.td 
b/llvm/lib/Target/RISCV/RISCVInstrInfoB.td
index b97306c459ad..29ccffb05cfd 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfoB.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfoB.td
@@ -789,17 +789,9 @@ def : Pat<(sext_inreg GPR:$rs1, i16), (SEXTH GPR:$rs1)>;
 
 let Predicates = [HasStdExtZbb] in {
 def : Pat<(smin GPR:$rs1, GPR:$rs2), (MIN  GPR:$rs1, GPR:$rs2)>;
-def : Pat<(riscv_selectcc GPR:$rs1, GPR:$rs2, (XLenVT 20), GPR:$rs1, GPR:$rs2),
-  (MIN  GPR:$rs1, GPR:$rs2)>;
 def : Pat<(smax GPR:$rs1, GPR:$rs2), (MAX  GPR:$rs1, GPR:$rs2)>;
-def : Pat<(riscv_selectcc GPR:$rs2, GPR:$rs1, (XLenVT 20), GPR:$rs1, GPR:$rs2),
-  (MAX  GPR:$rs1, GPR:$rs2)>;
 def : Pat<(umin GPR:$rs1, GPR:$rs2), (MINU GPR:$rs1, GPR:$rs2)>;
-def : Pat<(riscv_selectcc GPR:$rs1, GPR:$rs2, (XLenVT 12), GPR:$rs1, GPR:$rs2),
-  (MINU  GPR:$rs1, GPR:$rs2)>;
 def : Pat<(umax GPR:$rs1, GPR:$rs2), (MAXU GPR:$rs1, GPR:$rs2)>;
-def : Pat<(riscv_selectcc GPR:$rs2, GPR:$rs1, (XLenVT 12), GPR:$rs1, GPR:$rs2),
-  (MAXU  GPR:$rs1, GPR:$rs2)>;
 } // Predicates = [HasStdExtZbb]
 
 let Predicates = [HasStdExtZbbOrZbp, IsRV32] in

diff  --git a/llvm/test/CodeGen/RISCV/rv32Zbb.ll 
b/llvm/test/CodeGen/RISCV/rv32Zbb.ll
index 8da1fe64c65f..d67bc0cc667a 100644
--- a/llvm/test/CodeGen/RISCV/rv32Zbb.ll
+++ b/llvm/test/CodeGen/RISCV/rv32Zbb.ll
@@ -910,34 +910,36 @@ define i64 @min_i64(i64 %a, i64 %b) nounwind {
 ;
 ; RV32IB-LABEL: min_i64:
 ; RV32IB:   # %bb.0:
-; RV32IB-NEXT:beq a1, a3, .LBB19_2
+; RV32IB-NEXT:mv a4, a0
+; RV32IB-NEXT:bge a1, a3, .LBB19_3
 ; RV32IB-NEXT:  # %bb.1:
-; RV32IB-NEXT:slt a4, a1, a3
-; RV32IB-NEXT:beqz a4, .LBB19_3
-; RV32IB-NEXT:j .LBB19_4
+; RV32IB-NEXT:beq a1, a3, .LBB19_4
 ; RV32IB-NEXT:  .LBB19_2:
-; RV32IB-NEXT:sltu a4, a0, a2
-; RV32IB-NEXT:bnez a4, .LBB19_4
+; RV32IB-NEXT:min a1, a1, a3
+; RV32IB-NEXT:ret
 ; RV32IB-NEXT:  .LBB19_3:
 ; RV32IB-NEXT:mv a0, a2
-; RV32IB-NEXT:mv a1, a3
+; RV32IB-NEXT:bne a1, a3, .LBB19_2
 ; RV32IB-NEXT:  .LBB19_4:
+; RV32IB-NEXT:minu a0, a4, a2
+; RV32IB-NEXT:min a1, a1, a3
 ; RV32IB-NEXT:ret
 ;
 ; RV32IBB-LABEL: min_i64:
 ; RV32IBB:   # %bb.0:
-; RV32IBB-NEXT:beq a1, a3, .LBB19_2
+; RV32IBB-NEXT:mv a4, a0
+; RV32IBB-NEXT:bge a1, a3, .LBB19_3
 ; RV32IBB-NEXT:  # %bb.1:
-; RV32IBB-NEXT:slt a4, a1, a3
-; RV32IBB-NEXT:beqz a4, .LBB19_3
-; RV32IBB-NEXT:j .LBB19_4
+; RV32IBB-NEXT:beq a1, a3, .LBB19_4
 ; RV32IBB-NEXT:  .LBB19_2:
-; RV32IBB-NEXT:sltu a4, a0, a2
-; RV32IBB-NEXT:bnez a4, .LBB19_4
+; RV32IBB-NEXT:min a1, a1, a3
+; RV32IBB-NEXT:ret
 ; RV32IBB-NEXT:  .LBB19_3:
 ; RV32IBB-NEXT:mv a0, a2
-; RV32IBB-NEXT:mv a1, a3
+; RV32IBB-NEXT:bne a1, a3, .LBB19_2
 ; RV32IBB-NEXT:  .LBB19_4:
+; RV32IBB-NEXT:minu a0, a4, a2
+; RV32IBB-NEXT:min a1, a1, a3
 ; RV32IBB-NEXT:ret
   %cmp = icmp slt i64 %a, %b
   %cond = select i1 %cmp, i6

[llvm-branch-commits] [llvm] bd0527f - [RISCV] Add test cases to check that we use (smax X, (neg X)) for abs with Zbb extension.

2020-11-25 Thread Craig Topper via llvm-branch-commits

Author: Craig Topper
Date: 2020-11-25T12:48:43-08:00
New Revision: bd0527f3942d2045be4e3a6b5e7eb98752bf7200

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

LOG: [RISCV] Add test cases to check that we use (smax X, (neg X)) for abs with 
Zbb extension.

Added: 


Modified: 
llvm/test/CodeGen/RISCV/rv32Zbb.ll
llvm/test/CodeGen/RISCV/rv64Zbb.ll

Removed: 




diff  --git a/llvm/test/CodeGen/RISCV/rv32Zbb.ll 
b/llvm/test/CodeGen/RISCV/rv32Zbb.ll
index d67bc0cc667a..86ef499b1807 100644
--- a/llvm/test/CodeGen/RISCV/rv32Zbb.ll
+++ b/llvm/test/CodeGen/RISCV/rv32Zbb.ll
@@ -1194,3 +1194,67 @@ define i64 @maxu_i64(i64 %a, i64 %b) nounwind {
   %cond = select i1 %cmp, i64 %a, i64 %b
   ret i64 %cond
 }
+
+declare i32 @llvm.abs.i32(i32, i1 immarg)
+
+define i32 @abs_i32(i32 %x) {
+; RV32I-LABEL: abs_i32:
+; RV32I:   # %bb.0:
+; RV32I-NEXT:srai a1, a0, 31
+; RV32I-NEXT:add a0, a0, a1
+; RV32I-NEXT:xor a0, a0, a1
+; RV32I-NEXT:ret
+;
+; RV32IB-LABEL: abs_i32:
+; RV32IB:   # %bb.0:
+; RV32IB-NEXT:neg a1, a0
+; RV32IB-NEXT:max a0, a0, a1
+; RV32IB-NEXT:ret
+;
+; RV32IBB-LABEL: abs_i32:
+; RV32IBB:   # %bb.0:
+; RV32IBB-NEXT:neg a1, a0
+; RV32IBB-NEXT:max a0, a0, a1
+; RV32IBB-NEXT:ret
+  %abs = tail call i32 @llvm.abs.i32(i32 %x, i1 true)
+  ret i32 %abs
+}
+
+declare i64 @llvm.abs.i64(i64, i1 immarg)
+
+define i64 @abs_i64(i64 %x) {
+; RV32I-LABEL: abs_i64:
+; RV32I:   # %bb.0:
+; RV32I-NEXT:bgez a1, .LBB27_2
+; RV32I-NEXT:  # %bb.1:
+; RV32I-NEXT:snez a2, a0
+; RV32I-NEXT:neg a0, a0
+; RV32I-NEXT:add a1, a1, a2
+; RV32I-NEXT:neg a1, a1
+; RV32I-NEXT:  .LBB27_2:
+; RV32I-NEXT:ret
+;
+; RV32IB-LABEL: abs_i64:
+; RV32IB:   # %bb.0:
+; RV32IB-NEXT:bgez a1, .LBB27_2
+; RV32IB-NEXT:  # %bb.1:
+; RV32IB-NEXT:snez a2, a0
+; RV32IB-NEXT:neg a0, a0
+; RV32IB-NEXT:add a1, a1, a2
+; RV32IB-NEXT:neg a1, a1
+; RV32IB-NEXT:  .LBB27_2:
+; RV32IB-NEXT:ret
+;
+; RV32IBB-LABEL: abs_i64:
+; RV32IBB:   # %bb.0:
+; RV32IBB-NEXT:bgez a1, .LBB27_2
+; RV32IBB-NEXT:  # %bb.1:
+; RV32IBB-NEXT:snez a2, a0
+; RV32IBB-NEXT:neg a0, a0
+; RV32IBB-NEXT:add a1, a1, a2
+; RV32IBB-NEXT:neg a1, a1
+; RV32IBB-NEXT:  .LBB27_2:
+; RV32IBB-NEXT:ret
+  %abs = tail call i64 @llvm.abs.i64(i64 %x, i1 true)
+  ret i64 %abs
+}

diff  --git a/llvm/test/CodeGen/RISCV/rv64Zbb.ll 
b/llvm/test/CodeGen/RISCV/rv64Zbb.ll
index da072a171728..3c96af27c057 100644
--- a/llvm/test/CodeGen/RISCV/rv64Zbb.ll
+++ b/llvm/test/CodeGen/RISCV/rv64Zbb.ll
@@ -949,6 +949,59 @@ define i64 @maxu_i64(i64 %a, i64 %b) nounwind {
   ret i64 %cond
 }
 
+declare i32 @llvm.abs.i32(i32, i1 immarg)
+
+define i32 @abs_i32(i32 %x) {
+; RV64I-LABEL: abs_i32:
+; RV64I:   # %bb.0:
+; RV64I-NEXT:sext.w a0, a0
+; RV64I-NEXT:srai a1, a0, 63
+; RV64I-NEXT:add a0, a0, a1
+; RV64I-NEXT:xor a0, a0, a1
+; RV64I-NEXT:ret
+;
+; RV64IB-LABEL: abs_i32:
+; RV64IB:   # %bb.0:
+; RV64IB-NEXT:sext.w a0, a0
+; RV64IB-NEXT:neg a1, a0
+; RV64IB-NEXT:max a0, a0, a1
+; RV64IB-NEXT:ret
+;
+; RV64IBB-LABEL: abs_i32:
+; RV64IBB:   # %bb.0:
+; RV64IBB-NEXT:sext.w a0, a0
+; RV64IBB-NEXT:neg a1, a0
+; RV64IBB-NEXT:max a0, a0, a1
+; RV64IBB-NEXT:ret
+  %abs = tail call i32 @llvm.abs.i32(i32 %x, i1 true)
+  ret i32 %abs
+}
+
+declare i64 @llvm.abs.i64(i64, i1 immarg)
+
+define i64 @abs_i64(i64 %x) {
+; RV64I-LABEL: abs_i64:
+; RV64I:   # %bb.0:
+; RV64I-NEXT:srai a1, a0, 63
+; RV64I-NEXT:add a0, a0, a1
+; RV64I-NEXT:xor a0, a0, a1
+; RV64I-NEXT:ret
+;
+; RV64IB-LABEL: abs_i64:
+; RV64IB:   # %bb.0:
+; RV64IB-NEXT:neg a1, a0
+; RV64IB-NEXT:max a0, a0, a1
+; RV64IB-NEXT:ret
+;
+; RV64IBB-LABEL: abs_i64:
+; RV64IBB:   # %bb.0:
+; RV64IBB-NEXT:neg a1, a0
+; RV64IBB-NEXT:max a0, a0, a1
+; RV64IBB-NEXT:ret
+  %abs = tail call i64 @llvm.abs.i64(i64 %x, i1 true)
+  ret i64 %abs
+}
+
 ; We select a i32 addi that zero-extends the result on RV64 as addiwu
 
 define zeroext i32 @zext_add_to_addiwu(i32 signext %a) nounwind {



___
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] c5d0172 - [mlir] Add build configuration for Quant unittest

2020-11-25 Thread Marius Brehler via llvm-branch-commits

Author: Marius Brehler
Date: 2020-11-25T21:59:05+01:00
New Revision: c5d017267dea6c4e84b0e67f043bde94815052ac

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

LOG: [mlir] Add build configuration for Quant unittest

Added: 
mlir/unittests/Dialect/Quant/CMakeLists.txt

Modified: 
mlir/unittests/Dialect/CMakeLists.txt

Removed: 




diff  --git a/mlir/unittests/Dialect/CMakeLists.txt 
b/mlir/unittests/Dialect/CMakeLists.txt
index 87eccaae8a30..22f1475a1393 100644
--- a/mlir/unittests/Dialect/CMakeLists.txt
+++ b/mlir/unittests/Dialect/CMakeLists.txt
@@ -6,4 +6,5 @@ target_link_libraries(MLIRDialectTests
   MLIRIR
   MLIRDialect)
 
+add_subdirectory(Quant)
 add_subdirectory(SPIRV)

diff  --git a/mlir/unittests/Dialect/Quant/CMakeLists.txt 
b/mlir/unittests/Dialect/Quant/CMakeLists.txt
new file mode 100644
index ..6341ca326447
--- /dev/null
+++ b/mlir/unittests/Dialect/Quant/CMakeLists.txt
@@ -0,0 +1,6 @@
+add_mlir_unittest(MLIRQuantTests
+  QuantizationUtilsTest.cpp
+)
+target_link_libraries(MLIRQuantTests
+  PRIVATE
+  MLIRQuant)



___
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] c5d0172 - [mlir] Add build configuration for Quant unittest

2020-11-25 Thread Marius Brehler via llvm-branch-commits

Author: Marius Brehler
Date: 2020-11-25T21:59:05+01:00
New Revision: c5d017267dea6c4e84b0e67f043bde94815052ac

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

LOG: [mlir] Add build configuration for Quant unittest

Added: 
mlir/unittests/Dialect/Quant/CMakeLists.txt

Modified: 
mlir/unittests/Dialect/CMakeLists.txt

Removed: 




diff  --git a/mlir/unittests/Dialect/CMakeLists.txt 
b/mlir/unittests/Dialect/CMakeLists.txt
index 87eccaae8a30..22f1475a1393 100644
--- a/mlir/unittests/Dialect/CMakeLists.txt
+++ b/mlir/unittests/Dialect/CMakeLists.txt
@@ -6,4 +6,5 @@ target_link_libraries(MLIRDialectTests
   MLIRIR
   MLIRDialect)
 
+add_subdirectory(Quant)
 add_subdirectory(SPIRV)

diff  --git a/mlir/unittests/Dialect/Quant/CMakeLists.txt 
b/mlir/unittests/Dialect/Quant/CMakeLists.txt
new file mode 100644
index ..6341ca326447
--- /dev/null
+++ b/mlir/unittests/Dialect/Quant/CMakeLists.txt
@@ -0,0 +1,6 @@
+add_mlir_unittest(MLIRQuantTests
+  QuantizationUtilsTest.cpp
+)
+target_link_libraries(MLIRQuantTests
+  PRIVATE
+  MLIRQuant)



___
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] 35828b8 - [ms] [llvm-ml] Implement the expression expansion operator

2020-11-25 Thread Eric Astor via llvm-branch-commits

Author: Eric Astor
Date: 2020-11-25T16:11:00-05:00
New Revision: 35828b84a5232df020d6de250c3c268e2ccaaf11

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

LOG: [ms] [llvm-ml] Implement the expression expansion operator

In text-item contexts, %expr expands to a string containing the results of 
evaluating `expr`.

Reviewed By: thakis

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

Added: 


Modified: 
llvm/lib/MC/MCParser/MasmParser.cpp
llvm/test/tools/llvm-ml/macro_function.test

Removed: 




diff  --git a/llvm/lib/MC/MCParser/MasmParser.cpp 
b/llvm/lib/MC/MCParser/MasmParser.cpp
index 9b63148c6860..8b5d4b85a58b 100644
--- a/llvm/lib/MC/MCParser/MasmParser.cpp
+++ b/llvm/lib/MC/MCParser/MasmParser.cpp
@@ -912,7 +912,8 @@ class MasmParser : public MCAsmParser {
 
   // macro directives
   bool parseDirectivePurgeMacro(SMLoc DirectiveLoc);
-  bool parseDirectiveExitMacro(StringRef Directive, std::string &Value);
+  bool parseDirectiveExitMacro(SMLoc DirectiveLoc, StringRef Directive,
+   std::string &Value);
   bool parseDirectiveEndMacro(StringRef Directive);
   bool parseDirectiveMacro(StringRef Name, SMLoc NameLoc);
 
@@ -2307,7 +2308,7 @@ bool MasmParser::parseStatement(ParseStatementInfo &Info,
   return parseDirectiveCFIWindowSave();
 case DK_EXITM:
   Info.ExitValue = "";
-  return parseDirectiveExitMacro(IDVal, *Info.ExitValue);
+  return parseDirectiveExitMacro(IDLoc, IDVal, *Info.ExitValue);
 case DK_ENDM:
   Info.ExitValue = "";
   return parseDirectiveEndMacro(IDVal);
@@ -3207,7 +3208,7 @@ bool MasmParser::parseDirectiveEquate(StringRef IDVal, 
StringRef Name,
   // Accept a text-list, not just one text-item.
   auto parseItem = [&]() -> bool {
 if (parseTextItem(Value))
-  return true;
+  return TokError("expected text item");
 Var.TextValue += Value;
 return false;
   };
@@ -3283,8 +3284,38 @@ bool MasmParser::parseAngleBracketString(std::string 
&Data) {
 
 /// textItem ::= textLiteral | textMacroID | % constExpr
 bool MasmParser::parseTextItem(std::string &Data) {
-  // TODO(epastor): Support textMacroID and % expansion of expressions.
-  return parseAngleBracketString(Data);
+  switch (getTok().getKind()) {
+  default:
+return true;
+  case AsmToken::Percent: {
+int64_t Res;
+if (parseToken(AsmToken::Percent) || parseAbsoluteExpression(Res))
+  return true;
+Data = std::to_string(Res);
+return false;
+  }
+  case AsmToken::Less:
+  case AsmToken::LessEqual:
+  case AsmToken::LessLess:
+  case AsmToken::LessGreater:
+return parseAngleBracketString(Data);
+  case AsmToken::Identifier: {
+StringRef ID;
+if (parseIdentifier(ID))
+  return true;
+
+auto it = Variables.find(ID);
+if (it == Variables.end())
+  return true;
+
+const Variable &Var = it->second;
+if (!Var.IsText)
+  return true;
+Data = Var.TextValue;
+return false;
+  }
+  }
+  llvm_unreachable("unhandled token kind");
 }
 
 /// parseDirectiveAscii:
@@ -5503,11 +5534,13 @@ bool MasmParser::parseDirectiveMacro(StringRef Name, 
SMLoc NameLoc) {
 
 /// parseDirectiveExitMacro
 /// ::= "exitm" [textitem]
-bool MasmParser::parseDirectiveExitMacro(StringRef Directive,
+bool MasmParser::parseDirectiveExitMacro(SMLoc DirectiveLoc,
+ StringRef Directive,
  std::string &Value) {
-  if (getTok().isNot(AsmToken::EndOfStatement)) {
-parseTextItem(Value);
-  }
+  SMLoc EndLoc = getTok().getLoc();
+  if (getTok().isNot(AsmToken::EndOfStatement) && parseTextItem(Value))
+return Error(EndLoc,
+ "unable to parse text item in '" + Directive + "' directive");
   eatToEndOfStatement();
 
   if (!isInsideMacroInstantiation())
@@ -5740,7 +5773,7 @@ bool MasmParser::parseDirectiveIf(SMLoc DirectiveLoc, 
DirectiveKind DirKind) {
 }
 
 /// parseDirectiveIfb
-/// ::= .ifb string
+/// ::= .ifb textitem
 bool MasmParser::parseDirectiveIfb(SMLoc DirectiveLoc, bool ExpectBlank) {
   TheCondStack.push_back(TheCondState);
   TheCondState.TheCond = AsmCond::IfCond;
@@ -5750,7 +5783,7 @@ bool MasmParser::parseDirectiveIfb(SMLoc DirectiveLoc, 
bool ExpectBlank) {
   } else {
 std::string Str;
 if (parseTextItem(Str))
-  return TokError("expected string parameter for 'ifb' directive");
+  return TokError("expected text item parameter for 'ifb' directive");
 
 if (parseToken(AsmToken::EndOfStatement,
"unexpected token in 'ifb' directive"))
@@ -5764,14 +5797,15 @@ bool MasmParser::parseDirectiveIfb(SMLoc DirectiveLoc, 
bool ExpectBlank) {
 }
 
 /// parseDirectiveIfidn
-///   ::= ifidn string1, string2
-boo

[llvm-branch-commits] [libcxx] e5cc7ba - [libc++] NFC: Reindent non-lockfree-atomics feature

2020-11-25 Thread Louis Dionne via llvm-branch-commits

Author: Louis Dionne
Date: 2020-11-25T16:14:34-05:00
New Revision: e5cc7baf67dbd53d282bd9dff3f2241ca1d33f1d

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

LOG: [libc++] NFC: Reindent non-lockfree-atomics feature

Added: 


Modified: 
libcxx/utils/libcxx/test/features.py

Removed: 




diff  --git a/libcxx/utils/libcxx/test/features.py 
b/libcxx/utils/libcxx/test/features.py
index f78db66f49ad..2f9a048df345 100644
--- a/libcxx/utils/libcxx/test/features.py
+++ b/libcxx/utils/libcxx/test/features.py
@@ -41,12 +41,14 @@
  
sys.platform.lower().strip() == 'darwin'), # TODO: this doesn't handle 
cross-compiling to Apple platforms.
   Feature(name='objective-c++', when=lambda cfg: 
hasCompileFlag(cfg, '-xobjective-c++ -fobjc-arc')),
   Feature(name='modules-support',   when=lambda cfg: 
hasCompileFlag(cfg, '-fmodules')),
-  Feature(name='non-lockfree-atomics',  when=lambda cfg: 
sourceBuilds(cfg, """
-  #include 

-  struct Large 
{ int storage[100]; };
-  
std::atomic x;
-  int 
main(int, char**) { return x.load(), x.is_lock_free(); }
-""")),
+
+  Feature(name='non-lockfree-atomics',
+  when=lambda cfg: sourceBuilds(cfg, """
+#include 
+struct Large { int storage[100]; };
+std::atomic x;
+int main(int, char**) { return x.load(), x.is_lock_free(); }
+  """)),
 
   Feature(name='apple-clang',  
when=_isAppleClang),
   Feature(name=lambda cfg: 
'apple-clang-{__clang_major__}'.format(**compilerMacros(cfg)),  
when=_isAppleClang),



___
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] 175ebad - DebugInfo: remove unnecessary mtriple from test/DebugInfo/X86/abstract_origin.ll

2020-11-25 Thread David Blaikie via llvm-branch-commits

Author: David Blaikie
Date: 2020-11-25T13:34:15-08:00
New Revision: 175ebad958a0ebaf6c56c20ab30b9d4347742c29

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

LOG: DebugInfo: remove unnecessary mtriple from 
test/DebugInfo/X86/abstract_origin.ll

The test already specifies a triple in the IR itself.

Based on post-commit feedback from Luís Marques.

Added: 


Modified: 
llvm/test/DebugInfo/X86/abstract_origin.ll

Removed: 




diff  --git a/llvm/test/DebugInfo/X86/abstract_origin.ll 
b/llvm/test/DebugInfo/X86/abstract_origin.ll
index 4cf49055cbd8..a9eb970cfb62 100644
--- a/llvm/test/DebugInfo/X86/abstract_origin.ll
+++ b/llvm/test/DebugInfo/X86/abstract_origin.ll
@@ -1,4 +1,4 @@
-; RUN: llc -mtriple=x86_64 -filetype=obj %s -o - | llvm-dwarfdump -debug-info 
- | FileCheck %s
+; RUN: llc -filetype=obj %s -o - | llvm-dwarfdump -debug-info - | FileCheck %s
 ; Generated at -O2 from:
 ;   void f();
 ;   __attribute__((always_inline)) void g() {



___
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] 2d60429 - [SelectionDAGBuilder] Add SPF_NABS support to visitSelect

2020-11-25 Thread Craig Topper via llvm-branch-commits

Author: Craig Topper
Date: 2020-11-25T14:54:26-08:00
New Revision: 2d6042937b04eef00672b5c4ce623bf8f7b9a201

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

LOG: [SelectionDAGBuilder] Add SPF_NABS support to visitSelect

We currently don't match this which limits the effectiveness of D91120 until
InstCombine starts canonicalizing to llvm.abs. This should be easy to remove
if/when we remove the SPF_ABS handling.

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

Added: 


Modified: 
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
llvm/test/CodeGen/PowerPC/select.ll
llvm/test/CodeGen/RISCV/neg-abs.ll

Removed: 




diff  --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp 
b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index 959bb52cb223..ca4c2ca2a846 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -3131,6 +3131,7 @@ void SelectionDAGBuilder::visitSelect(const User &I) {
   Cond.getValueType().isVector() ? ISD::VSELECT : ISD::SELECT;
 
   bool IsUnaryAbs = false;
+  bool Negate = false;
 
   SDNodeFlags Flags;
   if (auto *FPOp = dyn_cast(&I))
@@ -3195,12 +3196,13 @@ void SelectionDAGBuilder::visitSelect(const User &I) {
 break;
   }
   break;
+case SPF_NABS:
+  Negate = true;
+  LLVM_FALLTHROUGH;
 case SPF_ABS:
   IsUnaryAbs = true;
   Opc = ISD::ABS;
   break;
-case SPF_NABS:
-  // TODO: we need to produce sub(0, abs(X)).
 default: break;
 }
 
@@ -3227,10 +3229,13 @@ void SelectionDAGBuilder::visitSelect(const User &I) {
 
   if (IsUnaryAbs) {
 for (unsigned i = 0; i != NumValues; ++i) {
+  SDLoc dl = getCurSDLoc();
+  EVT VT = LHSVal.getNode()->getValueType(LHSVal.getResNo() + i);
   Values[i] =
-  DAG.getNode(OpCode, getCurSDLoc(),
-  LHSVal.getNode()->getValueType(LHSVal.getResNo() + i),
-  SDValue(LHSVal.getNode(), LHSVal.getResNo() + i));
+  DAG.getNode(OpCode, dl, VT, LHSVal.getValue(LHSVal.getResNo() + i));
+  if (Negate)
+Values[i] = DAG.getNode(ISD::SUB, dl, VT, DAG.getConstant(0, dl, VT),
+Values[i]);
 }
   } else {
 for (unsigned i = 0; i != NumValues; ++i) {

diff  --git a/llvm/test/CodeGen/PowerPC/select.ll 
b/llvm/test/CodeGen/PowerPC/select.ll
index 1b53724079c7..bbbffe4d62cd 100644
--- a/llvm/test/CodeGen/PowerPC/select.ll
+++ b/llvm/test/CodeGen/PowerPC/select.ll
@@ -111,26 +111,18 @@ define i64 @f3(i64 %x, i64 %y) {
 define i64 @f4(i64 %x) {
 ; CHECK-LE-LABEL: f4:
 ; CHECK-LE:   # %bb.0:
-; CHECK-LE-NEXT:neg r4, r3
-; CHECK-LE-NEXT:cmpdi r3, 0
-; CHECK-LE-NEXT:iselgt r3, r4, r3
+; CHECK-LE-NEXT:sradi r4, r3, 63
+; CHECK-LE-NEXT:xor r3, r3, r4
+; CHECK-LE-NEXT:sub r3, r4, r3
 ; CHECK-LE-NEXT:blr
 ;
 ; CHECK-32-LABEL: f4:
 ; CHECK-32:   # %bb.0:
-; CHECK-32-NEXT:cmplwi r3, 0
-; CHECK-32-NEXT:cmpwi cr1, r3, 0
-; CHECK-32-NEXT:crandc 4*cr5+lt, 4*cr1+gt, eq
-; CHECK-32-NEXT:cmpwi cr1, r4, 0
-; CHECK-32-NEXT:subfic r5, r4, 0
-; CHECK-32-NEXT:crandc 4*cr5+gt, eq, 4*cr1+eq
-; CHECK-32-NEXT:cror 4*cr5+lt, 4*cr5+gt, 4*cr5+lt
-; CHECK-32-NEXT:subfze r6, r3
-; CHECK-32-NEXT:bc 12, 4*cr5+lt, .LBB4_1
-; CHECK-32-NEXT:blr
-; CHECK-32-NEXT:  .LBB4_1:
-; CHECK-32-NEXT:addi r3, r6, 0
-; CHECK-32-NEXT:addi r4, r5, 0
+; CHECK-32-NEXT:srawi r5, r3, 31
+; CHECK-32-NEXT:xor r4, r4, r5
+; CHECK-32-NEXT:xor r3, r3, r5
+; CHECK-32-NEXT:subc r4, r5, r4
+; CHECK-32-NEXT:subfe r3, r3, r5
 ; CHECK-32-NEXT:blr
   %c = icmp sgt i64 %x, 0
   %x.neg = sub i64 0, %x
@@ -166,20 +158,18 @@ define i64 @f4_sge_0(i64 %x) {
 define i64 @f4_slt_0(i64 %x) {
 ; CHECK-LE-LABEL: f4_slt_0:
 ; CHECK-LE:   # %bb.0:
-; CHECK-LE-NEXT:neg r4, r3
-; CHECK-LE-NEXT:cmpdi r3, 0
-; CHECK-LE-NEXT:isellt r3, r3, r4
+; CHECK-LE-NEXT:sradi r4, r3, 63
+; CHECK-LE-NEXT:xor r3, r3, r4
+; CHECK-LE-NEXT:sub r3, r4, r3
 ; CHECK-LE-NEXT:blr
 ;
 ; CHECK-32-LABEL: f4_slt_0:
 ; CHECK-32:   # %bb.0:
-; CHECK-32-NEXT:subfic r5, r4, 0
-; CHECK-32-NEXT:subfze r6, r3
-; CHECK-32-NEXT:cmpwi r3, 0
-; CHECK-32-NEXT:bclr 12, lt, 0
-; CHECK-32-NEXT:  # %bb.1:
-; CHECK-32-NEXT:ori r3, r6, 0
-; CHECK-32-NEXT:ori r4, r5, 0
+; CHECK-32-NEXT:srawi r5, r3, 31
+; CHECK-32-NEXT:xor r4, r4, r5
+; CHECK-32-NEXT:xor r3, r3, r5
+; CHECK-32-NEXT:subc r4, r5, r4
+; CHECK-32-NEXT:subfe r3, r3, r5
 ; CHECK-32-NEXT:blr
   %c = icmp slt i64 %x, 0
   %x.neg = sub i64 0, %x
@@ -219,21 +209,18 @@ define i64 @f4_sle_0(i64 %x) {
 define i64 @f4_sgt_m1(i64 %x) {
 ; CHECK

[llvm-branch-commits] [llvm] ed95caf - [RISCV] Add an implementation of isFMAFasterThanFMulAndFAdd

2020-11-25 Thread Craig Topper via llvm-branch-commits

Author: Craig Topper
Date: 2020-11-25T15:07:34-08:00
New Revision: ed95cafbc5fa9efbfe3f38da0b17efdb3806598c

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

LOG: [RISCV] Add an implementation of isFMAFasterThanFMulAndFAdd

Start with an assumption that FMA is faster than Fmul+FAdd. If thats not true
on some particular implementation we can add a tuning parameter in the future.

I've update the fmuladd test cases and added new test cases for fast math flag
based contraction.

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

Added: 


Modified: 
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
llvm/lib/Target/RISCV/RISCVISelLowering.h
llvm/test/CodeGen/RISCV/double-arith.ll
llvm/test/CodeGen/RISCV/double-intrinsics.ll
llvm/test/CodeGen/RISCV/float-arith.ll
llvm/test/CodeGen/RISCV/float-intrinsics.ll

Removed: 




diff  --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp 
b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index c182a34c0c9a..e855b77bfa64 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -3365,6 +3365,25 @@ Value 
*RISCVTargetLowering::emitMaskedAtomicCmpXchgIntrinsic(
   return Result;
 }
 
+bool RISCVTargetLowering::isFMAFasterThanFMulAndFAdd(const MachineFunction &MF,
+ EVT VT) const {
+  VT = VT.getScalarType();
+
+  if (!VT.isSimple())
+return false;
+
+  switch (VT.getSimpleVT().SimpleTy) {
+  case MVT::f32:
+return Subtarget.hasStdExtF();
+  case MVT::f64:
+return Subtarget.hasStdExtD();
+  default:
+break;
+  }
+
+  return false;
+}
+
 Register RISCVTargetLowering::getExceptionPointerRegister(
 const Constant *PersonalityFn) const {
   return RISCV::X10;

diff  --git a/llvm/lib/Target/RISCV/RISCVISelLowering.h 
b/llvm/lib/Target/RISCV/RISCVISelLowering.h
index 39aa360860bc..065b35874e84 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.h
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.h
@@ -146,6 +146,9 @@ class RISCVTargetLowering : public TargetLowering {
   Instruction *emitTrailingFence(IRBuilder<> &Builder, Instruction *Inst,
  AtomicOrdering Ord) const override;
 
+  bool isFMAFasterThanFMulAndFAdd(const MachineFunction &MF,
+  EVT VT) const override;
+
   ISD::NodeType getExtendForAtomicOps() const override {
 return ISD::SIGN_EXTEND;
   }

diff  --git a/llvm/test/CodeGen/RISCV/double-arith.ll 
b/llvm/test/CodeGen/RISCV/double-arith.ll
index 5f9d3501665e..e33d2e473658 100644
--- a/llvm/test/CodeGen/RISCV/double-arith.ll
+++ b/llvm/test/CodeGen/RISCV/double-arith.ll
@@ -644,3 +644,160 @@ define double @fnmsub_d_2(double %a, double %b, double 
%c) nounwind {
   %1 = call double @llvm.fma.f64(double %a, double %negb, double %c)
   ret double %1
 }
+
+define double @fmadd_d_contract(double %a, double %b, double %c) nounwind {
+; RV32IFD-LABEL: fmadd_d_contract:
+; RV32IFD:   # %bb.0:
+; RV32IFD-NEXT:addi sp, sp, -16
+; RV32IFD-NEXT:sw a4, 8(sp)
+; RV32IFD-NEXT:sw a5, 12(sp)
+; RV32IFD-NEXT:fld ft0, 8(sp)
+; RV32IFD-NEXT:sw a2, 8(sp)
+; RV32IFD-NEXT:sw a3, 12(sp)
+; RV32IFD-NEXT:fld ft1, 8(sp)
+; RV32IFD-NEXT:sw a0, 8(sp)
+; RV32IFD-NEXT:sw a1, 12(sp)
+; RV32IFD-NEXT:fld ft2, 8(sp)
+; RV32IFD-NEXT:fmadd.d ft0, ft2, ft1, ft0
+; RV32IFD-NEXT:fsd ft0, 8(sp)
+; RV32IFD-NEXT:lw a0, 8(sp)
+; RV32IFD-NEXT:lw a1, 12(sp)
+; RV32IFD-NEXT:addi sp, sp, 16
+; RV32IFD-NEXT:ret
+;
+; RV64IFD-LABEL: fmadd_d_contract:
+; RV64IFD:   # %bb.0:
+; RV64IFD-NEXT:fmv.d.x ft0, a2
+; RV64IFD-NEXT:fmv.d.x ft1, a1
+; RV64IFD-NEXT:fmv.d.x ft2, a0
+; RV64IFD-NEXT:fmadd.d ft0, ft2, ft1, ft0
+; RV64IFD-NEXT:fmv.x.d a0, ft0
+; RV64IFD-NEXT:ret
+  %1 = fmul contract double %a, %b
+  %2 = fadd contract double %1, %c
+  ret double %2
+}
+
+define double @fmsub_d_contract(double %a, double %b, double %c) nounwind {
+; RV32IFD-LABEL: fmsub_d_contract:
+; RV32IFD:   # %bb.0:
+; RV32IFD-NEXT:addi sp, sp, -16
+; RV32IFD-NEXT:sw a2, 8(sp)
+; RV32IFD-NEXT:sw a3, 12(sp)
+; RV32IFD-NEXT:fld ft0, 8(sp)
+; RV32IFD-NEXT:sw a0, 8(sp)
+; RV32IFD-NEXT:sw a1, 12(sp)
+; RV32IFD-NEXT:fld ft1, 8(sp)
+; RV32IFD-NEXT:sw a4, 8(sp)
+; RV32IFD-NEXT:sw a5, 12(sp)
+; RV32IFD-NEXT:fld ft2, 8(sp)
+; RV32IFD-NEXT:fcvt.d.w ft3, zero
+; RV32IFD-NEXT:fadd.d ft2, ft2, ft3
+; RV32IFD-NEXT:fmsub.d ft0, ft1, ft0, ft2
+; RV32IFD-NEXT:fsd ft0, 8(sp)
+; RV32IFD-NEXT:lw a0, 8(sp)
+; RV32IFD-NEXT:lw a1, 12(sp)
+; RV32IFD-NEXT:addi sp, sp, 16
+; RV32IFD-NEXT:ret
+;
+; RV64IFD-LABEL: fmsub_d_contract:
+; RV64IFD:   # %bb.0:
+; RV64IFD-NEXT:

[llvm-branch-commits] [mlir] 5488a6b - [NFC] Fix pattern name.

2020-11-25 Thread Sean Silva via llvm-branch-commits

Author: Sean Silva
Date: 2020-11-25T16:10:34-08:00
New Revision: 5488a6b0ffb1c34898db6bd50798be2472db93c8

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

LOG: [NFC] Fix pattern name.

It still had the old name from before ElementwiseMappable was added.

Added: 


Modified: 
mlir/lib/Dialect/Linalg/Transforms/ElementwiseToLinalg.cpp

Removed: 




diff  --git a/mlir/lib/Dialect/Linalg/Transforms/ElementwiseToLinalg.cpp 
b/mlir/lib/Dialect/Linalg/Transforms/ElementwiseToLinalg.cpp
index a0e5d74e1767..8ee1b389dee8 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/ElementwiseToLinalg.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/ElementwiseToLinalg.cpp
@@ -26,8 +26,8 @@ static bool isElementwiseMappableOpOnRankedTensors(Operation 
*op) {
 }
 
 namespace {
-struct ConvertStdElementwiseOpOnRankedTensors : public RewritePattern {
-  ConvertStdElementwiseOpOnRankedTensors()
+struct ConvertAnyElementwiseMappableOpOnRankedTensors : public RewritePattern {
+  ConvertAnyElementwiseMappableOpOnRankedTensors()
   : RewritePattern(/*benefit=*/1, MatchAnyOpTypeTag()) {}
   LogicalResult matchAndRewrite(Operation *op,
 PatternRewriter &rewriter) const final {
@@ -68,7 +68,7 @@ struct ConvertStdElementwiseOpOnRankedTensors : public 
RewritePattern {
 
 void mlir::populateElementwiseToLinalgConversionPatterns(
 OwningRewritePatternList &patterns, MLIRContext *) {
-  patterns.insert();
+  patterns.insert();
 }
 
 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] [compiler-rt] b534bea - Revert builtins fp16 support: tests do not pass on Mac

2020-11-25 Thread Reid Kleckner via llvm-branch-commits

Author: Reid Kleckner
Date: 2020-11-25T16:12:49-08:00
New Revision: b534beabeed3ba1777cd0ff9ce552d077e496726

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

LOG: Revert builtins fp16 support: tests do not pass on Mac

Revert "[compiler-rt] [builtins] Support conversion between fp16 and fp128" & 
dependency

Revert "[compiler-rt] [builtins] Use _Float16 on extendhfsf2, truncdfhf2 
__truncsfhf2 if available"

This reverts commit 7a948298813c913841a36ed0b460db0856fe7082.

This reverts commit 1fb91fcf9cfe849c7e9996597c491306e34e7abc.

Added: 


Modified: 
compiler-rt/cmake/builtin-config-ix.cmake
compiler-rt/lib/builtins/CMakeLists.txt
compiler-rt/lib/builtins/extendhfsf2.c
compiler-rt/lib/builtins/fp_extend.h
compiler-rt/lib/builtins/fp_trunc.h
compiler-rt/lib/builtins/truncdfhf2.c
compiler-rt/lib/builtins/truncsfhf2.c
compiler-rt/test/builtins/CMakeLists.txt
compiler-rt/test/builtins/Unit/extendhfsf2_test.c
compiler-rt/test/builtins/Unit/fp_test.h
compiler-rt/test/builtins/Unit/truncdfhf2_test.c
compiler-rt/test/builtins/Unit/truncsfhf2_test.c

Removed: 
compiler-rt/lib/builtins/extendhftf2.c
compiler-rt/lib/builtins/trunctfhf2.c
compiler-rt/test/builtins/Unit/extendhftf2_test.c
compiler-rt/test/builtins/Unit/trunctfhf2_test.c



diff  --git a/compiler-rt/cmake/builtin-config-ix.cmake 
b/compiler-rt/cmake/builtin-config-ix.cmake
index 8c6243a832cc..16d82b127878 100644
--- a/compiler-rt/cmake/builtin-config-ix.cmake
+++ b/compiler-rt/cmake/builtin-config-ix.cmake
@@ -22,13 +22,6 @@ int foo(int x, int y) {
 }
 ")
 
-builtin_check_c_compiler_source(COMPILER_RT_HAS_FLOAT16
-"
-_Float16 foo(_Float16 x) {
- return x;
-}
-"
-)
 
 set(ARM64 aarch64)
 set(ARM32 arm armhf armv6m armv7m armv7em armv7 armv7s armv7k)

diff  --git a/compiler-rt/lib/builtins/CMakeLists.txt 
b/compiler-rt/lib/builtins/CMakeLists.txt
index 8b70c1e82781..3c29bba612e1 100644
--- a/compiler-rt/lib/builtins/CMakeLists.txt
+++ b/compiler-rt/lib/builtins/CMakeLists.txt
@@ -179,7 +179,6 @@ set(GENERIC_TF_SOURCES
   divtc3.c
   divtf3.c
   extenddftf2.c
-  extendhftf2.c
   extendsftf2.c
   fixtfdi.c
   fixtfsi.c
@@ -198,7 +197,6 @@ set(GENERIC_TF_SOURCES
   powitf2.c
   subtf3.c
   trunctfdf2.c
-  trunctfhf2.c
   trunctfsf2.c
 )
 
@@ -630,8 +628,6 @@ if (APPLE)
 else ()
   set(BUILTIN_CFLAGS "")
 
-  append_list_if(COMPILER_RT_HAS_FLOAT16 -DCOMPILER_RT_HAS_FLOAT16 
BUILTIN_CFLAGS)
-
   append_list_if(COMPILER_RT_HAS_STD_C11_FLAG -std=c11 BUILTIN_CFLAGS)
 
   # These flags would normally be added to CMAKE_C_FLAGS by the llvm

diff  --git a/compiler-rt/lib/builtins/extendhfsf2.c 
b/compiler-rt/lib/builtins/extendhfsf2.c
index 0159ab09d3eb..7c1a76eb5851 100644
--- a/compiler-rt/lib/builtins/extendhfsf2.c
+++ b/compiler-rt/lib/builtins/extendhfsf2.c
@@ -12,15 +12,15 @@
 
 // Use a forwarding definition and noinline to implement a poor man's alias,
 // as there isn't a good cross-platform way of defining one.
-COMPILER_RT_ABI NOINLINE float __extendhfsf2(src_t a) {
+COMPILER_RT_ABI NOINLINE float __extendhfsf2(uint16_t a) {
   return __extendXfYf2__(a);
 }
 
-COMPILER_RT_ABI float __gnu_h2f_ieee(src_t a) { return __extendhfsf2(a); }
+COMPILER_RT_ABI float __gnu_h2f_ieee(uint16_t a) { return __extendhfsf2(a); }
 
 #if defined(__ARM_EABI__)
 #if defined(COMPILER_RT_ARMHF_TARGET)
-AEABI_RTABI float __aeabi_h2f(src_t a) { return __extendhfsf2(a); }
+AEABI_RTABI float __aeabi_h2f(uint16_t a) { return __extendhfsf2(a); }
 #else
 COMPILER_RT_ALIAS(__extendhfsf2, __aeabi_h2f)
 #endif

diff  --git a/compiler-rt/lib/builtins/extendhftf2.c 
b/compiler-rt/lib/builtins/extendhftf2.c
deleted file mode 100644
index aefe9737d34f..
--- a/compiler-rt/lib/builtins/extendhftf2.c
+++ /dev/null
@@ -1,23 +0,0 @@
-//===-- lib/extendhftf2.c - half -> quad conversion ---*- C 
-*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===--===//
-
-#define QUAD_PRECISION
-#include "fp_lib.h"
-
-#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT) && 
\
-defined(COMPILER_RT_HAS_FLOAT16)
-#define SRC_HALF
-#define DST_QUAD
-#include "fp_extend_impl.inc"
-
-COMPILER_RT_ABI long double __extendhftf2(_Float16 a) {
-  return __extendXfYf2__(a);
-}
-
-#endif

diff  --git a/compiler-rt/lib/builtins/fp_extend.h 
b/compiler-rt/lib/builtins/fp_extend.h
index aad4436730dd..fb512672e35e 100644
--- a/compiler-rt/lib/builtins/fp_extend.h
+++ b/compiler-rt/lib/builtins/fp_extend.h
@@ -40,11 +40,7 @@ static __inline int src_rep_t_clz(src_rep_t a

[llvm-branch-commits] [clang] 8ac7095 - [SemaTemplate] Stop passing insertion position around during VarTemplate instantiation

2020-11-25 Thread Tom Stellard via llvm-branch-commits

Author: Bruno Cardoso Lopes
Date: 2020-11-24T23:25:38-05:00
New Revision: 8ac709578067f77a7036fe50610277516fa36d50

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

LOG: [SemaTemplate] Stop passing insertion position around during VarTemplate 
instantiation

They can get stale at use time because of updates from other recursive
specializations. Instead, rely on the existence of previous declarations to add
the specialization.

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

(cherry picked from commit cffb0dd54d41d8e249d2009467c4beb5b681ba26)

Added: 


Modified: 
clang/include/clang/Sema/Sema.h
clang/include/clang/Sema/Template.h
clang/lib/Sema/SemaTemplate.cpp
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/test/SemaTemplate/instantiate-var-template.cpp

Removed: 




diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 6f7ad8076718..7a7722559397 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -9123,7 +9123,7 @@ class Sema final {
   const TemplateArgumentList &TemplateArgList,
   const TemplateArgumentListInfo &TemplateArgsInfo,
   SmallVectorImpl &Converted,
-  SourceLocation PointOfInstantiation, void *InsertPos,
+  SourceLocation PointOfInstantiation,
   LateInstantiatedAttrVec *LateAttrs = nullptr,
   LocalInstantiationScope *StartingScope = nullptr);
   VarTemplateSpecializationDecl *CompleteVarTemplateSpecializationDecl(

diff  --git a/clang/include/clang/Sema/Template.h 
b/clang/include/clang/Sema/Template.h
index 91d175fdd050..0dcaf565591b 100644
--- a/clang/include/clang/Sema/Template.h
+++ b/clang/include/clang/Sema/Template.h
@@ -600,7 +600,7 @@ enum class TemplateSubstitutionKind : char {
 TagDecl *NewDecl);
 
 Decl *VisitVarTemplateSpecializationDecl(
-VarTemplateDecl *VarTemplate, VarDecl *FromVar, void *InsertPos,
+VarTemplateDecl *VarTemplate, VarDecl *FromVar,
 const TemplateArgumentListInfo &TemplateArgsInfo,
 ArrayRef Converted,
 VarTemplateSpecializationDecl *PrevDecl = nullptr);

diff  --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index c05ed0b14e3e..ddae944a48f3 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -4471,7 +4471,7 @@ Sema::CheckVarTemplateId(VarTemplateDecl *Template, 
SourceLocation TemplateLoc,
   // FIXME: LateAttrs et al.?
   VarTemplateSpecializationDecl *Decl = BuildVarTemplateInstantiation(
   Template, InstantiationPattern, *InstantiationArgs, TemplateArgs,
-  Converted, TemplateNameLoc, InsertPos /*, LateAttrs, StartingScope*/);
+  Converted, TemplateNameLoc /*, LateAttrs, StartingScope*/);
   if (!Decl)
 return true;
 

diff  --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp 
b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index baec13ba627c..903785a2be42 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -3602,11 +3602,11 @@ Decl 
*TemplateDeclInstantiator::VisitVarTemplateSpecializationDecl(
 return nullptr;
 
   return VisitVarTemplateSpecializationDecl(
-  InstVarTemplate, D, InsertPos, VarTemplateArgsInfo, Converted, PrevDecl);
+  InstVarTemplate, D, VarTemplateArgsInfo, Converted, PrevDecl);
 }
 
 Decl *TemplateDeclInstantiator::VisitVarTemplateSpecializationDecl(
-VarTemplateDecl *VarTemplate, VarDecl *D, void *InsertPos,
+VarTemplateDecl *VarTemplate, VarDecl *D,
 const TemplateArgumentListInfo &TemplateArgsInfo,
 ArrayRef Converted,
 VarTemplateSpecializationDecl *PrevDecl) {
@@ -3629,8 +3629,11 @@ Decl 
*TemplateDeclInstantiator::VisitVarTemplateSpecializationDecl(
   SemaRef.Context, Owner, D->getInnerLocStart(), D->getLocation(),
   VarTemplate, DI->getType(), DI, D->getStorageClass(), Converted);
   Var->setTemplateArgsInfo(TemplateArgsInfo);
-  if (InsertPos)
+  if (!PrevDecl) {
+void *InsertPos = nullptr;
+VarTemplate->findSpecialization(Converted, InsertPos);
 VarTemplate->AddSpecialization(Var, InsertPos);
+  }
 
   if (SemaRef.getLangOpts().OpenCL)
 SemaRef.deduceOpenCLAddressSpace(Var);
@@ -4839,7 +4842,7 @@ VarTemplateSpecializationDecl 
*Sema::BuildVarTemplateInstantiation(
 const TemplateArgumentList &TemplateArgList,
 const TemplateArgumentListInfo &TemplateArgsInfo,
 SmallVectorImpl &Converted,
-SourceLocation PointOfInstantiation, void *InsertPos,
+SourceLocation PointOfInstantiation,
 LateInstantiatedAttrVec *LateAttrs,
 LocalInstantiationScope *StartingScope) {
   if (FromVar->isInvalidDecl())
@@ -4878,7 +4881,7 @@ VarTemplateSpecializationDecl 
*Sema::BuildVarTemplateInstantiation(

[llvm-branch-commits] [clang] 03565ff - [CMake][compiler-rt][libunwind] Compile assembly files as ASM not C, unify workarounds

2020-11-25 Thread Tom Stellard via llvm-branch-commits

Author: Raul Tambre
Date: 2020-11-25T19:14:42-05:00
New Revision: 03565ffd5da8370f5b89b69cd9868f32e2d75403

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

LOG: [CMake][compiler-rt][libunwind] Compile assembly files as ASM not C, unify 
workarounds

It isn't very wise to pass an assembly file to the compiler and tell it to 
compile as a C file and hope that the compiler recognizes it as assembly 
instead.
Simply don't mark the file as C and CMake will recognize the rest.

This was attempted earlier in https://reviews.llvm.org/D85706, but reverted due 
to architecture issues on Apple.
Subsequent digging revealed a similar change was done earlier for libunwind in 
https://reviews.llvm.org/rGb780df052dd2b246a760d00e00f7de9ebdab9d09.
Afterwards workarounds were added for MinGW and Apple:
* https://reviews.llvm.org/rGb780df052dd2b246a760d00e00f7de9ebdab9d09
* https://reviews.llvm.org/rGd4ded05ba851304b26a437896bc3962ef56f62cb

The workarounds in libunwind and compiler-rt are unified and comments added 
pointing to each other.
The workaround is updated to only be used for MinGW for CMake versions before 
3.17, which fixed the issue 
(https://gitlab.kitware.com/cmake/cmake/-/merge_requests/4287).

Additionally fixed Clang not being passed as the assembly compiler for 
compiler-rt runtime build.

Example error:
[525/634] Building C object 
lib/tsan/CMakeFiles/clang_rt.tsan-aarch64.dir/rtl/tsan_rtl_aarch64.S.o
FAILED: lib/tsan/CMakeFiles/clang_rt.tsan-aarch64.dir/rtl/tsan_rtl_aarch64.S.o
/opt/tooling/drive/host/bin/clang --target=aarch64-linux-gnu 
-I/opt/tooling/drive/llvm/compiler-rt/lib/tsan/.. -isystem 
/opt/tooling/drive/toolchain/opt/drive/toolchain/include -x c -Wall 
-Wno-unused-parameter -fno-lto -fPIC -fno-builtin -fno-exceptions 
-fomit-frame-pointer -funwind-tables -fno-stack-protector 
-fno-sanitize=safe-stack -fvisibility=hidden -fno-lto -O3 -gline-tables-only 
-Wno-gnu -Wno-variadic-macros -Wno-c99-extensions -Wno-non-virtual-dtor -fPIE 
-fno-rtti -Wframe-larger-than=530 -Wglobal-constructors --sysroot=. -MD -MT 
lib/tsan/CMakeFiles/clang_rt.tsan-aarch64.dir/rtl/tsan_rtl_aarch64.S.o -MF 
lib/tsan/CMakeFiles/clang_rt.tsan-aarch64.dir/rtl/tsan_rtl_aarch64.S.o.d -o 
lib/tsan/CMakeFiles/clang_rt.tsan-aarch64.dir/rtl/tsan_rtl_aarch64.S.o -c 
/opt/tooling/drive/llvm/compiler-rt/lib/tsan/rtl/tsan_rtl_aarch64.S
/opt/tooling/drive/llvm/compiler-rt/lib/tsan/rtl/tsan_rtl_aarch64.S:29:1: 
error: expected identifier or '('
.section .text
^
1 error generated.

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

(cherry picked from commit 45344cf7ac5b848f77825ffa37b0cb3b69b9b07b)

Added: 


Modified: 
clang/runtime/CMakeLists.txt
compiler-rt/cmake/Modules/AddCompilerRT.cmake
libunwind/src/CMakeLists.txt

Removed: 




diff  --git a/clang/runtime/CMakeLists.txt b/clang/runtime/CMakeLists.txt
index e20cc26f60af..61bbbf8faedd 100644
--- a/clang/runtime/CMakeLists.txt
+++ b/clang/runtime/CMakeLists.txt
@@ -75,6 +75,7 @@ if(LLVM_BUILD_EXTERNAL_COMPILER_RT AND EXISTS 
${COMPILER_RT_SRC_ROOT}/)
 CMAKE_ARGS ${CLANG_COMPILER_RT_CMAKE_ARGS}
-DCMAKE_C_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang
-DCMAKE_CXX_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang++
+   -DCMAKE_ASM_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
-DLLVM_CONFIG_PATH=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-config

diff  --git a/compiler-rt/cmake/Modules/AddCompilerRT.cmake 
b/compiler-rt/cmake/Modules/AddCompilerRT.cmake
index dab55707338a..7c127a93dfa7 100644
--- a/compiler-rt/cmake/Modules/AddCompilerRT.cmake
+++ b/compiler-rt/cmake/Modules/AddCompilerRT.cmake
@@ -109,11 +109,11 @@ endfunction()
 
 function(add_asm_sources output)
   set(${output} ${ARGN} PARENT_SCOPE)
-  # Xcode will try to compile asm files as C ('clang -x c'), and that will 
fail.
-  if (${CMAKE_GENERATOR} STREQUAL "Xcode")
-enable_language(ASM)
-  else()
-# Pass ASM file directly to the C++ compiler.
+  # CMake doesn't pass the correct architecture for Apple prior to CMake 3.19. 
https://gitlab.kitware.com/cmake/cmake/-/issues/20771
+  # MinGW didn't work correctly with assembly prior to CMake 3.17. 
https://gitlab.kitware.com/cmake/cmake/-/merge_requests/4287 and 
https://reviews.llvm.org/rGb780df052dd2b246a760d00e00f7de9ebdab9d09
+  # Workaround these two issues by compiling as C.
+  # Same workaround used in libunwind. Also update there if changed here.
+  if((APPLE AND CMAKE_VERSION VERSION_LESS 3.19) OR (MINGW AND CMAKE_VERSION 
VERSION_LESS 3.17))
 set_source_files_properties(${ARGN} PROPERTIES LANGUAGE C)
   endif()
 endfunction()

diff  --git a/libunwind/src

[llvm-branch-commits] [lld] 1363dfa - [CodeView] Avoid emitting empty debug globals subsection.

2020-11-25 Thread Amy Huang via llvm-branch-commits

Author: Amy Huang
Date: 2020-11-25T16:13:32-08:00
New Revision: 1363dfaf3105470e1724ed1f17c6d9c0713f442e

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

LOG: [CodeView] Avoid emitting empty debug globals subsection.

In https://reviews.llvm.org/D89072 I added static const data members
to the debug subsection for globals. It skipped emitting an S_CONSTANT if it
didn't have a value, which meant the subsection could be empty.

This patch fixes the empty subsection issue.

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

Added: 
lld/test/COFF/empty-subsection.s
llvm/test/DebugInfo/COFF/empty-globals-subsection.ll

Modified: 
lld/COFF/PDB.cpp
llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp

Removed: 




diff  --git a/lld/COFF/PDB.cpp b/lld/COFF/PDB.cpp
index 5e65eca5b9fe..36526de7796c 100644
--- a/lld/COFF/PDB.cpp
+++ b/lld/COFF/PDB.cpp
@@ -500,6 +500,9 @@ void PDBLinker::mergeSymbolRecords(TpiSource *source,
   cantFail(symData.readBytes(0, symData.getLength(), symsBuffer));
   SmallVector scopes;
 
+  if (symsBuffer.empty())
+warn("empty symbols subsection in " + file->getName());
+
   // Iterate every symbol to check if any need to be realigned, and if so, how
   // much space we need to allocate for them.
   bool needsRealignment = false;

diff  --git a/lld/test/COFF/empty-subsection.s 
b/lld/test/COFF/empty-subsection.s
new file mode 100644
index ..e573d5b57bdd
--- /dev/null
+++ b/lld/test/COFF/empty-subsection.s
@@ -0,0 +1,20 @@
+# REQUIRES: x86
+# RUN: llvm-mc -triple=x86_64-windows-msvc -filetype=obj -o %t.obj %s
+# RUN: lld-link /entry:main /debug /out:%t.exe %t.obj 2>&1 | FileCheck %s
+
+# CHECK: warning: empty symbols subsection
+
+.globl main
+.Lfunc_begin0:
+main:
+  xorl  %eax, %eax
+  retq
+.Lfunc_end0:
+
+.section .debug$S,"dr"
+   .p2align2
+   .long   4   # Debug section magic
+   .long   241 # Symbol subsection for globals
+  .long .Ltmp5-.Ltmp4   # Subsection size
+.Ltmp4:
+.Ltmp5:

diff  --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp 
b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
index 4d618cf3d687..b15e750aaf85 100644
--- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
@@ -2150,10 +2150,13 @@ void CodeViewDebug::collectMemberInfo(ClassInfo &Info,
   if (!DDTy->getName().empty()) {
 Info.Members.push_back({DDTy, 0});
 
-// Collect static const data members.
+// Collect static const data members with values.
 if ((DDTy->getFlags() & DINode::FlagStaticMember) ==
-DINode::FlagStaticMember)
-  StaticConstMembers.push_back(DDTy);
+DINode::FlagStaticMember) {
+  if (DDTy->getConstant() && (isa(DDTy->getConstant()) ||
+  isa(DDTy->getConstant(
+StaticConstMembers.push_back(DDTy);
+}
 
 return;
   }
@@ -3134,7 +3137,7 @@ void CodeViewDebug::emitStaticConstMemberList() {
  dyn_cast_or_null(DTy->getConstant()))
   Value = APSInt(CFP->getValueAPF().bitcastToAPInt(), true);
 else
-  continue;
+  llvm_unreachable("cannot emit a constant without a value");
 
 std::string QualifiedName = getFullyQualifiedName(Scope, DTy->getName());
 

diff  --git a/llvm/test/DebugInfo/COFF/empty-globals-subsection.ll 
b/llvm/test/DebugInfo/COFF/empty-globals-subsection.ll
new file mode 100644
index ..b6f3c9a752d0
--- /dev/null
+++ b/llvm/test/DebugInfo/COFF/empty-globals-subsection.ll
@@ -0,0 +1,29 @@
+; RUN: llc < %s | FileCheck %s
+
+; The debug info contains a struct with a non-const static member.
+; Check that we don't emit a symbol subsection for globals.
+
+; CHECK-NOT:  Symbol subsection for globals
+
+; ModuleID = 'a.cpp'
+source_filename = "a.cpp"
+target triple = "x86_64-pc-windows-msvc19.25.28614"
+
+define dso_local i32 @main() {
+entry:
+  ret i32 0
+}
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!8, !9}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, 
producer: "clang", isOptimized: false, runtimeVersion: 0, emissionKind: 
FullDebug, enums: !2, retainedTypes: !3, nameTableKind: None)
+!1 = !DIFile(filename: "a.cpp", directory: "C:/path/to/test", checksumkind: 
CSK_MD5, checksum: "a1dbf3aabea9e8f9d1be48f60287942f")
+!2 = !{}
+!3 = !{!4}
+!4 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "S", file: 
!1, line: 5, size: 32, flags: DIFlagTypePassByValue | DIFlagNonTrivial, 
elements: !5, identifier: ".?AU?$A@J@@")
+!5 = !{!6}
+!6 = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: !4, file: !1, line: 
6, baseType: !7, size: 32, flags: DIFlagStaticMember)
+!7 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_sig

[llvm-branch-commits] [llvm] e4500ba - [AArch64][GlobalISel] Handle rtcGPR64RegClassID in AArch64RegisterBankInfo::getRegBankFromRegClass()

2020-11-25 Thread Tom Stellard via llvm-branch-commits

Author: Raul Tambre
Date: 2020-11-25T19:18:04-05:00
New Revision: e4500bab8b29bdea2f4c51e8a143b8122491e6f5

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

LOG: [AArch64][GlobalISel] Handle rtcGPR64RegClassID in 
AArch64RegisterBankInfo::getRegBankFromRegClass()

TargetRegisterInfo::getMinimalPhysRegClass() returns rtcGPR64RegClassID for X16
and X17, as it's the last matching class. This in turn gets passed to
AArch64RegisterBankInfo::getRegBankFromRegClass(), which hits an unreachable.

It seems sensible to handle this case, so copies from X16 and X17 work.
Copying from X17 is used in inline assembly in libunwind for pointer
authentication.

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

(cherry picked from commit e887d0e89b837be37b4279735a9c1ac57e90c995)

Added: 


Modified: 
llvm/lib/Target/AArch64/GISel/AArch64RegisterBankInfo.cpp
llvm/test/CodeGen/AArch64/GlobalISel/regbankselect-default.mir

Removed: 




diff  --git a/llvm/lib/Target/AArch64/GISel/AArch64RegisterBankInfo.cpp 
b/llvm/lib/Target/AArch64/GISel/AArch64RegisterBankInfo.cpp
index 7e3ff1948dad..93213f5977e5 100644
--- a/llvm/lib/Target/AArch64/GISel/AArch64RegisterBankInfo.cpp
+++ b/llvm/lib/Target/AArch64/GISel/AArch64RegisterBankInfo.cpp
@@ -261,6 +261,7 @@ AArch64RegisterBankInfo::getRegBankFromRegClass(const 
TargetRegisterClass &RC,
   case AArch64::GPR64common_and_GPR64noipRegClassID:
   case AArch64::GPR64noip_and_tcGPR64RegClassID:
   case AArch64::tcGPR64RegClassID:
+  case AArch64::rtcGPR64RegClassID:
   case AArch64::WSeqPairsClassRegClassID:
   case AArch64::XSeqPairsClassRegClassID:
 return getRegBank(AArch64::GPRRegBankID);

diff  --git a/llvm/test/CodeGen/AArch64/GlobalISel/regbankselect-default.mir 
b/llvm/test/CodeGen/AArch64/GlobalISel/regbankselect-default.mir
index e226c0fbae7d..09884c75409e 100644
--- a/llvm/test/CodeGen/AArch64/GlobalISel/regbankselect-default.mir
+++ b/llvm/test/CodeGen/AArch64/GlobalISel/regbankselect-default.mir
@@ -75,6 +75,8 @@
 
   define void @test_gphi_ptr() { ret void }
 
+  define void @test_restricted_tail_call() { ret void }
+
 ...
 
 ---
@@ -888,3 +890,20 @@ body: |
 RET_ReallyLR implicit $x0
 
 ...
+
+---
+name:test_restricted_tail_call
+legalized:   true
+tracksRegLiveness: true
+body: |
+  bb.0:
+liveins: $x16, $x17
+; CHECK-LABEL: name: test_restricted_tail_call
+; CHECK: liveins: $x16, $x17
+; CHECK: [[COPY:%[0-9]+]]:gpr(s64) = COPY $x16
+; CHECK: [[COPY1:%[0-9]+]]:gpr(s64) = COPY $x17
+; CHECK: RET_ReallyLR
+%0:_(s64) = COPY $x16
+%1:_(s64) = COPY $x17
+RET_ReallyLR
+...



___
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] 3fb0879 - Refactor and simplify class scope name lookup.

2020-11-25 Thread Richard Smith via llvm-branch-commits

Author: Richard Smith
Date: 2020-11-25T16:25:33-08:00
New Revision: 3fb0879867d7039cb61ffb6287ac17ac949adfa9

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

LOG: Refactor and simplify class scope name lookup.

This is partly in preparation for an upcoming change that can change the
order in which DeclContext lookup results are presented.

In passing, fix some obvious errors where name lookup's notion of a
"static member function" missed static member function templates, and
where its notion of "same set of declarations" was confused by the same
declarations appearing in a different order.

Added: 


Modified: 
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
clang/include/clang/AST/DeclCXX.h
clang/include/clang/Sema/Sema.h
clang/lib/AST/CXXInheritance.cpp
clang/lib/Sema/SemaLookup.cpp
clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
clang/test/SemaCXX/lookup-member.cpp
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
index efc683c6c05d..ef8f54913ed9 100644
--- a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -611,12 +611,10 @@ static StyleKind findStyleKind(
 
 // If this method has the same name as any base method, this is likely
 // necessary even if it's not an override. e.g. CRTP.
-auto FindHidden = [&](const CXXBaseSpecifier *S, clang::CXXBasePath &P) {
-  return CXXRecordDecl::FindOrdinaryMember(S, P, Decl->getDeclName());
-};
-CXXBasePaths UnusedPaths;
-if (Decl->getParent()->lookupInBases(FindHidden, UnusedPaths))
-  return SK_Invalid;
+for (const CXXBaseSpecifier &Base : Decl->getParent()->bases())
+  if (const auto *RD = Base.getType()->getAsCXXRecordDecl())
+if (RD->hasMemberName(Decl->getDeclName()))
+  return SK_Invalid;
 
 if (Decl->isConstexpr() && NamingStyles[SK_ConstexprMethod])
   return SK_ConstexprMethod;

diff  --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index 36f42c06a300..568eeb614a76 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -1622,58 +1622,6 @@ class CXXRecordDecl : public RecordDecl {
CXXBasePath &Path,
const CXXRecordDecl *BaseRecord);
 
-  /// Base-class lookup callback that determines whether there exists
-  /// a tag with the given name.
-  ///
-  /// This callback can be used with \c lookupInBases() to find tag members
-  /// of the given name within a C++ class hierarchy.
-  static bool FindTagMember(const CXXBaseSpecifier *Specifier,
-CXXBasePath &Path, DeclarationName Name);
-
-  /// Base-class lookup callback that determines whether there exists
-  /// a member with the given name.
-  ///
-  /// This callback can be used with \c lookupInBases() to find members
-  /// of the given name within a C++ class hierarchy.
-  static bool FindOrdinaryMember(const CXXBaseSpecifier *Specifier,
- CXXBasePath &Path, DeclarationName Name);
-
-  /// Base-class lookup callback that determines whether there exists
-  /// a member with the given name.
-  ///
-  /// This callback can be used with \c lookupInBases() to find members
-  /// of the given name within a C++ class hierarchy, including dependent
-  /// classes.
-  static bool
-  FindOrdinaryMemberInDependentClasses(const CXXBaseSpecifier *Specifier,
-   CXXBasePath &Path, DeclarationName 
Name);
-
-  /// Base-class lookup callback that determines whether there exists
-  /// an OpenMP declare reduction member with the given name.
-  ///
-  /// This callback can be used with \c lookupInBases() to find members
-  /// of the given name within a C++ class hierarchy.
-  static bool FindOMPReductionMember(const CXXBaseSpecifier *Specifier,
- CXXBasePath &Path, DeclarationName Name);
-
-  /// Base-class lookup callback that determines whether there exists
-  /// an OpenMP declare mapper member with the given name.
-  ///
-  /// This callback can be used with \c lookupInBases() to find members
-  /// of the given name within a C++ class hierarchy.
-  static bool FindOMPMapperMember(const CXXBaseSpecifier *Specifier,
-  CXXBasePath &Path, DeclarationName Name);
-
-  /// Base-class lookup callback that determines whether there exists
-  /// a member with the given name that can be used in a nested-name-specifier.
-  /

[llvm-branch-commits] [clang] d8e8ae1 - Revert "[SemaTemplate] Stop passing insertion position around during VarTemplate instantiation"

2020-11-25 Thread Tom Stellard via llvm-branch-commits

Author: Tom Stellard
Date: 2020-11-25T16:38:08-08:00
New Revision: d8e8ae195a2581bea454317c4c4eabf0943d1e6d

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

LOG: Revert "[SemaTemplate] Stop passing insertion position around during 
VarTemplate instantiation"

This reverts commit 8ac709578067f77a7036fe50610277516fa36d50.

This commit changes the public API of clang, so it needs to be reworked.

Added: 


Modified: 
clang/include/clang/Sema/Sema.h
clang/include/clang/Sema/Template.h
clang/lib/Sema/SemaTemplate.cpp
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/test/SemaTemplate/instantiate-var-template.cpp

Removed: 




diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 7a7722559397..6f7ad8076718 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -9123,7 +9123,7 @@ class Sema final {
   const TemplateArgumentList &TemplateArgList,
   const TemplateArgumentListInfo &TemplateArgsInfo,
   SmallVectorImpl &Converted,
-  SourceLocation PointOfInstantiation,
+  SourceLocation PointOfInstantiation, void *InsertPos,
   LateInstantiatedAttrVec *LateAttrs = nullptr,
   LocalInstantiationScope *StartingScope = nullptr);
   VarTemplateSpecializationDecl *CompleteVarTemplateSpecializationDecl(

diff  --git a/clang/include/clang/Sema/Template.h 
b/clang/include/clang/Sema/Template.h
index 0dcaf565591b..91d175fdd050 100644
--- a/clang/include/clang/Sema/Template.h
+++ b/clang/include/clang/Sema/Template.h
@@ -600,7 +600,7 @@ enum class TemplateSubstitutionKind : char {
 TagDecl *NewDecl);
 
 Decl *VisitVarTemplateSpecializationDecl(
-VarTemplateDecl *VarTemplate, VarDecl *FromVar,
+VarTemplateDecl *VarTemplate, VarDecl *FromVar, void *InsertPos,
 const TemplateArgumentListInfo &TemplateArgsInfo,
 ArrayRef Converted,
 VarTemplateSpecializationDecl *PrevDecl = nullptr);

diff  --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index ddae944a48f3..c05ed0b14e3e 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -4471,7 +4471,7 @@ Sema::CheckVarTemplateId(VarTemplateDecl *Template, 
SourceLocation TemplateLoc,
   // FIXME: LateAttrs et al.?
   VarTemplateSpecializationDecl *Decl = BuildVarTemplateInstantiation(
   Template, InstantiationPattern, *InstantiationArgs, TemplateArgs,
-  Converted, TemplateNameLoc /*, LateAttrs, StartingScope*/);
+  Converted, TemplateNameLoc, InsertPos /*, LateAttrs, StartingScope*/);
   if (!Decl)
 return true;
 

diff  --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp 
b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 903785a2be42..baec13ba627c 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -3602,11 +3602,11 @@ Decl 
*TemplateDeclInstantiator::VisitVarTemplateSpecializationDecl(
 return nullptr;
 
   return VisitVarTemplateSpecializationDecl(
-  InstVarTemplate, D, VarTemplateArgsInfo, Converted, PrevDecl);
+  InstVarTemplate, D, InsertPos, VarTemplateArgsInfo, Converted, PrevDecl);
 }
 
 Decl *TemplateDeclInstantiator::VisitVarTemplateSpecializationDecl(
-VarTemplateDecl *VarTemplate, VarDecl *D,
+VarTemplateDecl *VarTemplate, VarDecl *D, void *InsertPos,
 const TemplateArgumentListInfo &TemplateArgsInfo,
 ArrayRef Converted,
 VarTemplateSpecializationDecl *PrevDecl) {
@@ -3629,11 +3629,8 @@ Decl 
*TemplateDeclInstantiator::VisitVarTemplateSpecializationDecl(
   SemaRef.Context, Owner, D->getInnerLocStart(), D->getLocation(),
   VarTemplate, DI->getType(), DI, D->getStorageClass(), Converted);
   Var->setTemplateArgsInfo(TemplateArgsInfo);
-  if (!PrevDecl) {
-void *InsertPos = nullptr;
-VarTemplate->findSpecialization(Converted, InsertPos);
+  if (InsertPos)
 VarTemplate->AddSpecialization(Var, InsertPos);
-  }
 
   if (SemaRef.getLangOpts().OpenCL)
 SemaRef.deduceOpenCLAddressSpace(Var);
@@ -4842,7 +4839,7 @@ VarTemplateSpecializationDecl 
*Sema::BuildVarTemplateInstantiation(
 const TemplateArgumentList &TemplateArgList,
 const TemplateArgumentListInfo &TemplateArgsInfo,
 SmallVectorImpl &Converted,
-SourceLocation PointOfInstantiation,
+SourceLocation PointOfInstantiation, void *InsertPos,
 LateInstantiatedAttrVec *LateAttrs,
 LocalInstantiationScope *StartingScope) {
   if (FromVar->isInvalidDecl())
@@ -4881,7 +4878,7 @@ VarTemplateSpecializationDecl 
*Sema::BuildVarTemplateInstantiation(
 
   return cast_or_null(
   Instantiator.VisitVarTemplateSpecializationDecl(
-  VarTemplate, FromVar, TemplateArgsInfo, Converted));
+  V

[llvm-branch-commits] [llvm] 75f50e1 - Adding PoisonValue for representing poison value explicitly in IR

2020-11-25 Thread Zhengyang Liu via llvm-branch-commits

Author: Zhengyang Liu
Date: 2020-11-25T17:33:51-07:00
New Revision: 75f50e15bf8fff6fba1d4678adedd33ef6a945e5

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

LOG: Adding PoisonValue for representing poison value explicitly in IR

Define ConstantData::PoisonValue.
Add support for poison value to LLLexer/LLParser/BitcodeReader/BitcodeWriter.
Add support for poison value to llvm-c interface.
Add support for poison value to OCaml binding.
Add m_Poison in PatternMatch.

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

Added: 
llvm/test/CodeGen/X86/poison-ops.ll

Modified: 
llvm/bindings/ocaml/llvm/llvm.ml
llvm/bindings/ocaml/llvm/llvm.mli
llvm/bindings/ocaml/llvm/llvm_ocaml.c
llvm/include/llvm-c/Core.h
llvm/include/llvm/Bitcode/LLVMBitCodes.h
llvm/include/llvm/IR/Constants.h
llvm/include/llvm/IR/PatternMatch.h
llvm/include/llvm/IR/Value.def
llvm/lib/AsmParser/LLLexer.cpp
llvm/lib/AsmParser/LLParser.cpp
llvm/lib/AsmParser/LLParser.h
llvm/lib/AsmParser/LLToken.h
llvm/lib/Bitcode/Reader/BitcodeReader.cpp
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
llvm/lib/IR/AsmWriter.cpp
llvm/lib/IR/Constants.cpp
llvm/lib/IR/Core.cpp
llvm/lib/IR/LLVMContextImpl.h
llvm/test/Bindings/OCaml/core.ml
llvm/test/Bitcode/compatibility.ll
llvm/tools/llvm-c-test/echo.cpp

Removed: 




diff  --git a/llvm/bindings/ocaml/llvm/llvm.ml 
b/llvm/bindings/ocaml/llvm/llvm.ml
index fdef6eb176d6..723ac66ffd05 100644
--- a/llvm/bindings/ocaml/llvm/llvm.ml
+++ b/llvm/bindings/ocaml/llvm/llvm.ml
@@ -314,6 +314,7 @@ module ValueKind = struct
   | GlobalIFunc
   | GlobalVariable
   | UndefValue
+  | PoisonValue
   | Instruction of Opcode.t
 end
 
@@ -547,8 +548,10 @@ external const_null : lltype -> llvalue = "LLVMConstNull"
 external const_all_ones : (*int|vec*)lltype -> llvalue = "LLVMConstAllOnes"
 external const_pointer_null : lltype -> llvalue = "LLVMConstPointerNull"
 external undef : lltype -> llvalue = "LLVMGetUndef"
+external poison : lltype -> llvalue = "LLVMGetPoison"
 external is_null : llvalue -> bool = "llvm_is_null"
 external is_undef : llvalue -> bool = "llvm_is_undef"
+external is_poison : llvalue -> bool = "llvm_is_poison"
 external constexpr_opcode : llvalue -> Opcode.t = "llvm_constexpr_get_opcode"
 
 (*--... Operations on instructions 
.--*)

diff  --git a/llvm/bindings/ocaml/llvm/llvm.mli 
b/llvm/bindings/ocaml/llvm/llvm.mli
index 04e27438a479..ba9e6c1f2120 100644
--- a/llvm/bindings/ocaml/llvm/llvm.mli
+++ b/llvm/bindings/ocaml/llvm/llvm.mli
@@ -347,6 +347,7 @@ module ValueKind : sig
   | GlobalIFunc
   | GlobalVariable
   | UndefValue
+  | PoisonValue
   | Instruction of Opcode.t
 end
 
@@ -842,6 +843,10 @@ val const_pointer_null : lltype -> llvalue
 See the method [llvm::UndefValue::get]. *)
 val undef : lltype -> llvalue
 
+(** [poison ty] returns the poison value of the type [ty].
+See the method [llvm::PoisonValue::get]. *)
+val poison : lltype -> llvalue
+
 (** [is_null v] returns [true] if the value [v] is the null (zero) value.
 See the method [llvm::Constant::isNullValue]. *)
 val is_null : llvalue -> bool
@@ -850,6 +855,10 @@ val is_null : llvalue -> bool
 otherwise. Similar to [llvm::isa]. *)
 val is_undef : llvalue -> bool
 
+(** [is_poison v] returns [true] if the value [v] is a poison value, [false]
+otherwise. Similar to [llvm::isa]. *)
+val is_poison : llvalue -> bool
+
 (** [constexpr_opcode v] returns an [Opcode.t] corresponding to constexpr
 value [v], or [Opcode.Invalid] if [v] is not a constexpr. *)
 val constexpr_opcode : llvalue -> Opcode.t

diff  --git a/llvm/bindings/ocaml/llvm/llvm_ocaml.c 
b/llvm/bindings/ocaml/llvm/llvm_ocaml.c
index 1552abf29c03..5845783278d9 100644
--- a/llvm/bindings/ocaml/llvm/llvm_ocaml.c
+++ b/llvm/bindings/ocaml/llvm/llvm_ocaml.c
@@ -627,6 +627,7 @@ enum ValueKind {
   GlobalIFunc,
   GlobalVariable,
   UndefValue,
+  PoisonValue,
   Instruction
 };
 
@@ -669,6 +670,7 @@ CAMLprim value llvm_classify_value(LLVMValueRef Val) {
   DEFINE_CASE(Val, MDNode);
   DEFINE_CASE(Val, MDString);
   DEFINE_CASE(Val, UndefValue);
+  DEFINE_CASE(Val, PoisonValue);
   failwith("Unknown Value class");
 }
 
@@ -762,6 +764,11 @@ CAMLprim value llvm_is_undef(LLVMValueRef Val) {
   return Val_bool(LLVMIsUndef(Val));
 }
 
+/* llvalue -> bool */
+CAMLprim value llvm_is_poison(LLVMValueRef Val) {
+  return Val_bool(LLVMIsPoison(Val));
+}
+
 /* llvalue -> Opcode.t */
 CAMLprim value llvm_constexpr_get_opcode(LLVMValueRef Val) {
   return LLVMIsAConstantExpr(Val) ?

diff  --git a/llvm/include/llvm-c/Core.h b/llvm/include/llvm-c/Core.h
index e95038724276..1803c38b445d 100644
--- a/llvm/include/llvm-c/Core.h
+++ b/llvm/include/llvm-

[llvm-branch-commits] [clang] 7c327db - Part of C++ DR 39: a class member lookup is not ambiguous if it finds the

2020-11-25 Thread Richard Smith via llvm-branch-commits

Author: Richard Smith
Date: 2020-11-25T17:03:11-08:00
New Revision: 7c327db3ef73d771bc022d0723672fc356dc9017

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

LOG: Part of C++ DR 39: a class member lookup is not ambiguous if it finds the
same type in multiple base classes.

Not even if the type is introduced by distinct declarations (for
example, two typedef declarations, or a typedef and a class definition).

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaLookup.cpp
clang/test/CXX/drs/dr3xx.cpp
clang/test/CXX/temp/temp.res/temp.local/p3.cpp
clang/test/SemaCXX/member-name-lookup.cpp
clang/test/SemaTemplate/dependent-base-classes.cpp
clang/test/SemaTemplate/ms-lookup-template-base-classes.cpp
clang/test/SemaTemplate/temp.cpp
clang/test/SemaTemplate/typename-specifier-4.cpp
clang/www/cxx_dr_status.html

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 2e479307ce22..f2b2b1d3ab6f 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -8640,6 +8640,8 @@ def err_ambiguous_member_multiple_subobjects : Error<
 def err_ambiguous_member_multiple_subobject_types : Error<
   "member %0 found in multiple base classes of 
diff erent types">;
 def note_ambiguous_member_found : Note<"member found by ambiguous name 
lookup">;
+def note_ambiguous_member_type_found : Note<
+  "member type %0 found by ambiguous name lookup">;
 def err_ambiguous_reference : Error<"reference to %0 is ambiguous">;
 def note_ambiguous_candidate : Note<"candidate found by name lookup is %q0">;
 def err_ambiguous_tag_hiding : Error<"a type named %0 is hidden by a "

diff  --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp
index 9a1312af42eb..16dd8f510596 100644
--- a/clang/lib/Sema/SemaLookup.cpp
+++ b/clang/lib/Sema/SemaLookup.cpp
@@ -2228,11 +2228,10 @@ bool Sema::LookupQualifiedName(LookupResult &R, 
DeclContext *LookupCtx,
 
   // Determine whether two sets of members contain the same members, as
   // required by C++ [class.member.lookup]p6.
-  auto HasSameDeclarations = [IDNS,
-  TemplateNameLookup](DeclContextLookupResult A,
-  DeclContextLookupResult B) {
+  auto HasSameDeclarations = [&](DeclContextLookupResult A,
+ DeclContextLookupResult B) {
 using Iterator = DeclContextLookupResult::iterator;
-using Result = const Decl *;
+using Result = const void *;
 
 auto Next = [&](Iterator &It, Iterator End) -> Result {
   while (It != End) {
@@ -2252,14 +2251,15 @@ bool Sema::LookupQualifiedName(LookupResult &R, 
DeclContext *LookupCtx,
   if (auto *TD = getAsTemplateNameDecl(ND))
 ND = TD;
 
-// FIXME: Per C++ [class.member.lookup]p3:
-//   type declarations (including injected-class-names are replaced by 
the
-//   types they designate
-// So two 
diff erent typedef declarations with the same name from two
-// 
diff erent base classes declaring the same type do not introduce an
-// ambiguity.
+// C++ [class.member.lookup]p3:
+//   type declarations (including injected-class-names) are replaced by
+//   the types they designate
+if (const TypeDecl *TD = dyn_cast(ND->getUnderlyingDecl())) {
+  QualType T = Context.getTypeDeclType(TD);
+  return T.getCanonicalType().getAsOpaquePtr();
+}
 
-return cast(ND->getUnderlyingDecl()->getCanonicalDecl());
+return ND->getUnderlyingDecl()->getCanonicalDecl();
   }
   return nullptr;
 };
@@ -2509,13 +2509,23 @@ void Sema::DiagnoseAmbiguousLookup(LookupResult 
&Result) {
   << Name << LookupRange;
 
 CXXBasePaths *Paths = Result.getBasePaths();
-std::set DeclsPrinted;
+std::set DeclsPrinted;
 for (CXXBasePaths::paths_iterator Path = Paths->begin(),
   PathEnd = Paths->end();
  Path != PathEnd; ++Path) {
-  Decl *D = Path->Decls.front();
-  if (DeclsPrinted.insert(D).second)
-Diag(D->getLocation(), diag::note_ambiguous_member_found);
+  const NamedDecl *D = Path->Decls.front();
+  if (!D->isInIdentifierNamespace(Result.getIdentifierNamespace()))
+continue;
+  if (DeclsPrinted.insert(D).second) {
+if (const auto *TD = dyn_cast(D->getUnderlyingDecl()))
+  Diag(D->getLocation(), diag::note_ambiguous_member_type_found)
+  << TD->getUnderlyingType();
+else if (const auto *TD = dyn_cast(D->getUnderlyingDecl()))
+  Diag(D->getLoc

[llvm-branch-commits] [lld] da0aaed - [gn build] (manually) port b534beabeed3ba

2020-11-25 Thread Nico Weber via llvm-branch-commits

Author: Nico Weber
Date: 2020-11-25T20:19:46-05:00
New Revision: da0aaedcd0cd7053fa38d56aca26fd035a7fe75c

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

LOG: [gn build] (manually) port b534beabeed3ba

Added: 


Modified: 
lld/COFF/InputFiles.h
llvm/utils/gn/secondary/compiler-rt/lib/builtins/BUILD.gn

Removed: 




diff  --git a/lld/COFF/InputFiles.h b/lld/COFF/InputFiles.h
index f657d8f0a808..3fa6819157a9 100644
--- a/lld/COFF/InputFiles.h
+++ b/lld/COFF/InputFiles.h
@@ -358,7 +358,7 @@ class ImportFile : public InputFile {
   const coff_import_header *hdr;
   Chunk *location = nullptr;
 
-  // We want to eliminate dllimported symbols if no one actually refers them.
+  // We want to eliminate dllimported symbols if no one actually refers to 
them.
   // These "Live" bits are used to keep track of which import library members
   // are actually in use.
   //

diff  --git a/llvm/utils/gn/secondary/compiler-rt/lib/builtins/BUILD.gn 
b/llvm/utils/gn/secondary/compiler-rt/lib/builtins/BUILD.gn
index e7b532f57dab..0292479ecd66 100644
--- a/llvm/utils/gn/secondary/compiler-rt/lib/builtins/BUILD.gn
+++ b/llvm/utils/gn/secondary/compiler-rt/lib/builtins/BUILD.gn
@@ -197,7 +197,6 @@ static_library("builtins") {
 sources += [
   "comparetf2.c",
   "extenddftf2.c",
-  "extendhftf2.c",
   "extendsftf2.c",
   "fixtfdi.c",
   "fixtfsi.c",
@@ -213,7 +212,6 @@ static_library("builtins") {
   "floatuntitf.c",
   "multc3.c",
   "trunctfdf2.c",
-  "trunctfhf2.c",
   "trunctfsf2.c",
 ]
   }



___
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] d5f0d0c - [mlir][sparse] add ability to select pointer/index storage type

2020-11-25 Thread Aart Bik via llvm-branch-commits

Author: Aart Bik
Date: 2020-11-25T17:32:44-08:00
New Revision: d5f0d0c0c4117295d9e76bbafaf0597e01ef3c99

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

LOG: [mlir][sparse] add ability to select pointer/index storage type

This change gives sparse compiler clients more control over selecting
individual types for the pointers and indices in the sparse storage schemes.
Narrower width obviously results in smaller memory footprints, but the
range should always suffice for the maximum number of entries or index value.

Reviewed By: penpornk

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

Added: 
mlir/test/Dialect/Linalg/sparse_storage.mlir

Modified: 
mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
mlir/lib/Dialect/Linalg/Transforms/Sparsification.cpp
mlir/test/lib/Transforms/TestSparsification.cpp

Removed: 




diff  --git a/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h 
b/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
index 7a96a5ed1390..b37a14f0eb7a 100644
--- a/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
+++ b/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
@@ -821,18 +821,31 @@ enum class SparseVectorizationStrategy {
   kAnyStorageInnerLoop
 };
 
+/// Defines a type for "pointer" and "index" storage in the sparse storage
+/// scheme, with a choice between the native platform-dependent index width,
+/// 64-bit integers, or 32-bit integers. A narrow width obviously reduces
+/// the memory footprint of the sparse storage scheme, but the width should
+/// suffice to define the total required range (viz. the maximum number of
+/// stored entries per indirection level for the "pointers" and the maximum
+/// value of each tensor index over all dimensions for the "indices").
+enum class SparseIntType { kNative, kI64, kI32 };
+
 /// Sparsification options.
 struct SparsificationOptions {
   SparsificationOptions(SparseParallelizationStrategy p,
-SparseVectorizationStrategy v, unsigned vl)
-  : parallelizationStrategy(p), vectorizationStrategy(v), vectorLength(vl) 
{
-  }
+SparseVectorizationStrategy v, unsigned vl,
+SparseIntType pt, SparseIntType it)
+  : parallelizationStrategy(p), vectorizationStrategy(v), vectorLength(vl),
+ptrType(pt), indType(it) {}
   SparsificationOptions()
   : SparsificationOptions(SparseParallelizationStrategy::kNone,
-  SparseVectorizationStrategy::kNone, 1u) {}
+  SparseVectorizationStrategy::kNone, 1u,
+  SparseIntType::kNative, SparseIntType::kNative) 
{}
   SparseParallelizationStrategy parallelizationStrategy;
   SparseVectorizationStrategy vectorizationStrategy;
   unsigned vectorLength;
+  SparseIntType ptrType;
+  SparseIntType indType;
 };
 
 /// Set up sparsification rewriting rules with the given options.

diff  --git a/mlir/lib/Dialect/Linalg/Transforms/Sparsification.cpp 
b/mlir/lib/Dialect/Linalg/Transforms/Sparsification.cpp
index 729268393ed9..07a3e1569622 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/Sparsification.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Sparsification.cpp
@@ -420,16 +420,27 @@ static unsigned buildLattices(Merger &merger, 
linalg::GenericOp op,
   }
 }
 
+/// Maps sparse integer option to actual integral storage type.
+static Type genIntType(PatternRewriter &rewriter, linalg::SparseIntType tp) {
+  switch (tp) {
+  case linalg::SparseIntType::kNative:
+return rewriter.getIndexType();
+  case linalg::SparseIntType::kI64:
+return rewriter.getIntegerType(64);
+  case linalg::SparseIntType::kI32:
+return rewriter.getIntegerType(32);
+  }
+}
+
 /// Local bufferization of all dense and sparse data structures.
 /// This code enables testing the first prototype sparse compiler.
 // TODO: replace this with a proliferated bufferization strategy
-void genBuffers(Merger &merger, CodeGen &codegen, PatternRewriter &rewriter,
-linalg::GenericOp op) {
+static void genBuffers(Merger &merger, CodeGen &codegen,
+   PatternRewriter &rewriter, linalg::GenericOp op) {
   Location loc = op.getLoc();
   unsigned numTensors = op.getNumInputsAndOutputs();
   unsigned numInputs = op.getNumInputs();
   assert(numTensors == numInputs + 1);
-  Type indexType = rewriter.getIndexType();
 
   // For now, set all unknown dimensions to 999.
   // TODO: compute these values (using sparsity or by reading tensor)
@@ -450,9 +461,13 @@ void genBuffers(Merger &merger, CodeGen &codegen, 
PatternRewriter &rewriter,
   // Handle sparse storage schemes.
   if (merger.isSparseAccess(t, i)) {
 allDense = false;
-auto dynTp = MemRefType::get({ShapedT

[llvm-branch-commits] [clang-tools-extra] c6cb47b - [clangd] Collect main file refs by default

2020-11-25 Thread Nathan Ridge via llvm-branch-commits

Author: Nathan Ridge
Date: 2020-11-25T20:33:57-05:00
New Revision: c6cb47b640ffafda113581c488a73fb62b6ea38a

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

LOG: [clangd] Collect main file refs by default

This is needed for call hierarchy to be able to find callers of
main-file-only functions.

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

Added: 


Modified: 
clang-tools-extra/clangd/ClangdServer.h
clang-tools-extra/clangd/tool/ClangdMain.cpp
clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/ClangdServer.h 
b/clang-tools-extra/clangd/ClangdServer.h
index b6a1bd757894..35ba4686cc9a 100644
--- a/clang-tools-extra/clangd/ClangdServer.h
+++ b/clang-tools-extra/clangd/ClangdServer.h
@@ -106,7 +106,7 @@ class ClangdServer {
 bool BackgroundIndex = false;
 
 /// Store refs to main-file symbols in the index.
-bool CollectMainFileRefs = false;
+bool CollectMainFileRefs = true;
 
 /// If set, use this index to augment code completion results.
 SymbolIndex *StaticIndex = nullptr;

diff  --git a/clang-tools-extra/clangd/tool/ClangdMain.cpp 
b/clang-tools-extra/clangd/tool/ClangdMain.cpp
index 5c89e423cde4..d0eab3650750 100644
--- a/clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ b/clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -494,7 +494,7 @@ opt CollectMainFileRefs{
 "collect-main-file-refs",
 cat(Misc),
 desc("Store references to main-file-only symbols in the index"),
-init(false),
+init(ClangdServer::Options().CollectMainFileRefs),
 };
 
 #if CLANGD_ENABLE_REMOTE

diff  --git a/clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp 
b/clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
index b25d3fde0002..f4a9b2fa2d13 100644
--- a/clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
+++ b/clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
@@ -188,8 +188,10 @@ TEST_F(BackgroundIndexTest, IndexTwoFiles) {
   size_t CacheHits = 0;
   MemoryShardStorage MSS(Storage, CacheHits);
   OverlayCDB CDB(/*Base=*/nullptr);
-  BackgroundIndex Idx(FS, CDB, [&](llvm::StringRef) { return &MSS; },
-  /*Opts=*/{});
+  BackgroundIndex::Options Opts;
+  Opts.CollectMainFileRefs = true;
+  BackgroundIndex Idx(
+  FS, CDB, [&](llvm::StringRef) { return &MSS; }, Opts);
 
   tooling::CompileCommand Cmd;
   Cmd.Filename = testPath("root/A.cc");
@@ -201,7 +203,7 @@ TEST_F(BackgroundIndexTest, IndexTwoFiles) {
   EXPECT_THAT(runFuzzyFind(Idx, ""),
   UnorderedElementsAre(AllOf(Named("common"), NumReferences(1U)),
AllOf(Named("A_CC"), NumReferences(0U)),
-   AllOf(Named("g"), NumReferences(0U)),
+   AllOf(Named("g"), NumReferences(1U)),
AllOf(Named("f_b"), Declared(),
  Not(Defined()), NumReferences(0U;
 
@@ -214,7 +216,7 @@ TEST_F(BackgroundIndexTest, IndexTwoFiles) {
   EXPECT_THAT(runFuzzyFind(Idx, ""),
   UnorderedElementsAre(AllOf(Named("common"), NumReferences(5U)),
AllOf(Named("A_CC"), NumReferences(0U)),
-   AllOf(Named("g"), NumReferences(0U)),
+   AllOf(Named("g"), NumReferences(1U)),
AllOf(Named("f_b"), Declared(), Defined(),
  NumReferences(1U;
 
@@ -238,7 +240,8 @@ TEST_F(BackgroundIndexTest, MainFileRefs) {
   FS.Files[testPath("root/A.cc")] =
   "#include \"A.h\"\nstatic void main_sym() { (void)header_sym; }";
 
-  // Check the behaviour with CollectMainFileRefs = false (the default).
+  // Check the behaviour with CollectMainFileRefs = false (the default
+  // at the SymbolCollector level).
   {
 llvm::StringMap Storage;
 size_t CacheHits = 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] 48d1017 - [gn build] sync script: handle multiple source lists if only deleting

2020-11-25 Thread Nico Weber via llvm-branch-commits

Author: Nico Weber
Date: 2020-11-25T20:57:55-05:00
New Revision: 48d10172453511b549dfb3b46c717c60dc9786f1

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

LOG: [gn build] sync script: handle multiple source lists if only deleting

With this, changes like b534beabeed3ba can be merged automatically.

Added: 


Modified: 
llvm/utils/gn/build/sync_source_lists_from_cmake.py

Removed: 




diff  --git a/llvm/utils/gn/build/sync_source_lists_from_cmake.py 
b/llvm/utils/gn/build/sync_source_lists_from_cmake.py
index ae65b50b1b55..bb57d49179ea 100755
--- a/llvm/utils/gn/build/sync_source_lists_from_cmake.py
+++ b/llvm/utils/gn/build/sync_source_lists_from_cmake.py
@@ -34,15 +34,16 @@ def patch_gn_file(gn_file, add, remove):
 tokloc = gn_contents.find(srcs_tok, tokloc + 1)
 
 if tokloc == -1: raise ValueError(gn_file + ': Failed to find source list')
-if gn_contents.find(srcs_tok, tokloc + 1) != -1:
-raise ValueError(gn_file + ': Multiple source lists')
-if gn_contents.find('# NOSORT', 0, tokloc) != -1:
-raise ValueError(gn_file + ': Found # NOSORT, needs manual merge')
-
-tokloc += len(srcs_tok)
-for a in add:
-gn_contents = (gn_contents[:tokloc] + ('"%s",' % a) +
-   gn_contents[tokloc:])
+if add:
+if gn_contents.find(srcs_tok, tokloc + 1) != -1:
+raise ValueError(gn_file + ': Multiple source lists')
+if gn_contents.find('# NOSORT', 0, tokloc) != -1:
+raise ValueError(gn_file + ': Found # NOSORT, needs manual merge')
+
+tokloc += len(srcs_tok)
+for a in add:
+gn_contents = (gn_contents[:tokloc] + ('"%s",' % a) +
+   gn_contents[tokloc:])
 for r in remove:
 gn_contents = gn_contents.replace('"%s",' % r, '')
 with open(gn_file, 'w') as f:



___
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] 12c2646 - [gn build] sync script: only compute tokloc when adding files

2020-11-25 Thread Nico Weber via llvm-branch-commits

Author: Nico Weber
Date: 2020-11-25T21:05:13-05:00
New Revision: 12c2646feb10c3aa14f590bcf9f5a3f9fc7b41b7

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

LOG: [gn build] sync script: only compute tokloc when adding files

No behavior change, but maybe a bit clearer.

Added: 


Modified: 
llvm/utils/gn/build/sync_source_lists_from_cmake.py

Removed: 




diff  --git a/llvm/utils/gn/build/sync_source_lists_from_cmake.py 
b/llvm/utils/gn/build/sync_source_lists_from_cmake.py
index bb57d49179ea..5c96fd7263f4 100755
--- a/llvm/utils/gn/build/sync_source_lists_from_cmake.py
+++ b/llvm/utils/gn/build/sync_source_lists_from_cmake.py
@@ -26,20 +26,17 @@
 def patch_gn_file(gn_file, add, remove):
 with open(gn_file) as f:
 gn_contents = f.read()
-
-srcs_tok = 'sources = ['
-tokloc = gn_contents.find(srcs_tok)
-while tokloc != -1 and tokloc + len(srcs_tok) < len(gn_contents) and \
-gn_contents[tokloc + len(srcs_tok)] == ']':
-tokloc = gn_contents.find(srcs_tok, tokloc + 1)
-
-if tokloc == -1: raise ValueError(gn_file + ': Failed to find source list')
 if add:
+srcs_tok = 'sources = ['
+tokloc = gn_contents.find(srcs_tok)
+while tokloc != -1 and tokloc + len(srcs_tok) < len(gn_contents) and \
+gn_contents[tokloc + len(srcs_tok)] == ']':
+tokloc = gn_contents.find(srcs_tok, tokloc + 1)
+if tokloc == -1: raise ValueError(gn_file + ': No source list')
 if gn_contents.find(srcs_tok, tokloc + 1) != -1:
 raise ValueError(gn_file + ': Multiple source lists')
 if gn_contents.find('# NOSORT', 0, tokloc) != -1:
 raise ValueError(gn_file + ': Found # NOSORT, needs manual merge')
-
 tokloc += len(srcs_tok)
 for a in add:
 gn_contents = (gn_contents[:tokloc] + ('"%s",' % a) +



___
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] 43afba0 - [gn build] sync script: try to make a loop clearer

2020-11-25 Thread Nico Weber via llvm-branch-commits

Author: Nico Weber
Date: 2020-11-25T21:16:22-05:00
New Revision: 43afba0677d4630ee6a35308a4b227144b8f1d42

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

LOG: [gn build] sync script: try to make a loop clearer

We want to find 'sources = [', but only if it's not the prefix
of 'sources = []' -- we're looking for a non-empty list.

No behavior change.

Added: 


Modified: 
llvm/utils/gn/build/sync_source_lists_from_cmake.py

Removed: 




diff  --git a/llvm/utils/gn/build/sync_source_lists_from_cmake.py 
b/llvm/utils/gn/build/sync_source_lists_from_cmake.py
index 5c96fd7263f4..912cf37c7e54 100755
--- a/llvm/utils/gn/build/sync_source_lists_from_cmake.py
+++ b/llvm/utils/gn/build/sync_source_lists_from_cmake.py
@@ -29,8 +29,7 @@ def patch_gn_file(gn_file, add, remove):
 if add:
 srcs_tok = 'sources = ['
 tokloc = gn_contents.find(srcs_tok)
-while tokloc != -1 and tokloc + len(srcs_tok) < len(gn_contents) and \
-gn_contents[tokloc + len(srcs_tok)] == ']':
+while gn_contents[tokloc:].startswith('sources = []'):
 tokloc = gn_contents.find(srcs_tok, tokloc + 1)
 if tokloc == -1: raise ValueError(gn_file + ': No source list')
 if gn_contents.find(srcs_tok, tokloc + 1) != -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] [lld] 48ddf5e - [lld][WebAssembly] Ensure stub symbols always get address 0

2020-11-25 Thread Sam Clegg via llvm-branch-commits

Author: Sam Clegg
Date: 2020-11-25T18:26:34-08:00
New Revision: 48ddf5e182c61cb93d66325f5690312d9e9226eb

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

LOG: [lld][WebAssembly] Ensure stub symbols always get address 0

Without this extra flag we can't distingish between stub functions and
functions that happen to have address 0 (relative to __table_base).

Adding this flag bit the base symbol class actually avoids growing the
SymbolUnion struct which would not be true if we added it to the
FunctionSymbol subclass (due to bitbacking).

The previous approach of setting it's table index to zero worked for
normal static relocations but not for `-fPIC` code.

See https://github.com/emscripten-core/emscripten/issues/12819

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

Added: 
lld/test/wasm/weak-undefined-pic.s

Modified: 
lld/wasm/Driver.cpp
lld/wasm/MarkLive.cpp
lld/wasm/Relocations.cpp
lld/wasm/SymbolTable.cpp
lld/wasm/Symbols.h
lld/wasm/SyntheticSections.cpp

Removed: 




diff  --git a/lld/test/wasm/weak-undefined-pic.s 
b/lld/test/wasm/weak-undefined-pic.s
new file mode 100644
index ..c12ef235d85f
--- /dev/null
+++ b/lld/test/wasm/weak-undefined-pic.s
@@ -0,0 +1,90 @@
+# Checks handling of undefined weak external functions.  When the
+# static linker decides they are undefined, check GOT relocations
+# resolve to zero (i.e. a global that contains zero.).
+#
+# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown -o %t.o %s
+# RUN: wasm-ld %t.o -o %t1.wasm
+# RUN: obj2yaml %t1.wasm | FileCheck %s
+#
+# With `--unresolved-symbols=ignore-all` the behaviour should be the same
+# as the default.>
+#
+# RUN: wasm-ld --unresolved-symbols=ignore-all %t.o -o %t2.wasm
+# RUN: obj2yaml %t2.wasm | FileCheck %s
+
+.globl get_foo_addr
+get_foo_addr:
+  .functype get_foo_addr () -> (i32)
+  global.get foo@GOT
+  end_function
+
+.globl _start
+_start:
+  .functype _start () -> ()
+  call get_foo_addr
+  end_function
+
+.weak foo
+.functype foo () -> (i32)
+
+# Verify that we do not generate dynamnic relocations for the GOT entry.
+
+# CHECK-NOT: __wasm_apply_relocs
+
+# Verify that we do not generate an import for foo
+
+# CHECK-NOT:  - Type:IMPORT
+
+#  CHECK:   - Type:GLOBAL
+# CHECK-NEXT: Globals:
+# CHECK-NEXT:   - Index:   0
+# CHECK-NEXT: Type:I32
+# CHECK-NEXT: Mutable: true
+# CHECK-NEXT: InitExpr:
+# CHECK-NEXT:   Opcode:  I32_CONST
+# CHECK-NEXT:   Value:   66560
+# Global 'undefined_weak:foo' representing the GOT entry for foo
+# Unlike other internal GOT entries that need to be mutable this one
+# is immutable and not updated by `__wasm_apply_relocs`
+# CHECK-NEXT:   - Index:   1
+# CHECK-NEXT: Type:I32
+# CHECK-NEXT: Mutable: false
+# CHECK-NEXT: InitExpr:
+# CHECK-NEXT:   Opcode:  I32_CONST
+# CHECK-NEXT:   Value:   0
+
+#  CHECK:  - Type:CUSTOM
+# CHECK-NEXT:Name:name
+# CHECK-NEXT:FunctionNames:
+# CHECK-NEXT:  - Index:   0
+# CHECK-NEXT:Name:'undefined_weak:foo'
+# CHECK-NEXT:  - Index:   1
+# CHECK-NEXT:Name:get_foo_addr
+# CHECK-NEXT:  - Index:   2
+# CHECK-NEXT:Name:_start
+# CHECK-NEXT:GlobalNames:
+# CHECK-NEXT:  - Index:   0
+# CHECK-NEXT:Name:__stack_pointer
+# CHECK-NEXT:  - Index:   1
+# CHECK-NEXT:Name:'undefined_weak:foo'
+
+# With `-pie` or `-shared` the resolution should is defered to the dynamic
+# linker and the function address should be imported as GOT.func.foo.
+#
+# RUN: wasm-ld --experimental-pic -pie %t.o -o %t3.wasm
+# RUN: obj2yaml %t3.wasm | FileCheck %s --check-prefix=IMPORT
+
+#  IMPORT:  - Type:IMPORT
+#  IMPORT:  - Module:  GOT.func
+# IMPORT-NEXT:Field:   foo
+# IMPORT-NEXT:Kind:GLOBAL
+# IMPORT-NEXT:GlobalType:  I32
+# IMPORT-NEXT:GlobalMutable:   true
+
+#  IMPORT: GlobalNames:
+# IMPORT-NEXT:   - Index:   0
+# IMPORT-NEXT: Name:__memory_base
+# IMPORT-NEXT:   - Index:   1
+# IMPORT-NEXT: Name:__table_base
+# IMPORT-NEXT:   - Index:   2
+# IMPORT-NEXT: Name:foo

diff  --git a/lld/wasm/Driver.cpp b/lld/wasm/Driver.cpp
index 8aa124795f6f..f26b190b6058 100644
--- a/lld/wasm/Driver.cpp
+++ b/lld/wasm/Driver.cpp
@@ -973,7 +973,7 @@ void LinkerDriver::link(ArrayRef argsArr) {
   warn(Twine("symbol exported via --

[llvm-branch-commits] [mlir] 2fb5f4a - [mlir][Python] Add additional capsule interop types.

2020-11-25 Thread Stella Laurenzo via llvm-branch-commits

Author: Stella Laurenzo
Date: 2020-11-25T19:09:25-08:00
New Revision: 2fb5f4a1cf41af31eaf31ea90cdda7f644794b99

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

LOG: [mlir][Python] Add additional capsule interop types.

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

Added: 


Modified: 
mlir/include/mlir-c/Bindings/Python/Interop.h

Removed: 




diff  --git a/mlir/include/mlir-c/Bindings/Python/Interop.h 
b/mlir/include/mlir-c/Bindings/Python/Interop.h
index dad51563a324..05519d804e31 100644
--- a/mlir/include/mlir-c/Bindings/Python/Interop.h
+++ b/mlir/include/mlir-c/Bindings/Python/Interop.h
@@ -26,8 +26,11 @@
 #include "mlir-c/IR.h"
 #include "mlir-c/Pass.h"
 
+#define MLIR_PYTHON_CAPSULE_ATTRIBUTE "mlir.ir.Attribute._CAPIPtr"
 #define MLIR_PYTHON_CAPSULE_CONTEXT "mlir.ir.Context._CAPIPtr"
 #define MLIR_PYTHON_CAPSULE_MODULE "mlir.ir.Module._CAPIPtr"
+#define MLIR_PYTHON_CAPSULE_OPERATION "mlir.ir.Operation._CAPIPtr"
+#define MLIR_PYTHON_CAPSULE_TYPE "mlir.ir.Type._CAPIPtr"
 #define MLIR_PYTHON_CAPSULE_PASS_MANAGER 
"mlir.passmanager.PassManager._CAPIPtr"
 
 /** Attribute on MLIR Python objects that expose their C-API pointer.
@@ -66,6 +69,25 @@
 extern "C" {
 #endif
 
+/** Creates a capsule object encapsulating the raw C-API MlirAttribute.
+ * The returned capsule does not extend or affect ownership of any Python
+ * objects that reference the attribute in any way.
+ */
+static inline PyObject *mlirPythonAttributeToCapsule(MlirAttribute attribute) {
+  return PyCapsule_New(MLIR_PYTHON_GET_WRAPPED_POINTER(attribute),
+   MLIR_PYTHON_CAPSULE_ATTRIBUTE, NULL);
+}
+
+/** Extracts an MlirAttribute from a capsule as produced from
+ * mlirPythonAttributeToCapsule. If the capsule is not of the right type, then
+ * a null attribute is returned (as checked via mlirAttributeIsNull). In such a
+ * case, the Python APIs will have already set an error. */
+static inline MlirAttribute mlirPythonCapsuleToAttribute(PyObject *capsule) {
+  void *ptr = PyCapsule_GetPointer(capsule, MLIR_PYTHON_CAPSULE_ATTRIBUTE);
+  MlirAttribute attr = {ptr};
+  return attr;
+}
+
 /** Creates a capsule object encapsulating the raw C-API MlirContext.
  * The returned capsule does not extend or affect ownership of any Python
  * objects that reference the context in any way.
@@ -120,6 +142,43 @@ mlirPythonCapsuleToPassManager(PyObject *capsule) {
   return pm;
 }
 
+/** Creates a capsule object encapsulating the raw C-API MlirOperation.
+ * The returned capsule does not extend or affect ownership of any Python
+ * objects that reference the operation in any way.
+ */
+static inline PyObject *mlirPythonOperationToCapsule(MlirOperation operation) {
+  return PyCapsule_New(operation.ptr, MLIR_PYTHON_CAPSULE_OPERATION, NULL);
+}
+
+/** Extracts an MlirOperations from a capsule as produced from
+ * mlirPythonOperationToCapsule. If the capsule is not of the right type, then
+ * a null type is returned (as checked via mlirOperationIsNull). In such a
+ * case, the Python APIs will have already set an error. */
+static inline MlirOperation mlirPythonCapsuleToOperation(PyObject *capsule) {
+  void *ptr = PyCapsule_GetPointer(capsule, MLIR_PYTHON_CAPSULE_OPERATION);
+  MlirOperation op = {ptr};
+  return op;
+}
+
+/** Creates a capsule object encapsulating the raw C-API MlirType.
+ * The returned capsule does not extend or affect ownership of any Python
+ * objects that reference the type in any way.
+ */
+static inline PyObject *mlirPythonTypeToCapsule(MlirType type) {
+  return PyCapsule_New(MLIR_PYTHON_GET_WRAPPED_POINTER(type),
+   MLIR_PYTHON_CAPSULE_TYPE, NULL);
+}
+
+/** Extracts an MlirType from a capsule as produced from
+ * mlirPythonTypeToCapsule. If the capsule is not of the right type, then
+ * a null type is returned (as checked via mlirTypeIsNull). In such a
+ * case, the Python APIs will have already set an error. */
+static inline MlirType mlirPythonCapsuleToType(PyObject *capsule) {
+  void *ptr = PyCapsule_GetPointer(capsule, MLIR_PYTHON_CAPSULE_TYPE);
+  MlirType type = {ptr};
+  return type;
+}
+
 #ifdef __cplusplus
 }
 #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] [llvm] 664e1da - [LoopLoadElim] Make sure all loops are in simplify form. PR48150

2020-11-25 Thread Max Kazantsev via llvm-branch-commits

Author: Max Kazantsev
Date: 2020-11-26T10:51:11+07:00
New Revision: 664e1da485d244325947d056a271c3c733ad4c7c

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

LOG: [LoopLoadElim] Make sure all loops are in simplify form. PR48150

LoopLoadElim may end up expanding an AddRec from a loop
which is not the current loop. This loop may not be in simplify
form. We figure it out after the no-return point, so cannot bail
in this case.

AddRec requires simplify form to expand. The only way to ensure
this does not crash is to simplify all loops beforehand.

The issue only exists in new PM. Old PM requests LoopSimplify
required pass and it simplifies all loops before the opt begins.

Differential Revision: https://reviews.llvm.org/D91525
Reviewed By: asbirlea, aeubanks

Added: 


Modified: 
llvm/lib/Transforms/Scalar/LoopLoadElimination.cpp
llvm/test/Transforms/LoopLoadElim/pr-48150.ll

Removed: 




diff  --git a/llvm/lib/Transforms/Scalar/LoopLoadElimination.cpp 
b/llvm/lib/Transforms/Scalar/LoopLoadElimination.cpp
index 74e32fb870b5..475448740ae4 100644
--- a/llvm/lib/Transforms/Scalar/LoopLoadElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopLoadElimination.cpp
@@ -56,6 +56,7 @@
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Transforms/Scalar.h"
 #include "llvm/Transforms/Utils.h"
+#include "llvm/Transforms/Utils/LoopSimplify.h"
 #include "llvm/Transforms/Utils/LoopVersioning.h"
 #include "llvm/Transforms/Utils/ScalarEvolutionExpander.h"
 #include "llvm/Transforms/Utils/SizeOpts.h"
@@ -610,6 +611,7 @@ class LoadEliminationForLoop {
 static bool
 eliminateLoadsAcrossLoops(Function &F, LoopInfo &LI, DominatorTree &DT,
   BlockFrequencyInfo *BFI, ProfileSummaryInfo *PSI,
+  ScalarEvolution *SE, AssumptionCache *AC,
   function_ref GetLAI) 
{
   // Build up a worklist of inner-loops to transform to avoid iterator
   // invalidation.
@@ -618,14 +620,17 @@ eliminateLoadsAcrossLoops(Function &F, LoopInfo &LI, 
DominatorTree &DT,
   // which merely optimizes the use of loads in a loop.
   SmallVector Worklist;
 
+  bool Changed = false;
+
   for (Loop *TopLevelLoop : LI)
-for (Loop *L : depth_first(TopLevelLoop))
+for (Loop *L : depth_first(TopLevelLoop)) {
+  Changed |= simplifyLoop(L, &DT, &LI, SE, AC, /*MSSAU*/ nullptr, false);
   // We only handle inner-most loops.
   if (L->isInnermost())
 Worklist.push_back(L);
+}
 
   // Now walk the identified inner loops.
-  bool Changed = false;
   for (Loop *L : Worklist) {
 // The actual work is performed by LoadEliminationForLoop.
 LoadEliminationForLoop LEL(L, &LI, GetLAI(*L), &DT, BFI, PSI);
@@ -660,7 +665,7 @@ class LoopLoadElimination : public FunctionPass {
 
 // Process each loop nest in the function.
 return eliminateLoadsAcrossLoops(
-F, LI, DT, BFI, PSI,
+F, LI, DT, BFI, PSI, /*SE*/ nullptr, /*AC*/ nullptr,
 [&LAA](Loop &L) -> const LoopAccessInfo & { return LAA.getInfo(&L); });
   }
 
@@ -717,7 +722,7 @@ PreservedAnalyses LoopLoadEliminationPass::run(Function &F,
 
   auto &LAM = AM.getResult(F).getManager();
   bool Changed = eliminateLoadsAcrossLoops(
-  F, LI, DT, BFI, PSI, [&](Loop &L) -> const LoopAccessInfo & {
+  F, LI, DT, BFI, PSI, &SE, &AC, [&](Loop &L) -> const LoopAccessInfo & {
 LoopStandardAnalysisResults AR = {AA,  AC,  DT,  LI,  SE,
   TLI, TTI, nullptr, MSSA};
 return LAM.getResult(L, AR);

diff  --git a/llvm/test/Transforms/LoopLoadElim/pr-48150.ll 
b/llvm/test/Transforms/LoopLoadElim/pr-48150.ll
index 60cc02c50ad4..a88fd9b9d938 100644
--- a/llvm/test/Transforms/LoopLoadElim/pr-48150.ll
+++ b/llvm/test/Transforms/LoopLoadElim/pr-48150.ll
@@ -1,6 +1,4 @@
 ; RUN: opt -passes=loop-load-elim -S < %s | FileCheck %s
-; REQUIRES: asserts
-; XFAIL: *
 
 target datalayout = 
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128-ni:1-p2:32:8:8:32-ni:2"
 target triple = "x86_64-unknown-linux-gnu"



___
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] aea130f - [LegalizerTypes] Add support for scalarizing the operand of an FP_EXTEND when the result type is legal.

2020-11-25 Thread Craig Topper via llvm-branch-commits

Author: Craig Topper
Date: 2020-11-25T20:30:21-08:00
New Revision: aea130f7366bd7af5bdb68391f033cd5c051768c

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

LOG: [LegalizerTypes] Add support for scalarizing the operand of an FP_EXTEND 
when the result type is legal.

Added: 
llvm/test/CodeGen/AArch64/neon-fpextend_f16.ll

Modified: 
llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h
llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp

Removed: 




diff  --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h 
b/llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h
index 6ed480f5c17c..fdc829b61b65 100644
--- a/llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h
+++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h
@@ -776,6 +776,8 @@ class LLVM_LIBRARY_VISIBILITY DAGTypeLegalizer {
   SDValue ScalarizeVecOp_STORE(StoreSDNode *N, unsigned OpNo);
   SDValue ScalarizeVecOp_FP_ROUND(SDNode *N, unsigned OpNo);
   SDValue ScalarizeVecOp_STRICT_FP_ROUND(SDNode *N, unsigned OpNo);
+  SDValue ScalarizeVecOp_FP_EXTEND(SDNode *N);
+  SDValue ScalarizeVecOp_STRICT_FP_EXTEND(SDNode *N);
   SDValue ScalarizeVecOp_VECREDUCE(SDNode *N);
   SDValue ScalarizeVecOp_VECREDUCE_SEQ(SDNode *N);
 

diff  --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp 
b/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
index 634a37b4c706..552545b854d8 100644
--- a/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
@@ -607,6 +607,12 @@ bool DAGTypeLegalizer::ScalarizeVectorOperand(SDNode *N, 
unsigned OpNo) {
   case ISD::FP_ROUND:
 Res = ScalarizeVecOp_FP_ROUND(N, OpNo);
 break;
+  case ISD::STRICT_FP_EXTEND:
+Res = ScalarizeVecOp_STRICT_FP_EXTEND(N);
+break;
+  case ISD::FP_EXTEND:
+Res = ScalarizeVecOp_FP_EXTEND(N);
+break;
   case ISD::VECREDUCE_FADD:
   case ISD::VECREDUCE_FMUL:
   case ISD::VECREDUCE_ADD:
@@ -770,6 +776,7 @@ SDValue DAGTypeLegalizer::ScalarizeVecOp_STORE(StoreSDNode 
*N, unsigned OpNo){
 /// If the value to round is a vector that needs to be scalarized, it must be
 /// <1 x ty>. Convert the element instead.
 SDValue DAGTypeLegalizer::ScalarizeVecOp_FP_ROUND(SDNode *N, unsigned OpNo) {
+  assert(OpNo == 0 && "Wrong operand for scalarization!");
   SDValue Elt = GetScalarizedVector(N->getOperand(0));
   SDValue Res = DAG.getNode(ISD::FP_ROUND, SDLoc(N),
 N->getValueType(0).getVectorElementType(), Elt,
@@ -795,7 +802,36 @@ SDValue 
DAGTypeLegalizer::ScalarizeVecOp_STRICT_FP_ROUND(SDNode *N,
   // handled all replacements since caller can only handle a single result.
   ReplaceValueWith(SDValue(N, 0), Res);
   return SDValue();
-} 
+}
+
+/// If the value to extend is a vector that needs to be scalarized, it must be
+/// <1 x ty>. Convert the element instead.
+SDValue DAGTypeLegalizer::ScalarizeVecOp_FP_EXTEND(SDNode *N) {
+  SDValue Elt = GetScalarizedVector(N->getOperand(0));
+  SDValue Res = DAG.getNode(ISD::FP_EXTEND, SDLoc(N),
+N->getValueType(0).getVectorElementType(), Elt);
+  return DAG.getNode(ISD::SCALAR_TO_VECTOR, SDLoc(N), N->getValueType(0), Res);
+}
+
+/// If the value to extend is a vector that needs to be scalarized, it must be
+/// <1 x ty>. Convert the element instead.
+SDValue DAGTypeLegalizer::ScalarizeVecOp_STRICT_FP_EXTEND(SDNode *N) {
+  SDValue Elt = GetScalarizedVector(N->getOperand(1));
+  SDValue Res =
+  DAG.getNode(ISD::STRICT_FP_EXTEND, SDLoc(N),
+  {N->getValueType(0).getVectorElementType(), MVT::Other},
+  {N->getOperand(0), Elt});
+  // Legalize the chain result - switch anything that used the old chain to
+  // use the new one.
+  ReplaceValueWith(SDValue(N, 1), Res.getValue(1));
+
+  Res = DAG.getNode(ISD::SCALAR_TO_VECTOR, SDLoc(N), N->getValueType(0), Res);
+
+  // Do our own replacement and return SDValue() to tell the caller that we
+  // handled all replacements since caller can only handle a single result.
+  ReplaceValueWith(SDValue(N, 0), Res);
+  return SDValue();
+}
 
 SDValue DAGTypeLegalizer::ScalarizeVecOp_VECREDUCE(SDNode *N) {
   SDValue Res = GetScalarizedVector(N->getOperand(0));

diff  --git a/llvm/test/CodeGen/AArch64/neon-fpextend_f16.ll 
b/llvm/test/CodeGen/AArch64/neon-fpextend_f16.ll
new file mode 100644
index ..b78486770dda
--- /dev/null
+++ b/llvm/test/CodeGen/AArch64/neon-fpextend_f16.ll
@@ -0,0 +1,26 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -verify-machineinstrs -mtriple=aarch64-none-linux-gnu 
-mattr=+neon -fp-contract=fast | FileCheck %s
+
+; This is testing that we can scalarize the v1f16 input to fp_extend even
+; though the v1f64 result is legal.
+
+define <1 x double> @fpext_v1f16_v1f64(

[llvm-branch-commits] [llvm] f78ad68 - [RISCV] Remove unused PatFrag argument from the tablegen class used for c.beqz/c.bnez. NFC

2020-11-25 Thread Craig Topper via llvm-branch-commits

Author: Craig Topper
Date: 2020-11-25T20:35:23-08:00
New Revision: f78ad68b6d8ccfd6e082e6430528751376084726

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

LOG: [RISCV] Remove unused PatFrag argument from the tablegen class used for 
c.beqz/c.bnez. NFC

Added: 


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

Removed: 




diff  --git a/llvm/lib/Target/RISCV/RISCVInstrInfoC.td 
b/llvm/lib/Target/RISCV/RISCVInstrInfoC.td
index a9960ea546ad..fbddde2b4bdc 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfoC.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfoC.td
@@ -239,7 +239,7 @@ class CStore_rri funct3, string OpcodeStr,
  OpcodeStr, "$rs2, ${imm}(${rs1})">;
 
 let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in
-class Bcz funct3, string OpcodeStr, PatFrag CondOp,
+class Bcz funct3, string OpcodeStr,
   RegisterClass cls>
 : RVInst16CB {
@@ -469,8 +469,8 @@ def C_J : RVInst16CJ<0b101, 0b01, (outs), (ins 
simm12_lsb0:$offset),
   let isBarrier=1;
 }
 
-def C_BEQZ : Bcz<0b110, "c.beqz",  seteq, GPRC>, Sched<[WriteJmp]>;
-def C_BNEZ : Bcz<0b111, "c.bnez",  setne, GPRC>, Sched<[WriteJmp]>;
+def C_BEQZ : Bcz<0b110, "c.beqz", GPRC>, Sched<[WriteJmp]>;
+def C_BNEZ : Bcz<0b111, "c.bnez", GPRC>, Sched<[WriteJmp]>;
 
 let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in
 def C_SLLI : RVInst16CI<0b000, 0b10, (outs GPRNoX0:$rd_wb),



___
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] 075cca3 - [RTDYLD] support absolute relocations where needed

2020-11-25 Thread Tom Stellard via llvm-branch-commits

Author: Valentin Churavy
Date: 2020-11-26T00:34:52-05:00
New Revision: 075cca3448389e97d60a9bb61f313642c31653dc

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

LOG: [RTDYLD] support absolute relocations where needed

These appear in some sections, such as DWARF tables, since
RuntimeDyldELF explicitly maps to this as a sentinel value:
https://github.com/llvm/llvm-project/blob/29d1fba7b5335d969e3e5daa84b7a25cd1fa75ef/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp#L1199

That could then be a source of problems if it tried to examine these
sections (for example, with either setProcessAllSections(true) or ORCv2 on 
i686).

Replaces https://reviews.llvm.org/D89241

Reviewed By: lhames, vchuravy

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

(cherry picked from commit 85f4be09124cc53e1a18a884ac7caf19988ab2a5)

Added: 


Modified: 
llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp

Removed: 




diff  --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp 
b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
index 7e9b0690ccea..04f541b59557 100644
--- a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
+++ b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
@@ -308,7 +308,9 @@ RuntimeDyldImpl::loadObjectImpl(const object::ObjectFile 
&Obj) {
 << " SID: " << SectionID
 << " Offset: " << format("%p", (uintptr_t)Addr)
 << " flags: " << *FlagsOrErr << "\n");
-  GlobalSymbolTable[Name] = SymbolTableEntry(SectionID, Addr, 
*JITSymFlags);
+  if (!Name.empty()) // Skip absolute symbol relocations.
+GlobalSymbolTable[Name] =
+SymbolTableEntry(SectionID, Addr, *JITSymFlags);
 } else if (SymType == object::SymbolRef::ST_Function ||
SymType == object::SymbolRef::ST_Data ||
SymType == object::SymbolRef::ST_Unknown ||
@@ -340,8 +342,9 @@ RuntimeDyldImpl::loadObjectImpl(const object::ObjectFile 
&Obj) {
 << " SID: " << SectionID
 << " Offset: " << format("%p", (uintptr_t)SectOffset)
 << " flags: " << *FlagsOrErr << "\n");
-  GlobalSymbolTable[Name] =
-  SymbolTableEntry(SectionID, SectOffset, *JITSymFlags);
+  if (!Name.empty()) // Skip absolute symbol relocations
+GlobalSymbolTable[Name] =
+SymbolTableEntry(SectionID, SectOffset, *JITSymFlags);
 }
   }
 
@@ -769,8 +772,9 @@ Error RuntimeDyldImpl::emitCommonSymbols(const ObjectFile 
&Obj,
 
 LLVM_DEBUG(dbgs() << "Allocating common symbol " << Name << " address "
   << format("%p", Addr) << "\n");
-GlobalSymbolTable[Name] =
-SymbolTableEntry(SectionID, Offset, std::move(*JITSymFlags));
+if (!Name.empty()) // Skip absolute symbol relocations.
+  GlobalSymbolTable[Name] =
+  SymbolTableEntry(SectionID, Offset, std::move(*JITSymFlags));
 Offset += Size;
 Addr += Size;
   }
@@ -930,6 +934,8 @@ void RuntimeDyldImpl::addRelocationForSymbol(const 
RelocationEntry &RE,
   if (Loc == GlobalSymbolTable.end()) {
 ExternalSymbolRelocations[SymbolName].push_back(RE);
   } else {
+assert(!SymbolName.empty() &&
+   "Empty symbol should not be in GlobalSymbolTable");
 // Copy the RE since we want to modify its addend.
 RelocationEntry RECopy = RE;
 const auto &SymInfo = Loc->second;
@@ -1234,7 +1240,8 @@ void RuntimeDyldImpl::finalizeAsync(
 
   for (auto &RelocKV : SharedThis->ExternalSymbolRelocations) {
 StringRef Name = RelocKV.first();
-assert(!Name.empty() && "Symbol has no name?");
+if (Name.empty()) // Skip absolute symbol relocations.
+  continue;
 assert(!SharedThis->GlobalSymbolTable.count(Name) &&
"Name already processed. RuntimeDyld instances can not be re-used "
"when finalizing with finalizeAsync.");



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


  1   2   >