[llvm-branch-commits] [llvm] 8b330f1 - [SCEV] Add missing type check into getRangeForAffineNoSelfWrappingAR

2020-12-14 Thread Max Kazantsev via llvm-branch-commits

Author: Max Kazantsev
Date: 2020-12-15T14:50:32+07:00
New Revision: 8b330f1f6919a2ac85eeda753ad8d1090468e23f

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

LOG: [SCEV] Add missing type check into getRangeForAffineNoSelfWrappingAR

We make type widening without checking if it's needed. Bail if the max
iteration count is wider than AR's type.

Added: 


Modified: 
llvm/lib/Analysis/ScalarEvolution.cpp

llvm/test/Transforms/IndVarSimplify/2020-12-15-trunc-bug-expensive-range-inference.ll

Removed: 




diff  --git a/llvm/lib/Analysis/ScalarEvolution.cpp 
b/llvm/lib/Analysis/ScalarEvolution.cpp
index 3005a44b44ef..071b569d3f17 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -6006,6 +6006,9 @@ ConstantRange 
ScalarEvolution::getRangeForAffineNoSelfWrappingAR(
   // iteration count estimate, and we might infer nw from some exit for which 
we
   // do not know max exit count (or any other side reasoning).
   // TODO: Turn into assert at some point.
+  if (getTypeSizeInBits(MaxBECount->getType()) >
+  getTypeSizeInBits(AddRec->getType()))
+return ConstantRange::getFull(BitWidth);
   MaxBECount = getNoopOrZeroExtend(MaxBECount, AddRec->getType());
   const SCEV *RangeWidth = getMinusOne(AddRec->getType());
   const SCEV *StepAbs = getUMinExpr(Step, getNegativeSCEV(Step));

diff  --git 
a/llvm/test/Transforms/IndVarSimplify/2020-12-15-trunc-bug-expensive-range-inference.ll
 
b/llvm/test/Transforms/IndVarSimplify/2020-12-15-trunc-bug-expensive-range-inference.ll
index dd105f40544e..a1ad4d07fab2 100644
--- 
a/llvm/test/Transforms/IndVarSimplify/2020-12-15-trunc-bug-expensive-range-inference.ll
+++ 
b/llvm/test/Transforms/IndVarSimplify/2020-12-15-trunc-bug-expensive-range-inference.ll
@@ -1,7 +1,5 @@
 ; RUN: opt < %s -indvars -S -scalar-evolution-use-expensive-range-sharpening | 
FileCheck %s
 ; RUN: opt < %s -passes=indvars -S 
-scalar-evolution-use-expensive-range-sharpening | 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] a69b76c - [GlobalISel][IRTranslator] Ensure branch probabilities are added when translating invoke edges.

2020-12-14 Thread Amara Emerson via llvm-branch-commits

Author: Amara Emerson
Date: 2020-12-14T23:36:54-08:00
New Revision: a69b76c500849bacc0ba494df03b465e4bcff0ef

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

LOG: [GlobalISel][IRTranslator] Ensure branch probabilities are added when 
translating invoke edges.

This uses a straightforward port of findUnwindDestinations() from SelectionDAG.

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

Added: 
llvm/test/CodeGen/AArch64/GlobalISel/irtranslator-invoke-probabilities.ll

Modified: 
llvm/include/llvm/CodeGen/GlobalISel/IRTranslator.h
llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp

Removed: 




diff  --git a/llvm/include/llvm/CodeGen/GlobalISel/IRTranslator.h 
b/llvm/include/llvm/CodeGen/GlobalISel/IRTranslator.h
index 37c94ccbbd20..8eab8a5846a7 100644
--- a/llvm/include/llvm/CodeGen/GlobalISel/IRTranslator.h
+++ b/llvm/include/llvm/CodeGen/GlobalISel/IRTranslator.h
@@ -260,6 +260,19 @@ class IRTranslator : public MachineFunctionPass {
   /// \pre \p U is a call instruction.
   bool translateCall(const User , MachineIRBuilder );
 
+  /// When an invoke or a cleanupret unwinds to the next EH pad, there are
+  /// many places it could ultimately go. In the IR, we have a single unwind
+  /// destination, but in the machine CFG, we enumerate all the possible 
blocks.
+  /// This function skips over imaginary basic blocks that hold catchswitch
+  /// instructions, and finds all the "real" machine
+  /// basic block destinations. As those destinations may not be successors of
+  /// EHPadBB, here we also calculate the edge probability to those
+  /// destinations. The passed-in Prob is the edge probability to EHPadBB.
+  bool findUnwindDestinations(
+  const BasicBlock *EHPadBB, BranchProbability Prob,
+  SmallVectorImpl>
+  );
+
   bool translateInvoke(const User , MachineIRBuilder );
 
   bool translateCallBr(const User , MachineIRBuilder );
@@ -659,8 +672,9 @@ class IRTranslator : public MachineFunctionPass {
   BranchProbability getEdgeProbability(const MachineBasicBlock *Src,
const MachineBasicBlock *Dst) const;
 
-  void addSuccessorWithProb(MachineBasicBlock *Src, MachineBasicBlock *Dst,
-BranchProbability Prob);
+  void addSuccessorWithProb(
+  MachineBasicBlock *Src, MachineBasicBlock *Dst,
+  BranchProbability Prob = BranchProbability::getUnknown());
 
 public:
   IRTranslator(CodeGenOpt::Level OptLevel = CodeGenOpt::None);

diff  --git a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp 
b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
index 202163ff9507..dde97ba599b9 100644
--- a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
@@ -2347,6 +2347,62 @@ bool IRTranslator::translateCall(const User , 
MachineIRBuilder ) {
   return true;
 }
 
+bool IRTranslator::findUnwindDestinations(
+const BasicBlock *EHPadBB,
+BranchProbability Prob,
+SmallVectorImpl>
+) {
+  EHPersonality Personality = classifyEHPersonality(
+  EHPadBB->getParent()->getFunction().getPersonalityFn());
+  bool IsMSVCCXX = Personality == EHPersonality::MSVC_CXX;
+  bool IsCoreCLR = Personality == EHPersonality::CoreCLR;
+  bool IsWasmCXX = Personality == EHPersonality::Wasm_CXX;
+  bool IsSEH = isAsynchronousEHPersonality(Personality);
+
+  if (IsWasmCXX) {
+// Ignore this for now.
+return false;
+  }
+
+  while (EHPadBB) {
+const Instruction *Pad = EHPadBB->getFirstNonPHI();
+BasicBlock *NewEHPadBB = nullptr;
+if (isa(Pad)) {
+  // Stop on landingpads. They are not funclets.
+  UnwindDests.emplace_back((*EHPadBB), Prob);
+  break;
+}
+if (isa(Pad)) {
+  // Stop on cleanup pads. Cleanups are always funclet entries for all 
known
+  // personalities.
+  UnwindDests.emplace_back((*EHPadBB), Prob);
+  UnwindDests.back().first->setIsEHScopeEntry();
+  UnwindDests.back().first->setIsEHFuncletEntry();
+  break;
+}
+if (auto *CatchSwitch = dyn_cast(Pad)) {
+  // Add the catchpad handlers to the possible destinations.
+  for (const BasicBlock *CatchPadBB : CatchSwitch->handlers()) {
+UnwindDests.emplace_back((*CatchPadBB), Prob);
+// For MSVC++ and the CLR, catchblocks are funclets and need prologues.
+if (IsMSVCCXX || IsCoreCLR)
+  UnwindDests.back().first->setIsEHFuncletEntry();
+if (!IsSEH)
+  UnwindDests.back().first->setIsEHScopeEntry();
+  }
+  NewEHPadBB = CatchSwitch->getUnwindDest();
+} else {
+  continue;
+}
+
+BranchProbabilityInfo *BPI = FuncInfo.BPI;
+if (BPI && NewEHPadBB)
+  Prob *= BPI->getEdgeProbability(EHPadBB, NewEHPadBB);
+EHPadBB = NewEHPadBB;
+  }
+  return true;
+}
+
 

[llvm-branch-commits] [llvm] cbbdcfc - [RISCV] V does not imply F.

2020-12-14 Thread Hsiangkai Wang via llvm-branch-commits

Author: Hsiangkai Wang
Date: 2020-12-15T14:59:22+08:00
New Revision: cbbdcfc47c86ddafe4ebad49f93dd37b513db0ac

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

LOG: [RISCV] V does not imply F.

If users want to use vector floating point instructions, they need to
specify 'F' extension additionally.

Added: 


Modified: 
llvm/lib/Target/RISCV/RISCV.td
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
llvm/lib/Target/RISCV/RISCVInstrInfoV.td
llvm/lib/Target/RISCV/RISCVSchedRocket.td
llvm/lib/Target/RISCV/RISCVSchedSiFive7.td
llvm/test/MC/RISCV/rvv/convert.s
llvm/test/MC/RISCV/rvv/fadd.s
llvm/test/MC/RISCV/rvv/fcompare.s
llvm/test/MC/RISCV/rvv/fdiv.s
llvm/test/MC/RISCV/rvv/fmacc.s
llvm/test/MC/RISCV/rvv/fminmax.s
llvm/test/MC/RISCV/rvv/fmul.s
llvm/test/MC/RISCV/rvv/fmv.s
llvm/test/MC/RISCV/rvv/fothers.s
llvm/test/MC/RISCV/rvv/freduction.s
llvm/test/MC/RISCV/rvv/fsub.s
llvm/test/MC/RISCV/rvv/sign-injection.s

Removed: 




diff  --git a/llvm/lib/Target/RISCV/RISCV.td b/llvm/lib/Target/RISCV/RISCV.td
index 7a7b3bb0ad32..b1f2658e76b8 100644
--- a/llvm/lib/Target/RISCV/RISCV.td
+++ b/llvm/lib/Target/RISCV/RISCV.td
@@ -160,11 +160,14 @@ def HasRVCHints : 
Predicate<"Subtarget->enableRVCHintInstrs()">,
 
 def FeatureStdExtV
 : SubtargetFeature<"experimental-v", "HasStdExtV", "true",
-   "'V' (Vector Instructions)",
-   [FeatureStdExtF]>;
+   "'V' (Vector Instructions)">;
 def HasStdExtV : Predicate<"Subtarget->hasStdExtV()">,
AssemblerPredicate<(all_of FeatureStdExtV),
"'V' (Vector Instructions)">;
+def HasStdExtVAndF
+: Predicate<"Subtarget->hasStdExtV() && Subtarget->hasStdExtF()">,
+AssemblerPredicate<(all_of FeatureStdExtV, FeatureStdExtF),
+"'V' and 'F' (Vector Floating-point Instructions)">;
 
 def FeatureStdExtZvlsseg
 : SubtargetFeature<"experimental-zvlsseg", "HasStdExtZvlsseg", "true",

diff  --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp 
b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index 529a5bf784f4..f805a7dcc60c 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -124,23 +124,29 @@ RISCVTargetLowering::RISCVTargetLowering(const 
TargetMachine ,
 addRegisterClass(RISCVVMVTs::vint64m4_t, ::VRM4RegClass);
 addRegisterClass(RISCVVMVTs::vint64m8_t, ::VRM8RegClass);
 
-addRegisterClass(RISCVVMVTs::vfloat16mf4_t, ::VRRegClass);
-addRegisterClass(RISCVVMVTs::vfloat16mf2_t, ::VRRegClass);
-addRegisterClass(RISCVVMVTs::vfloat16m1_t, ::VRRegClass);
-addRegisterClass(RISCVVMVTs::vfloat16m2_t, ::VRM2RegClass);
-addRegisterClass(RISCVVMVTs::vfloat16m4_t, ::VRM4RegClass);
-addRegisterClass(RISCVVMVTs::vfloat16m8_t, ::VRM8RegClass);
-
-addRegisterClass(RISCVVMVTs::vfloat32mf2_t, ::VRRegClass);
-addRegisterClass(RISCVVMVTs::vfloat32m1_t, ::VRRegClass);
-addRegisterClass(RISCVVMVTs::vfloat32m2_t, ::VRM2RegClass);
-addRegisterClass(RISCVVMVTs::vfloat32m4_t, ::VRM4RegClass);
-addRegisterClass(RISCVVMVTs::vfloat32m8_t, ::VRM8RegClass);
-
-addRegisterClass(RISCVVMVTs::vfloat64m1_t, ::VRRegClass);
-addRegisterClass(RISCVVMVTs::vfloat64m2_t, ::VRM2RegClass);
-addRegisterClass(RISCVVMVTs::vfloat64m4_t, ::VRM4RegClass);
-addRegisterClass(RISCVVMVTs::vfloat64m8_t, ::VRM8RegClass);
+if (Subtarget.hasStdExtZfh()) {
+  addRegisterClass(RISCVVMVTs::vfloat16mf4_t, ::VRRegClass);
+  addRegisterClass(RISCVVMVTs::vfloat16mf2_t, ::VRRegClass);
+  addRegisterClass(RISCVVMVTs::vfloat16m1_t, ::VRRegClass);
+  addRegisterClass(RISCVVMVTs::vfloat16m2_t, ::VRM2RegClass);
+  addRegisterClass(RISCVVMVTs::vfloat16m4_t, ::VRM4RegClass);
+  addRegisterClass(RISCVVMVTs::vfloat16m8_t, ::VRM8RegClass);
+}
+
+if (Subtarget.hasStdExtF()) {
+  addRegisterClass(RISCVVMVTs::vfloat32mf2_t, ::VRRegClass);
+  addRegisterClass(RISCVVMVTs::vfloat32m1_t, ::VRRegClass);
+  addRegisterClass(RISCVVMVTs::vfloat32m2_t, ::VRM2RegClass);
+  addRegisterClass(RISCVVMVTs::vfloat32m4_t, ::VRM4RegClass);
+  addRegisterClass(RISCVVMVTs::vfloat32m8_t, ::VRM8RegClass);
+}
+
+if (Subtarget.hasStdExtD()) {
+  addRegisterClass(RISCVVMVTs::vfloat64m1_t, ::VRRegClass);
+  addRegisterClass(RISCVVMVTs::vfloat64m2_t, ::VRM2RegClass);
+  addRegisterClass(RISCVVMVTs::vfloat64m4_t, ::VRM4RegClass);
+  addRegisterClass(RISCVVMVTs::vfloat64m8_t, ::VRM8RegClass);
+}
   }
 
   // Compute derived properties from the register classes.

diff  --git a/llvm/lib/Target/RISCV/RISCVInstrInfoV.td 
b/llvm/lib/Target/RISCV/RISCVInstrInfoV.td

[llvm-branch-commits] [llvm] e0d43a3 - [RISCV][NFC] Define scalable vectors for half types.

2020-12-14 Thread Hsiangkai Wang via llvm-branch-commits

Author: Hsiangkai Wang
Date: 2020-12-15T13:49:54+08:00
New Revision: e0d43a3b37a0d14c1caf3a79a4ad57a7a75fc3ae

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

LOG: [RISCV][NFC] Define scalable vectors for half types.

This is a preperation work for vfadd intrinsics.

Added: 


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

Removed: 




diff  --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp 
b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index a6aa81be1e40..529a5bf784f4 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -124,6 +124,13 @@ RISCVTargetLowering::RISCVTargetLowering(const 
TargetMachine ,
 addRegisterClass(RISCVVMVTs::vint64m4_t, ::VRM4RegClass);
 addRegisterClass(RISCVVMVTs::vint64m8_t, ::VRM8RegClass);
 
+addRegisterClass(RISCVVMVTs::vfloat16mf4_t, ::VRRegClass);
+addRegisterClass(RISCVVMVTs::vfloat16mf2_t, ::VRRegClass);
+addRegisterClass(RISCVVMVTs::vfloat16m1_t, ::VRRegClass);
+addRegisterClass(RISCVVMVTs::vfloat16m2_t, ::VRM2RegClass);
+addRegisterClass(RISCVVMVTs::vfloat16m4_t, ::VRM4RegClass);
+addRegisterClass(RISCVVMVTs::vfloat16m8_t, ::VRM8RegClass);
+
 addRegisterClass(RISCVVMVTs::vfloat32mf2_t, ::VRRegClass);
 addRegisterClass(RISCVVMVTs::vfloat32m1_t, ::VRRegClass);
 addRegisterClass(RISCVVMVTs::vfloat32m2_t, ::VRM2RegClass);

diff  --git a/llvm/lib/Target/RISCV/RISCVRegisterInfo.td 
b/llvm/lib/Target/RISCV/RISCVRegisterInfo.td
index ea7357c9c073..b69cdde6c532 100644
--- a/llvm/lib/Target/RISCV/RISCVRegisterInfo.td
+++ b/llvm/lib/Target/RISCV/RISCVRegisterInfo.td
@@ -314,6 +314,13 @@ defvar vint64m2_t = nxv2i64;
 defvar vint64m4_t = nxv4i64;
 defvar vint64m8_t = nxv8i64;
 
+defvar vfloat16mf4_t = nxv1f16;
+defvar vfloat16mf2_t = nxv2f16;
+defvar vfloat16m1_t  = nxv4f16;
+defvar vfloat16m2_t  = nxv8f16;
+defvar vfloat16m4_t  = nxv16f16;
+defvar vfloat16m8_t  = nxv32f16;
+
 defvar vfloat32mf2_t = nxv1f32;
 defvar vfloat32m1_t  = nxv2f32;
 defvar vfloat32m2_t  = nxv4f32;
@@ -391,6 +398,7 @@ class VReg regTypes, dag regList, int Vlmul>
 def VR : VReg<[vint8mf2_t, vint8mf4_t, vint8mf8_t,
vint16mf2_t, vint16mf4_t, vint32mf2_t,
vint8m1_t, vint16m1_t, vint32m1_t, vint64m1_t,
+   vfloat16mf4_t, vfloat16mf2_t, vfloat16m1_t,
vfloat32mf2_t, vfloat32m1_t, vfloat64m1_t,
vbool64_t, vbool32_t, vbool16_t, vbool8_t, vbool4_t,
vbool2_t, vbool1_t],
@@ -401,6 +409,7 @@ def VR : VReg<[vint8mf2_t, vint8mf4_t, vint8mf8_t,
 def VRNoV0 : VReg<[vint8mf2_t, vint8mf4_t, vint8mf8_t,
vint16mf2_t, vint16mf4_t, vint32mf2_t,
vint8m1_t, vint16m1_t, vint32m1_t, vint64m1_t,
+   vfloat16mf4_t, vfloat16mf2_t, vfloat16m1_t,
vfloat32mf2_t, vfloat32m1_t, vfloat64m1_t,
vbool64_t, vbool32_t, vbool16_t, vbool8_t, vbool4_t,
vbool2_t, vbool1_t],
@@ -409,29 +418,29 @@ def VRNoV0 : VReg<[vint8mf2_t, vint8mf4_t, vint8mf8_t,
 (sequence "V%u", 1, 7)), 1>;
 
 def VRM2 : VReg<[vint8m2_t, vint16m2_t, vint32m2_t, vint64m2_t,
- vfloat32m2_t, vfloat64m2_t],
+ vfloat16m2_t, vfloat32m2_t, vfloat64m2_t],
  (add V26M2, V28M2, V30M2, V8M2, V10M2, V12M2, V14M2, V16M2,
   V18M2, V20M2, V22M2, V24M2, V0M2, V2M2, V4M2, V6M2), 2>;
 
 def VRM2NoV0 : VReg<[vint8m2_t, vint16m2_t, vint32m2_t, vint64m2_t,
- vfloat32m2_t, vfloat64m2_t],
+ vfloat16m2_t, vfloat32m2_t, vfloat64m2_t],
  (add V26M2, V28M2, V30M2, V8M2, V10M2, V12M2, V14M2, V16M2,
   V18M2, V20M2, V22M2, V24M2, V2M2, V4M2, V6M2), 2>;
 
 def VRM4 : VReg<[vint8m4_t, vint16m4_t, vint32m4_t, vint64m4_t,
- vfloat32m4_t, vfloat64m4_t],
+ vfloat16m4_t, vfloat32m4_t, vfloat64m4_t],
  (add V28M4, V8M4, V12M4, V16M4, V20M4, V24M4, V0M4, V4M4), 4>;
 
 def VRM4NoV0 : VReg<[vint8m4_t, vint16m4_t, vint32m4_t, vint64m4_t,
- vfloat32m4_t, vfloat64m4_t],
+ vfloat16m4_t, vfloat32m4_t, vfloat64m4_t],
  (add V28M4, V8M4, V12M4, V16M4, V20M4, V24M4, V4M4), 4>;
 
 def VRM8 : VReg<[vint8m8_t, vint16m8_t, vint32m8_t, vint64m8_t,
- vfloat32m8_t, vfloat64m8_t],
+ vfloat16m8_t, vfloat32m8_t, vfloat64m8_t],
  (add V8M8, V16M8, V24M8, V0M8), 8>;
 
 def VRM8NoV0 : VReg<[vint8m8_t, vint16m8_t, vint32m8_t, vint64m8_t,
- vfloat32m8_t, vfloat64m8_t],
+ vfloat16m8_t, vfloat32m8_t, vfloat64m8_t],
  

[llvm-branch-commits] [llvm] 504e4be - [IR] Remove isPowerOf2ByteWidth

2020-12-14 Thread Kazu Hirata via llvm-branch-commits

Author: Kazu Hirata
Date: 2020-12-14T23:00:17-08:00
New Revision: 504e4be2c111ef8e79a91f0b92fdc009995204d1

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

LOG: [IR] Remove isPowerOf2ByteWidth

The predicate used to be used with the C backend, which was removed on
Mar 23, 2012 in commit 64a232343aa649fdacf78698da3e4d5737dee56a.  It
seems to be unused since then.

Added: 


Modified: 
llvm/include/llvm/IR/DerivedTypes.h
llvm/lib/IR/Type.cpp

Removed: 




diff  --git a/llvm/include/llvm/IR/DerivedTypes.h 
b/llvm/include/llvm/IR/DerivedTypes.h
index 9534edc4ea06..51c5dd2d5845 100644
--- a/llvm/include/llvm/IR/DerivedTypes.h
+++ b/llvm/include/llvm/IR/DerivedTypes.h
@@ -87,12 +87,6 @@ class IntegerType : public Type {
   /// Get a bit mask for this type.
   APInt getMask() const;
 
-  /// This method determines if the width of this IntegerType is a power-of-2
-  /// in terms of 8 bit bytes.
-  /// @returns true if this is a power-of-2 byte width.
-  /// Is this a power-of-2 byte-width IntegerType ?
-  bool isPowerOf2ByteWidth() const;
-
   /// Methods for support type inquiry through isa, cast, and dyn_cast.
   static bool classof(const Type *T) {
 return T->getTypeID() == IntegerTyID;

diff  --git a/llvm/lib/IR/Type.cpp b/llvm/lib/IR/Type.cpp
index 5e33c022a7ae..3b085129a375 100644
--- a/llvm/lib/IR/Type.cpp
+++ b/llvm/lib/IR/Type.cpp
@@ -275,11 +275,6 @@ IntegerType *IntegerType::get(LLVMContext , unsigned 
NumBits) {
   return Entry;
 }
 
-bool IntegerType::isPowerOf2ByteWidth() const {
-  unsigned BitWidth = getBitWidth();
-  return (BitWidth > 7) && isPowerOf2_32(BitWidth);
-}
-
 APInt IntegerType::getMask() const {
   return APInt::getAllOnesValue(getBitWidth());
 }



___
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] 2fc2e6d - [Test] Test on assertion failure with expensive SCEV range inference

2020-12-14 Thread Max Kazantsev via llvm-branch-commits

Author: Max Kazantsev
Date: 2020-12-15T13:47:19+07:00
New Revision: 2fc2e6de8222ae44fc4fd44fb31238b4a8cc990c

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

LOG: [Test] Test on assertion failure with expensive SCEV range inference

Added: 

llvm/test/Transforms/IndVarSimplify/2020-12-15-trunc-bug-expensive-range-inference.ll

Modified: 


Removed: 




diff  --git 
a/llvm/test/Transforms/IndVarSimplify/2020-12-15-trunc-bug-expensive-range-inference.ll
 
b/llvm/test/Transforms/IndVarSimplify/2020-12-15-trunc-bug-expensive-range-inference.ll
new file mode 100644
index ..dd105f40544e
--- /dev/null
+++ 
b/llvm/test/Transforms/IndVarSimplify/2020-12-15-trunc-bug-expensive-range-inference.ll
@@ -0,0 +1,61 @@
+; RUN: opt < %s -indvars -S -scalar-evolution-use-expensive-range-sharpening | 
FileCheck %s
+; RUN: opt < %s -passes=indvars -S 
-scalar-evolution-use-expensive-range-sharpening | 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"
+
+define void @test() {
+; CHECK-LABEL: test
+
+bb:
+  br label %bb1
+
+bb1:  ; preds = %bb10, %bb
+  %tmp = phi i32 [ undef, %bb ], [ %tmp11, %bb10 ]
+  %tmp2 = phi i32 [ 0, %bb ], [ 1, %bb10 ]
+  br i1 false, label %bb3, label %bb4
+
+bb3:  ; preds = %bb1
+  br label %bb8
+
+bb4:  ; preds = %bb1
+  br label %bb16
+
+bb5:  ; preds = %bb16
+  %tmp6 = phi i64 [ %tmp21, %bb16 ]
+  %tmp7 = phi i64 [ undef, %bb16 ]
+  br label %bb8
+
+bb8:  ; preds = %bb5, %bb3
+  %tmp9 = phi i64 [ undef, %bb3 ], [ %tmp6, %bb5 ]
+  br label %bb13
+
+bb10: ; preds = %bb13
+  %tmp11 = phi i32 [ %tmp15, %bb13 ]
+  br i1 undef, label %bb12, label %bb1
+
+bb12: ; preds = %bb10
+  ret void
+
+bb13: ; preds = %bb13, %bb8
+  %tmp14 = phi i32 [ %tmp, %bb8 ], [ %tmp15, %bb13 ]
+  %tmp15 = add i32 %tmp14, undef
+  br i1 undef, label %bb10, label %bb13
+
+bb16: ; preds = %bb16, %bb4
+  %tmp17 = phi i32 [ %tmp27, %bb16 ], [ %tmp2, %bb4 ]
+  %tmp18 = phi i64 [ %tmp21, %bb16 ], [ undef, %bb4 ]
+  %tmp19 = sext i32 %tmp17 to i64
+  %tmp20 = mul i64 undef, %tmp19
+  %tmp21 = add i64 %tmp18, 1
+  %tmp22 = add i32 %tmp17, %tmp
+  %tmp23 = add i32 %tmp22, undef
+  %tmp24 = add i32 %tmp23, undef
+  %tmp25 = and i32 %tmp24, 31
+  %tmp26 = lshr i32 undef, %tmp25
+  %tmp27 = add nsw i32 %tmp17, 1
+  %tmp28 = icmp sgt i32 %tmp17, 111
+  br i1 %tmp28, label %bb5, label %bb16
+}



___
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] ddc5a59 - [Analysis] Use llvm::erase_value (NFC)

2020-12-14 Thread Kazu Hirata via llvm-branch-commits

Author: Kazu Hirata
Date: 2020-12-14T22:40:13-08:00
New Revision: ddc5a5920e5d00336ee12f9c4682969ac18bca7f

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

LOG: [Analysis] Use llvm::erase_value (NFC)

Added: 


Modified: 
llvm/include/llvm/Analysis/IntervalIterator.h
llvm/lib/Analysis/AssumptionCache.cpp
llvm/lib/Analysis/LoopPass.cpp

Removed: 




diff  --git a/llvm/include/llvm/Analysis/IntervalIterator.h 
b/llvm/include/llvm/Analysis/IntervalIterator.h
index efaaf9715b3d..38bb3bbb1719 100644
--- a/llvm/include/llvm/Analysis/IntervalIterator.h
+++ b/llvm/include/llvm/Analysis/IntervalIterator.h
@@ -227,9 +227,7 @@ class IntervalIterator {
 
   if (Int->isSuccessor(NodeHeader)) {
 // If we were in the successor list from before... remove from succ 
list
-Int->Successors.erase(std::remove(Int->Successors.begin(),
-  Int->Successors.end(), NodeHeader),
-  Int->Successors.end());
+llvm::erase_value(Int->Successors, NodeHeader);
   }
 
   // Now that we have discovered that Node is in the interval, perhaps some

diff  --git a/llvm/lib/Analysis/AssumptionCache.cpp 
b/llvm/lib/Analysis/AssumptionCache.cpp
index cb94f716bdb3..bb1ac616ee7f 100644
--- a/llvm/lib/Analysis/AssumptionCache.cpp
+++ b/llvm/lib/Analysis/AssumptionCache.cpp
@@ -163,9 +163,7 @@ void AssumptionCache::unregisterAssumption(CallInst *CI) {
   AffectedValues.erase(AVI);
   }
 
-  AssumeHandles.erase(
-  remove_if(AssumeHandles, [CI](ResultElem ) { return CI == RE; }),
-  AssumeHandles.end());
+  erase_value(AssumeHandles, CI);
 }
 
 void AssumptionCache::AffectedValueCallbackVH::deleted() {

diff  --git a/llvm/lib/Analysis/LoopPass.cpp b/llvm/lib/Analysis/LoopPass.cpp
index 13e744f02665..9e470e998e67 100644
--- a/llvm/lib/Analysis/LoopPass.cpp
+++ b/llvm/lib/Analysis/LoopPass.cpp
@@ -117,7 +117,7 @@ void LPPassManager::markLoopAsDeleted(Loop ) {
   // there. However, we have to be careful to not remove the back of the queue
   // as that is assumed to match the current loop.
   assert(LQ.back() == CurrentLoop && "Loop queue back isn't the current 
loop!");
-  LQ.erase(std::remove(LQ.begin(), LQ.end(), ), LQ.end());
+  llvm::erase_value(LQ, );
 
   if ( == CurrentLoop) {
 CurrentLoopDeleted = true;



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [compiler-rt] a72d462 - Re-apply "[CMake][compiler-rt][AArch64] Avoid preprocessing LSE builtins separately"

2020-12-14 Thread Raul Tambre via llvm-branch-commits

Author: Raul Tambre
Date: 2020-12-15T08:18:07+02:00
New Revision: a72d462eb9b9f5698e081c8ccf3bc7fa3e35da08

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

LOG: Re-apply "[CMake][compiler-rt][AArch64] Avoid preprocessing LSE builtins 
separately"

aa772fc85e0f526615c78b9c3979c2be945a754c (D92530) has landed fixing relocations 
on Darwin.
3000c19df64f89ff319590f3a6e4d6b93d20983d (D93236) has landed working around an 
assembly parser bug on Darwin.
Previous quick-fix d9697c2e6b153ac7dc40a69450d9b672f71b1029 (D93198) included 
in this commit.

Invoking the preprocessor ourselves is fragile and would require us to 
replicate CMake's handling of definitions, compiler flags, etc for proper 
compatibility.
In my toolchain builds this notably resulted in a bunch of warnings from unused 
flags as my CMAKE_C_FLAGS includes CPU-specific optimization options.
Notably this part was already duplicating the logic for VISIBILITY_HIDDEN 
define.

Instead, symlink the files and set the proper set of defines on each.
This should also be faster as we avoid invoking the compiler multiple times.

Fixes https://llvm.org/PR48494

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

Added: 


Modified: 
compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
compiler-rt/lib/builtins/CMakeLists.txt
compiler-rt/lib/builtins/aarch64/lse.S

Removed: 




diff  --git a/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake 
b/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
index f6689c2e79ad..456a8dcda59f 100644
--- a/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
+++ b/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
@@ -395,7 +395,9 @@ macro(darwin_add_builtin_libraries)
   set(CMAKE_CXX_FLAGS "")
   set(CMAKE_ASM_FLAGS "")
 
-  set(PROFILE_SOURCES ../profile/InstrProfiling 
+  append_string_if(COMPILER_RT_HAS_ASM_LSE " -DHAS_ASM_LSE" CFLAGS)
+
+  set(PROFILE_SOURCES ../profile/InstrProfiling
   ../profile/InstrProfilingBuffer
   ../profile/InstrProfilingPlatformDarwin
   ../profile/InstrProfilingWriter

diff  --git a/compiler-rt/lib/builtins/CMakeLists.txt 
b/compiler-rt/lib/builtins/CMakeLists.txt
index d84f4d09e53e..5259e951dff3 100644
--- a/compiler-rt/lib/builtins/CMakeLists.txt
+++ b/compiler-rt/lib/builtins/CMakeLists.txt
@@ -509,31 +509,24 @@ set(aarch64_SOURCES
 )
 
 # Generate outline atomics helpers from lse.S base
-set(CUSTOM_FLAGS ${CMAKE_C_FLAGS})
-if(NOT ANDROID)
-  append_list_if(COMPILER_RT_HAS_VISIBILITY_HIDDEN_FLAG -DVISIBILITY_HIDDEN 
CUSTOM_FLAGS)
-endif()
-append_list_if(COMPILER_RT_HAS_ASM_LSE -DHAS_ASM_LSE CUSTOM_FLAGS)
-string(REPLACE " " "\t" CUSTOM_FLAGS "${CUSTOM_FLAGS}")
 set(OA_HELPERS_DIR "${CMAKE_CURRENT_BINARY_DIR}/outline_atomic_helpers.dir")
-file(MAKE_DIRECTORY ${OA_HELPERS_DIR})
+file(MAKE_DIRECTORY "${OA_HELPERS_DIR}")
 
 foreach(pat cas swp ldadd ldclr ldeor ldset)
   foreach(size 1 2 4 8 16)
 foreach(model 1 2 3 4)
   if(pat STREQUAL "cas" OR NOT size STREQUAL "16")
-set(helper_asm 
${OA_HELPERS_DIR}/outline_atomic_${pat}${size}_${model}.S)
+set(helper_asm 
"${OA_HELPERS_DIR}/outline_atomic_${pat}${size}_${model}.S")
 add_custom_command(
   OUTPUT ${helper_asm}
-  COMMAND ${CMAKE_C_COMPILER} -E ${CUSTOM_FLAGS} -DL_${pat} 
-DSIZE=${size} -DMODEL=${model}
-  ${CMAKE_CURRENT_SOURCE_DIR}/aarch64/lse.S -o ${helper_asm}
-  DEPENDS aarch64/lse.S assembly.h
+  COMMAND ${CMAKE_COMMAND} -E create_symlink 
"${CMAKE_CURRENT_SOURCE_DIR}/aarch64/lse.S" "${helper_asm}"
 )
-set_source_files_properties(${helper_asm} PROPERTIES GENERATED TRUE)
-set(aarch64_SOURCES
-  ${aarch64_SOURCES}
-  ${helper_asm}
+set_source_files_properties("${helper_asm}"
+  PROPERTIES
+  COMPILE_DEFINITIONS "L_${pat};SIZE=${size};MODEL=${model}"
+  INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}"
 )
+list(APPEND aarch64_SOURCES "${helper_asm}")
   endif()
 endforeach(model)
   endforeach(size)
@@ -687,6 +680,8 @@ else ()
 append_list_if(COMPILER_RT_HAS_VISIBILITY_HIDDEN_FLAG VISIBILITY_HIDDEN 
BUILTIN_DEFS)
   endif()
 
+  append_list_if(COMPILER_RT_HAS_ASM_LSE HAS_ASM_LSE BUILTIN_DEFS)
+
   foreach (arch ${BUILTIN_SUPPORTED_ARCH})
 if (CAN_TARGET_${arch})
   # For ARM archs, exclude any VFP builtins if VFP is not supported

diff  --git a/compiler-rt/lib/builtins/aarch64/lse.S 
b/compiler-rt/lib/builtins/aarch64/lse.S
index e1c801cd62fc..87d8b3ac9be4 100644
--- a/compiler-rt/lib/builtins/aarch64/lse.S
+++ b/compiler-rt/lib/builtins/aarch64/lse.S
@@ -2,7 +2,7 @@
 // See https://llvm.org/LICENSE.txt for license information.
 // 

[llvm-branch-commits] [compiler-rt] 3000c19 - [Compiler-rt][AArch64] Workaround for .cfi_startproc assembler parser bug.

2020-12-14 Thread Raul Tambre via llvm-branch-commits

Author: Raul Tambre
Date: 2020-12-15T08:14:42+02:00
New Revision: 3000c19df64f89ff319590f3a6e4d6b93d20983d

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

LOG: [Compiler-rt][AArch64] Workaround for .cfi_startproc assembler parser bug.

Put .cfi_startproc on a new line to avoid hitting the assembly parser bug in 
MasmParser::parseDirectiveCFIStartProc().

Reviewed By: tambre

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

Added: 


Modified: 
compiler-rt/lib/builtins/aarch64/lse.S
compiler-rt/lib/builtins/assembly.h

Removed: 




diff  --git a/compiler-rt/lib/builtins/aarch64/lse.S 
b/compiler-rt/lib/builtins/aarch64/lse.S
index 770f098b7cf1..e1c801cd62fc 100644
--- a/compiler-rt/lib/builtins/aarch64/lse.S
+++ b/compiler-rt/lib/builtins/aarch64/lse.S
@@ -113,7 +113,8 @@ HIDDEN(__aarch64_have_lse_atomics)
 .endm
 
 #ifdef L_cas
-DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(NAME(cas))
+DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED_START(NAME(cas))
+DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED_END(NAME(cas))
 JUMP_IF_NOT_LSE 8f
 #if SIZE < 16
 #ifdef HAS_ASM_LSE
@@ -166,7 +167,8 @@ END_COMPILERRT_OUTLINE_FUNCTION(NAME(cas))
 #else
 #define SWP .inst 0x38208020 + B + N
 #endif
-DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(NAME(swp))
+DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED_START(NAME(swp))
+DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED_END(NAME(swp))
 JUMP_IF_NOT_LSE 8f
 SWP// s(0), s(0), [x1]
 ret
@@ -209,7 +211,8 @@ END_COMPILERRT_OUTLINE_FUNCTION(NAME(swp))
 #define LDOP .inst 0x38200020 + OPN + B + N
 #endif
 
-DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(NAME(LDNM))
+DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED_START(NAME(LDNM))
+DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED_END(NAME(LDNM))
 JUMP_IF_NOT_LSE 8f
 LDOP // s(0), s(0), [x1]
 ret

diff  --git a/compiler-rt/lib/builtins/assembly.h 
b/compiler-rt/lib/builtins/assembly.h
index 66625a926cd0..3b00a5def6f3 100644
--- a/compiler-rt/lib/builtins/assembly.h
+++ b/compiler-rt/lib/builtins/assembly.h
@@ -243,12 +243,16 @@
   DECLARE_FUNC_ENCODING
\
   name:
 
-#define DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(name) 
\
+// TODO(ilinpv) START & END parts will be merged when assembly parser bug
+// (kristina) in MasmParser::parseDirectiveCFIStartProc() is fixed.
+#define DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED_START(name)   
\
   DEFINE_CODE_STATE
\
   FUNC_ALIGN   
\
   .globl name SEPARATOR
\
   SYMBOL_IS_FUNC(name) SEPARATOR   
\
-  DECLARE_SYMBOL_VISIBILITY(name) SEPARATOR
\
+  DECLARE_SYMBOL_VISIBILITY(name)
+
+#define DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED_END(name) 
\
   CFI_START SEPARATOR  
\
   DECLARE_FUNC_ENCODING
\
   name: SEPARATOR BTI_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] [lldb] dc82890 - [lldb/API] Expose Target::CreateBreakpoint(..., move_to_nearest_code) overload

2020-12-14 Thread Med Ismail Bennani via llvm-branch-commits

Author: Med Ismail Bennani
Date: 2020-12-15T06:18:04+01:00
New Revision: dc82890a77fe894e90103f4465bb4c838617feff

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

LOG: [lldb/API] Expose Target::CreateBreakpoint(..., move_to_nearest_code) 
overload

This patch exposes the Target::CreateBreakpoint overload with the
boolean argument to move to the neareast code to the SBAPI.

This is useful when creating column breakpoints to restrict lldb's
resolution to the pointed source location, preventing it to go to the next
line.

rdar://72196842

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

Signed-off-by: Med Ismail Bennani 

Added: 


Modified: 
lldb/bindings/interface/SBTarget.i
lldb/include/lldb/API/SBTarget.h
lldb/source/API/SBTarget.cpp

lldb/test/API/functionalities/breakpoint/breakpoint_by_line_and_column/TestBreakpointByLineAndColumn.py

Removed: 




diff  --git a/lldb/bindings/interface/SBTarget.i 
b/lldb/bindings/interface/SBTarget.i
index 57b5ccea6399..41b9be2bf1fb 100644
--- a/lldb/bindings/interface/SBTarget.i
+++ b/lldb/bindings/interface/SBTarget.i
@@ -579,6 +579,12 @@ public:
 uint32_t column, lldb::addr_t offset,
 SBFileSpecList _list);
 
+lldb::SBBreakpoint
+BreakpointCreateByLocation (const lldb::SBFileSpec _spec, uint32_t 
line,
+uint32_t column, lldb::addr_t offset,
+SBFileSpecList _list,
+bool move_to_nearest_code);
+
 lldb::SBBreakpoint
 BreakpointCreateByName (const char *symbol_name, const char *module_name = 
NULL);
 

diff  --git a/lldb/include/lldb/API/SBTarget.h 
b/lldb/include/lldb/API/SBTarget.h
index fad842c9cb1c..30f4005dfc0f 100644
--- a/lldb/include/lldb/API/SBTarget.h
+++ b/lldb/include/lldb/API/SBTarget.h
@@ -560,6 +560,12 @@ class LLDB_API SBTarget {
  uint32_t column, lldb::addr_t offset,
  SBFileSpecList _list);
 
+  lldb::SBBreakpoint
+  BreakpointCreateByLocation(const lldb::SBFileSpec _spec, uint32_t line,
+ uint32_t column, lldb::addr_t offset,
+ SBFileSpecList _list,
+ bool move_to_nearest_code);
+
   lldb::SBBreakpoint BreakpointCreateByName(const char *symbol_name,
 const char *module_name = nullptr);
 

diff  --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp
index 2a305159bbb5..6128c04de32b 100644
--- a/lldb/source/API/SBTarget.cpp
+++ b/lldb/source/API/SBTarget.cpp
@@ -787,6 +787,38 @@ SBBreakpoint SBTarget::BreakpointCreateByLocation(
   return LLDB_RECORD_RESULT(sb_bp);
 }
 
+SBBreakpoint SBTarget::BreakpointCreateByLocation(
+const SBFileSpec _file_spec, uint32_t line, uint32_t column,
+lldb::addr_t offset, SBFileSpecList _module_list,
+bool move_to_nearest_code) {
+  LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByLocation,
+ (const lldb::SBFileSpec &, uint32_t, uint32_t,
+  lldb::addr_t, lldb::SBFileSpecList &, bool),
+ sb_file_spec, line, column, offset, sb_module_list,
+ move_to_nearest_code);
+
+  SBBreakpoint sb_bp;
+  TargetSP target_sp(GetSP());
+  if (target_sp && line != 0) {
+std::lock_guard guard(target_sp->GetAPIMutex());
+
+const LazyBool check_inlines = eLazyBoolCalculate;
+const LazyBool skip_prologue = eLazyBoolCalculate;
+const bool internal = false;
+const bool hardware = false;
+const FileSpecList *module_list = nullptr;
+if (sb_module_list.GetSize() > 0) {
+  module_list = sb_module_list.get();
+}
+sb_bp = target_sp->CreateBreakpoint(
+module_list, *sb_file_spec, line, column, offset, check_inlines,
+skip_prologue, internal, hardware,
+move_to_nearest_code ? eLazyBoolYes : eLazyBoolNo);
+  }
+
+  return LLDB_RECORD_RESULT(sb_bp);
+}
+
 SBBreakpoint SBTarget::BreakpointCreateByName(const char *symbol_name,
   const char *module_name) {
   LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByName,
@@ -2489,6 +2521,9 @@ void RegisterMethods(Registry ) {
BreakpointCreateByLocation,
(const lldb::SBFileSpec &, uint32_t, uint32_t,
 lldb::addr_t, lldb::SBFileSpecList &));
+  LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, 
BreakpointCreateByLocation,
+   (const lldb::SBFileSpec &, uint32_t, uint32_t,
+lldb::addr_t, lldb::SBFileSpecList &, bool));
   

[llvm-branch-commits] [lldb] 1d3f1eb - Revert "[lldb/API] Expose Target::CreateBreakpoint(..., move_to_nearest_code) overload"

2020-12-14 Thread Med Ismail Bennani via llvm-branch-commits

Author: Med Ismail Bennani
Date: 2020-12-15T06:18:04+01:00
New Revision: 1d3f1eb855fcfb03b6ddb92543c02694115b5739

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

LOG: Revert "[lldb/API] Expose Target::CreateBreakpoint(..., 
move_to_nearest_code) overload"

This reverts commit 04696ff002e7d311887b7b7e6e171340a0623dd9.

Exposing the LazyBool private type in SBTarget.h breaks some tests.

Added: 


Modified: 
lldb/bindings/interface/SBTarget.i
lldb/include/lldb/API/SBTarget.h
lldb/source/API/SBTarget.cpp

lldb/test/API/functionalities/breakpoint/breakpoint_by_line_and_column/TestBreakpointByLineAndColumn.py

Removed: 




diff  --git a/lldb/bindings/interface/SBTarget.i 
b/lldb/bindings/interface/SBTarget.i
index 41b9be2bf1fb..57b5ccea6399 100644
--- a/lldb/bindings/interface/SBTarget.i
+++ b/lldb/bindings/interface/SBTarget.i
@@ -579,12 +579,6 @@ public:
 uint32_t column, lldb::addr_t offset,
 SBFileSpecList _list);
 
-lldb::SBBreakpoint
-BreakpointCreateByLocation (const lldb::SBFileSpec _spec, uint32_t 
line,
-uint32_t column, lldb::addr_t offset,
-SBFileSpecList _list,
-bool move_to_nearest_code);
-
 lldb::SBBreakpoint
 BreakpointCreateByName (const char *symbol_name, const char *module_name = 
NULL);
 

diff  --git a/lldb/include/lldb/API/SBTarget.h 
b/lldb/include/lldb/API/SBTarget.h
index bf423726f080..fad842c9cb1c 100644
--- a/lldb/include/lldb/API/SBTarget.h
+++ b/lldb/include/lldb/API/SBTarget.h
@@ -9,8 +9,6 @@
 #ifndef LLDB_API_SBTARGET_H
 #define LLDB_API_SBTARGET_H
 
-#include "lldb/lldb-private-enumerations.h"
-
 #include "lldb/API/SBAddress.h"
 #include "lldb/API/SBAttachInfo.h"
 #include "lldb/API/SBBreakpoint.h"
@@ -562,12 +560,6 @@ class LLDB_API SBTarget {
  uint32_t column, lldb::addr_t offset,
  SBFileSpecList _list);
 
-  lldb::SBBreakpoint
-  BreakpointCreateByLocation(const lldb::SBFileSpec _spec, uint32_t line,
- uint32_t column, lldb::addr_t offset,
- SBFileSpecList _list,
- bool move_to_nearest_code);
-
   lldb::SBBreakpoint BreakpointCreateByName(const char *symbol_name,
 const char *module_name = nullptr);
 
@@ -866,11 +858,6 @@ class LLDB_API SBTarget {
   void SetSP(const lldb::TargetSP _sp);
 
 private:
-  lldb::SBBreakpoint BreakpointCreateByLocationImpl(
-  const lldb::SBFileSpec _spec, uint32_t line, uint32_t column,
-  lldb::addr_t offset, SBFileSpecList _list,
-  const lldb_private::LazyBool move_to_nearest_code);
-
   lldb::TargetSP m_opaque_sp;
 };
 

diff  --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp
index d0761d69c667..2a305159bbb5 100644
--- a/lldb/source/API/SBTarget.cpp
+++ b/lldb/source/API/SBTarget.cpp
@@ -757,10 +757,14 @@ SBTarget::BreakpointCreateByLocation(const SBFileSpec 
_file_spec,
offset, 
sb_module_list));
 }
 
-SBBreakpoint SBTarget::BreakpointCreateByLocationImpl(
-const lldb::SBFileSpec _file_spec, uint32_t line, uint32_t column,
-lldb::addr_t offset, SBFileSpecList _module_list,
-const LazyBool move_to_nearest_code) {
+SBBreakpoint SBTarget::BreakpointCreateByLocation(
+const SBFileSpec _file_spec, uint32_t line, uint32_t column,
+lldb::addr_t offset, SBFileSpecList _module_list) {
+  LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByLocation,
+ (const lldb::SBFileSpec &, uint32_t, uint32_t,
+  lldb::addr_t, lldb::SBFileSpecList &),
+ sb_file_spec, line, column, offset, sb_module_list);
+
   SBBreakpoint sb_bp;
   TargetSP target_sp(GetSP());
   if (target_sp && line != 0) {
@@ -770,6 +774,7 @@ SBBreakpoint SBTarget::BreakpointCreateByLocationImpl(
 const LazyBool skip_prologue = eLazyBoolCalculate;
 const bool internal = false;
 const bool hardware = false;
+const LazyBool move_to_nearest_code = eLazyBoolCalculate;
 const FileSpecList *module_list = nullptr;
 if (sb_module_list.GetSize() > 0) {
   module_list = sb_module_list.get();
@@ -779,34 +784,7 @@ SBBreakpoint SBTarget::BreakpointCreateByLocationImpl(
 skip_prologue, internal, hardware, move_to_nearest_code);
   }
 
-  return sb_bp;
-}
-
-SBBreakpoint SBTarget::BreakpointCreateByLocation(
-const SBFileSpec _file_spec, uint32_t line, uint32_t column,
-lldb::addr_t offset, SBFileSpecList _module_list) {
-  LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, 

[llvm-branch-commits] [llvm] 0869544 - [gn build] Port d2ed9d6b7ec

2020-12-14 Thread LLVM GN Syncbot via llvm-branch-commits

Author: LLVM GN Syncbot
Date: 2020-12-15T03:35:00Z
New Revision: 086954412f5089301e5e453becd329ea2320be94

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

LOG: [gn build] Port d2ed9d6b7ec

Added: 


Modified: 
llvm/utils/gn/secondary/llvm/unittests/Support/BUILD.gn

Removed: 




diff  --git a/llvm/utils/gn/secondary/llvm/unittests/Support/BUILD.gn 
b/llvm/utils/gn/secondary/llvm/unittests/Support/BUILD.gn
index 0dab9cd66050..4f6f40b85fb0 100644
--- a/llvm/utils/gn/secondary/llvm/unittests/Support/BUILD.gn
+++ b/llvm/utils/gn/secondary/llvm/unittests/Support/BUILD.gn
@@ -7,6 +7,7 @@ unittest("SupportTests") {
   ]
   sources = [
 "ARMAttributeParser.cpp",
+"AlignOfTest.cpp",
 "AlignmentTest.cpp",
 "AllocatorTest.cpp",
 "AnnotationsTest.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] a852ee1 - Reland "[MachineDebugify] Insert synthetic DBG_VALUE instructions"

2020-12-14 Thread Nico Weber via llvm-branch-commits

Author: Nico Weber
Date: 2020-12-14T22:34:23-05:00
New Revision: a852ee199c73237d89932019e8a74cf38842f2bd

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

LOG: Reland "[MachineDebugify] Insert synthetic DBG_VALUE instructions"

This reverts commit 841f9c937f6e593c926a26aedf054436eb807fe6.
The change landed many months ago; something else broke those tests.

Added: 
llvm/test/CodeGen/AArch64/GlobalISel/constant-mir-debugify.mir
llvm/test/CodeGen/AArch64/GlobalISel/phi-mir-debugify.mir
llvm/test/CodeGen/Generic/MIRDebugify/locations-and-values.mir

Modified: 
llvm/lib/CodeGen/MachineDebugify.cpp
llvm/lib/Transforms/Utils/Debugify.cpp
llvm/test/CodeGen/AArch64/GlobalISel/legalize-phi-insertpt-decrement.mir
llvm/test/DebugInfo/debugify.ll

Removed: 
llvm/test/CodeGen/Generic/MIRDebugify/locations.mir



diff  --git a/llvm/lib/CodeGen/MachineDebugify.cpp 
b/llvm/lib/CodeGen/MachineDebugify.cpp
index bc607cabcc68..bf57ec0e8c28 100644
--- a/llvm/lib/CodeGen/MachineDebugify.cpp
+++ b/llvm/lib/CodeGen/MachineDebugify.cpp
@@ -7,16 +7,23 @@
 
//===--===//
 ///
 /// \file This pass attaches synthetic debug info to everything. It can be used
-/// to create targeted tests for debug info preservation.
+/// to create targeted tests for debug info preservation, or test for CodeGen
+/// 
diff erences with vs. without debug info.
 ///
 /// This isn't intended to have feature parity with Debugify.
 
//===--===//
 
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/SmallVector.h"
 #include "llvm/CodeGen/MachineFunctionPass.h"
+#include "llvm/CodeGen/MachineInstrBuilder.h"
 #include "llvm/CodeGen/MachineModuleInfo.h"
 #include "llvm/CodeGen/Passes.h"
+#include "llvm/CodeGen/TargetInstrInfo.h"
+#include "llvm/CodeGen/TargetSubtargetInfo.h"
 #include "llvm/IR/DIBuilder.h"
 #include "llvm/IR/DebugInfo.h"
+#include "llvm/IR/IntrinsicInst.h"
 #include "llvm/InitializePasses.h"
 #include "llvm/Transforms/Utils/Debugify.h"
 
@@ -31,13 +38,15 @@ bool 
applyDebugifyMetadataToMachineFunction(MachineModuleInfo ,
   if (!MaybeMF)
 return false;
   MachineFunction  = *MaybeMF;
+  const TargetInstrInfo  = *MF.getSubtarget().getInstrInfo();
 
   DISubprogram *SP = F.getSubprogram();
   assert(SP && "IR Debugify just created it?");
 
-  LLVMContext  = F.getParent()->getContext();
-  unsigned NextLine = SP->getLine();
+  Module  = *F.getParent();
+  LLVMContext  = M.getContext();
 
+  unsigned NextLine = SP->getLine();
   for (MachineBasicBlock  : MF) {
 for (MachineInstr  : MBB) {
   // This will likely emit line numbers beyond the end of the imagined
@@ -48,6 +57,81 @@ bool 
applyDebugifyMetadataToMachineFunction(MachineModuleInfo ,
 }
   }
 
+  // Find local variables defined by debugify. No attempt is made to match up
+  // MIR-level regs to the 'correct' IR-level variables: there isn't a simple
+  // way to do that, and it isn't necessary to find interesting CodeGen bugs.
+  // Instead, simply keep track of one variable per line. Later, we can insert
+  // DBG_VALUE insts that point to these local variables. Emitting DBG_VALUEs
+  // which cover a wide range of lines can help stress the debug info passes:
+  // if we can't do that, fall back to using the local variable which precedes
+  // all the others.
+  Function *DbgValF = M.getFunction("llvm.dbg.value");
+  DbgValueInst *EarliestDVI = nullptr;
+  DenseMap Line2Var;
+  DIExpression *Expr = nullptr;
+  if (DbgValF) {
+for (const Use  : DbgValF->uses()) {
+  auto *DVI = dyn_cast(U.getUser());
+  if (!DVI || DVI->getFunction() != )
+continue;
+  unsigned Line = DVI->getDebugLoc().getLine();
+  assert(Line != 0 && "debugify should not insert line 0 locations");
+  Line2Var[Line] = DVI->getVariable();
+  if (!EarliestDVI || Line < EarliestDVI->getDebugLoc().getLine())
+EarliestDVI = DVI;
+  Expr = DVI->getExpression();
+}
+  }
+  if (Line2Var.empty())
+return true;
+
+  // Now, try to insert a DBG_VALUE instruction after each real instruction.
+  // Do this by introducing debug uses of each register definition. If that is
+  // not possible (e.g. we have a phi or a meta instruction), emit a constant.
+  uint64_t NextImm = 0;
+  const MCInstrDesc  = TII.get(TargetOpcode::DBG_VALUE);
+  for (MachineBasicBlock  : MF) {
+MachineBasicBlock::iterator FirstNonPHIIt = MBB.getFirstNonPHI();
+for (auto I = MBB.begin(), E = MBB.end(); I != E; ) {
+  MachineInstr  = *I;
+  ++I;
+
+  // `I` may point to a DBG_VALUE created in the previous loop iteration.
+  if (MI.isDebugInstr())
+continue;
+
+  // It's not 

[llvm-branch-commits] [lldb] 0470169 - [lldb/API] Expose Target::CreateBreakpoint(..., move_to_nearest_code) overload

2020-12-14 Thread Med Ismail Bennani via llvm-branch-commits

Author: Med Ismail Bennani
Date: 2020-12-15T04:24:44+01:00
New Revision: 04701698ebaff8d0c108e590a7e55c3c5bcd4d9e

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

LOG: [lldb/API] Expose Target::CreateBreakpoint(..., move_to_nearest_code) 
overload

This patch exposes the Target::CreateBreakpoint overload with the
boolean argument to move to the neareast code to the SBAPI.

This is useful when creating column breakpoints to restrict lldb's
resolution to the pointed source location, preventing it to go to the next
line.

rdar://72196842

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

Signed-off-by: Med Ismail Bennani 

Added: 


Modified: 
lldb/bindings/interface/SBTarget.i
lldb/include/lldb/API/SBTarget.h
lldb/source/API/SBTarget.cpp

lldb/test/API/functionalities/breakpoint/breakpoint_by_line_and_column/TestBreakpointByLineAndColumn.py

Removed: 




diff  --git a/lldb/bindings/interface/SBTarget.i 
b/lldb/bindings/interface/SBTarget.i
index 57b5ccea6399..41b9be2bf1fb 100644
--- a/lldb/bindings/interface/SBTarget.i
+++ b/lldb/bindings/interface/SBTarget.i
@@ -579,6 +579,12 @@ public:
 uint32_t column, lldb::addr_t offset,
 SBFileSpecList _list);
 
+lldb::SBBreakpoint
+BreakpointCreateByLocation (const lldb::SBFileSpec _spec, uint32_t 
line,
+uint32_t column, lldb::addr_t offset,
+SBFileSpecList _list,
+bool move_to_nearest_code);
+
 lldb::SBBreakpoint
 BreakpointCreateByName (const char *symbol_name, const char *module_name = 
NULL);
 

diff  --git a/lldb/include/lldb/API/SBTarget.h 
b/lldb/include/lldb/API/SBTarget.h
index fad842c9cb1c..bf423726f080 100644
--- a/lldb/include/lldb/API/SBTarget.h
+++ b/lldb/include/lldb/API/SBTarget.h
@@ -9,6 +9,8 @@
 #ifndef LLDB_API_SBTARGET_H
 #define LLDB_API_SBTARGET_H
 
+#include "lldb/lldb-private-enumerations.h"
+
 #include "lldb/API/SBAddress.h"
 #include "lldb/API/SBAttachInfo.h"
 #include "lldb/API/SBBreakpoint.h"
@@ -560,6 +562,12 @@ class LLDB_API SBTarget {
  uint32_t column, lldb::addr_t offset,
  SBFileSpecList _list);
 
+  lldb::SBBreakpoint
+  BreakpointCreateByLocation(const lldb::SBFileSpec _spec, uint32_t line,
+ uint32_t column, lldb::addr_t offset,
+ SBFileSpecList _list,
+ bool move_to_nearest_code);
+
   lldb::SBBreakpoint BreakpointCreateByName(const char *symbol_name,
 const char *module_name = nullptr);
 
@@ -858,6 +866,11 @@ class LLDB_API SBTarget {
   void SetSP(const lldb::TargetSP _sp);
 
 private:
+  lldb::SBBreakpoint BreakpointCreateByLocationImpl(
+  const lldb::SBFileSpec _spec, uint32_t line, uint32_t column,
+  lldb::addr_t offset, SBFileSpecList _list,
+  const lldb_private::LazyBool move_to_nearest_code);
+
   lldb::TargetSP m_opaque_sp;
 };
 

diff  --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp
index 2a305159bbb5..d0761d69c667 100644
--- a/lldb/source/API/SBTarget.cpp
+++ b/lldb/source/API/SBTarget.cpp
@@ -757,14 +757,10 @@ SBTarget::BreakpointCreateByLocation(const SBFileSpec 
_file_spec,
offset, 
sb_module_list));
 }
 
-SBBreakpoint SBTarget::BreakpointCreateByLocation(
-const SBFileSpec _file_spec, uint32_t line, uint32_t column,
-lldb::addr_t offset, SBFileSpecList _module_list) {
-  LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByLocation,
- (const lldb::SBFileSpec &, uint32_t, uint32_t,
-  lldb::addr_t, lldb::SBFileSpecList &),
- sb_file_spec, line, column, offset, sb_module_list);
-
+SBBreakpoint SBTarget::BreakpointCreateByLocationImpl(
+const lldb::SBFileSpec _file_spec, uint32_t line, uint32_t column,
+lldb::addr_t offset, SBFileSpecList _module_list,
+const LazyBool move_to_nearest_code) {
   SBBreakpoint sb_bp;
   TargetSP target_sp(GetSP());
   if (target_sp && line != 0) {
@@ -774,7 +770,6 @@ SBBreakpoint SBTarget::BreakpointCreateByLocation(
 const LazyBool skip_prologue = eLazyBoolCalculate;
 const bool internal = false;
 const bool hardware = false;
-const LazyBool move_to_nearest_code = eLazyBoolCalculate;
 const FileSpecList *module_list = nullptr;
 if (sb_module_list.GetSize() > 0) {
   module_list = sb_module_list.get();
@@ -784,7 +779,34 @@ SBBreakpoint SBTarget::BreakpointCreateByLocation(
 skip_prologue, internal, hardware, move_to_nearest_code);
   }
 
-  return 

[llvm-branch-commits] [llvm] 841f9c9 - Revert "[MachineDebugify] Insert synthetic DBG_VALUE instructions"

2020-12-14 Thread Nico Weber via llvm-branch-commits

Author: Nico Weber
Date: 2020-12-14T22:14:48-05:00
New Revision: 841f9c937f6e593c926a26aedf054436eb807fe6

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

LOG: Revert "[MachineDebugify] Insert synthetic DBG_VALUE instructions"

This reverts commit 2a5675f11d3bc803a245c0e2a3b47491c8f8a065.
The tests it adds fail: https://reviews.llvm.org/D78135#2453736

Added: 
llvm/test/CodeGen/Generic/MIRDebugify/locations.mir

Modified: 
llvm/lib/CodeGen/MachineDebugify.cpp
llvm/lib/Transforms/Utils/Debugify.cpp
llvm/test/CodeGen/AArch64/GlobalISel/legalize-phi-insertpt-decrement.mir
llvm/test/DebugInfo/debugify.ll

Removed: 
llvm/test/CodeGen/AArch64/GlobalISel/constant-mir-debugify.mir
llvm/test/CodeGen/AArch64/GlobalISel/phi-mir-debugify.mir
llvm/test/CodeGen/Generic/MIRDebugify/locations-and-values.mir



diff  --git a/llvm/lib/CodeGen/MachineDebugify.cpp 
b/llvm/lib/CodeGen/MachineDebugify.cpp
index bf57ec0e8c28..bc607cabcc68 100644
--- a/llvm/lib/CodeGen/MachineDebugify.cpp
+++ b/llvm/lib/CodeGen/MachineDebugify.cpp
@@ -7,23 +7,16 @@
 
//===--===//
 ///
 /// \file This pass attaches synthetic debug info to everything. It can be used
-/// to create targeted tests for debug info preservation, or test for CodeGen
-/// 
diff erences with vs. without debug info.
+/// to create targeted tests for debug info preservation.
 ///
 /// This isn't intended to have feature parity with Debugify.
 
//===--===//
 
-#include "llvm/ADT/DenseMap.h"
-#include "llvm/ADT/SmallVector.h"
 #include "llvm/CodeGen/MachineFunctionPass.h"
-#include "llvm/CodeGen/MachineInstrBuilder.h"
 #include "llvm/CodeGen/MachineModuleInfo.h"
 #include "llvm/CodeGen/Passes.h"
-#include "llvm/CodeGen/TargetInstrInfo.h"
-#include "llvm/CodeGen/TargetSubtargetInfo.h"
 #include "llvm/IR/DIBuilder.h"
 #include "llvm/IR/DebugInfo.h"
-#include "llvm/IR/IntrinsicInst.h"
 #include "llvm/InitializePasses.h"
 #include "llvm/Transforms/Utils/Debugify.h"
 
@@ -38,15 +31,13 @@ bool 
applyDebugifyMetadataToMachineFunction(MachineModuleInfo ,
   if (!MaybeMF)
 return false;
   MachineFunction  = *MaybeMF;
-  const TargetInstrInfo  = *MF.getSubtarget().getInstrInfo();
 
   DISubprogram *SP = F.getSubprogram();
   assert(SP && "IR Debugify just created it?");
 
-  Module  = *F.getParent();
-  LLVMContext  = M.getContext();
-
+  LLVMContext  = F.getParent()->getContext();
   unsigned NextLine = SP->getLine();
+
   for (MachineBasicBlock  : MF) {
 for (MachineInstr  : MBB) {
   // This will likely emit line numbers beyond the end of the imagined
@@ -57,81 +48,6 @@ bool 
applyDebugifyMetadataToMachineFunction(MachineModuleInfo ,
 }
   }
 
-  // Find local variables defined by debugify. No attempt is made to match up
-  // MIR-level regs to the 'correct' IR-level variables: there isn't a simple
-  // way to do that, and it isn't necessary to find interesting CodeGen bugs.
-  // Instead, simply keep track of one variable per line. Later, we can insert
-  // DBG_VALUE insts that point to these local variables. Emitting DBG_VALUEs
-  // which cover a wide range of lines can help stress the debug info passes:
-  // if we can't do that, fall back to using the local variable which precedes
-  // all the others.
-  Function *DbgValF = M.getFunction("llvm.dbg.value");
-  DbgValueInst *EarliestDVI = nullptr;
-  DenseMap Line2Var;
-  DIExpression *Expr = nullptr;
-  if (DbgValF) {
-for (const Use  : DbgValF->uses()) {
-  auto *DVI = dyn_cast(U.getUser());
-  if (!DVI || DVI->getFunction() != )
-continue;
-  unsigned Line = DVI->getDebugLoc().getLine();
-  assert(Line != 0 && "debugify should not insert line 0 locations");
-  Line2Var[Line] = DVI->getVariable();
-  if (!EarliestDVI || Line < EarliestDVI->getDebugLoc().getLine())
-EarliestDVI = DVI;
-  Expr = DVI->getExpression();
-}
-  }
-  if (Line2Var.empty())
-return true;
-
-  // Now, try to insert a DBG_VALUE instruction after each real instruction.
-  // Do this by introducing debug uses of each register definition. If that is
-  // not possible (e.g. we have a phi or a meta instruction), emit a constant.
-  uint64_t NextImm = 0;
-  const MCInstrDesc  = TII.get(TargetOpcode::DBG_VALUE);
-  for (MachineBasicBlock  : MF) {
-MachineBasicBlock::iterator FirstNonPHIIt = MBB.getFirstNonPHI();
-for (auto I = MBB.begin(), E = MBB.end(); I != E; ) {
-  MachineInstr  = *I;
-  ++I;
-
-  // `I` may point to a DBG_VALUE created in the previous loop iteration.
-  if (MI.isDebugInstr())
-continue;
-
-  // It's not allowed to insert DBG_VALUEs after a 

[llvm-branch-commits] [llvm] da2551f - Revert "[Debugify] Support checking Machine IR debug info"

2020-12-14 Thread Nico Weber via llvm-branch-commits

Author: Nico Weber
Date: 2020-12-14T22:14:48-05:00
New Revision: da2551f3d191c1f0a32a3c9e3a26d2a236825871

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

LOG: Revert "[Debugify] Support checking Machine IR debug info"

This reverts commit c4d2d4337d50bed3cafd564daece1a197005b22b.
Necessary to revert 2a5675f11d3bc803a245c0e.

Added: 


Modified: 
llvm/docs/HowToUpdateDebugInfo.rst
llvm/include/llvm/CodeGen/Passes.h
llvm/include/llvm/CodeGen/TargetPassConfig.h
llvm/include/llvm/InitializePasses.h
llvm/lib/CodeGen/CMakeLists.txt
llvm/lib/CodeGen/CodeGen.cpp
llvm/lib/CodeGen/MachineDebugify.cpp
llvm/lib/CodeGen/TargetPassConfig.cpp
llvm/test/CodeGen/Generic/MIRDebugify/locations-and-values.mir
llvm/utils/gn/secondary/llvm/lib/CodeGen/BUILD.gn

Removed: 
llvm/lib/CodeGen/MachineCheckDebugify.cpp
llvm/test/CodeGen/Generic/MIRDebugify/check-line-and-variables-x.mir
llvm/test/CodeGen/Generic/MIRDebugify/check-line-and-variables.ll
llvm/test/CodeGen/Generic/MIRDebugify/check-line-and-variables.mir



diff  --git a/llvm/docs/HowToUpdateDebugInfo.rst 
b/llvm/docs/HowToUpdateDebugInfo.rst
index fff0cdbe59c8..7df2a8a25827 100644
--- a/llvm/docs/HowToUpdateDebugInfo.rst
+++ b/llvm/docs/HowToUpdateDebugInfo.rst
@@ -342,8 +342,8 @@ A variant of the ``debugify`` utility described in
 :ref:`Mutation testing for IR-level transformations` can be used
 for MIR-level transformations as well: much like the IR-level pass,
 ``mir-debugify`` inserts sequentially increasing line locations to each
-``MachineInstr`` in a ``Module``. And the MIR-level ``mir-check-debugify`` is
-similar to IR-level ``check-debugify`` pass.
+``MachineInstr`` in a ``Module`` (although there is no equivalent MIR-level
+``check-debugify`` pass).
 
 For example, here is a snippet before:
 
@@ -403,32 +403,16 @@ and ``-start-after``. For example:
   $ llc -debugify-and-strip-all-safe -run-pass=... 
   $ llc -debugify-and-strip-all-safe -O1 
 
-If you want to check it after each pass in a pipeline, use
-``-debugify-check-and-strip-all-safe``. This can also be combined with
-``-start-before`` and ``-start-after``. For example:
-
-.. code-block:: bash
-
-  $ llc -debugify-check-and-strip-all-safe -run-pass=... 
-  $ llc -debugify-check-and-strip-all-safe -O1 
-
-To check all debug info from a test, use ``mir-check-debugify``, like:
-
-.. code-block:: bash
-
-  $ llc -run-pass=mir-debugify,other-pass,mir-check-debugify
-
 To strip out all debug info from a test, use ``mir-strip-debug``, like:
 
 .. code-block:: bash
 
   $ llc -run-pass=mir-debugify,other-pass,mir-strip-debug
 
-It can be useful to combine ``mir-debugify``, ``mir-check-debugify`` and/or
-``mir-strip-debug`` to identify backend transformations which break in
-the presence of debug info. For example, to run the AArch64 backend tests
-with all normal passes "sandwiched" in between MIRDebugify and
-MIRStripDebugify mutation passes, run:
+It can be useful to combine ``mir-debugify`` and ``mir-strip-debug`` to
+identify backend transformations which break in the presence of debug info.
+For example, to run the AArch64 backend tests with all normal passes
+"sandwiched" in between MIRDebugify and MIRStripDebugify mutation passes, run:
 
 .. code-block:: bash
 

diff  --git a/llvm/include/llvm/CodeGen/Passes.h 
b/llvm/include/llvm/CodeGen/Passes.h
index 676ed2c65eb1..47037bac6270 100644
--- a/llvm/include/llvm/CodeGen/Passes.h
+++ b/llvm/include/llvm/CodeGen/Passes.h
@@ -482,9 +482,6 @@ namespace llvm {
   /// info was generated by another source such as clang.
   ModulePass *createStripDebugMachineModulePass(bool OnlyDebugified);
 
-  /// Creates MIR Check Debug pass. \see MachineCheckDebugify.cpp
-  ModulePass *createCheckDebugMachineModulePass();
-
   /// The pass fixups statepoint machine instruction to replace usage of
   /// caller saved registers with stack slots.
   extern char 

diff  --git a/llvm/include/llvm/CodeGen/TargetPassConfig.h 
b/llvm/include/llvm/CodeGen/TargetPassConfig.h
index 9b42b0756d41..fc5245216941 100644
--- a/llvm/include/llvm/CodeGen/TargetPassConfig.h
+++ b/llvm/include/llvm/CodeGen/TargetPassConfig.h
@@ -313,9 +313,6 @@ class TargetPassConfig : public ImmutablePass {
   /// Add a pass to remove debug info from the MIR.
   void addStripDebugPass();
 
-  /// Add a pass to check synthesized debug info for MIR.
-  void addCheckDebugPass();
-
   /// Add standard passes before a pass that's about to be added. For example,
   /// the DebugifyMachineModulePass if it is enabled.
   void addMachinePrePasses(bool AllowDebugify = true);

diff  --git a/llvm/include/llvm/InitializePasses.h 
b/llvm/include/llvm/InitializePasses.h
index e1b3a8dd3f3a..b8420ade06a7 100644
--- 

[llvm-branch-commits] [llvm] 18925dd - [X86] Add test case for commit e52bc1d2bba794b.

2020-12-14 Thread via llvm-branch-commits

Author: Luo, Yuanke
Date: 2020-12-15T11:14:16+08:00
New Revision: 18925dd8722e713e25d55218a826e2aca8cdd7c3

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

LOG: [X86] Add test case for commit e52bc1d2bba794b.

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

Added: 
llvm/test/CodeGen/X86/AMX/amx-intrinsic-chain.ll

Modified: 


Removed: 




diff  --git a/llvm/test/CodeGen/X86/AMX/amx-intrinsic-chain.ll 
b/llvm/test/CodeGen/X86/AMX/amx-intrinsic-chain.ll
new file mode 100644
index ..a35e30ed5c67
--- /dev/null
+++ b/llvm/test/CodeGen/X86/AMX/amx-intrinsic-chain.ll
@@ -0,0 +1,59 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+amx-int8 
-mattr=+avx512f -verify-machineinstrs | FileCheck %s
+target datalayout = 
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+
+define dso_local void @test_chain(i8* %A_mem, i8* %B_mem, i8* %C_mem) 
local_unnamed_addr {
+; CHECK-LABEL: test_chain:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vpxord %zmm0, %zmm0, %zmm0
+; CHECK-NEXT:vmovdqu64 %zmm0, -{{[0-9]+}}(%rsp)
+; CHECK-NEXT:movb $1, -{{[0-9]+}}(%rsp)
+; CHECK-NEXT:movb $16, -{{[0-9]+}}(%rsp)
+; CHECK-NEXT:movw $64, -{{[0-9]+}}(%rsp)
+; CHECK-NEXT:movb $16, -{{[0-9]+}}(%rsp)
+; CHECK-NEXT:movw $64, -{{[0-9]+}}(%rsp)
+; CHECK-NEXT:movb $16, -{{[0-9]+}}(%rsp)
+; CHECK-NEXT:movw $64, -{{[0-9]+}}(%rsp)
+; CHECK-NEXT:movb $16, -{{[0-9]+}}(%rsp)
+; CHECK-NEXT:movw $64, -{{[0-9]+}}(%rsp)
+; CHECK-NEXT:movb $16, -{{[0-9]+}}(%rsp)
+; CHECK-NEXT:movw $64, -{{[0-9]+}}(%rsp)
+; CHECK-NEXT:ldtilecfg -{{[0-9]+}}(%rsp)
+; CHECK-NEXT:movl $64, %r8d
+; CHECK-NEXT:movw $64, %cx
+; CHECK-NEXT:movw $16, %ax
+; CHECK-NEXT:tileloadd (%rdi,%r8), %tmm0
+; CHECK-NEXT:addq $1024, %rdi # imm = 0x400
+; CHECK-NEXT:tileloadd (%rdi,%r8), %tmm1
+; CHECK-NEXT:tileloadd (%rdx,%r8), %tmm3
+; CHECK-NEXT:leaq 1024(%rdx), %rdi
+; CHECK-NEXT:tileloadd (%rdi,%r8), %tmm2
+; CHECK-NEXT:tileloadd (%rsi,%r8), %tmm4
+; CHECK-NEXT:tdpbssd %tmm4, %tmm0, %tmm3
+; CHECK-NEXT:tilestored %tmm3, (%rdx,%r8)
+; CHECK-NEXT:tdpbssd %tmm4, %tmm1, %tmm2
+; CHECK-NEXT:tilestored %tmm2, (%rdi,%r8)
+; CHECK-NEXT:tilerelease
+; CHECK-NEXT:vzeroupper
+; CHECK-NEXT:retq
+entry:
+  %a1 = call <256 x i32> @llvm.x86.tileloadd64.internal(i16 16, i16 64, i8* 
nonnull %A_mem, i64 64)
+  %addr = getelementptr inbounds i8, i8* %A_mem, i64 1024
+  %a2 = call <256 x i32> @llvm.x86.tileloadd64.internal(i16 16, i16 64, i8* 
nonnull %addr, i64 64)
+  %c1 = call <256 x i32> @llvm.x86.tileloadd64.internal(i16 16, i16 64, i8* 
nonnull %C_mem, i64 64)
+  %caddr = getelementptr inbounds i8, i8* %C_mem, i64 1024
+  %c2 = call <256 x i32> @llvm.x86.tileloadd64.internal(i16 16, i16 64, i8* 
nonnull %caddr, i64 64)
+  br label %dotpd
+
+dotpd:
+  %b = call <256 x i32> @llvm.x86.tileloadd64.internal(i16 16, i16 64, i8* 
nonnull %B_mem, i64 64)
+  %dp1 = call <256 x i32> @llvm.x86.tdpbssd.internal(i16 16, i16 64, i16 64, 
<256 x i32> %c1, <256 x i32> %a1, <256 x i32> %b)
+  call void @llvm.x86.tilestored64.internal(i16 16, i16 64, i8* nonnull 
%C_mem, i64 64, <256 x i32> %dp1)
+  %dp2 = call <256 x i32> @llvm.x86.tdpbssd.internal(i16 16, i16 64, i16 64, 
<256 x i32> %c2, <256 x i32> %a2, <256 x i32> %b)
+  call void @llvm.x86.tilestored64.internal(i16 16, i16 64, i8* nonnull 
%caddr, i64 64, <256 x i32> %dp2)
+  ret void
+}
+
+declare <256 x i32> @llvm.x86.tileloadd64.internal(i16, i16, i8*, i64)
+declare <256 x i32> @llvm.x86.tdpbssd.internal(i16, i16, i16, <256 x i32>, 
<256 x i32>, <256 x i32>)
+declare void @llvm.x86.tilestored64.internal(i16, i16, i8*, i64, <256 x i32>)



___
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] 7799ef7 - Revert "Lex: Migrate HeaderSearch::LoadedModuleMaps to FileEntryRef"

2020-12-14 Thread Nico Weber via llvm-branch-commits

Author: Nico Weber
Date: 2020-12-14T22:05:08-05:00
New Revision: 7799ef7121aa7d59f4bd95cdf70035de724ead6f

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

LOG: Revert "Lex: Migrate HeaderSearch::LoadedModuleMaps to FileEntryRef"

This reverts commit a40db5502b2515a6f2f1676b5d7a655ae0f41179.
and follow-up d636b881bb9214938973098a012fad453082c444

Somewhat speculative, likely broke check-clang on Windows:
https://reviews.llvm.org/D92975#2453482

Added: 


Modified: 
clang-tools-extra/modularize/ModularizeUtilities.cpp
clang/include/clang/Lex/HeaderSearch.h
clang/include/clang/Lex/ModuleMap.h
clang/lib/Frontend/FrontendAction.cpp
clang/lib/Lex/HeaderSearch.cpp
clang/lib/Lex/ModuleMap.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp

Removed: 




diff  --git a/clang-tools-extra/modularize/ModularizeUtilities.cpp 
b/clang-tools-extra/modularize/ModularizeUtilities.cpp
index 7470c324bbdb..200370c135df 100644
--- a/clang-tools-extra/modularize/ModularizeUtilities.cpp
+++ b/clang-tools-extra/modularize/ModularizeUtilities.cpp
@@ -258,22 +258,22 @@ std::error_code 
ModularizeUtilities::loadProblemHeaderList(
 std::error_code ModularizeUtilities::loadModuleMap(
 llvm::StringRef InputPath) {
   // Get file entry for module.modulemap file.
-  auto ExpectedModuleMapEntry =
-SourceMgr->getFileManager().getFileRef(InputPath);
+  auto ModuleMapEntryOrErr =
+SourceMgr->getFileManager().getFile(InputPath);
 
   // return error if not found.
-  if (!ExpectedModuleMapEntry) {
+  if (!ModuleMapEntryOrErr) {
 llvm::errs() << "error: File \"" << InputPath << "\" not found.\n";
-return errorToErrorCode(ExpectedModuleMapEntry.takeError());
+return ModuleMapEntryOrErr.getError();
   }
-  FileEntryRef ModuleMapEntry = *ExpectedModuleMapEntry;
+  const FileEntry *ModuleMapEntry = *ModuleMapEntryOrErr;
 
   // Because the module map parser uses a ForwardingDiagnosticConsumer,
   // which doesn't forward the BeginSourceFile call, we do it explicitly here.
   DC.BeginSourceFile(*LangOpts, nullptr);
 
   // Figure out the home directory for the module map file.
-  const DirectoryEntry *Dir = ModuleMapEntry.getDir();
+  const DirectoryEntry *Dir = ModuleMapEntry->getDir();
   StringRef DirName(Dir->getName());
   if (llvm::sys::path::filename(DirName) == "Modules") {
 DirName = llvm::sys::path::parent_path(DirName);

diff  --git a/clang/include/clang/Lex/HeaderSearch.h 
b/clang/include/clang/Lex/HeaderSearch.h
index 8ea81226cf77..93d6ea72270a 100644
--- a/clang/include/clang/Lex/HeaderSearch.h
+++ b/clang/include/clang/Lex/HeaderSearch.h
@@ -239,7 +239,7 @@ class HeaderSearch {
 
   /// Set of module map files we've already loaded, and a flag indicating
   /// whether they were valid or not.
-  llvm::DenseMap LoadedModuleMaps;
+  llvm::DenseMap LoadedModuleMaps;
 
   /// Uniqued set of framework names, which is used to track which
   /// headers were included as framework headers.
@@ -560,8 +560,8 @@ class HeaderSearch {
 
   /// Try to find a module map file in the given directory, returning
   /// \c nullptr if none is found.
-  Optional lookupModuleMapFile(const DirectoryEntry *Dir,
- bool IsFramework);
+  const FileEntry *lookupModuleMapFile(const DirectoryEntry *Dir,
+   bool IsFramework);
 
   /// Determine whether there is a module map that may map the header
   /// with the given file name to a (sub)module.
@@ -603,8 +603,8 @@ class HeaderSearch {
   ///used to resolve paths within the module (this is required when
   ///building the module from preprocessed source).
   /// \returns true if an error occurred, false otherwise.
-  bool loadModuleMapFile(FileEntryRef File, bool IsSystem, FileID ID = 
FileID(),
- unsigned *Offset = nullptr,
+  bool loadModuleMapFile(const FileEntry *File, bool IsSystem,
+ FileID ID = FileID(), unsigned *Offset = nullptr,
  StringRef OriginalModuleMapFile = StringRef());
 
   /// Collect the set of all known, top-level modules.
@@ -794,7 +794,8 @@ class HeaderSearch {
 LMM_InvalidModuleMap
   };
 
-  LoadModuleMapResult loadModuleMapFileImpl(FileEntryRef File, bool IsSystem,
+  LoadModuleMapResult loadModuleMapFileImpl(const FileEntry *File,
+bool IsSystem,
 const DirectoryEntry *Dir,
 FileID ID = FileID(),
 unsigned *Offset = nullptr);

diff  --git a/clang/include/clang/Lex/ModuleMap.h 
b/clang/include/clang/Lex/ModuleMap.h
index 

[llvm-branch-commits] [llvm] c9ede6f - Revert "[amdgpu] Default to code object v3"

2020-12-14 Thread Nico Weber via llvm-branch-commits

Author: Nico Weber
Date: 2020-12-14T22:01:26-05:00
New Revision: c9ede6f3367a627baeef78f30d18078af9a4ffca

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

LOG: Revert "[amdgpu] Default to code object v3"

This reverts commit 4b2e7d0215021d0d1df1a6319884b21d33936265.
Breaks check-clang, see https://reviews.llvm.org/D93258#2453600

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/CommonArgs.cpp
llvm/docs/AMDGPUUsage.rst

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 87c786065fa9..67d41c3711f5 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2811,7 +2811,7 @@ def mexec_model_EQ : Joined<["-"], "mexec-model=">, 
Group;
 
 def mcode_object_version_EQ : Joined<["-"], "mcode-object-version=">, 
Group,
-  HelpText<"Specify code object ABI version. Defaults to 3. (AMDGPU only)">,
+  HelpText<"Specify code object ABI version. Defaults to 4. (AMDGPU only)">,
   MetaVarName<"">, Values<"2,3,4">;
 
 def mcode_object_v3_legacy : Flag<["-"], "mcode-object-v3">, Group,

diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 04d0e0771f70..72bedc16846d 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1549,7 +1549,7 @@ unsigned tools::getOrCheckAMDGPUCodeObjectVersion(
 const Driver , const llvm::opt::ArgList , bool Diagnose) {
   const unsigned MinCodeObjVer = 2;
   const unsigned MaxCodeObjVer = 4;
-  unsigned CodeObjVer = 3;
+  unsigned CodeObjVer = 4;
 
   // Emit warnings for legacy options even if they are overridden.
   if (Diagnose) {

diff  --git a/llvm/docs/AMDGPUUsage.rst b/llvm/docs/AMDGPUUsage.rst
index 95fb164310cc..e5d081a37500 100644
--- a/llvm/docs/AMDGPUUsage.rst
+++ b/llvm/docs/AMDGPUUsage.rst
@@ -911,12 +911,12 @@ The AMDGPU backend uses the following ELF header:
 
   * ``ELFABIVERSION_AMDGPU_HSA_V3`` is used to specify the version of AMD HSA
 runtime ABI for code object V3. Specify using the Clang option
-``-mcode-object-version=3``. This is the default code object
-version if not specified.
+``-mcode-object-version=3``.
 
   * ``ELFABIVERSION_AMDGPU_HSA_V4`` is used to specify the version of AMD HSA
 runtime ABI for code object V4. Specify using the Clang option
-``-mcode-object-version=4``.
+``-mcode-object-version=4``. This is the default code object
+version if not specified.
 
   * ``ELFABIVERSION_AMDGPU_PAL`` is used to specify the version of AMD PAL
 runtime ABI.
@@ -2871,6 +2871,10 @@ non-AMD key names should be prefixed by "*vendor-name*.".
 Code Object V3 Metadata
 +++
 
+.. warning::
+  Code object V3 is not the default code object version emitted by this version
+  of LLVM.
+
 Code object V3 to V4 metadata is specified by the ``NT_AMDGPU_METADATA`` note
 record (see :ref:`amdgpu-note-records-v3-v4`).
 
@@ -3275,10 +3279,6 @@ same *vendor-name*.
 Code Object V4 Metadata
 +++
 
-.. warning::
-  Code object V4 is not the default code object version emitted by this version
-  of LLVM.
-
 Code object V4 metadata is the same as
 :ref:`amdgpu-amdhsa-code-object-metadata-v3` with the changes and additions
 defined in table :ref:`amdgpu-amdhsa-code-object-metadata-map-table-v3`.



___
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] 38b4442 - [NFC] [Legalizer] Use common method for expanding fp-to-int operands

2020-12-14 Thread Qiu Chaofan via llvm-branch-commits

Author: Qiu Chaofan
Date: 2020-12-15T10:45:40+08:00
New Revision: 38b44421986937376989bfa4f4eaf0138c1139e1

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

LOG: [NFC] [Legalizer] Use common method for expanding fp-to-int operands

Reviewed By: RKSimon, steven.zhang

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

Added: 


Modified: 
llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h

Removed: 




diff  --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp 
b/llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
index 76536b5622db..5c12682f81f9 100644
--- a/llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
@@ -1750,9 +1750,9 @@ bool DAGTypeLegalizer::ExpandFloatOperand(SDNode *N, 
unsigned OpNo) {
   case ISD::STRICT_FP_ROUND:
   case ISD::FP_ROUND:   Res = ExpandFloatOp_FP_ROUND(N); break;
   case ISD::STRICT_FP_TO_SINT:
-  case ISD::FP_TO_SINT: Res = ExpandFloatOp_FP_TO_SINT(N); break;
   case ISD::STRICT_FP_TO_UINT:
-  case ISD::FP_TO_UINT: Res = ExpandFloatOp_FP_TO_UINT(N); break;
+  case ISD::FP_TO_SINT:
+  case ISD::FP_TO_UINT: Res = ExpandFloatOp_FP_TO_XINT(N); break;
   case ISD::LROUND: Res = ExpandFloatOp_LROUND(N); break;
   case ISD::LLROUND:Res = ExpandFloatOp_LLROUND(N); break;
   case ISD::LRINT:  Res = ExpandFloatOp_LRINT(N); break;
@@ -1878,38 +1878,21 @@ SDValue DAGTypeLegalizer::ExpandFloatOp_FP_ROUND(SDNode 
*N) {
   return SDValue();
 }
 
-SDValue DAGTypeLegalizer::ExpandFloatOp_FP_TO_SINT(SDNode *N) {
-  EVT RVT = N->getValueType(0);
-  SDLoc dl(N);
-
-  bool IsStrict = N->isStrictFPOpcode();
-  SDValue Op = N->getOperand(IsStrict ? 1 : 0);
-  SDValue Chain = IsStrict ? N->getOperand(0) : SDValue();
-  RTLIB::Libcall LC = RTLIB::getFPTOSINT(Op.getValueType(), RVT);
-  assert(LC != RTLIB::UNKNOWN_LIBCALL && "Unsupported FP_TO_SINT!");
-  TargetLowering::MakeLibCallOptions CallOptions;
-  std::pair Tmp = TLI.makeLibCall(DAG, LC, RVT, Op,
-CallOptions, dl, Chain);
-  if (!IsStrict)
-return Tmp.first;
-
-  ReplaceValueWith(SDValue(N, 1), Tmp.second);
-  ReplaceValueWith(SDValue(N, 0), Tmp.first);
-  return SDValue();
-}
-
-SDValue DAGTypeLegalizer::ExpandFloatOp_FP_TO_UINT(SDNode *N) {
+SDValue DAGTypeLegalizer::ExpandFloatOp_FP_TO_XINT(SDNode *N) {
   EVT RVT = N->getValueType(0);
   SDLoc dl(N);
 
   bool IsStrict = N->isStrictFPOpcode();
+  bool Signed = N->getOpcode() == ISD::FP_TO_SINT ||
+N->getOpcode() == ISD::STRICT_FP_TO_SINT;
   SDValue Op = N->getOperand(IsStrict ? 1 : 0);
   SDValue Chain = IsStrict ? N->getOperand(0) : SDValue();
-  RTLIB::Libcall LC = RTLIB::getFPTOUINT(Op.getValueType(), RVT);
-  assert(LC != RTLIB::UNKNOWN_LIBCALL && "Unsupported FP_TO_UINT!");
+  RTLIB::Libcall LC = Signed ? RTLIB::getFPTOSINT(Op.getValueType(), RVT)
+ : RTLIB::getFPTOUINT(Op.getValueType(), RVT);
+  assert(LC != RTLIB::UNKNOWN_LIBCALL && "Unsupported FP_TO_XINT!");
   TargetLowering::MakeLibCallOptions CallOptions;
-  std::pair Tmp = TLI.makeLibCall(DAG, LC, RVT, Op,
-CallOptions, dl, Chain);
+  std::pair Tmp =
+  TLI.makeLibCall(DAG, LC, RVT, Op, CallOptions, dl, Chain);
   if (!IsStrict)
 return Tmp.first;
 

diff  --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h 
b/llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h
index aea2e9ba2bd5..c267016cf37e 100644
--- a/llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h
+++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h
@@ -629,8 +629,7 @@ class LLVM_LIBRARY_VISIBILITY DAGTypeLegalizer {
   SDValue ExpandFloatOp_BR_CC(SDNode *N);
   SDValue ExpandFloatOp_FCOPYSIGN(SDNode *N);
   SDValue ExpandFloatOp_FP_ROUND(SDNode *N);
-  SDValue ExpandFloatOp_FP_TO_SINT(SDNode *N);
-  SDValue ExpandFloatOp_FP_TO_UINT(SDNode *N);
+  SDValue ExpandFloatOp_FP_TO_XINT(SDNode *N);
   SDValue ExpandFloatOp_LROUND(SDNode *N);
   SDValue ExpandFloatOp_LLROUND(SDNode *N);
   SDValue ExpandFloatOp_LRINT(SDNode *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] [clang] c36f31c - [PGO] remove unintentional code in early commit

2020-12-14 Thread Rong Xu via llvm-branch-commits

Author: Rong Xu
Date: 2020-12-14T18:41:49-08:00
New Revision: c36f31c4db065e987160a776749f5da81efc24c5

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

LOG: [PGO] remove unintentional code in early commit

Remove unintentional code in
commit 54e03d [PGO] Verify BFI counts after loading profile data.

Added: 


Modified: 
clang/lib/CodeGen/CGCall.cpp
clang/lib/CodeGen/CodeGenModule.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index ced287643c28..73194be922dd 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -1943,11 +1943,6 @@ void CodeGenModule::ConstructAttributeList(
   FuncAttrs.addAttribute(llvm::Attribute::NoReturn);
 if (TargetDecl->hasAttr())
   FuncAttrs.addAttribute(llvm::Attribute::Cold);
-if (TargetDecl->hasAttr()) {
-  // xur
-  fprintf(stderr, "hihi 2\n");
-  //  FuncAttrs.addAttribute(llvm::Attribute::Hot);
-}
 if (TargetDecl->hasAttr())
   FuncAttrs.addAttribute(llvm::Attribute::NoDuplicate);
 if (TargetDecl->hasAttr())

diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index dec0cba84343..0bb9c91f2434 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -1744,13 +1744,6 @@ void 
CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D,
 B.addAttribute(llvm::Attribute::OptimizeForSize);
   B.addAttribute(llvm::Attribute::Cold);
 }
-if (D->hasAttr()) {
-  if (!ShouldAddOptNone)
-B.addAttribute(llvm::Attribute::OptimizeForSize);
-  // xur
-  //  B.addAttribute(llvm::Attribute::Hot);
-  fprintf(stderr, "hihi 1\n");
-}
 
 if (D->hasAttr())
   B.addAttribute(llvm::Attribute::MinSize);



___
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] d7eba20 - [mlir][Inliner] Refactor the inliner to use nested pass pipelines instead of just canonicalization

2020-12-14 Thread River Riddle via llvm-branch-commits

Author: River Riddle
Date: 2020-12-14T18:09:47-08:00
New Revision: d7eba2005267aa4a8f46f73f208c7cc23e6c6a1a

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

LOG: [mlir][Inliner] Refactor the inliner to use nested pass pipelines instead 
of just canonicalization

Now that passes have support for running nested pipelines, the inliner can now 
allow for users to provide proper nested pipelines to use for optimization 
during inlining. This revision also changes the behavior of optimization during 
inlining to optimize before attempting to inline, which should lead to a more 
accurate cost model and prevents the need for users to schedule additional 
duplicate cleanup passes before/after the inliner that would already be run 
during inlining.

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

Added: 


Modified: 
llvm/include/llvm/ADT/Sequence.h
mlir/include/mlir/Pass/AnalysisManager.h
mlir/include/mlir/Pass/Pass.h
mlir/include/mlir/Pass/PassManager.h
mlir/include/mlir/Transforms/Passes.h
mlir/include/mlir/Transforms/Passes.td
mlir/lib/Pass/Pass.cpp
mlir/lib/Pass/PassDetail.h
mlir/lib/Pass/PassRegistry.cpp
mlir/lib/Pass/PassTiming.cpp
mlir/lib/Transforms/Inliner.cpp
mlir/test/Dialect/Affine/inlining.mlir
mlir/test/Dialect/SPIRV/Transforms/inlining.mlir
mlir/test/Pass/dynamic-pipeline-nested.mlir
mlir/test/Transforms/inlining.mlir
mlir/test/lib/Transforms/TestDynamicPipeline.cpp

Removed: 




diff  --git a/llvm/include/llvm/ADT/Sequence.h 
b/llvm/include/llvm/ADT/Sequence.h
index 8c505f2010dd..8a695d75f77a 100644
--- a/llvm/include/llvm/ADT/Sequence.h
+++ b/llvm/include/llvm/ADT/Sequence.h
@@ -42,6 +42,10 @@ class value_sequence_iterator
   value_sequence_iterator(const value_sequence_iterator &) = default;
   value_sequence_iterator(value_sequence_iterator &)
   : Value(std::move(Arg.Value)) {}
+  value_sequence_iterator =(const value_sequence_iterator ) {
+Value = Arg.Value;
+return *this;
+  }
 
   template ()))>
   value_sequence_iterator(U &) : Value(std::forward(Value)) {}

diff  --git a/mlir/include/mlir/Pass/AnalysisManager.h 
b/mlir/include/mlir/Pass/AnalysisManager.h
index ec6b7696ce60..5da0c95d78dc 100644
--- a/mlir/include/mlir/Pass/AnalysisManager.h
+++ b/mlir/include/mlir/Pass/AnalysisManager.h
@@ -98,7 +98,7 @@ struct AnalysisConcept {
 /// A derived analysis model used to hold a specific analysis object.
 template  struct AnalysisModel : public AnalysisConcept {
   template 
-  explicit AnalysisModel(Args &&... args)
+  explicit AnalysisModel(Args &&...args)
   : analysis(std::forward(args)...) {}
 
   /// A hook used to query analyses for invalidation.
@@ -198,7 +198,10 @@ class AnalysisMap {
 /// An analysis map that contains a map for the current operation, and a set of
 /// maps for any child operations.
 struct NestedAnalysisMap {
-  NestedAnalysisMap(Operation *op) : analyses(op) {}
+  NestedAnalysisMap(Operation *op, PassInstrumentor *instrumentor)
+  : analyses(op), parentOrInstrumentor(instrumentor) {}
+  NestedAnalysisMap(Operation *op, NestedAnalysisMap *parent)
+  : analyses(op), parentOrInstrumentor(parent) {}
 
   /// Get the operation for this analysis map.
   Operation *getOperation() const { return analyses.getOperation(); }
@@ -206,11 +209,34 @@ struct NestedAnalysisMap {
   /// Invalidate any non preserved analyses.
   void invalidate(const PreservedAnalyses );
 
+  /// Returns the parent analysis map for this analysis map, or null if this is
+  /// the top-level map.
+  const NestedAnalysisMap *getParent() const {
+return parentOrInstrumentor.dyn_cast();
+  }
+
+  /// Returns a pass instrumentation object for the current operation. This
+  /// value may be null.
+  PassInstrumentor *getPassInstrumentor() const {
+if (auto *parent = getParent())
+  return parent->getPassInstrumentor();
+return parentOrInstrumentor.get();
+  }
+
   /// The cached analyses for nested operations.
   DenseMap> childAnalyses;
 
-  /// The analyses for the owning module.
+  /// The analyses for the owning operation.
   detail::AnalysisMap analyses;
+
+  /// This value has three possible states:
+  /// NestedAnalysisMap*: A pointer to the parent analysis map.
+  /// PassInstrumentor*: This analysis map is the top-level map, and this
+  ///pointer is the optional pass instrumentor for the
+  ///current compilation.
+  /// nullptr: This analysis map is the top-level map, and there is nop pass
+  ///  instrumentor.
+  PointerUnion parentOrInstrumentor;
 };
 } // namespace detail
 
@@ -236,11 +262,11 @@ class AnalysisManager {
   template 
   Optional>
   getCachedParentAnalysis(Operation *parentOp) const {
-

[llvm-branch-commits] [libc] f0cd6aa - [libc] Add remainder[f|l] and remquo[f|l] to the list of aarch64 entrypoints.

2020-12-14 Thread Siva Chandra via llvm-branch-commits

Author: Siva Chandra
Date: 2020-12-14T18:06:05-08:00
New Revision: f0cd6aa614f49bb0c66e65fdf6637222c982efe4

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

LOG: [libc] Add remainder[f|l] and remquo[f|l] to the list of aarch64 
entrypoints.

Added: 


Modified: 
libc/config/linux/aarch64/entrypoints.txt

Removed: 




diff  --git a/libc/config/linux/aarch64/entrypoints.txt 
b/libc/config/linux/aarch64/entrypoints.txt
index 89f910b5766c..67e2b72aa1af 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -88,6 +88,12 @@ set(TARGET_LIBM_ENTRYPOINTS
 libc.src.math.modf
 libc.src.math.modff
 libc.src.math.modfl
+libc.src.math.remainderf
+libc.src.math.remainder
+libc.src.math.remainderl
+libc.src.math.remquof
+libc.src.math.remquo
+libc.src.math.remquol
 libc.src.math.round
 libc.src.math.roundf
 libc.src.math.roundl



___
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] c4d2d43 - [Debugify] Support checking Machine IR debug info

2020-12-14 Thread Xiang1 Zhang via llvm-branch-commits

Author: Xiang1 Zhang
Date: 2020-12-14T17:53:46-08:00
New Revision: c4d2d4337d50bed3cafd564daece1a197005b22b

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

LOG: [Debugify] Support checking Machine IR debug info
Add mir-check-debug pass to check MIR-level debug info.

For IR-level, currently, LLVM have debugify + check-debugify to generate
and check debug IR. Much like the IR-level pass debugify, mir-debugify
inserts sequentially increasing line locations to each MachineInstr in a
Module, But there is no equivalent MIR-level check-debugify pass, So now
we support it at "mir-check-debug".

Reviewed By: djtodoro

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

Added: 
llvm/lib/CodeGen/MachineCheckDebugify.cpp
llvm/test/CodeGen/Generic/MIRDebugify/check-line-and-variables-x.mir
llvm/test/CodeGen/Generic/MIRDebugify/check-line-and-variables.ll
llvm/test/CodeGen/Generic/MIRDebugify/check-line-and-variables.mir

Modified: 
llvm/docs/HowToUpdateDebugInfo.rst
llvm/include/llvm/CodeGen/Passes.h
llvm/include/llvm/CodeGen/TargetPassConfig.h
llvm/include/llvm/InitializePasses.h
llvm/lib/CodeGen/CMakeLists.txt
llvm/lib/CodeGen/CodeGen.cpp
llvm/lib/CodeGen/MachineDebugify.cpp
llvm/lib/CodeGen/TargetPassConfig.cpp
llvm/test/CodeGen/Generic/MIRDebugify/locations-and-values.mir
llvm/utils/gn/secondary/llvm/lib/CodeGen/BUILD.gn

Removed: 




diff  --git a/llvm/docs/HowToUpdateDebugInfo.rst 
b/llvm/docs/HowToUpdateDebugInfo.rst
index 7df2a8a25827..fff0cdbe59c8 100644
--- a/llvm/docs/HowToUpdateDebugInfo.rst
+++ b/llvm/docs/HowToUpdateDebugInfo.rst
@@ -342,8 +342,8 @@ A variant of the ``debugify`` utility described in
 :ref:`Mutation testing for IR-level transformations` can be used
 for MIR-level transformations as well: much like the IR-level pass,
 ``mir-debugify`` inserts sequentially increasing line locations to each
-``MachineInstr`` in a ``Module`` (although there is no equivalent MIR-level
-``check-debugify`` pass).
+``MachineInstr`` in a ``Module``. And the MIR-level ``mir-check-debugify`` is
+similar to IR-level ``check-debugify`` pass.
 
 For example, here is a snippet before:
 
@@ -403,16 +403,32 @@ and ``-start-after``. For example:
   $ llc -debugify-and-strip-all-safe -run-pass=... 
   $ llc -debugify-and-strip-all-safe -O1 
 
+If you want to check it after each pass in a pipeline, use
+``-debugify-check-and-strip-all-safe``. This can also be combined with
+``-start-before`` and ``-start-after``. For example:
+
+.. code-block:: bash
+
+  $ llc -debugify-check-and-strip-all-safe -run-pass=... 
+  $ llc -debugify-check-and-strip-all-safe -O1 
+
+To check all debug info from a test, use ``mir-check-debugify``, like:
+
+.. code-block:: bash
+
+  $ llc -run-pass=mir-debugify,other-pass,mir-check-debugify
+
 To strip out all debug info from a test, use ``mir-strip-debug``, like:
 
 .. code-block:: bash
 
   $ llc -run-pass=mir-debugify,other-pass,mir-strip-debug
 
-It can be useful to combine ``mir-debugify`` and ``mir-strip-debug`` to
-identify backend transformations which break in the presence of debug info.
-For example, to run the AArch64 backend tests with all normal passes
-"sandwiched" in between MIRDebugify and MIRStripDebugify mutation passes, run:
+It can be useful to combine ``mir-debugify``, ``mir-check-debugify`` and/or
+``mir-strip-debug`` to identify backend transformations which break in
+the presence of debug info. For example, to run the AArch64 backend tests
+with all normal passes "sandwiched" in between MIRDebugify and
+MIRStripDebugify mutation passes, run:
 
 .. code-block:: bash
 

diff  --git a/llvm/include/llvm/CodeGen/Passes.h 
b/llvm/include/llvm/CodeGen/Passes.h
index 47037bac6270..676ed2c65eb1 100644
--- a/llvm/include/llvm/CodeGen/Passes.h
+++ b/llvm/include/llvm/CodeGen/Passes.h
@@ -482,6 +482,9 @@ namespace llvm {
   /// info was generated by another source such as clang.
   ModulePass *createStripDebugMachineModulePass(bool OnlyDebugified);
 
+  /// Creates MIR Check Debug pass. \see MachineCheckDebugify.cpp
+  ModulePass *createCheckDebugMachineModulePass();
+
   /// The pass fixups statepoint machine instruction to replace usage of
   /// caller saved registers with stack slots.
   extern char 

diff  --git a/llvm/include/llvm/CodeGen/TargetPassConfig.h 
b/llvm/include/llvm/CodeGen/TargetPassConfig.h
index fc5245216941..9b42b0756d41 100644
--- a/llvm/include/llvm/CodeGen/TargetPassConfig.h
+++ b/llvm/include/llvm/CodeGen/TargetPassConfig.h
@@ -313,6 +313,9 @@ class TargetPassConfig : public ImmutablePass {
   /// Add a pass to remove debug info from the MIR.
   void addStripDebugPass();
 
+  /// Add a pass to check synthesized debug info for MIR.
+  void addCheckDebugPass();
+
   /// Add 

[llvm-branch-commits] [libc] b1067a9 - [libc][NFC] Skip adding dummy targets for skipped unit tests.

2020-12-14 Thread Siva Chandra via llvm-branch-commits

Author: Siva Chandra
Date: 2020-12-14T17:52:47-08:00
New Revision: b1067a9b3c8e2c692c31598bf8f399e31f486d4e

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

LOG: [libc][NFC] Skip adding dummy targets for skipped unit tests.

Added: 


Modified: 
libc/cmake/modules/LLVMLibCTestRules.cmake
libc/test/src/math/CMakeLists.txt

Removed: 




diff  --git a/libc/cmake/modules/LLVMLibCTestRules.cmake 
b/libc/cmake/modules/LLVMLibCTestRules.cmake
index 33dc2cc7ca74..421e1a16b700 100644
--- a/libc/cmake/modules/LLVMLibCTestRules.cmake
+++ b/libc/cmake/modules/LLVMLibCTestRules.cmake
@@ -111,14 +111,6 @@ function(add_libc_unittest target_name)
 set(msg "Skipping unittest ${fq_target_name} as it has missing deps: "
 "${skipped_entrypoints_list}.")
 message(STATUS ${msg})
-add_custom_target(${fq_target_name})
-
-# A post build custom command is used to avoid running the command always.
-add_custom_command(
-  TARGET ${fq_target_name}
-  POST_BUILD
-  COMMAND ${CMAKE_COMMAND} -E echo ${msg}
-)
 return()
   endif()
 

diff  --git a/libc/test/src/math/CMakeLists.txt 
b/libc/test/src/math/CMakeLists.txt
index 44abc401da44..7475be150900 100644
--- a/libc/test/src/math/CMakeLists.txt
+++ b/libc/test/src/math/CMakeLists.txt
@@ -18,6 +18,9 @@ function(add_fp_unittest name)
 
   add_libc_unittest(${name} ${MATH_UNITTEST_UNPARSED_ARGUMENTS})
   get_fq_target_name(${name} fq_target_name)
+  if (NOT TARGET ${fq_target_name})
+return()
+  endif()
   if(MATH_UNITTEST_NEED_MPFR)
 target_link_libraries(${fq_target_name} PRIVATE libcMPFRWrapper -lmpfr 
-lgmp)
   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] fc0f401 - Revert "[Debugify] Support checking Machine IR debug info"

2020-12-14 Thread Xiang1 Zhang via llvm-branch-commits

Author: Xiang1 Zhang
Date: 2020-12-14T17:48:49-08:00
New Revision: fc0f4010bb4c4fb843218c6e3aa0112ffc67c299

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

LOG: Revert "[Debugify] Support checking Machine IR debug info"

This reverts commit 57a3d9ec4a8c1422f07264bed9f12a4ea416707e.

Added: 


Modified: 
llvm/docs/HowToUpdateDebugInfo.rst
llvm/include/llvm/CodeGen/Passes.h
llvm/include/llvm/CodeGen/TargetPassConfig.h
llvm/include/llvm/InitializePasses.h
llvm/lib/CodeGen/CMakeLists.txt
llvm/lib/CodeGen/CodeGen.cpp
llvm/lib/CodeGen/MachineDebugify.cpp
llvm/lib/CodeGen/TargetPassConfig.cpp
llvm/test/CodeGen/Generic/MIRDebugify/locations-and-values.mir
llvm/utils/gn/secondary/llvm/lib/CodeGen/BUILD.gn

Removed: 
llvm/lib/CodeGen/MachineCheckDebugify.cpp
llvm/test/CodeGen/Generic/MIRDebugify/check-line-and-variables-x.mir
llvm/test/CodeGen/Generic/MIRDebugify/check-line-and-variables.ll
llvm/test/CodeGen/Generic/MIRDebugify/check-line-and-variables.mir



diff  --git a/llvm/docs/HowToUpdateDebugInfo.rst 
b/llvm/docs/HowToUpdateDebugInfo.rst
index fff0cdbe59c8..7df2a8a25827 100644
--- a/llvm/docs/HowToUpdateDebugInfo.rst
+++ b/llvm/docs/HowToUpdateDebugInfo.rst
@@ -342,8 +342,8 @@ A variant of the ``debugify`` utility described in
 :ref:`Mutation testing for IR-level transformations` can be used
 for MIR-level transformations as well: much like the IR-level pass,
 ``mir-debugify`` inserts sequentially increasing line locations to each
-``MachineInstr`` in a ``Module``. And the MIR-level ``mir-check-debugify`` is
-similar to IR-level ``check-debugify`` pass.
+``MachineInstr`` in a ``Module`` (although there is no equivalent MIR-level
+``check-debugify`` pass).
 
 For example, here is a snippet before:
 
@@ -403,32 +403,16 @@ and ``-start-after``. For example:
   $ llc -debugify-and-strip-all-safe -run-pass=... 
   $ llc -debugify-and-strip-all-safe -O1 
 
-If you want to check it after each pass in a pipeline, use
-``-debugify-check-and-strip-all-safe``. This can also be combined with
-``-start-before`` and ``-start-after``. For example:
-
-.. code-block:: bash
-
-  $ llc -debugify-check-and-strip-all-safe -run-pass=... 
-  $ llc -debugify-check-and-strip-all-safe -O1 
-
-To check all debug info from a test, use ``mir-check-debugify``, like:
-
-.. code-block:: bash
-
-  $ llc -run-pass=mir-debugify,other-pass,mir-check-debugify
-
 To strip out all debug info from a test, use ``mir-strip-debug``, like:
 
 .. code-block:: bash
 
   $ llc -run-pass=mir-debugify,other-pass,mir-strip-debug
 
-It can be useful to combine ``mir-debugify``, ``mir-check-debugify`` and/or
-``mir-strip-debug`` to identify backend transformations which break in
-the presence of debug info. For example, to run the AArch64 backend tests
-with all normal passes "sandwiched" in between MIRDebugify and
-MIRStripDebugify mutation passes, run:
+It can be useful to combine ``mir-debugify`` and ``mir-strip-debug`` to
+identify backend transformations which break in the presence of debug info.
+For example, to run the AArch64 backend tests with all normal passes
+"sandwiched" in between MIRDebugify and MIRStripDebugify mutation passes, run:
 
 .. code-block:: bash
 

diff  --git a/llvm/include/llvm/CodeGen/Passes.h 
b/llvm/include/llvm/CodeGen/Passes.h
index 676ed2c65eb1..47037bac6270 100644
--- a/llvm/include/llvm/CodeGen/Passes.h
+++ b/llvm/include/llvm/CodeGen/Passes.h
@@ -482,9 +482,6 @@ namespace llvm {
   /// info was generated by another source such as clang.
   ModulePass *createStripDebugMachineModulePass(bool OnlyDebugified);
 
-  /// Creates MIR Check Debug pass. \see MachineCheckDebugify.cpp
-  ModulePass *createCheckDebugMachineModulePass();
-
   /// The pass fixups statepoint machine instruction to replace usage of
   /// caller saved registers with stack slots.
   extern char 

diff  --git a/llvm/include/llvm/CodeGen/TargetPassConfig.h 
b/llvm/include/llvm/CodeGen/TargetPassConfig.h
index 9b42b0756d41..fc5245216941 100644
--- a/llvm/include/llvm/CodeGen/TargetPassConfig.h
+++ b/llvm/include/llvm/CodeGen/TargetPassConfig.h
@@ -313,9 +313,6 @@ class TargetPassConfig : public ImmutablePass {
   /// Add a pass to remove debug info from the MIR.
   void addStripDebugPass();
 
-  /// Add a pass to check synthesized debug info for MIR.
-  void addCheckDebugPass();
-
   /// Add standard passes before a pass that's about to be added. For example,
   /// the DebugifyMachineModulePass if it is enabled.
   void addMachinePrePasses(bool AllowDebugify = true);

diff  --git a/llvm/include/llvm/InitializePasses.h 
b/llvm/include/llvm/InitializePasses.h
index e1b3a8dd3f3a..b8420ade06a7 100644
--- a/llvm/include/llvm/InitializePasses.h
+++ 

[llvm-branch-commits] [libc] af68c3b - [libc] Add memcmp implementation.

2020-12-14 Thread Cheng Wang via llvm-branch-commits

Author: Cheng Wang
Date: 2020-12-15T09:47:29+08:00
New Revision: af68c3b8924218596ecee948cc22cbb2c69c7f42

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

LOG: [libc] Add memcmp implementation.

Reviewed By: gchatelet

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

Added: 
libc/src/string/memcmp.cpp
libc/src/string/memcmp.h
libc/test/src/string/memcmp_test.cpp

Modified: 
libc/config/linux/aarch64/entrypoints.txt
libc/config/linux/x86_64/entrypoints.txt
libc/src/string/CMakeLists.txt
libc/test/src/string/CMakeLists.txt

Removed: 




diff  --git a/libc/config/linux/aarch64/entrypoints.txt 
b/libc/config/linux/aarch64/entrypoints.txt
index 534a4bdd6131..89f910b5766c 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -26,6 +26,7 @@ set(TARGET_LIBC_ENTRYPOINTS
 # string.h entrypoints
 libc.src.string.bzero
 libc.src.string.memchr
+libc.src.string.memcmp
 libc.src.string.memcpy
 libc.src.string.memset
 libc.src.string.memrchr

diff  --git a/libc/config/linux/x86_64/entrypoints.txt 
b/libc/config/linux/x86_64/entrypoints.txt
index fce28231f319..d5a2f295d9d9 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -48,6 +48,7 @@ set(TARGET_LIBC_ENTRYPOINTS
 # string.h entrypoints
 libc.src.string.bzero
 libc.src.string.memchr
+libc.src.string.memcmp
 libc.src.string.memcpy
 libc.src.string.memrchr
 libc.src.string.memset

diff  --git a/libc/src/string/CMakeLists.txt b/libc/src/string/CMakeLists.txt
index 94df8a9d2166..683b85720c60 100644
--- a/libc/src/string/CMakeLists.txt
+++ b/libc/src/string/CMakeLists.txt
@@ -58,6 +58,14 @@ add_entrypoint_object(
 .string_utils
 )
 
+add_entrypoint_object(
+  memcmp
+  SRCS
+memcmp.cpp
+  HDRS
+memcmp.h
+)
+
 add_entrypoint_object(
   strchr
   SRCS

diff  --git a/libc/src/string/memcmp.cpp b/libc/src/string/memcmp.cpp
new file mode 100644
index ..1bd1c60ee1be
--- /dev/null
+++ b/libc/src/string/memcmp.cpp
@@ -0,0 +1,27 @@
+//===-- Implementation of memcmp 
--===//
+//
+// 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
+//
+//===--===//
+
+#include "src/string/memcmp.h"
+#include "src/__support/common.h"
+#include  // size_t
+
+namespace __llvm_libc {
+
+// TODO: It is a simple implementation, an optimized version is preparing.
+int LLVM_LIBC_ENTRYPOINT(memcmp)(const void *lhs, const void *rhs,
+ size_t count) {
+  const unsigned char *_lhs = reinterpret_cast(lhs);
+  const unsigned char *_rhs = reinterpret_cast(rhs);
+  for (size_t i = 0; i < count; ++i)
+if (_lhs[i] != _rhs[i])
+  return _lhs[i] - _rhs[i];
+  // count is 0 or _lhs and _rhs are the same.
+  return 0;
+}
+
+} // namespace __llvm_libc

diff  --git a/libc/src/string/memcmp.h b/libc/src/string/memcmp.h
new file mode 100644
index ..1d79df5d4591
--- /dev/null
+++ b/libc/src/string/memcmp.h
@@ -0,0 +1,20 @@
+//===-- Implementation header for memcmp *- 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
+//
+//===--===//
+
+#ifndef LLVM_LIBC_SRC_STRING_MEMCMP_H
+#define LLVM_LIBC_SRC_STRING_MEMCMP_H
+
+#include  // size_t
+
+namespace __llvm_libc {
+
+int memcmp(const void *lhs, const void *rhs, size_t count);
+
+} // namespace __llvm_libc
+
+#endif // LLVM_LIBC_SRC_STRING_MEMCMP_H

diff  --git a/libc/test/src/string/CMakeLists.txt 
b/libc/test/src/string/CMakeLists.txt
index 8b78fcfdd020..8202c699f20b 100644
--- a/libc/test/src/string/CMakeLists.txt
+++ b/libc/test/src/string/CMakeLists.txt
@@ -52,6 +52,16 @@ add_libc_unittest(
 libc.src.string.memchr
 )
 
+add_libc_unittest(
+  memcmp_test
+  SUITE
+libc_string_unittests
+  SRCS
+memcmp_test.cpp
+  DEPENDS
+libc.src.string.memcmp
+)
+
 add_libc_unittest(
   strchr_test
   SUITE

diff  --git a/libc/test/src/string/memcmp_test.cpp 
b/libc/test/src/string/memcmp_test.cpp
new file mode 100644
index ..3cfde0e8a34f
--- /dev/null
+++ b/libc/test/src/string/memcmp_test.cpp
@@ -0,0 +1,34 @@
+//===-- Unittests for memcmp 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with 

[llvm-branch-commits] [llvm] 57a3d9e - [Debugify] Support checking Machine IR debug info

2020-12-14 Thread Xiang1 Zhang via llvm-branch-commits

Author: Xiang1 Zhang
Date: 2020-12-14T17:38:01-08:00
New Revision: 57a3d9ec4a8c1422f07264bed9f12a4ea416707e

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

LOG: [Debugify] Support checking Machine IR debug info
Add mir-check-debug pass to check MIR-level debug info.

For IR-level, currently, LLVM have debugify + check-debugify to generate
and check debug IR. Much like the IR-level pass debugify, mir-debugify
inserts sequentially increasing line locations to each MachineInstr in a
Module, But there is no equivalent MIR-level check-debugify pass, So now
we support it at "mir-check-debug".

Reviewed By: djtodoro

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

Added: 
llvm/lib/CodeGen/MachineCheckDebugify.cpp
llvm/test/CodeGen/Generic/MIRDebugify/check-line-and-variables-x.mir
llvm/test/CodeGen/Generic/MIRDebugify/check-line-and-variables.ll
llvm/test/CodeGen/Generic/MIRDebugify/check-line-and-variables.mir

Modified: 
llvm/docs/HowToUpdateDebugInfo.rst
llvm/include/llvm/CodeGen/Passes.h
llvm/include/llvm/CodeGen/TargetPassConfig.h
llvm/include/llvm/InitializePasses.h
llvm/lib/CodeGen/CMakeLists.txt
llvm/lib/CodeGen/CodeGen.cpp
llvm/lib/CodeGen/MachineDebugify.cpp
llvm/lib/CodeGen/TargetPassConfig.cpp
llvm/test/CodeGen/Generic/MIRDebugify/locations-and-values.mir
llvm/utils/gn/secondary/llvm/lib/CodeGen/BUILD.gn

Removed: 




diff  --git a/llvm/docs/HowToUpdateDebugInfo.rst 
b/llvm/docs/HowToUpdateDebugInfo.rst
index 7df2a8a25827..fff0cdbe59c8 100644
--- a/llvm/docs/HowToUpdateDebugInfo.rst
+++ b/llvm/docs/HowToUpdateDebugInfo.rst
@@ -342,8 +342,8 @@ A variant of the ``debugify`` utility described in
 :ref:`Mutation testing for IR-level transformations` can be used
 for MIR-level transformations as well: much like the IR-level pass,
 ``mir-debugify`` inserts sequentially increasing line locations to each
-``MachineInstr`` in a ``Module`` (although there is no equivalent MIR-level
-``check-debugify`` pass).
+``MachineInstr`` in a ``Module``. And the MIR-level ``mir-check-debugify`` is
+similar to IR-level ``check-debugify`` pass.
 
 For example, here is a snippet before:
 
@@ -403,16 +403,32 @@ and ``-start-after``. For example:
   $ llc -debugify-and-strip-all-safe -run-pass=... 
   $ llc -debugify-and-strip-all-safe -O1 
 
+If you want to check it after each pass in a pipeline, use
+``-debugify-check-and-strip-all-safe``. This can also be combined with
+``-start-before`` and ``-start-after``. For example:
+
+.. code-block:: bash
+
+  $ llc -debugify-check-and-strip-all-safe -run-pass=... 
+  $ llc -debugify-check-and-strip-all-safe -O1 
+
+To check all debug info from a test, use ``mir-check-debugify``, like:
+
+.. code-block:: bash
+
+  $ llc -run-pass=mir-debugify,other-pass,mir-check-debugify
+
 To strip out all debug info from a test, use ``mir-strip-debug``, like:
 
 .. code-block:: bash
 
   $ llc -run-pass=mir-debugify,other-pass,mir-strip-debug
 
-It can be useful to combine ``mir-debugify`` and ``mir-strip-debug`` to
-identify backend transformations which break in the presence of debug info.
-For example, to run the AArch64 backend tests with all normal passes
-"sandwiched" in between MIRDebugify and MIRStripDebugify mutation passes, run:
+It can be useful to combine ``mir-debugify``, ``mir-check-debugify`` and/or
+``mir-strip-debug`` to identify backend transformations which break in
+the presence of debug info. For example, to run the AArch64 backend tests
+with all normal passes "sandwiched" in between MIRDebugify and
+MIRStripDebugify mutation passes, run:
 
 .. code-block:: bash
 

diff  --git a/llvm/include/llvm/CodeGen/Passes.h 
b/llvm/include/llvm/CodeGen/Passes.h
index 47037bac6270..676ed2c65eb1 100644
--- a/llvm/include/llvm/CodeGen/Passes.h
+++ b/llvm/include/llvm/CodeGen/Passes.h
@@ -482,6 +482,9 @@ namespace llvm {
   /// info was generated by another source such as clang.
   ModulePass *createStripDebugMachineModulePass(bool OnlyDebugified);
 
+  /// Creates MIR Check Debug pass. \see MachineCheckDebugify.cpp
+  ModulePass *createCheckDebugMachineModulePass();
+
   /// The pass fixups statepoint machine instruction to replace usage of
   /// caller saved registers with stack slots.
   extern char 

diff  --git a/llvm/include/llvm/CodeGen/TargetPassConfig.h 
b/llvm/include/llvm/CodeGen/TargetPassConfig.h
index fc5245216941..9b42b0756d41 100644
--- a/llvm/include/llvm/CodeGen/TargetPassConfig.h
+++ b/llvm/include/llvm/CodeGen/TargetPassConfig.h
@@ -313,6 +313,9 @@ class TargetPassConfig : public ImmutablePass {
   /// Add a pass to remove debug info from the MIR.
   void addStripDebugPass();
 
+  /// Add a pass to check synthesized debug info for MIR.
+  void addCheckDebugPass();
+
   /// Add 

[llvm-branch-commits] [llvm] b094eaa - [RISCV] Prevent assertion in the assembler if vmerge or vfmerge are given a V0 destination.

2020-12-14 Thread Craig Topper via llvm-branch-commits

Author: Craig Topper
Date: 2020-12-14T17:22:55-08:00
New Revision: b094eaa392322a9a0073c84f0b6ea320d80dafcf

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

LOG: [RISCV] Prevent assertion in the assembler if vmerge or vfmerge are given 
a V0 destination.

Added: 


Modified: 
llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
llvm/test/MC/RISCV/rvv/invalid.s

Removed: 




diff  --git a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp 
b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
index fbc67e4c4195..3225559f6c4d 100644
--- a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
+++ b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
@@ -2306,7 +2306,9 @@ bool RISCVAsmParser::validateInstruction(MCInst ,
 unsigned Opcode = Inst.getOpcode();
 if (Opcode == RISCV::VADC_VVM || Opcode == RISCV::VADC_VXM ||
 Opcode == RISCV::VADC_VIM || Opcode == RISCV::VSBC_VVM ||
-Opcode == RISCV::VSBC_VXM)
+Opcode == RISCV::VSBC_VXM || Opcode == RISCV::VFMERGE_VFM ||
+Opcode == RISCV::VMERGE_VIM || Opcode == RISCV::VMERGE_VVM ||
+Opcode == RISCV::VMERGE_VXM)
   return Error(Loc, "The destination vector register group cannot be V0.");
 
 // Regardless masked or unmasked version, the number of operands is the

diff  --git a/llvm/test/MC/RISCV/rvv/invalid.s 
b/llvm/test/MC/RISCV/rvv/invalid.s
index 671373050441..b741cce7abd7 100644
--- a/llvm/test/MC/RISCV/rvv/invalid.s
+++ b/llvm/test/MC/RISCV/rvv/invalid.s
@@ -616,3 +616,19 @@ vmsge.vx v0, v4, a0, v0.t
 vmsge.vx v8, v4, a0, v0.t, v2
 # CHECK-ERROR: invalid operand for instruction
 # CHECK-ERROR-LABEL: vmsge.vx v8, v4, a0, v0.t, v2
+
+vmerge.vim v0, v1, 1, v0
+# CHECK-ERROR: The destination vector register group cannot be V0.
+# CHECK-ERROR-LABEL: vmerge.vim v0, v1, 1, v0
+
+vmerge.vvm v0, v1, v2, v0
+# CHECK-ERROR: The destination vector register group cannot be V0.
+# CHECK-ERROR-LABEL: vmerge.vvm v0, v1, v2, v0
+
+vmerge.vxm v0, v1, x1, v0
+# CHECK-ERROR: The destination vector register group cannot be V0.
+# CHECK-ERROR-LABEL: vmerge.vxm v0, v1, x1, v0
+
+vfmerge.vfm v0, v1, f1, v0
+# CHECK-ERROR: The destination vector register group cannot be V0.
+# CHECK-ERROR-LABEL: vfmerge.vfm v0, v1, f1, v0



___
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] 2cf12ae - [RISCV] Handle Match_InvalidSImm5 in RISCVAsmParser::MatchAndEmitInstruction

2020-12-14 Thread Craig Topper via llvm-branch-commits

Author: Craig Topper
Date: 2020-12-14T17:22:55-08:00
New Revision: 2cf12ae0cc3fd51b2708a2ee1f61d9e861ca6b9d

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

LOG: [RISCV] Handle Match_InvalidSImm5 in 
RISCVAsmParser::MatchAndEmitInstruction

Added: 


Modified: 
llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp

Removed: 




diff  --git a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp 
b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
index 4bb971368e83..fbc67e4c4195 100644
--- a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
+++ b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
@@ -1040,6 +1040,9 @@ bool RISCVAsmParser::MatchAndEmitInstruction(SMLoc IDLoc, 
unsigned ,
 return generateImmOutOfRangeError(Operands, ErrorInfo, 0, (1 << 4) - 1);
   case Match_InvalidUImm5:
 return generateImmOutOfRangeError(Operands, ErrorInfo, 0, (1 << 5) - 1);
+  case Match_InvalidSImm5:
+return generateImmOutOfRangeError(Operands, ErrorInfo, -(1 << 4),
+  (1 << 4) - 1);
   case Match_InvalidSImm6:
 return generateImmOutOfRangeError(Operands, ErrorInfo, -(1 << 5),
   (1 << 5) - 1);



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] 413596e - [RISCV] Teach debug output from assembly parser to print register names instead of enum values.

2020-12-14 Thread Craig Topper via llvm-branch-commits

Author: Craig Topper
Date: 2020-12-14T17:22:55-08:00
New Revision: 413596ee45d327a7254d9f3d5f89bf58bbcbb310

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

LOG: [RISCV] Teach debug output from assembly parser to print register names 
instead of enum values.

Added: 


Modified: 
llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp

Removed: 




diff  --git a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp 
b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
index cfbf3c51736c..4bb971368e83 100644
--- a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
+++ b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include "MCTargetDesc/RISCVAsmBackend.h"
+#include "MCTargetDesc/RISCVInstPrinter.h"
 #include "MCTargetDesc/RISCVMCExpr.h"
 #include "MCTargetDesc/RISCVMCTargetDesc.h"
 #include "MCTargetDesc/RISCVTargetStreamer.h"
@@ -737,13 +738,19 @@ struct RISCVOperand : public MCParsedAsmOperand {
   }
 
   void print(raw_ostream ) const override {
+auto RegName = [](unsigned Reg) {
+  if (Reg)
+return RISCVInstPrinter::getRegisterName(Reg);
+  else
+return "noreg";
+};
+
 switch (Kind) {
 case KindTy::Immediate:
   OS << *getImm();
   break;
 case KindTy::Register:
-  OS << "";
+  OS << "";
   break;
 case KindTy::Token:
   OS << "'" << getToken() << "'";



___
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] 9c49b0b - Remove the ast_type_traits namespace.

2020-12-14 Thread Alexander Kornienko via llvm-branch-commits

Author: Alexander Kornienko
Date: 2020-12-15T02:16:12+01:00
New Revision: 9c49b0bba0fcbe8b10c0f44ce60a8d26e6f30479

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

LOG: Remove the ast_type_traits namespace.

This is the final cleanup after https://reviews.llvm.org/D74499

Reviewed By: steveire

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

Added: 


Modified: 
clang/include/clang/AST/ASTTypeTraits.h

Removed: 




diff  --git a/clang/include/clang/AST/ASTTypeTraits.h 
b/clang/include/clang/AST/ASTTypeTraits.h
index 8791e41b9ac3..2141f85911be 100644
--- a/clang/include/clang/AST/ASTTypeTraits.h
+++ b/clang/include/clang/AST/ASTTypeTraits.h
@@ -529,18 +529,6 @@ template  struct 
DynTypedNode::BaseConverter {
   }
 };
 
-// Previously these types were defined in the clang::ast_type_traits namespace.
-// Provide typedefs so that legacy code can be fixed asynchronously.
-namespace ast_type_traits {
-using DynTypedNode = ::clang::DynTypedNode;
-using ASTNodeKind = ::clang::ASTNodeKind;
-using TraversalKind = ::clang::TraversalKind;
-
-constexpr TraversalKind TK_AsIs = ::clang::TK_AsIs;
-constexpr TraversalKind TK_IgnoreUnlessSpelledInSource =
-::clang::TK_IgnoreUnlessSpelledInSource;
-} // namespace ast_type_traits
-
 } // end namespace clang
 
 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] 4b2e7d0 - [amdgpu] Default to code object v3

2020-12-14 Thread Jon Chesterfield via llvm-branch-commits

Author: Jon Chesterfield
Date: 2020-12-15T01:11:09Z
New Revision: 4b2e7d0215021d0d1df1a6319884b21d33936265

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

LOG: [amdgpu] Default to code object v3

[amdgpu] Default to code object v3
v4 is not yet readily available, and doesn't appear
to be implemented in the back end

Reviewed By: t-tye

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

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/CommonArgs.cpp
llvm/docs/AMDGPUUsage.rst

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 67d41c3711f5..87c786065fa9 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2811,7 +2811,7 @@ def mexec_model_EQ : Joined<["-"], "mexec-model=">, 
Group;
 
 def mcode_object_version_EQ : Joined<["-"], "mcode-object-version=">, 
Group,
-  HelpText<"Specify code object ABI version. Defaults to 4. (AMDGPU only)">,
+  HelpText<"Specify code object ABI version. Defaults to 3. (AMDGPU only)">,
   MetaVarName<"">, Values<"2,3,4">;
 
 def mcode_object_v3_legacy : Flag<["-"], "mcode-object-v3">, Group,

diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 72bedc16846d..04d0e0771f70 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1549,7 +1549,7 @@ unsigned tools::getOrCheckAMDGPUCodeObjectVersion(
 const Driver , const llvm::opt::ArgList , bool Diagnose) {
   const unsigned MinCodeObjVer = 2;
   const unsigned MaxCodeObjVer = 4;
-  unsigned CodeObjVer = 4;
+  unsigned CodeObjVer = 3;
 
   // Emit warnings for legacy options even if they are overridden.
   if (Diagnose) {

diff  --git a/llvm/docs/AMDGPUUsage.rst b/llvm/docs/AMDGPUUsage.rst
index e5d081a37500..95fb164310cc 100644
--- a/llvm/docs/AMDGPUUsage.rst
+++ b/llvm/docs/AMDGPUUsage.rst
@@ -911,12 +911,12 @@ The AMDGPU backend uses the following ELF header:
 
   * ``ELFABIVERSION_AMDGPU_HSA_V3`` is used to specify the version of AMD HSA
 runtime ABI for code object V3. Specify using the Clang option
-``-mcode-object-version=3``.
+``-mcode-object-version=3``. This is the default code object
+version if not specified.
 
   * ``ELFABIVERSION_AMDGPU_HSA_V4`` is used to specify the version of AMD HSA
 runtime ABI for code object V4. Specify using the Clang option
-``-mcode-object-version=4``. This is the default code object
-version if not specified.
+``-mcode-object-version=4``.
 
   * ``ELFABIVERSION_AMDGPU_PAL`` is used to specify the version of AMD PAL
 runtime ABI.
@@ -2871,10 +2871,6 @@ non-AMD key names should be prefixed by "*vendor-name*.".
 Code Object V3 Metadata
 +++
 
-.. warning::
-  Code object V3 is not the default code object version emitted by this version
-  of LLVM.
-
 Code object V3 to V4 metadata is specified by the ``NT_AMDGPU_METADATA`` note
 record (see :ref:`amdgpu-note-records-v3-v4`).
 
@@ -3279,6 +3275,10 @@ same *vendor-name*.
 Code Object V4 Metadata
 +++
 
+.. warning::
+  Code object V4 is not the default code object version emitted by this version
+  of LLVM.
+
 Code object V4 metadata is the same as
 :ref:`amdgpu-amdhsa-code-object-metadata-v3` with the changes and additions
 defined in table :ref:`amdgpu-amdhsa-code-object-metadata-map-table-v3`.



___
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] b266c81 - [libc][Obvious] Mark functions in DummyFEnv.h as static inline.

2020-12-14 Thread Siva Chandra Reddy via llvm-branch-commits

Author: Siva Chandra Reddy
Date: 2020-12-14T17:12:54-08:00
New Revision: b266c818e7cb30464a7bb9e5f8241375ac1722b1

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

LOG: [libc][Obvious] Mark functions in DummyFEnv.h as static inline.

Added: 


Modified: 
libc/utils/FPUtil/DummyFEnv.h

Removed: 




diff  --git a/libc/utils/FPUtil/DummyFEnv.h b/libc/utils/FPUtil/DummyFEnv.h
index 4f4c2c05a231..19c661fd23eb 100644
--- a/libc/utils/FPUtil/DummyFEnv.h
+++ b/libc/utils/FPUtil/DummyFEnv.h
@@ -17,15 +17,15 @@ namespace fputil {
 
 // All dummy functions silently succeed.
 
-int clearExcept(int) { return 0; }
+static inline int clearExcept(int) { return 0; }
 
-int testExcept(int) { return 0; }
+static inline int testExcept(int) { return 0; }
 
-int raiseExcept(int) { return 0; }
+static inline int raiseExcept(int) { return 0; }
 
-int getRound() { return FE_TONEAREST; }
+static inline int getRound() { return FE_TONEAREST; }
 
-int setRound(int) { return 0; }
+static inline int setRound(int) { return 0; }
 
 } // namespace fputil
 } // namespace __llvm_libc



___
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] d2ed9d6 - Revert "ADT: Migrate users of AlignedCharArrayUnion to std::aligned_union_t, NFC"

2020-12-14 Thread Reid Kleckner via llvm-branch-commits

Author: Reid Kleckner
Date: 2020-12-14T17:04:06-08:00
New Revision: d2ed9d6b7ec6ae837aac0b2d2920c1e34b89d00b

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

LOG: Revert "ADT: Migrate users of AlignedCharArrayUnion to 
std::aligned_union_t, NFC"

We determined that the MSVC implementation of std::aligned* isn't suited
to our needs. It doesn't support 16 byte alignment or higher, and it
doesn't really guarantee 8 byte alignment. See
https://github.com/microsoft/STL/issues/1533

Also reverts "ADT: Change AlignedCharArrayUnion to an alias of 
std::aligned_union_t, NFC"

Also reverts "ADT: Remove AlignedCharArrayUnion, NFC" to bring back
AlignedCharArrayUnion.

This reverts commit 4d8bf870a82765eb0d4fe53c82f796b957c05954.

This reverts commit d10f9863a5ac1cb681af07719650c44b48f289ce.

This reverts commit 4b5dc150b9862271720b3d56a3e723a55dd81838.

Added: 
llvm/include/llvm/Support/AlignOf.h
llvm/unittests/Support/AlignOfTest.cpp

Modified: 
clang/include/clang/AST/APValue.h
clang/include/clang/AST/ASTContext.h
clang/include/clang/AST/ASTTypeTraits.h
clang/include/clang/AST/ParentMapContext.h
clang/include/clang/Frontend/PrecompiledPreamble.h
clang/include/clang/Sema/Overload.h
clang/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp
clang/lib/DirectoryWatcher/windows/DirectoryWatcher-windows.cpp
clang/lib/Lex/PPDirectives.cpp
llvm/include/llvm/ADT/DenseMap.h
llvm/include/llvm/ADT/IntervalMap.h
llvm/include/llvm/CodeGen/DIE.h
llvm/include/llvm/CodeGen/SelectionDAGNodes.h
llvm/include/llvm/Support/Error.h
llvm/include/llvm/Support/ErrorOr.h
llvm/include/llvm/Support/JSON.h
llvm/include/llvm/Support/TrailingObjects.h
llvm/include/llvm/Support/YAMLTraits.h
llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
llvm/unittests/Support/CMakeLists.txt

Removed: 




diff  --git a/clang/include/clang/AST/APValue.h 
b/clang/include/clang/AST/APValue.h
index d6a33c13b0961..eded34808ad7e 100644
--- a/clang/include/clang/AST/APValue.h
+++ b/clang/include/clang/AST/APValue.h
@@ -20,7 +20,7 @@
 #include "llvm/ADT/FoldingSet.h"
 #include "llvm/ADT/PointerIntPair.h"
 #include "llvm/ADT/PointerUnion.h"
-#include 
+#include "llvm/Support/AlignOf.h"
 
 namespace clang {
   class AddrLabelExpr;
@@ -286,10 +286,9 @@ class APValue {
   struct MemberPointerData;
 
   // We ensure elsewhere that Data is big enough for LV and MemberPointerData.
-  typedef std::aligned_union_t<1, void *, APSInt, APFloat, ComplexAPSInt,
-   ComplexAPFloat, Vec, Arr, StructData, UnionData,
-   AddrLabelDiffData>
-  DataType;
+  typedef llvm::AlignedCharArrayUnion DataType;
   static const size_t DataSize = sizeof(DataType);
 
   DataType Data;

diff  --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 0a635875207d1..71f824b69bc85 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -57,6 +57,7 @@
 #include "llvm/ADT/TinyPtrVector.h"
 #include "llvm/ADT/Triple.h"
 #include "llvm/ADT/iterator_range.h"
+#include "llvm/Support/AlignOf.h"
 #include "llvm/Support/Allocator.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/Compiler.h"

diff  --git a/clang/include/clang/AST/ASTTypeTraits.h 
b/clang/include/clang/AST/ASTTypeTraits.h
index ea3da8d90c5b9..8791e41b9ac3c 100644
--- a/clang/include/clang/AST/ASTTypeTraits.h
+++ b/clang/include/clang/AST/ASTTypeTraits.h
@@ -22,7 +22,7 @@
 #include "clang/AST/TypeLoc.h"
 #include "clang/Basic/LLVM.h"
 #include "llvm/ADT/DenseMapInfo.h"
-#include 
+#include "llvm/Support/AlignOf.h"
 
 namespace llvm {
 
@@ -456,8 +456,9 @@ class DynTypedNode {
   /// \c QualTypes, \c NestedNameSpecifierLocs, \c TypeLocs,
   /// \c TemplateArguments and \c TemplateArgumentLocs on the other hand do not
   /// have storage or unique pointers and thus need to be stored by value.
-  std::aligned_union_t<1, const void *, TemplateArgument, TemplateArgumentLoc,
-   NestedNameSpecifierLoc, QualType, TypeLoc>
+  llvm::AlignedCharArrayUnion
   Storage;
 };
 

diff  --git a/clang/include/clang/AST/ParentMapContext.h 
b/clang/include/clang/AST/ParentMapContext.h
index a15790605a3d5..a0412380a864e 100644
--- a/clang/include/clang/AST/ParentMapContext.h
+++ b/clang/include/clang/AST/ParentMapContext.h
@@ -89,7 +89,7 @@ class TraversalKindScope {
 /// Container for either a single DynTypedNode or for an ArrayRef to
 /// DynTypedNode. For use with ParentMap.
 class DynTypedNodeList {
-  std::aligned_union_t<1, DynTypedNode, ArrayRef> Storage;
+  llvm::AlignedCharArrayUnion> Storage;
   bool IsSingleNode;
 
 public:

diff  --git 

[llvm-branch-commits] [clang] 0312bec - Recognize setjmp and friends as builtins even if jmp_buf is not declared yet.

2020-12-14 Thread Tom Stellard via llvm-branch-commits

Author: Richard Smith
Date: 2020-12-14T19:43:12-05:00
New Revision: 0312bec0d7573b0549a222fb5d0a695fcf819dc3

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

LOG: Recognize setjmp and friends as builtins even if jmp_buf is not declared 
yet.

This happens in glibc's headers. It's important that we recognize these
functions so that we can mark them as returns_twice.

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

Added: 
clang/test/CodeGen/setjmp.c

Modified: 
clang/include/clang/Basic/Builtins.def
clang/include/clang/Basic/Builtins.h
clang/lib/Sema/SemaDecl.cpp
clang/test/Sema/builtin-setjmp.c
clang/test/Sema/implicit-builtin-decl.c

Removed: 




diff  --git a/clang/include/clang/Basic/Builtins.def 
b/clang/include/clang/Basic/Builtins.def
index 01c28ebab763..dbb5dde20a2b 100644
--- a/clang/include/clang/Basic/Builtins.def
+++ b/clang/include/clang/Basic/Builtins.def
@@ -75,6 +75,9 @@
 //  U -> pure
 //  c -> const
 //  t -> signature is meaningless, use custom typechecking
+//  T -> type is not important to semantic analysis and codegen; recognize as
+//   builtin even if type doesn't match signature, and don't warn if we
+//   can't be sure the type is right
 //  F -> this is a libc/libm function with a '__builtin_' prefix added.
 //  f -> this is a libc/libm function without the '__builtin_' prefix. It can
 //   be followed by ':headername:' to state which header this function
@@ -893,7 +896,7 @@ LANGBUILTIN(__va_start,   "vc**.", "nt", 
ALL_MS_LANGUAGES)
 LANGBUILTIN(__fastfail, "vUi","nr", ALL_MS_LANGUAGES)
 
 // Microsoft library builtins.
-LIBBUILTIN(_setjmpex, "iJ", "fj",   "setjmpex.h", ALL_MS_LANGUAGES)
+LIBBUILTIN(_setjmpex, "iJ", "fjT", "setjmpex.h", ALL_MS_LANGUAGES)
 
 // C99 library functions
 // C99 stdarg.h
@@ -987,8 +990,8 @@ LIBBUILTIN(wmemmove,"w*w*wC*z", "f", "wchar.h", 
ALL_LANGUAGES)
 // In some systems setjmp is a macro that expands to _setjmp. We undefine
 // it here to avoid having two identical LIBBUILTIN entries.
 #undef setjmp
-LIBBUILTIN(setjmp, "iJ",  "fj","setjmp.h", ALL_LANGUAGES)
-LIBBUILTIN(longjmp, "vJi","fr","setjmp.h", ALL_LANGUAGES)
+LIBBUILTIN(setjmp, "iJ",  "fjT",   "setjmp.h", ALL_LANGUAGES)
+LIBBUILTIN(longjmp, "vJi","frT",   "setjmp.h", ALL_LANGUAGES)
 
 // Non-C library functions, active in GNU mode only.
 // Functions with (returns_twice) attribute (marked as "j") are still active in
@@ -1015,21 +1018,21 @@ LIBBUILTIN(strcasecmp, "icC*cC*", "f", "strings.h", 
ALL_GNU_LANGUAGES)
 LIBBUILTIN(strncasecmp, "icC*cC*z", "f",   "strings.h", ALL_GNU_LANGUAGES)
 // POSIX unistd.h
 LIBBUILTIN(_exit, "vi",   "fr","unistd.h", ALL_GNU_LANGUAGES)
-LIBBUILTIN(vfork, "p","fj","unistd.h", ALL_LANGUAGES)
+LIBBUILTIN(vfork, "p","fjT",   "unistd.h", ALL_LANGUAGES)
 // POSIX pthread.h
 // FIXME: Should specify argument types.
 LIBBUILTIN(pthread_create, "",  "fC<2,3>", "pthread.h", ALL_GNU_LANGUAGES)
 
 // POSIX setjmp.h
 
-LIBBUILTIN(_setjmp, "iJ", "fj",   "setjmp.h", ALL_LANGUAGES)
-LIBBUILTIN(__sigsetjmp, "iSJi",   "fj",   "setjmp.h", ALL_LANGUAGES)
-LIBBUILTIN(sigsetjmp, "iSJi", "fj",   "setjmp.h", ALL_LANGUAGES)
-LIBBUILTIN(savectx, "iJ", "fj",   "setjmp.h", ALL_LANGUAGES)
-LIBBUILTIN(getcontext, "iK*", "fj",   "setjmp.h", ALL_LANGUAGES)
+LIBBUILTIN(_setjmp, "iJ", "fjT",   "setjmp.h", ALL_LANGUAGES)
+LIBBUILTIN(__sigsetjmp, "iSJi",   "fjT",   "setjmp.h", ALL_LANGUAGES)
+LIBBUILTIN(sigsetjmp, "iSJi", "fjT",   "setjmp.h", ALL_LANGUAGES)
+LIBBUILTIN(savectx, "iJ", "fjT",   "setjmp.h", ALL_LANGUAGES)
+LIBBUILTIN(getcontext, "iK*", "fjT",   "setjmp.h", ALL_LANGUAGES)
 
-LIBBUILTIN(_longjmp, "vJi",   "fr","setjmp.h", ALL_GNU_LANGUAGES)
-LIBBUILTIN(siglongjmp, "vSJi","fr","setjmp.h", ALL_GNU_LANGUAGES)
+LIBBUILTIN(_longjmp, "vJi",   "frT",   "setjmp.h", ALL_GNU_LANGUAGES)
+LIBBUILTIN(siglongjmp, "vSJi","frT",   "setjmp.h", ALL_GNU_LANGUAGES)
 // non-standard but very common
 LIBBUILTIN(strlcpy, "zc*cC*z","f", "string.h", ALL_GNU_LANGUAGES)
 LIBBUILTIN(strlcat, "zc*cC*z","f", "string.h", ALL_GNU_LANGUAGES)

diff  --git a/clang/include/clang/Basic/Builtins.h 
b/clang/include/clang/Basic/Builtins.h
index e4ed482d9068..15bfcf797917 100644
--- a/clang/include/clang/Basic/Builtins.h
+++ b/clang/include/clang/Basic/Builtins.h
@@ -158,6 +158,13 @@ class Context {
 return strchr(getRecord(ID).Attributes, 't') != nullptr;
   }
 
+  /// Determines whether a declaration of this builtin should be recognized
+  /// even if the type doesn't match the specified signature.
+  bool allowTypeMismatch(unsigned ID) const {
+return 

[llvm-branch-commits] [clang] 98f575f - Don't reject calls to MinGW's unusual _setjmp declaration.

2020-12-14 Thread Tom Stellard via llvm-branch-commits

Author: Richard Smith
Date: 2020-12-14T19:43:12-05:00
New Revision: 98f575ff55bff1e4128ffaeef4d05c356d996ab9

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

LOG: Don't reject calls to MinGW's unusual _setjmp declaration.

We now recognize this function as a builtin despite it having an
unexpected number of parameters; make sure we don't enforce that it has
only 1 argument for its 2 parameters.

Added: 


Modified: 
clang/include/clang/Basic/Builtins.def
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/Sema/SemaChecking.cpp
clang/test/Sema/builtin-setjmp.c

Removed: 




diff  --git a/clang/include/clang/Basic/Builtins.def 
b/clang/include/clang/Basic/Builtins.def
index dbb5dde20a2b..5463b7dfc18c 100644
--- a/clang/include/clang/Basic/Builtins.def
+++ b/clang/include/clang/Basic/Builtins.def
@@ -1025,6 +1025,7 @@ LIBBUILTIN(pthread_create, "",  "fC<2,3>", "pthread.h", 
ALL_GNU_LANGUAGES)
 
 // POSIX setjmp.h
 
+// FIXME: MinGW _setjmp has an additional void* parameter.
 LIBBUILTIN(_setjmp, "iJ", "fjT",   "setjmp.h", ALL_LANGUAGES)
 LIBBUILTIN(__sigsetjmp, "iSJi",   "fjT",   "setjmp.h", ALL_LANGUAGES)
 LIBBUILTIN(sigsetjmp, "iSJi", "fjT",   "setjmp.h", ALL_LANGUAGES)

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 8994b939093e..6b93f1b60af5 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -3754,11 +3754,13 @@ RValue CodeGenFunction::EmitBuiltinExpr(const 
GlobalDecl GD, unsigned BuiltinID,
   case Builtin::BI_abnormal_termination:
 return RValue::get(EmitSEHAbnormalTermination());
   case Builtin::BI_setjmpex:
-if (getTarget().getTriple().isOSMSVCRT())
+if (getTarget().getTriple().isOSMSVCRT() && E->getNumArgs() == 1 &&
+E->getArg(0)->getType()->isPointerType())
   return EmitMSVCRTSetJmp(*this, MSVCSetJmpKind::_setjmpex, E);
 break;
   case Builtin::BI_setjmp:
-if (getTarget().getTriple().isOSMSVCRT()) {
+if (getTarget().getTriple().isOSMSVCRT() && E->getNumArgs() == 1 &&
+E->getArg(0)->getType()->isPointerType()) {
   if (getTarget().getTriple().getArch() == llvm::Triple::x86)
 return EmitMSVCRTSetJmp(*this, MSVCSetJmpKind::_setjmp3, E);
   else if (getTarget().getTriple().getArch() == llvm::Triple::aarch64)

diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index b00d2ff5f1d5..1bf04d9cb4f2 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -1573,11 +1573,6 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, 
unsigned BuiltinID,
 if (SemaBuiltinSetjmp(TheCall))
   return ExprError();
 break;
-  case Builtin::BI_setjmp:
-  case Builtin::BI_setjmpex:
-if (checkArgCount(*this, TheCall, 1))
-  return true;
-break;
   case Builtin::BI__builtin_classify_type:
 if (checkArgCount(*this, TheCall, 1)) return true;
 TheCall->setType(Context.IntTy);

diff  --git a/clang/test/Sema/builtin-setjmp.c 
b/clang/test/Sema/builtin-setjmp.c
index 6a114fad05d9..604d534eb504 100644
--- a/clang/test/Sema/builtin-setjmp.c
+++ b/clang/test/Sema/builtin-setjmp.c
@@ -1,34 +1,47 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify 
-DNO_JMP_BUF %s -ast-dump | FileCheck %s
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify 
-DWRONG_JMP_BUF %s -ast-dump | FileCheck %s
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify 
-DRIGHT_JMP_BUF %s -ast-dump | FileCheck %s
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify 
-DONLY_JMP_BUF %s -ast-dump | FileCheck %s
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify 
-DNO_SETJMP %s -ast-dump 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only 
-verify=c,expected -DNO_JMP_BUF %s -ast-dump | FileCheck %s 
--check-prefixes=CHECK1,CHECK2
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only 
-verify=c,expected -DWRONG_JMP_BUF %s -ast-dump | FileCheck %s 
--check-prefixes=CHECK1,CHECK2
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only 
-verify=c,expected -DRIGHT_JMP_BUF %s -ast-dump | FileCheck %s 
--check-prefixes=CHECK1,CHECK2
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only 
-verify=c,expected -DONLY_JMP_BUF %s -ast-dump | FileCheck %s 
--check-prefixes=CHECK1,CHECK2
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only 
-verify=c,expected -DNO_SETJMP %s -ast-dump 2>&1 | FileCheck %s 
--check-prefixes=CHECK1,CHECK2
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only 
-verify=cxx,expected -x c++ -DNO_JMP_BUF %s -ast-dump | FileCheck %s 
--check-prefixes=CHECK1,CHECK2
+// RUN: %clang_cc1 -triple 

[llvm-branch-commits] [clang] fdab756 - [Sema] Handle objc_super special lookup when checking builtin compatibility

2020-12-14 Thread Tom Stellard via llvm-branch-commits

Author: Raul Tambre
Date: 2020-12-14T19:43:12-05:00
New Revision: fdab756331f322a9818c1bdf14d23d9cd6036c81

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

LOG: [Sema] Handle objc_super special lookup when checking builtin compatibility

objc_super is special and needs LookupPredefedObjCSuperType() called before 
performing builtin type comparisons.
This fixes an error when compiling macOS headers. A test is added.

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

Added: 
clang/test/SemaObjCXX/builtin-objcsuper.mm

Modified: 
clang/lib/Sema/SemaDecl.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 2703d9876f85..82c78e3003f0 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -9643,6 +9643,7 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator , 
DeclContext *DC,
 NewFD->addAttr(BuiltinAttr::CreateImplicit(Context, BuiltinID));
   } else {
 ASTContext::GetBuiltinTypeError Error;
+LookupPredefedObjCSuperType(*this, S, NewFD->getIdentifier());
 QualType BuiltinType = Context.GetBuiltinType(BuiltinID, Error);
 
 if (!Error && !BuiltinType.isNull() &&

diff  --git a/clang/test/SemaObjCXX/builtin-objcsuper.mm 
b/clang/test/SemaObjCXX/builtin-objcsuper.mm
new file mode 100644
index ..a6baf3c5165a
--- /dev/null
+++ b/clang/test/SemaObjCXX/builtin-objcsuper.mm
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -verify %s
+// expected-no-diagnostics
+
+// objc_super has special lookup rules for compatibility with macOS headers, so
+// the following should compile.
+struct objc_super {};
+extern "C" id objc_msgSendSuper(struct objc_super *super, SEL op, ...);
+extern "C" void objc_msgSendSuper_stret(struct objc_super *super, SEL op, ...);



___
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] adf8453 - [Sema] Introduce BuiltinAttr, per-declaration builtin-ness

2020-12-14 Thread Tom Stellard via llvm-branch-commits

Author: Raul Tambre
Date: 2020-12-14T19:43:12-05:00
New Revision: adf845300c9cc023d386d97b6ebeb1e82bd97763

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

LOG: [Sema] Introduce BuiltinAttr, per-declaration builtin-ness

Instead of relying on whether a certain identifier is a builtin, introduce 
BuiltinAttr to specify a declaration as having builtin semantics.

This fixes incompatible redeclarations of builtins, as reverting the identifier 
as being builtin due to one incompatible redeclaration would have broken rest 
of the builtin calls.
Mostly-compatible redeclarations of builtins also no longer have builtin 
semantics. They don't call the builtin nor inherit their attributes.
A long-standing FIXME regarding builtins inside a namespace enclosed in extern 
"C" not being recognized is also addressed.

Due to the more correct handling attributes for builtin functions are added in 
more places, resulting in more useful warnings.
Tests are updated to reflect that.

Intrinsics without an inline definition in intrin.h had `inline` and `static` 
removed as they had no effect and caused them to no longer be recognized as 
builtins otherwise.

A pthread_create() related test is XFAIL-ed, as it relied on it being 
recognized as a builtin based on its name.
The builtin declaration syntax is too restrictive and doesn't allow custom 
structs, function pointers, etc.
It seems to be the only case and fixing this would require reworking the 
current builtin syntax, so this seems acceptable.

Fixes PR45410.

Reviewed By: rsmith, yutsumi

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

Added: 
clang/test/CodeGen/builtin-redeclaration.c

Modified: 
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/Builtins.def
clang/include/clang/Basic/IdentifierTable.h
clang/include/clang/Sema/Sema.h
clang/lib/AST/Decl.cpp
clang/lib/Headers/intrin.h
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaLookup.cpp
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/test/AST/ast-dump-attr.cpp
clang/test/CodeGen/callback_pthread_create.c
clang/test/CodeGenCXX/builtins.cpp
clang/test/Sema/implicit-builtin-decl.c
clang/test/Sema/warn-fortify-source.c
clang/test/SemaCXX/cxx11-compat.cpp
clang/test/SemaCXX/warn-unused-local-typedef.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 19eccf7ceadf..60eaee7839e2 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -3444,3 +3444,11 @@ def ReleaseHandle : InheritableParamAttr {
   let Subjects = SubjectList<[ParmVar]>;
   let Documentation = [ReleaseHandleDocs];
 }
+
+def Builtin : InheritableAttr {
+  let Spellings = [];
+  let Args = [UnsignedArgument<"ID">];
+  let Subjects = SubjectList<[Function]>;
+  let SemaHandler = 0;
+  let Documentation = [Undocumented];
+}

diff  --git a/clang/include/clang/Basic/Builtins.def 
b/clang/include/clang/Basic/Builtins.def
index 1416a64543a4..01c28ebab763 100644
--- a/clang/include/clang/Basic/Builtins.def
+++ b/clang/include/clang/Basic/Builtins.def
@@ -1017,6 +1017,7 @@ LIBBUILTIN(strncasecmp, "icC*cC*z", "f",   "strings.h", 
ALL_GNU_LANGUAGES)
 LIBBUILTIN(_exit, "vi",   "fr","unistd.h", ALL_GNU_LANGUAGES)
 LIBBUILTIN(vfork, "p","fj","unistd.h", ALL_LANGUAGES)
 // POSIX pthread.h
+// FIXME: Should specify argument types.
 LIBBUILTIN(pthread_create, "",  "fC<2,3>", "pthread.h", ALL_GNU_LANGUAGES)
 
 // POSIX setjmp.h

diff  --git a/clang/include/clang/Basic/IdentifierTable.h 
b/clang/include/clang/Basic/IdentifierTable.h
index fc554a35e721..204a0f0cc0a5 100644
--- a/clang/include/clang/Basic/IdentifierTable.h
+++ b/clang/include/clang/Basic/IdentifierTable.h
@@ -225,18 +225,6 @@ class alignas(IdentifierInfoAlignment) IdentifierInfo {
   }
   void setObjCKeywordID(tok::ObjCKeywordKind ID) { ObjCOrBuiltinID = ID; }
 
-  /// True if setNotBuiltin() was called.
-  bool hasRevertedBuiltin() const {
-return ObjCOrBuiltinID == tok::NUM_OBJC_KEYWORDS;
-  }
-
-  /// Revert the identifier to a non-builtin identifier. We do this if
-  /// the name of a known builtin library function is used to declare that
-  /// function, but an unexpected type is specified.
-  void revertBuiltin() {
-setBuiltinID(0);
-  }
-
   /// Return a value indicating whether this is a builtin function.
   ///
   /// 0 is not-built-in. 1+ are specific builtin functions.

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 6f7ad8076718..16a7084f6b08 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -3957,6 +3957,8 @@ class Sema final {
 

[llvm-branch-commits] [llvm] ce0c001 - AMDGPU: If a store defines (alias) a load, it clobbers the load.

2020-12-14 Thread Changpeng Fang via llvm-branch-commits

Author: Changpeng Fang
Date: 2020-12-14T16:34:32-08:00
New Revision: ce0c0013d8b11e9ce9820c0add2a013f5992e6a6

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

LOG: AMDGPU: If a store defines (alias) a load, it clobbers the load.

Summary:
 If a store defines (must alias) a load, it clobbers the load.

Fixes: SWDEV-258915

Reviewers:
  arsenm

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

Added: 
llvm/test/CodeGen/AMDGPU/store-clobbers-load.ll

Modified: 
llvm/lib/Target/AMDGPU/AMDGPUAnnotateUniformValues.cpp
llvm/test/CodeGen/AMDGPU/wave32.ll

Removed: 




diff  --git a/llvm/lib/Target/AMDGPU/AMDGPUAnnotateUniformValues.cpp 
b/llvm/lib/Target/AMDGPU/AMDGPUAnnotateUniformValues.cpp
index 6fc58816cf99..f23c4c17ab79 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUAnnotateUniformValues.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUAnnotateUniformValues.cpp
@@ -110,7 +110,9 @@ bool 
AMDGPUAnnotateUniformValues::isClobberedInFunction(LoadInst * Load) {
   BasicBlock::iterator(Load) : BB->end();
 auto Q = MDR->getPointerDependencyFrom(
 MemoryLocation::getBeforeOrAfter(Ptr), true, StartIt, BB, Load);
-if (Q.isClobber() || Q.isUnknown())
+if (Q.isClobber() || Q.isUnknown() ||
+// Store defines the load and thus clobbers it.
+(Q.isDef() && Q.getInst()->mayWriteToMemory()))
   return true;
   }
   return false;

diff  --git a/llvm/test/CodeGen/AMDGPU/store-clobbers-load.ll 
b/llvm/test/CodeGen/AMDGPU/store-clobbers-load.ll
new file mode 100644
index ..88cfffed47c5
--- /dev/null
+++ b/llvm/test/CodeGen/AMDGPU/store-clobbers-load.ll
@@ -0,0 +1,43 @@
+; RUN: opt -S --amdgpu-annotate-uniform < %s | FileCheck -check-prefix=OPT %s
+target datalayout = "A5"
+
+; "load vaddr" depends on the store, so we should not mark vaddr as 
amdgpu.noclobber.
+
+; OPT-LABEL: @store_clobbers_load(
+; OPT:  %vaddr = bitcast [4 x i32] addrspace(5)* %alloca to <4 x i32> 
addrspace(5)*, !amdgpu.uniform !0
+; OPT-NEXT: %zero = load <4 x i32>, <4 x i32> addrspace(5)* %vaddr, align 16
+define amdgpu_kernel void @store_clobbers_load(i32 addrspace(1)* %out, i32 
%index) {
+entry:
+  %alloca = alloca [4 x i32], addrspace(5)
+  %addr0 = bitcast [4 x i32] addrspace(5)* %alloca to i32 addrspace(5)*
+  store i32 0, i32 addrspace(5)* %addr0
+  %vaddr = bitcast [4 x i32] addrspace(5)* %alloca to <4 x i32> addrspace(5)*
+  %zero = load <4 x i32>, <4 x i32> addrspace(5)* %vaddr, align 16
+  %one = insertelement <4 x i32> %zero, i32 1, i32 1
+  %two = insertelement <4 x i32> %one, i32 2, i32 2
+  %three = insertelement <4 x i32> %two, i32 3, i32 3
+  store <4 x i32> %three, <4 x i32> addrspace(5)* %vaddr, align 16
+  %rslt = extractelement <4 x i32> %three, i32 %index
+  store i32 %rslt, i32 addrspace(1)* %out, align 4
+  ret void
+}
+
+declare i32 @llvm.amdgcn.workitem.id.x()
+@lds0 = addrspace(3) global [512 x i32] undef, align 4
+
+; To check that %arrayidx0 is not marked as amdgpu.noclobber.
+
+; OPT-LABEL: @atomicrmw_clobbers_load(
+; OPT:   %arrayidx0 = getelementptr inbounds [512 x i32], [512 x i32] 
addrspace(3)* @lds0, i32 0, i32 %idx.0, !amdgpu.uniform !0
+; OPT-NEXT:  %val = atomicrmw xchg i32 addrspace(3)* %arrayidx0, i32 3 seq_cst
+
+define amdgpu_kernel void @atomicrmw_clobbers_load(i32 addrspace(1)* %out0, 
i32 addrspace(1)* %out1) {
+  %tid.x = tail call i32 @llvm.amdgcn.workitem.id.x() #1
+  %idx.0 = add nsw i32 %tid.x, 2
+  %arrayidx0 = getelementptr inbounds [512 x i32], [512 x i32] addrspace(3)* 
@lds0, i32 0, i32 %idx.0
+  %val = atomicrmw xchg i32 addrspace(3)* %arrayidx0, i32 3 seq_cst
+  %load = load i32, i32 addrspace(3)* %arrayidx0, align 4
+  store i32 %val, i32 addrspace(1)* %out0, align 4
+  store i32 %load, i32 addrspace(1)* %out1, align 4
+  ret void
+}

diff  --git a/llvm/test/CodeGen/AMDGPU/wave32.ll 
b/llvm/test/CodeGen/AMDGPU/wave32.ll
index b5b42d893205..da37154985b5 100644
--- a/llvm/test/CodeGen/AMDGPU/wave32.ll
+++ b/llvm/test/CodeGen/AMDGPU/wave32.ll
@@ -231,9 +231,9 @@ bb13:
 ; GCN:   ; %bb.{{[0-9]+}}: ; %.preheader
 ; GCN:   BB{{.*}}:
 
+; GCN: global_store_dword
 ; GFX1032: s_or_b32 [[MASK0:s[0-9]+]], [[MASK0]], vcc_lo
 ; GFX1064: s_or_b64 [[MASK0:s\[[0-9:]+\]]], [[MASK0]], vcc
-; GCN: global_store_dword
 ; GFX1032: s_andn2_b32 [[MASK1:s[0-9]+]], [[MASK1]], exec_lo
 ; GFX1064: s_andn2_b64 [[MASK1:s\[[0-9:]+\]]], [[MASK1]], exec
 ; GFX1032: s_and_b32 [[MASK0]], [[MASK0]], exec_lo
@@ -249,10 +249,12 @@ bb13:
 ; GFX1064: s_andn2_b64 exec, exec, [[ACC]]
 ; GCN: s_cbranch_execz
 ; GCN:   BB{{.*}}:
-; GCN: s_load_dword [[LOAD:s[0-9]+]]
+
 ; GFX1032: s_or_b32 [[MASK1]], [[MASK1]], exec_lo
 ; GFX1064: s_or_b64 [[MASK1]], [[MASK1]], exec
-; GCN: s_cmp_lt_i32 [[LOAD]], 11
+; GCN: global_load_dword [[LOAD:v[0-9]+]]

[llvm-branch-commits] [clang] 200eb1a - Stop ExtractTypeForDeductionGuide from recursing on TypeSourceInfo

2020-12-14 Thread Tom Stellard via llvm-branch-commits

Author: Erich Keane
Date: 2020-12-14T19:35:08-05:00
New Revision: 200eb1abe2a1088a155f47b95dd1d35b3f37afa6

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

LOG: Stop ExtractTypeForDeductionGuide from recursing on TypeSourceInfo

As reported in PR48177, the type-deduction extraction ends up going into
an infinite loop when the type referred to has a recursive definition.
This stops recursing and just substitutes the type-source-info the
TypeLocBuilder identified when transforming the base.

(cherry picked from commit 1c98f984105e552daa83ed8e92c61fba0e401410)

Added: 


Modified: 
clang/lib/Sema/SemaTemplate.cpp
clang/test/AST/deduction-guides.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index c05ed0b14e3e..f788cf103503 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -1963,8 +1963,7 @@ class ExtractTypeForDeductionGuide
 TypeLocBuilder InnerTLB;
 QualType Transformed =
 TransformType(InnerTLB, OrigDecl->getTypeSourceInfo()->getTypeLoc());
-TypeSourceInfo *TSI =
-TransformType(InnerTLB.getTypeSourceInfo(Context, Transformed));
+TypeSourceInfo *TSI = InnerTLB.getTypeSourceInfo(Context, Transformed);
 
 TypedefNameDecl *Decl = nullptr;
 

diff  --git a/clang/test/AST/deduction-guides.cpp 
b/clang/test/AST/deduction-guides.cpp
index 0f5293bc063d..3a7f0bf4699e 100644
--- a/clang/test/AST/deduction-guides.cpp
+++ b/clang/test/AST/deduction-guides.cpp
@@ -37,3 +37,43 @@ 
HasDeductionGuideTypeAlias()->HasDeductionGuideTypeAlias;
 // CHECK: CXXDeductionGuideDecl {{.*}} implicit  'auto (HasDeductionGuideTypeAlias) -> 
HasDeductionGuideTypeAlias'
 // CHECK: CXXDeductionGuideDecl {{.*}}  'auto () -> HasDeductionGuideTypeAlias'
 } // namespace PR46111
+
+
+namespace PR48177 {
+  template  struct Base {
+using type_alias = A;
+  };
+  template
+  struct Derived : Base {
+using type_alias = typename Derived::type_alias;
+Derived(Derived &&, typename Derived::type_alias const&);
+Derived(T);
+  };
+
+  template
+  Derived(T, A) -> Derived;
+
+  void init() {
+Derived d {1,2};
+  }
+} // namespace PR48177
+
+// CHECK: CXXRecordDecl {{.*}} struct Derived
+// CHECK: TypeAliasDecl {{.*}} type_alias 'typename Derived::type_alias'
+// CHECK-NEXT: DependentNameType {{.*}} 'typename Derived::type_alias' dependent
+
+// CHECK: CXXRecordDecl {{.*}} struct Derived
+// CHECK: TypeAliasDecl {{.*}} type_alias 'typename Derived::type_alias':'int'
+// CHECK-NEXT: ElaboratedType {{.*}} 'typename Derived::type_alias' sugar
+// CHECK-NEXT: TypedefType {{.*}} 'PR48177::Base::type_alias' sugar
+// CHECK-NEXT: TypeAlias {{.*}} 'type_alias'
+// CHECK-NEXT: SubstTemplateTypeParmType {{.*}} 'int' sugar
+// CHECK-NEXT: TemplateTypeParmType {{.*}} 'A'
+// CHECK-NEXT: TemplateTypeParm {{.*}} 'A'
+// CHECK-NEXT: BuiltinType {{.*}} 'int'
+
+// CHECK: CXXDeductionGuideDecl {{.*}} implicit  
'auto (Derived &&, const typename Derived::type_alias &) -> 
Derived'
+// CHECK: CXXDeductionGuideDecl {{.*}} implicit  
'auto (T) -> Derived'
+// CHECK: CXXDeductionGuideDecl {{.*}} implicit  
'auto (Derived) -> Derived'
+// CHECK: CXXDeductionGuideDecl {{.*}}  'auto (T, 
A) -> Derived'
+// CHECK: CXXDeductionGuideDecl {{.*}}  'auto 
(int, int) -> Derived'



___
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] eed0b9a - [PowerPC] Temporarily disable asan longjmp tests

2020-12-14 Thread Nemanja Ivanovic via llvm-branch-commits

Author: Nemanja Ivanovic
Date: 2020-12-14T18:22:08-06:00
New Revision: eed0b9acdfe4409fb90b356d58c996f12cfd733f

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

LOG: [PowerPC] Temporarily disable asan longjmp tests

Commit bfdc19e77868b849b5c636bf0512970264aef571 seems to have broken
some PPC bots with a couple of asan test cases. Disable those test
cases for now until I can resolve the issue.

Added: 


Modified: 
compiler-rt/test/asan/TestCases/Posix/unpoison-alternate-stack.cpp
compiler-rt/test/asan/TestCases/longjmp.cpp

Removed: 




diff  --git 
a/compiler-rt/test/asan/TestCases/Posix/unpoison-alternate-stack.cpp 
b/compiler-rt/test/asan/TestCases/Posix/unpoison-alternate-stack.cpp
index 4774993cdf328..9da47facac276 100644
--- a/compiler-rt/test/asan/TestCases/Posix/unpoison-alternate-stack.cpp
+++ b/compiler-rt/test/asan/TestCases/Posix/unpoison-alternate-stack.cpp
@@ -1,3 +1,4 @@
+// UNSUPPORTED: powerpc64
 // Tests that __asan_handle_no_return properly unpoisons the signal alternate
 // stack.
 

diff  --git a/compiler-rt/test/asan/TestCases/longjmp.cpp 
b/compiler-rt/test/asan/TestCases/longjmp.cpp
index 8e9f2ae195c71..bc4165ffd8139 100644
--- a/compiler-rt/test/asan/TestCases/longjmp.cpp
+++ b/compiler-rt/test/asan/TestCases/longjmp.cpp
@@ -1,3 +1,4 @@
+// UNSUPPORTED: powerpc64
 // RUN: %clangxx_asan -O %s -o %t && %run %t
 
 #include 



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] 54e03d0 - [PGO] Verify BFI counts after loading profile data

2020-12-14 Thread Rong Xu via llvm-branch-commits

Author: Rong Xu
Date: 2020-12-14T15:56:10-08:00
New Revision: 54e03d03a7a4d47f09d40bcbcfe484066a52a077

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

LOG: [PGO] Verify BFI counts after loading profile data

This patch adds the functionality to compare BFI counts with real
profile
counts right after reading the profile. It will print remarks under
-Rpass-analysis=pgo, or the internal option -pass-remarks-analysis=pgo.

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

Added: 
llvm/test/Transforms/PGOProfile/Inputs/bfi_verification.proftext
llvm/test/Transforms/PGOProfile/bfi_verification.ll

Modified: 
clang/lib/CodeGen/CGCall.cpp
clang/lib/CodeGen/CodeGenModule.cpp
llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 73194be922dd..ced287643c28 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -1943,6 +1943,11 @@ void CodeGenModule::ConstructAttributeList(
   FuncAttrs.addAttribute(llvm::Attribute::NoReturn);
 if (TargetDecl->hasAttr())
   FuncAttrs.addAttribute(llvm::Attribute::Cold);
+if (TargetDecl->hasAttr()) {
+  // xur
+  fprintf(stderr, "hihi 2\n");
+  //  FuncAttrs.addAttribute(llvm::Attribute::Hot);
+}
 if (TargetDecl->hasAttr())
   FuncAttrs.addAttribute(llvm::Attribute::NoDuplicate);
 if (TargetDecl->hasAttr())

diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 0bb9c91f2434..dec0cba84343 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -1744,6 +1744,13 @@ void 
CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D,
 B.addAttribute(llvm::Attribute::OptimizeForSize);
   B.addAttribute(llvm::Attribute::Cold);
 }
+if (D->hasAttr()) {
+  if (!ShouldAddOptNone)
+B.addAttribute(llvm::Attribute::OptimizeForSize);
+  // xur
+  //  B.addAttribute(llvm::Attribute::Hot);
+  fprintf(stderr, "hihi 1\n");
+}
 
 if (D->hasAttr())
   B.addAttribute(llvm::Attribute::MinSize);

diff  --git a/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp 
b/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
index 0228c8a8ef14..eba8d9e9c3c3 100644
--- a/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
+++ b/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
@@ -252,6 +252,30 @@ static cl::opt PGOInstrumentEntry(
 "pgo-instrument-entry", cl::init(false), cl::Hidden,
 cl::desc("Force to instrument function entry basicblock."));
 
+static cl::opt PGOVerifyHotBFI(
+"pgo-verify-hot-bfi", cl::init(false), cl::Hidden,
+cl::desc("Print out the non-match BFI count if a hot raw profile count "
+ "becomes non-hot, or a cold raw profile count becomes hot. "
+ "The print is enabled under -Rpass-analysis=pgo, or "
+ "internal option -pass-remakrs-analysis=pgo."));
+
+static cl::opt PGOVerifyBFI(
+"pgo-verify-bfi", cl::init(false), cl::Hidden,
+cl::desc("Print out mismatched BFI counts after setting profile metadata "
+ "The print is enabled under -Rpass-analysis=pgo, or "
+ "internal option -pass-remakrs-analysis=pgo."));
+
+static cl::opt PGOVerifyBFIRatio(
+"pgo-verify-bfi-ratio", cl::init(5), cl::Hidden,
+cl::desc("Set the threshold for pgo-verify-big -- only print out "
+ "mismatched BFI if the 
diff erence percentage is greater than "
+ "this value (in percentage)."));
+
+static cl::opt PGOVerifyBFICutoff(
+"pgo-verify-bfi-cutoff", cl::init(1), cl::Hidden,
+cl::desc("Set the threshold for pgo-verify-bfi -- skip the counts whose "
+ "profile count value is below."));
+
 // Command line option to turn on CFG dot dump after profile annotation.
 // Defined in Analysis/BlockFrequencyInfo.cpp:  -pgo-view-counts
 extern cl::opt PGOViewCounts;
@@ -1616,6 +1640,82 @@ PreservedAnalyses PGOInstrumentationGen::run(Module ,
   return PreservedAnalyses::none();
 }
 
+// Compare the profile count values with BFI count values, and print out
+// the non-matching ones.
+static void verifyFuncBFI(PGOUseFunc , LoopInfo ,
+  BranchProbabilityInfo ,
+  uint64_t HotCountThreshold,
+  uint64_t ColdCountThreshold) {
+  Function  = Func.getFunc();
+  BlockFrequencyInfo NBFI(F, NBPI, LI);
+  //  bool PrintFunc = false;
+  bool HotBBOnly = PGOVerifyHotBFI;
+  std::string Msg;
+  OptimizationRemarkEmitter ORE();
+
+  unsigned BBNum = 0, BBMisMatchNum = 0, NonZeroBBNum = 0;
+  for (auto  : F) {
+uint64_t CountValue = 0;
+uint64_t 

[llvm-branch-commits] [llvm] 9eac818 - [X86] Fix variadic argument handling for x32

2020-12-14 Thread Harald van Dijk via llvm-branch-commits

Author: Harald van Dijk
Date: 2020-12-14T23:47:27Z
New Revision: 9eac818370fe4b50a167627593bfe53e61c216bc

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

LOG: [X86] Fix variadic argument handling for x32

The X86-64 ABI defines va_list as

  typedef struct {
unsigned int gp_offset;
unsigned int fp_offset;
void *overflow_arg_area;
void *reg_save_area;
  } va_list[1];

This means the size, alignment, and reg_save_area offset will depend on
whether we are in LP64 or in ILP32 mode, so this commit adds the checks.
Additionally, the VAARG_64 pseudo-instruction assumed 64-bit pointers, so
this commit adds a VAARG_X32 pseudo-instruction that behaves just like
VAARG_64, except for assuming 32-bit pointers.

Some of these changes were originally done by
Michael Liao .

Fixes https://bugs.llvm.org/show_bug.cgi?id=48428.

Reviewed By: RKSimon

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

Added: 


Modified: 
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/lib/Target/X86/X86ISelLowering.h
llvm/lib/Target/X86/X86InstrCompiler.td
llvm/lib/Target/X86/X86InstrInfo.td
llvm/test/CodeGen/X86/x86-64-varargs.ll

Removed: 




diff  --git a/llvm/lib/Target/X86/X86ISelLowering.cpp 
b/llvm/lib/Target/X86/X86ISelLowering.cpp
index e4fcafc3352f..21af1a5aad00 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -24360,15 +24360,16 @@ SDValue X86TargetLowering::LowerVAARG(SDValue Op, 
SelectionDAG ) const {
Subtarget.hasSSE1());
   }
 
-  // Insert VAARG_64 node into the DAG
-  // VAARG_64 returns two values: Variable Argument Address, Chain
+  // Insert VAARG node into the DAG
+  // VAARG returns two values: Variable Argument Address, Chain
   SDValue InstOps[] = {Chain, SrcPtr,
DAG.getTargetConstant(ArgSize, dl, MVT::i32),
DAG.getTargetConstant(ArgMode, dl, MVT::i8),
DAG.getTargetConstant(Align, dl, MVT::i32)};
   SDVTList VTs = DAG.getVTList(getPointerTy(DAG.getDataLayout()), MVT::Other);
   SDValue VAARG = DAG.getMemIntrinsicNode(
-  X86ISD::VAARG_64, dl, VTs, InstOps, MVT::i64, MachinePointerInfo(SV),
+  Subtarget.isTarget64BitLP64() ? X86ISD::VAARG_64 : X86ISD::VAARG_X32, dl,
+  VTs, InstOps, MVT::i64, MachinePointerInfo(SV),
   /*Alignment=*/None,
   MachineMemOperand::MOLoad | MachineMemOperand::MOStore);
   Chain = VAARG.getValue(1);
@@ -24394,9 +24395,11 @@ static SDValue LowerVACOPY(SDValue Op, const 
X86Subtarget ,
   const Value *SrcSV = cast(Op.getOperand(4))->getValue();
   SDLoc DL(Op);
 
-  return DAG.getMemcpy(Chain, DL, DstPtr, SrcPtr, DAG.getIntPtrConstant(24, 
DL),
-   Align(8), /*isVolatile*/ false, false, false,
-   MachinePointerInfo(DstSV), MachinePointerInfo(SrcSV));
+  return DAG.getMemcpy(
+  Chain, DL, DstPtr, SrcPtr,
+  DAG.getIntPtrConstant(Subtarget.isTarget64BitLP64() ? 24 : 16, DL),
+  Align(Subtarget.isTarget64BitLP64() ? 8 : 4), /*isVolatile*/ false, 
false,
+  false, MachinePointerInfo(DstSV), MachinePointerInfo(SrcSV));
 }
 
 // Helper to get immediate/variable SSE shift opcode from other shift opcodes.
@@ -30959,6 +30962,7 @@ const char 
*X86TargetLowering::getTargetNodeName(unsigned Opcode) const {
   NODE_NAME_CASE(DBPSADBW)
   NODE_NAME_CASE(VASTART_SAVE_XMM_REGS)
   NODE_NAME_CASE(VAARG_64)
+  NODE_NAME_CASE(VAARG_X32)
   NODE_NAME_CASE(WIN_ALLOCA)
   NODE_NAME_CASE(MEMBARRIER)
   NODE_NAME_CASE(MFENCE)
@@ -31548,11 +31552,9 @@ static MachineBasicBlock *emitXBegin(MachineInstr , 
MachineBasicBlock *MBB,
   return sinkMBB;
 }
 
-
-
 MachineBasicBlock *
-X86TargetLowering::EmitVAARG64WithCustomInserter(MachineInstr ,
- MachineBasicBlock *MBB) const 
{
+X86TargetLowering::EmitVAARGWithCustomInserter(MachineInstr ,
+   MachineBasicBlock *MBB) const {
   // Emit va_arg instruction on X86-64.
 
   // Operands to this pseudo-instruction:
@@ -31563,9 +31565,8 @@ 
X86TargetLowering::EmitVAARG64WithCustomInserter(MachineInstr ,
   // 8  ) Align : Alignment of type
   // 9  ) EFLAGS (implicit-def)
 
-  assert(MI.getNumOperands() == 10 && "VAARG_64 should have 10 operands!");
-  static_assert(X86::AddrNumOperands == 5,
-"VAARG_64 assumes 5 address operands");
+  assert(MI.getNumOperands() == 10 && "VAARG should have 10 operands!");
+  static_assert(X86::AddrNumOperands == 5, "VAARG assumes 5 address operands");
 
   Register DestReg = MI.getOperand(0).getReg();
   MachineOperand  = MI.getOperand(1);
@@ -31580,7 +31581,7 @@ 
X86TargetLowering::EmitVAARG64WithCustomInserter(MachineInstr ,
   MachineFunction *MF = 

[llvm-branch-commits] [lld] d058b69 - [lld/mac] implement -compatibility_version, -current_version

2020-12-14 Thread Nico Weber via llvm-branch-commits

Author: Nico Weber
Date: 2020-12-14T18:41:36-05:00
New Revision: d058b69b1cd3d71b9bcb45011f5f3ef3a576a5e2

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

LOG: [lld/mac] implement -compatibility_version, -current_version

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

Added: 
lld/test/MachO/dylib-version.s

Modified: 
lld/MachO/Config.h
lld/MachO/Driver.cpp
lld/MachO/Options.td
lld/MachO/Writer.cpp

Removed: 




diff  --git a/lld/MachO/Config.h b/lld/MachO/Config.h
index 2835b5c1546e..029b9ab2296c 100644
--- a/lld/MachO/Config.h
+++ b/lld/MachO/Config.h
@@ -44,6 +44,8 @@ struct Configuration {
   bool searchDylibsFirst = false;
   bool saveTemps = false;
   uint32_t headerPad;
+  uint32_t dylibCompatibilityVersion = 0;
+  uint32_t dylibCurrentVersion = 0;
   llvm::StringRef installName;
   llvm::StringRef outputFile;
   llvm::StringRef ltoObjPath;

diff  --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp
index 73846d420096..c456d2fb1fd5 100644
--- a/lld/MachO/Driver.cpp
+++ b/lld/MachO/Driver.cpp
@@ -663,6 +663,46 @@ static void parseClangOption(StringRef opt, const Twine 
) {
   error(msg + ": " + StringRef(err).trim());
 }
 
+static uint32_t parseDylibVersion(const opt::ArgList& args, unsigned id) {
+  const opt::Arg *arg = args.getLastArg(id);
+  if (!arg)
+return 0;
+
+  if (config->outputType != MH_DYLIB) {
+error(arg->getAsString(args) + ": only valid with -dylib");
+return 0;
+  }
+
+  llvm::VersionTuple version;
+  if (version.tryParse(arg->getValue()) || version.getBuild().hasValue()) {
+error(arg->getAsString(args) + ": malformed version");
+return 0;
+  }
+
+  unsigned major = version.getMajor();
+  if (major > UINT16_MAX) {
+error(arg->getAsString(args) + ": component " + Twine(major) +
+  " out of range");
+return 0;
+  }
+
+  unsigned minor = version.getMinor().getValueOr(0);
+  if (minor > UINT8_MAX) {
+error(arg->getAsString(args) + ": component " + Twine(minor) +
+  " out of range");
+return 0;
+  }
+
+  unsigned subminor = version.getSubminor().getValueOr(0);
+  if (subminor > UINT8_MAX) {
+error(arg->getAsString(args) + ": component " + Twine(subminor) +
+  " out of range");
+return 0;
+  }
+
+  return (major << 16) | (minor << 8) | subminor;
+}
+
 bool macho::link(llvm::ArrayRef argsArr, bool canExitEarly,
  raw_ostream , raw_ostream ) {
   lld::stdoutOS = 
@@ -732,6 +772,10 @@ bool macho::link(llvm::ArrayRef argsArr, 
bool canExitEarly,
 config->searchDylibsFirst =
 (arg && arg->getOption().getID() == OPT_search_dylibs_first);
 
+  config->dylibCompatibilityVersion =
+  parseDylibVersion(args, OPT_compatibility_version);
+  config->dylibCurrentVersion = parseDylibVersion(args, OPT_current_version);
+
   config->saveTemps = args.hasArg(OPT_save_temps);
 
   if (args.hasArg(OPT_v)) {

diff  --git a/lld/MachO/Options.td b/lld/MachO/Options.td
index d1d06879cafa..ca13e3b9 100644
--- a/lld/MachO/Options.td
+++ b/lld/MachO/Options.td
@@ -290,7 +290,6 @@ def mark_dead_strippable_dylib : Flag<["-"], 
"mark_dead_strippable_dylib">,
 def compatibility_version : Separate<["-"], "compatibility_version">,
  MetaVarName<"">,
  HelpText<"Compatibility  of this library">,
- Flags<[HelpHidden]>,
  Group;
 def dylib_compatibility_version : Separate<["-"], 
"dylib_compatibility_version">,
  MetaVarName<"">,
@@ -301,7 +300,6 @@ def dylib_compatibility_version : Separate<["-"], 
"dylib_compatibility_version">
 def current_version : Separate<["-"], "current_version">,
  MetaVarName<"">,
  HelpText<"Current  of this library">,
- Flags<[HelpHidden]>,
  Group;
 def dylib_current_version : Separate<["-"], "dylib_current_version">,
  MetaVarName<"">,

diff  --git a/lld/MachO/Writer.cpp b/lld/MachO/Writer.cpp
index 2d033febb79b..9f6aa0b49692 100644
--- a/lld/MachO/Writer.cpp
+++ b/lld/MachO/Writer.cpp
@@ -242,7 +242,10 @@ class LCSymtab : public LoadCommand {
 //   * LC_REEXPORT_DYLIB
 class LCDylib : public LoadCommand {
 public:
-  LCDylib(LoadCommandType type, StringRef path) : type(type), path(path) {
+  LCDylib(LoadCommandType type, StringRef path,
+  uint32_t compatibilityVersion = 0, uint32_t currentVersion = 0)
+  : type(type), path(path), compatibilityVersion(compatibilityVersion),
+currentVersion(currentVersion) {
 instanceCount++;
   }
 
@@ -257,6 +260,9 @@ class LCDylib : public LoadCommand {
 c->cmd = type;
 c->cmdsize = getSize();
 c->dylib.name = sizeof(dylib_command);
+c->dylib.timestamp = 0;
+c->dylib.compatibility_version = compatibilityVersion;
+c->dylib.current_version = currentVersion;
 
 memcpy(buf, path.data(), path.size());
 

[llvm-branch-commits] [compiler-rt] f21f333 - scudo: Remove positional template arguments for secondary cache. NFCI.

2020-12-14 Thread Peter Collingbourne via llvm-branch-commits

Author: Peter Collingbourne
Date: 2020-12-14T15:40:07-08:00
New Revision: f21f3339ba315f181e195f368f2a7ecff1cee597

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

LOG: scudo: Remove positional template arguments for secondary cache. NFCI.

Make these arguments named constants in the Config class instead
of being positional arguments to MapAllocatorCache. This makes the
configuration easier to follow.

Eventually we should follow suit with the other classes but this is
a start.

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

Added: 


Modified: 
compiler-rt/lib/scudo/standalone/allocator_config.h
compiler-rt/lib/scudo/standalone/combined.h
compiler-rt/lib/scudo/standalone/secondary.h
compiler-rt/lib/scudo/standalone/tests/combined_test.cpp
compiler-rt/lib/scudo/standalone/tests/secondary_test.cpp

Removed: 




diff  --git a/compiler-rt/lib/scudo/standalone/allocator_config.h 
b/compiler-rt/lib/scudo/standalone/allocator_config.h
index cf362da4e5be..8f1757dab322 100644
--- a/compiler-rt/lib/scudo/standalone/allocator_config.h
+++ b/compiler-rt/lib/scudo/standalone/allocator_config.h
@@ -32,7 +32,13 @@ struct DefaultConfig {
   // 512KB regions
   typedef SizeClassAllocator32 Primary;
 #endif
-  typedef MapAllocator> Secondary;
+  typedef MapAllocatorCache SecondaryCache;
+  static const u32 SecondaryCacheEntriesArraySize = 32U;
+  static const u32 SecondaryCacheDefaultMaxEntriesCount = 32U;
+  static const uptr SecondaryCacheDefaultMaxEntrySize = 1UL << 19;
+  static const s32 SecondaryCacheMinReleaseToOsIntervalMs = INT32_MIN;
+  static const s32 SecondaryCacheMaxReleaseToOsIntervalMs = INT32_MAX;
+
   template  using TSDRegistryT = TSDRegistryExT; // Exclusive
 };
 
@@ -47,9 +53,13 @@ struct AndroidConfig {
   // 256KB regions
   typedef SizeClassAllocator32 Primary;
 #endif
-  // Cache blocks up to 2MB
-  typedef MapAllocator>
-  Secondary;
+  typedef MapAllocatorCache SecondaryCache;
+  static const u32 SecondaryCacheEntriesArraySize = 256U;
+  static const u32 SecondaryCacheDefaultMaxEntriesCount = 32U;
+  static const uptr SecondaryCacheDefaultMaxEntrySize = 2UL << 20;
+  static const s32 SecondaryCacheMinReleaseToOsIntervalMs = 0;
+  static const s32 SecondaryCacheMaxReleaseToOsIntervalMs = 1000;
+
   template 
   using TSDRegistryT = TSDRegistrySharedT; // Shared, max 8 TSDs.
 };
@@ -63,7 +73,13 @@ struct AndroidSvelteConfig {
   // 64KB regions
   typedef SizeClassAllocator32 Primary;
 #endif
-  typedef MapAllocator> Secondary;
+  typedef MapAllocatorCache SecondaryCache;
+  static const u32 SecondaryCacheEntriesArraySize = 16U;
+  static const u32 SecondaryCacheDefaultMaxEntriesCount = 4U;
+  static const uptr SecondaryCacheDefaultMaxEntrySize = 1UL << 18;
+  static const s32 SecondaryCacheMinReleaseToOsIntervalMs = 0;
+  static const s32 SecondaryCacheMaxReleaseToOsIntervalMs = 0;
+
   template 
   using TSDRegistryT = TSDRegistrySharedT; // Shared, max 2 TSDs.
 };
@@ -72,7 +88,7 @@ struct AndroidSvelteConfig {
 struct FuchsiaConfig {
   // 1GB Regions
   typedef SizeClassAllocator64 Primary;
-  typedef MapAllocator Secondary;
+  typedef MapAllocatorNoCache SecondaryCache;
   template 
   using TSDRegistryT = TSDRegistrySharedT; // Shared, max 8 TSDs.
 };

diff  --git a/compiler-rt/lib/scudo/standalone/combined.h 
b/compiler-rt/lib/scudo/standalone/combined.h
index e214b0158bf4..7bf108e0b5e0 100644
--- a/compiler-rt/lib/scudo/standalone/combined.h
+++ b/compiler-rt/lib/scudo/standalone/combined.h
@@ -930,7 +930,7 @@ class Allocator {
   }
 
 private:
-  using SecondaryT = typename Params::Secondary;
+  using SecondaryT = MapAllocator;
   typedef typename PrimaryT::SizeClassMap SizeClassMap;
 
   static const uptr MinAlignmentLog = SCUDO_MIN_ALIGNMENT_LOG;

diff  --git a/compiler-rt/lib/scudo/standalone/secondary.h 
b/compiler-rt/lib/scudo/standalone/secondary.h
index ff41bd3e0722..cccbeb239dae 100644
--- a/compiler-rt/lib/scudo/standalone/secondary.h
+++ b/compiler-rt/lib/scudo/standalone/secondary.h
@@ -70,20 +70,18 @@ class MapAllocatorNoCache {
   }
 };
 
-template 
-class MapAllocatorCache {
+template  class MapAllocatorCache {
 public:
   // Ensure the default maximum specified fits the array.
-  static_assert(DefaultMaxEntriesCount <= EntriesArraySize, "");
+  static_assert(Config::SecondaryCacheDefaultMaxEntriesCount <=
+Config::SecondaryCacheEntriesArraySize,
+"");
 
   void initLinkerInitialized(s32 ReleaseToOsInterval) {
 setOption(Option::MaxCacheEntriesCount,
-  static_cast(DefaultMaxEntriesCount));
+  static_cast(Config::SecondaryCacheDefaultMaxEntriesCount));
 setOption(Option::MaxCacheEntrySize,
-  static_cast(DefaultMaxEntrySize));
+  

[llvm-branch-commits] [llvm] 8593e19 - [VectorCombine] add alignment test for gep load; NFC

2020-12-14 Thread Sanjay Patel via llvm-branch-commits

Author: Sanjay Patel
Date: 2020-12-14T18:31:19-05:00
New Revision: 8593e197bc837286abeb4dee50726b2391a77de9

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

LOG: [VectorCombine] add alignment test for gep load; NFC

Added: 


Modified: 
llvm/test/Transforms/VectorCombine/X86/load.ll

Removed: 




diff  --git a/llvm/test/Transforms/VectorCombine/X86/load.ll 
b/llvm/test/Transforms/VectorCombine/X86/load.ll
index 03902c48157f..d28d28761632 100644
--- a/llvm/test/Transforms/VectorCombine/X86/load.ll
+++ b/llvm/test/Transforms/VectorCombine/X86/load.ll
@@ -284,6 +284,21 @@ define <8 x i16> @gep01_load_i16_insert_v8i16_deref(<8 x 
i16>* align 16 derefere
   ret <8 x i16> %r
 }
 
+; TODO: Verify that alignment of the new load is not over-specified.
+
+define <8 x i16> @gep01_load_i16_insert_v8i16_deref_minalign(<8 x i16>* align 
2 dereferenceable(16) %p) {
+; CHECK-LABEL: @gep01_load_i16_insert_v8i16_deref_minalign(
+; CHECK-NEXT:[[GEP:%.*]] = getelementptr inbounds <8 x i16>, <8 x i16>* 
[[P:%.*]], i64 0, i64 1
+; CHECK-NEXT:[[S:%.*]] = load i16, i16* [[GEP]], align 8
+; CHECK-NEXT:[[R:%.*]] = insertelement <8 x i16> undef, i16 [[S]], i64 0
+; CHECK-NEXT:ret <8 x i16> [[R]]
+;
+  %gep = getelementptr inbounds <8 x i16>, <8 x i16>* %p, i64 0, i64 1
+  %s = load i16, i16* %gep, align 8
+  %r = insertelement <8 x i16> undef, i16 %s, i64 0
+  ret <8 x i16> %r
+}
+
 ; If there are enough dereferenceable bytes, we can offset the vector load.
 
 define <8 x i16> @gep10_load_i16_insert_v8i16(<8 x i16>* align 16 
dereferenceable(32) %p) {



___
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] 2733a5a - [gn build] (semi-manually) port 19d57b5c42b

2020-12-14 Thread Nico Weber via llvm-branch-commits

Author: Nico Weber
Date: 2020-12-14T18:23:15-05:00
New Revision: 2733a5a5b445e773f038f35adce776e74f92ac00

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

LOG: [gn build] (semi-manually) port 19d57b5c42b

Added: 


Modified: 
llvm/utils/gn/secondary/libcxx/include/BUILD.gn

Removed: 




diff  --git a/llvm/utils/gn/secondary/libcxx/include/BUILD.gn 
b/llvm/utils/gn/secondary/libcxx/include/BUILD.gn
index fd7da1d2311c..ac217956886a 100644
--- a/llvm/utils/gn/secondary/libcxx/include/BUILD.gn
+++ b/llvm/utils/gn/secondary/libcxx/include/BUILD.gn
@@ -68,6 +68,7 @@ copy("include") {
 "__memory/allocator_traits.h",
 "__memory/base.h",
 "__memory/pointer_traits.h",
+"__memory/utilities.h",
 "__mutex_base",
 "__node_handle",
 "__nullptr",



___
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] 9412932 - [gn build] (semi-manually) port 7ad49aec125

2020-12-14 Thread Nico Weber via llvm-branch-commits

Author: Nico Weber
Date: 2020-12-14T18:22:54-05:00
New Revision: 9412932bb5992c9fcaec0d29f30c914f7fc821c3

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

LOG: [gn build] (semi-manually) port 7ad49aec125

Added: 


Modified: 
llvm/utils/gn/secondary/libcxx/include/BUILD.gn

Removed: 




diff  --git a/llvm/utils/gn/secondary/libcxx/include/BUILD.gn 
b/llvm/utils/gn/secondary/libcxx/include/BUILD.gn
index ccc024fdf88c..fd7da1d2311c 100644
--- a/llvm/utils/gn/secondary/libcxx/include/BUILD.gn
+++ b/llvm/utils/gn/secondary/libcxx/include/BUILD.gn
@@ -65,6 +65,9 @@ copy("include") {
 "__hash_table",
 "__libcpp_version",
 "__locale",
+"__memory/allocator_traits.h",
+"__memory/base.h",
+"__memory/pointer_traits.h",
 "__mutex_base",
 "__node_handle",
 "__nullptr",



___
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] 0b510e7 - [mlir] Fix opaque struct typedef in AsyncRuntime header

2020-12-14 Thread Eugene Zhulenev via llvm-branch-commits

Author: Eugene Zhulenev
Date: 2020-12-14T15:04:59-08:00
New Revision: 0b510e79ce341af6a0ad951d52d516b833d5cefd

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

LOG: [mlir] Fix opaque struct typedef in AsyncRuntime header

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

Added: 


Modified: 
mlir/include/mlir/ExecutionEngine/AsyncRuntime.h

Removed: 




diff  --git a/mlir/include/mlir/ExecutionEngine/AsyncRuntime.h 
b/mlir/include/mlir/ExecutionEngine/AsyncRuntime.h
index 26b0a236f0d3..54724af4133d 100644
--- a/mlir/include/mlir/ExecutionEngine/AsyncRuntime.h
+++ b/mlir/include/mlir/ExecutionEngine/AsyncRuntime.h
@@ -37,10 +37,10 @@
 
//===--===//
 
 // Runtime implementation of `async.token` data type.
-typedef struct AsyncToken MLIR_AsyncToken;
+typedef struct AsyncToken AsyncToken;
 
 // Runtime implementation of `async.group` data type.
-typedef struct AsyncGroup MLIR_AsyncGroup;
+typedef struct AsyncGroup AsyncGroup;
 
 // Async runtime uses LLVM coroutines to represent asynchronous tasks. Task
 // function is a coroutine handle and a resume function that continue coroutine



___
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] ee43dca - [mlir] Add section page for Rationale docs.

2020-12-14 Thread River Riddle via llvm-branch-commits

Author: Richard Uhler
Date: 2020-12-14T14:49:30-08:00
New Revision: ee43dcaad75b8de43b914459c14050dc2a5dbb16

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

LOG: [mlir] Add section page for Rationale docs.

With a brief overview and summary of each of the Rationale docs.

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

Added: 
mlir/docs/Rationale/_index.md

Modified: 
mlir/docs/Rationale/UsageOfConst.md

Removed: 




diff  --git a/mlir/docs/Rationale/UsageOfConst.md 
b/mlir/docs/Rationale/UsageOfConst.md
index 1f0d9c6fee2f..3082dda7ad23 100644
--- a/mlir/docs/Rationale/UsageOfConst.md
+++ b/mlir/docs/Rationale/UsageOfConst.md
@@ -1,4 +1,4 @@
-# Usage of 'Const' in MLIR, for core IR types
+# Usage of 'const' in MLIR, for core IR types
 
 aka, where'd `const` go?
 

diff  --git a/mlir/docs/Rationale/_index.md b/mlir/docs/Rationale/_index.md
new file mode 100644
index ..4fd0362ff55f
--- /dev/null
+++ b/mlir/docs/Rationale/_index.md
@@ -0,0 +1,31 @@
+# Rationale
+
+This section contains a collection of documents describing the motivation and
+rationale for some of the design decisions behind MLIR.
+
+[MLIR: Incremental Application to Graph Algorithms in ML 
Frameworks](MLIRForGraphAlgorithms.md)
+:   A discussion of how the adoption of MLIR can be taken in incremental steps,
+with each step providing tangible benefits along the way. Refutes the idea
+that full adoption of MLIR is required before we can reap the benefits of
+MLIR.
+
+[MLIR Rationale](Rationale.md)
+:   Introduces the motivation for MLIR and captures design discussions and
+decisions made for various core features of MLIR.
+
+[Generic DAG Rewriter Infrastructure Rationale](RationaleGenericDAGRewriter.md)
+:   Details the rationale behind a general DAG-to-DAG rewrite infrastructure 
for
+MLIR.
+
+[Linalg Dialect Rationale: The Case for Compiler-Friendly Custom 
Operations](RationaleLinalgDialect.md)
+:   Describes the key design principles that led to the existing implementation
+of Linalg and lessons learned along the way.
+
+[MLIR: The case for a simplified polyhedral 
form](RationaleSimplifiedPolyhedralForm.md)
+:   An early design proposal exploring the tradeoffs of using a simplified form
+for polyhedral compiler techniques in MLIR instead of the traditional
+polyhedral schedule list form.
+
+[Usage of 'const' in MLIR, for core IR types](UsageOfConst.md)
+:   Explains the rationale for eschewing the use of `const` entirely for the
+core IR types in MLIR.



___
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] 7c0e3a7 - [clang][IR] Add support for leaf attribute

2020-12-14 Thread Haowei Wu via llvm-branch-commits

Author: Gulfem Savrun Yeniceri
Date: 2020-12-14T14:48:17-08:00
New Revision: 7c0e3a77bc43a9c4d05f68ffd4e84d0f75efbd91

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

LOG: [clang][IR] Add support for leaf attribute

This patch adds support for leaf attribute as an optimization hint
in Clang/LLVM.

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

Added: 
clang/test/CodeGen/attr-leaf.c
clang/test/Sema/attr-leaf.c

Modified: 
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/AttrDocs.td
clang/lib/CodeGen/CGCall.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/test/Misc/pragma-attribute-supported-attributes-list.test
llvm/include/llvm/Bitcode/LLVMBitCodes.h
llvm/include/llvm/IR/Attributes.td
llvm/lib/AsmParser/LLLexer.cpp
llvm/lib/AsmParser/LLParser.cpp
llvm/lib/AsmParser/LLToken.h
llvm/lib/Bitcode/Reader/BitcodeReader.cpp
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
llvm/lib/IR/Attributes.cpp
llvm/lib/IR/Verifier.cpp
llvm/lib/Transforms/Utils/CodeExtractor.cpp
llvm/test/Bitcode/attributes.ll

Removed: 




diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 79902c8f5b89..61eb86ac81a1 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -1448,6 +1448,13 @@ def LayoutVersion : InheritableAttr, 
TargetSpecificAttr {
   let Documentation = [LayoutVersionDocs];
 }
 
+def Leaf : InheritableAttr {
+  let Spellings = [GCC<"leaf">];
+  let Subjects = SubjectList<[Function]>;
+  let Documentation = [LeafDocs];
+  let SimpleHandler = 1;
+}
+
 def LifetimeBound : DeclOrTypeAttr {
   let Spellings = [Clang<"lifetimebound", 0>];
   let Subjects = SubjectList<[ParmVar, ImplicitObjectParameter], ErrorDiag>;

diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 28f35cf2c0c7..e70596b5ac28 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -3976,6 +3976,22 @@ are used to instantiate the specialization.
   }];
 }
 
+def LeafDocs : Documentation {
+  let Category = DocCatVariable;
+  let Content = [{
+
+The ``leaf`` attribute is used as a compiler hint to improve dataflow analysis
+in library functions. Functions marked with the ``leaf`` attribute are not 
allowed
+to jump back into the caller's translation unit, whether through invoking a
+callback function, an external function call, use of ``longjmp``, or other 
means.
+Therefore, they cannot use or modify any data that does not escape the caller 
function's
+compilation unit.
+
+For more information see
+`gcc documentation 
`
+}];
+}
+
 def NoStackProtectorDocs : Documentation {
   let Category = DocCatFunction;
   let Content = [{

diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 5db34b693bf3..73194be922dd 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -1989,6 +1989,8 @@ void CodeGenModule::ConstructAttributeList(
   FuncAttrs.addAttribute("no_caller_saved_registers");
 if (TargetDecl->hasAttr())
   FuncAttrs.addAttribute(llvm::Attribute::NoCfCheck);
+if (TargetDecl->hasAttr())
+  FuncAttrs.addAttribute(llvm::Attribute::NoCallback);
 
 HasOptnone = TargetDecl->hasAttr();
 if (auto *AllocSize = TargetDecl->getAttr()) {

diff  --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 15094854300d..395d0ef57945 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -7715,6 +7715,9 @@ static void ProcessDeclAttribute(Sema , Scope *scope, 
Decl *D,
   case ParsedAttr::AT_AnyX86NoCfCheck:
 handleNoCfCheckAttr(S, D, AL);
 break;
+  case ParsedAttr::AT_Leaf:
+handleSimpleAttribute(S, D, AL);
+break;
   case ParsedAttr::AT_NoThrow:
 if (!AL.isUsedAsTypeAttr())
   handleSimpleAttribute(S, D, AL);

diff  --git a/clang/test/CodeGen/attr-leaf.c b/clang/test/CodeGen/attr-leaf.c
new file mode 100644
index ..2b2bacf5e725
--- /dev/null
+++ b/clang/test/CodeGen/attr-leaf.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -Oz -o - %s | FileCheck 
%s
+
+// CHECK: define void @f() local_unnamed_addr [[ATTRS:#[0-9]+]] {
+void f() __attribute__((leaf));
+
+void f()
+{
+}
+
+// CHECK: attributes [[ATTRS]] = { {{.*}}nocallback{{.*}} }

diff  --git a/clang/test/Misc/pragma-attribute-supported-attributes-list.test 
b/clang/test/Misc/pragma-attribute-supported-attributes-list.test
index 0ba6769a1a8a..cb1e48217a81 100644
--- a/clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ b/clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -68,6 

[llvm-branch-commits] [libcxx] b3d1d1f - [libc++] Remove unnecessary static assertion in allocate_shared

2020-12-14 Thread Louis Dionne via llvm-branch-commits

Author: Louis Dionne
Date: 2020-12-14T17:47:43-05:00
New Revision: b3d1d1f4fff816423ea8c652d8d849aacc4c6ce8

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

LOG: [libc++] Remove unnecessary static assertion in allocate_shared

Checking that `T` is constructible from `Args...` is technically not
required by the Standard, although any implementation will obviously
error out if that's not satisfied. However, this check is incompatible
with using Allocator construction in the control block (upcoming change
as part of implementing P0674), so I'm removing it now to reduce the
upcoming diff as much as possible.

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

Added: 


Modified: 
libcxx/include/memory

Removed: 

libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared.protected.verify.cpp

libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.protected.verify.cpp



diff  --git a/libcxx/include/memory b/libcxx/include/memory
index c676cd01c0f5..4167f0140d51 100644
--- a/libcxx/include/memory
+++ b/libcxx/include/memory
@@ -3307,8 +3307,6 @@ template allocate_shared(const _Alloc& __a, _Args&& ...__args)
 {
-static_assert(is_constructible<_Tp, _Args...>::value,
-"allocate_shared/make_shared: the type is not constructible from the 
provided arguments");
 using _ControlBlock = __shared_ptr_emplace<_Tp, _Alloc>;
 using _ControlBlockAllocator = typename __allocator_traits_rebind<_Alloc, 
_ControlBlock>::type;
 __allocation_guard<_ControlBlockAllocator> __guard(__a, 1);

diff  --git 
a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared.protected.verify.cpp
 
b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared.protected.verify.cpp
deleted file mode 100644
index fbd7bfa3e8b8..
--- 
a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared.protected.verify.cpp
+++ /dev/null
@@ -1,34 +0,0 @@
-//===--===//
-//
-// 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
-//
-//===--===//
-
-// GCC 5 does not evaluate static assertions dependent on a template parameter.
-// UNSUPPORTED: gcc-5
-
-// 
-
-// shared_ptr
-
-// template
-//shared_ptr allocate_shared(const A& a, Args&&... args);
-
-#include 
-
-#include "test_macros.h"
-
-struct S {
-protected:
-   S () {};  // ctor is protected
-};
-
-int main(int, char**) {
-typedef std::allocator A;
-A a;
-std::shared_ptr p = std::allocate_shared(a); // 
expected-error@memory:* {{static_assert failed due to requirement 
'is_constructible::value}}
-
-return 0;
-}

diff  --git 
a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.protected.verify.cpp
 
b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.protected.verify.cpp
deleted file mode 100644
index a2b6e9898245..
--- 
a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.protected.verify.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
-//===--===//
-//
-// 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
-//
-//===--===//
-
-// GCC 5 does not evaluate static assertions dependent on a template parameter.
-// UNSUPPORTED: gcc-5
-
-// 
-
-// shared_ptr
-
-// template shared_ptr make_shared(Args&&... args);
-
-#include 
-
-#include "test_macros.h"
-
-struct S {
-protected:
-   S () {};  // ctor is protected
-};
-
-int main(int, char**) {
-  std::shared_ptr p = std::make_shared(); // expected-error@memory:* 
{{static_assert failed due to requirement 'is_constructible::value}}
-
-  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] [libcxx] 3b7280f - [libc++] NFCI: Return pointer instead of reference from __shared_ptr_emplace helper method

2020-12-14 Thread Louis Dionne via llvm-branch-commits

Author: Louis Dionne
Date: 2020-12-14T17:46:09-05:00
New Revision: 3b7280f5e4aec935c7debf68e792c1aad2f7c5a7

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

LOG: [libc++] NFCI: Return pointer instead of reference from 
__shared_ptr_emplace helper method

This makes __get_alloc consistent with __get_elem, and will reduce the
diff required to implement P0674R1.

Added: 


Modified: 
libcxx/include/memory

Removed: 




diff  --git a/libcxx/include/memory b/libcxx/include/memory
index 24ad9e567b99..c676cd01c0f5 100644
--- a/libcxx/include/memory
+++ b/libcxx/include/memory
@@ -2594,7 +2594,7 @@ struct __shared_ptr_emplace
 _Tp* __get_elem() _NOEXCEPT { return _VSTD::addressof(__data_.second()); }
 
 _LIBCPP_HIDE_FROM_ABI
-_Alloc& __get_alloc() _NOEXCEPT { return __data_.first(); }
+_Alloc* __get_alloc() _NOEXCEPT { return 
_VSTD::addressof(__data_.first()); }
 
 private:
 virtual void __on_zero_shared() _NOEXCEPT {
@@ -2604,8 +2604,8 @@ private:
 virtual void __on_zero_shared_weak() _NOEXCEPT {
 using _ControlBlockAlloc = typename __allocator_traits_rebind<_Alloc, 
__shared_ptr_emplace>::type;
 using _ControlBlockPointer = typename 
allocator_traits<_ControlBlockAlloc>::pointer;
-_ControlBlockAlloc __tmp(__get_alloc());
-__get_alloc().~_Alloc();
+_ControlBlockAlloc __tmp(*__get_alloc());
+__get_alloc()->~_Alloc();
 allocator_traits<_ControlBlockAlloc>::deallocate(__tmp,
 pointer_traits<_ControlBlockPointer>::pointer_to(*this), 1);
 }



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] d399f87 - [VectorCombine] make load transform poison-safe

2020-12-14 Thread Sanjay Patel via llvm-branch-commits

Author: Sanjay Patel
Date: 2020-12-14T17:42:01-05:00
New Revision: d399f870b5a94b9dcc1817ed69fec88c325bb817

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

LOG: [VectorCombine] make load transform poison-safe

As noted in D93229, the transform from scalar load to vector load
potentially leaks poison from the extra vector elements that are
being loaded.

We could use freeze here (and x86 codegen at least appears to be
the same either way), but we already have a shuffle in this logic
to optionally change the vector size, so let's allow that
instruction to serve both purposes.

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

Added: 


Modified: 
llvm/lib/Transforms/Vectorize/VectorCombine.cpp
llvm/test/Transforms/VectorCombine/X86/load.ll

Removed: 




diff  --git a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp 
b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
index 19f5a2b432f7a..89b60045ce910 100644
--- a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
+++ b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
@@ -161,15 +161,17 @@ bool VectorCombine::vectorizeLoadInsert(Instruction ) {
   Value *CastedPtr = Builder.CreateBitCast(SrcPtr, MinVecTy->getPointerTo(AS));
   Value *VecLd = Builder.CreateAlignedLoad(MinVecTy, CastedPtr, Alignment);
 
-  // If the insert type does not match the target's minimum vector type,
-  // use an identity shuffle to shrink/grow the vector.
-  if (Ty != MinVecTy) {
-unsigned OutputNumElts = Ty->getNumElements();
-SmallVector Mask(OutputNumElts, UndefMaskElem);
-for (unsigned i = 0; i < OutputNumElts && i < MinVecNumElts; ++i)
-  Mask[i] = i;
-VecLd = Builder.CreateShuffleVector(VecLd, Mask);
-  }
+  // Set everything but element 0 to undef to prevent poison from propagating
+  // from the extra loaded memory. This will also optionally shrink/grow the
+  // vector from the loaded size to the output size.
+  // We assume this operation has no cost in codegen.
+  // Note that we could use freeze to avoid poison problems, but then we might
+  // still need a shuffle to change the vector size.
+  unsigned OutputNumElts = Ty->getNumElements();
+  SmallVector Mask(OutputNumElts, UndefMaskElem);
+  Mask[0] = 0;
+  VecLd = Builder.CreateShuffleVector(VecLd, Mask);
+
   replaceValue(I, *VecLd);
   ++NumVecLoad;
   return true;

diff  --git a/llvm/test/Transforms/VectorCombine/X86/load.ll 
b/llvm/test/Transforms/VectorCombine/X86/load.ll
index ba2bf3f37d7b6..03902c48157fe 100644
--- a/llvm/test/Transforms/VectorCombine/X86/load.ll
+++ b/llvm/test/Transforms/VectorCombine/X86/load.ll
@@ -175,7 +175,8 @@ define double @larger_fp_scalar_256bit_vec(<8 x float>* 
align 32 dereferenceable
 define <4 x float> @load_f32_insert_v4f32(float* align 16 dereferenceable(16) 
%p) {
 ; CHECK-LABEL: @load_f32_insert_v4f32(
 ; CHECK-NEXT:[[TMP1:%.*]] = bitcast float* [[P:%.*]] to <4 x float>*
-; CHECK-NEXT:[[R:%.*]] = load <4 x float>, <4 x float>* [[TMP1]], align 4
+; CHECK-NEXT:[[TMP2:%.*]] = load <4 x float>, <4 x float>* [[TMP1]], align 
4
+; CHECK-NEXT:[[R:%.*]] = shufflevector <4 x float> [[TMP2]], <4 x float> 
undef, <4 x i32> 
 ; CHECK-NEXT:ret <4 x float> [[R]]
 ;
   %s = load float, float* %p, align 4
@@ -185,7 +186,8 @@ define <4 x float> @load_f32_insert_v4f32(float* align 16 
dereferenceable(16) %p
 
 define <4 x float> @casted_load_f32_insert_v4f32(<4 x float>* align 4 
dereferenceable(16) %p) {
 ; CHECK-LABEL: @casted_load_f32_insert_v4f32(
-; CHECK-NEXT:[[R:%.*]] = load <4 x float>, <4 x float>* [[P:%.*]], align 4
+; CHECK-NEXT:[[TMP1:%.*]] = load <4 x float>, <4 x float>* [[P:%.*]], 
align 4
+; CHECK-NEXT:[[R:%.*]] = shufflevector <4 x float> [[TMP1]], <4 x float> 
undef, <4 x i32> 
 ; CHECK-NEXT:ret <4 x float> [[R]]
 ;
   %b = bitcast <4 x float>* %p to float*
@@ -199,7 +201,8 @@ define <4 x float> @casted_load_f32_insert_v4f32(<4 x 
float>* align 4 dereferenc
 define <4 x i32> @load_i32_insert_v4i32(i32* align 16 dereferenceable(16) %p) {
 ; CHECK-LABEL: @load_i32_insert_v4i32(
 ; CHECK-NEXT:[[TMP1:%.*]] = bitcast i32* [[P:%.*]] to <4 x i32>*
-; CHECK-NEXT:[[R:%.*]] = load <4 x i32>, <4 x i32>* [[TMP1]], align 4
+; CHECK-NEXT:[[TMP2:%.*]] = load <4 x i32>, <4 x i32>* [[TMP1]], align 4
+; CHECK-NEXT:[[R:%.*]] = shufflevector <4 x i32> [[TMP2]], <4 x i32> 
undef, <4 x i32> 
 ; CHECK-NEXT:ret <4 x i32> [[R]]
 ;
   %s = load i32, i32* %p, align 4
@@ -212,7 +215,8 @@ define <4 x i32> @load_i32_insert_v4i32(i32* align 16 
dereferenceable(16) %p) {
 define <4 x i32> @casted_load_i32_insert_v4i32(<16 x i8>* align 4 
dereferenceable(16) %p) {
 ; CHECK-LABEL: @casted_load_i32_insert_v4i32(
 ; CHECK-NEXT:[[TMP1:%.*]] = bitcast <16 x i8>* [[P:%.*]] to <4 x i32>*
-; 

[llvm-branch-commits] [lldb] d636b88 - Adapt lldb to a40db5502b2515a6f2f1676b5d7a655ae0f41179

2020-12-14 Thread Duncan P. N. Exon Smith via llvm-branch-commits

Author: Duncan P. N. Exon Smith
Date: 2020-12-14T14:41:15-08:00
New Revision: d636b881bb9214938973098a012fad453082c444

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

LOG: Adapt lldb to a40db5502b2515a6f2f1676b5d7a655ae0f41179

The bots just told me about a place in LLDB I missed in
a40db5502b2515a6f2f1676b5d7a655ae0f41179 when changing
`HeaderSearch::LoadedModuleMaps`, but I think this will fix it.

Added: 


Modified: 
lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp

Removed: 




diff  --git 
a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
index c014ad504d37..89cb9d52356a 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
@@ -278,10 +278,10 @@ bool ClangModulesDeclVendorImpl::AddModule(const 
SourceModule ,
   HS.getFileMgr().getDirectory(module.search_path.GetStringRef());
   if (!dir)
 return error();
-  auto *file = HS.lookupModuleMapFile(*dir, is_framework);
+  auto file = HS.lookupModuleMapFile(*dir, is_framework);
   if (!file)
 return error();
-  if (!HS.loadModuleMapFile(file, is_system))
+  if (!HS.loadModuleMapFile(*file, is_system))
 return error();
 }
   }



___
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] b61f288 - Add comment to closing brace of anonymous namespace, NFC

2020-12-14 Thread Duncan P. N. Exon Smith via llvm-branch-commits

Author: Duncan P. N. Exon Smith
Date: 2020-12-14T14:38:12-08:00
New Revision: b61f288a58e40430a739900ab74df61e711a2c55

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

LOG: Add comment to closing brace of anonymous namespace, NFC

Added: 


Modified: 
clang/unittests/Frontend/OutputStreamTest.cpp

Removed: 




diff  --git a/clang/unittests/Frontend/OutputStreamTest.cpp 
b/clang/unittests/Frontend/OutputStreamTest.cpp
index 6a867bf053cbd..5f23d782499b3 100644
--- a/clang/unittests/Frontend/OutputStreamTest.cpp
+++ b/clang/unittests/Frontend/OutputStreamTest.cpp
@@ -100,4 +100,5 @@ TEST(FrontendOutputTests, TestVerboseOutputStreamOwned) {
   EXPECT_TRUE(!VerboseBuffer.empty());
   EXPECT_TRUE(StringRef(VerboseBuffer.data()).contains("errors generated"));
 }
-}
+
+} // anonymous 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] [clang] 90d056c - AST: Silence an instance of -Wsign-compare, NFC

2020-12-14 Thread Duncan P. N. Exon Smith via llvm-branch-commits

Author: Duncan P. N. Exon Smith
Date: 2020-12-14T14:36:59-08:00
New Revision: 90d056ceb97d5e3242a37dfc1c9f6bf11af9a053

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

LOG: AST: Silence an instance of -Wsign-compare, NFC

Looks this this was added by 68f53960e17d93c3a2727164dac4e54140bd98ba.

Added: 


Modified: 
clang/unittests/AST/ASTImporterTest.cpp

Removed: 




diff  --git a/clang/unittests/AST/ASTImporterTest.cpp 
b/clang/unittests/AST/ASTImporterTest.cpp
index 40340cb6f9bc..de0705d3019b 100644
--- a/clang/unittests/AST/ASTImporterTest.cpp
+++ b/clang/unittests/AST/ASTImporterTest.cpp
@@ -6096,7 +6096,7 @@ TEST_P(ASTImporterOptionSpecificTestBase, 
TypedefWithAttribute) {
   FirstDeclMatcher().match(TU, typedefDecl(hasName("X")));
   auto *ToD = Import(FromD, Lang_CXX17);
   ASSERT_TRUE(ToD);
-  ASSERT_EQ(ToD->getAttrs().size(), 1);
+  ASSERT_EQ(ToD->getAttrs().size(), 1U);
   auto *ToAttr = dyn_cast(ToD->getAttrs()[0]);
   ASSERT_TRUE(ToAttr);
   EXPECT_EQ(ToAttr->getAnnotation(), "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] [clang] a40db55 - Lex: Migrate HeaderSearch::LoadedModuleMaps to FileEntryRef

2020-12-14 Thread Duncan P. N. Exon Smith via llvm-branch-commits

Author: Duncan P. N. Exon Smith
Date: 2020-12-14T14:35:11-08:00
New Revision: a40db5502b2515a6f2f1676b5d7a655ae0f41179

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

LOG: Lex: Migrate HeaderSearch::LoadedModuleMaps to FileEntryRef

Migrate `HeaderSearch::LoadedModuleMaps` and a number of APIs over to
`FileEntryRef`. This should have no functionality change. Note that two
`FileEntryRef`s hash the same if they point at the same `FileEntry`.

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

Added: 


Modified: 
clang-tools-extra/modularize/ModularizeUtilities.cpp
clang/include/clang/Lex/HeaderSearch.h
clang/include/clang/Lex/ModuleMap.h
clang/lib/Frontend/FrontendAction.cpp
clang/lib/Lex/HeaderSearch.cpp
clang/lib/Lex/ModuleMap.cpp

Removed: 




diff  --git a/clang-tools-extra/modularize/ModularizeUtilities.cpp 
b/clang-tools-extra/modularize/ModularizeUtilities.cpp
index 200370c135df..7470c324bbdb 100644
--- a/clang-tools-extra/modularize/ModularizeUtilities.cpp
+++ b/clang-tools-extra/modularize/ModularizeUtilities.cpp
@@ -258,22 +258,22 @@ std::error_code 
ModularizeUtilities::loadProblemHeaderList(
 std::error_code ModularizeUtilities::loadModuleMap(
 llvm::StringRef InputPath) {
   // Get file entry for module.modulemap file.
-  auto ModuleMapEntryOrErr =
-SourceMgr->getFileManager().getFile(InputPath);
+  auto ExpectedModuleMapEntry =
+SourceMgr->getFileManager().getFileRef(InputPath);
 
   // return error if not found.
-  if (!ModuleMapEntryOrErr) {
+  if (!ExpectedModuleMapEntry) {
 llvm::errs() << "error: File \"" << InputPath << "\" not found.\n";
-return ModuleMapEntryOrErr.getError();
+return errorToErrorCode(ExpectedModuleMapEntry.takeError());
   }
-  const FileEntry *ModuleMapEntry = *ModuleMapEntryOrErr;
+  FileEntryRef ModuleMapEntry = *ExpectedModuleMapEntry;
 
   // Because the module map parser uses a ForwardingDiagnosticConsumer,
   // which doesn't forward the BeginSourceFile call, we do it explicitly here.
   DC.BeginSourceFile(*LangOpts, nullptr);
 
   // Figure out the home directory for the module map file.
-  const DirectoryEntry *Dir = ModuleMapEntry->getDir();
+  const DirectoryEntry *Dir = ModuleMapEntry.getDir();
   StringRef DirName(Dir->getName());
   if (llvm::sys::path::filename(DirName) == "Modules") {
 DirName = llvm::sys::path::parent_path(DirName);

diff  --git a/clang/include/clang/Lex/HeaderSearch.h 
b/clang/include/clang/Lex/HeaderSearch.h
index 93d6ea72270a..8ea81226cf77 100644
--- a/clang/include/clang/Lex/HeaderSearch.h
+++ b/clang/include/clang/Lex/HeaderSearch.h
@@ -239,7 +239,7 @@ class HeaderSearch {
 
   /// Set of module map files we've already loaded, and a flag indicating
   /// whether they were valid or not.
-  llvm::DenseMap LoadedModuleMaps;
+  llvm::DenseMap LoadedModuleMaps;
 
   /// Uniqued set of framework names, which is used to track which
   /// headers were included as framework headers.
@@ -560,8 +560,8 @@ class HeaderSearch {
 
   /// Try to find a module map file in the given directory, returning
   /// \c nullptr if none is found.
-  const FileEntry *lookupModuleMapFile(const DirectoryEntry *Dir,
-   bool IsFramework);
+  Optional lookupModuleMapFile(const DirectoryEntry *Dir,
+ bool IsFramework);
 
   /// Determine whether there is a module map that may map the header
   /// with the given file name to a (sub)module.
@@ -603,8 +603,8 @@ class HeaderSearch {
   ///used to resolve paths within the module (this is required when
   ///building the module from preprocessed source).
   /// \returns true if an error occurred, false otherwise.
-  bool loadModuleMapFile(const FileEntry *File, bool IsSystem,
- FileID ID = FileID(), unsigned *Offset = nullptr,
+  bool loadModuleMapFile(FileEntryRef File, bool IsSystem, FileID ID = 
FileID(),
+ unsigned *Offset = nullptr,
  StringRef OriginalModuleMapFile = StringRef());
 
   /// Collect the set of all known, top-level modules.
@@ -794,8 +794,7 @@ class HeaderSearch {
 LMM_InvalidModuleMap
   };
 
-  LoadModuleMapResult loadModuleMapFileImpl(const FileEntry *File,
-bool IsSystem,
+  LoadModuleMapResult loadModuleMapFileImpl(FileEntryRef File, bool IsSystem,
 const DirectoryEntry *Dir,
 FileID ID = FileID(),
 unsigned *Offset = nullptr);

diff  --git a/clang/include/clang/Lex/ModuleMap.h 
b/clang/include/clang/Lex/ModuleMap.h
index 6827408f10a3..1d7ce5fc2320 100644
--- 

[llvm-branch-commits] [llvm] 700baa0 - [MC][ELF] Accept abbreviated form with sh_flags and sh_entsize

2020-12-14 Thread Tom Stellard via llvm-branch-commits

Author: Tobias Burnus
Date: 2020-12-14T17:31:14-05:00
New Revision: 700baa009dc685a0adc5f94d258be4ae24742471

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

LOG: [MC][ELF] Accept abbreviated form with sh_flags and sh_entsize

D73999 / commit 75af9da755721123e62b45cd0bc0c5e688a9722a
added for LLVM 11 a check that sh_flags and sh_entsize (and sh_type)
changes are an error, in line with GNU assembler.

However, GNU assembler accepts and GCC generates an abbreviated form:
while the first .section contains the flags and entsize, subsequent
sections simply contain the name without repeating entsize or flags.

Do likewise for better compatibility.

See https://bugs.llvm.org/show_bug.cgi?id=48201

Reviewed By: jhenderson, MaskRay

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

(cherry picked from commit 1deff4009e0ae661b03682901bf6932297ce7ea1)

Added: 
llvm/test/MC/ELF/section-omitted-attributes.s

Modified: 
llvm/lib/MC/MCParser/ELFAsmParser.cpp
llvm/test/MC/ELF/section-flags-changed.s

Removed: 




diff  --git a/llvm/lib/MC/MCParser/ELFAsmParser.cpp 
b/llvm/lib/MC/MCParser/ELFAsmParser.cpp
index e5ab13bc719d..fb8215ef2281 100644
--- a/llvm/lib/MC/MCParser/ELFAsmParser.cpp
+++ b/llvm/lib/MC/MCParser/ELFAsmParser.cpp
@@ -644,10 +644,13 @@ bool ELFAsmParser::ParseSectionArguments(bool IsPush, 
SMLoc loc) {
   !(SectionName == ".eh_frame" && Type == ELF::SHT_PROGBITS))
 Error(loc, "changed section type for " + SectionName + ", expected: 0x" +
utohexstr(Section->getType()));
-  if (Section->getFlags() != Flags)
+  // Check that flags are used consistently. However, the GNU assembler permits
+  // to leave out in subsequent uses of the same sections; for compatibility,
+  // do likewise.
+  if ((Flags || Size || !TypeName.empty()) && Section->getFlags() != Flags)
 Error(loc, "changed section flags for " + SectionName + ", expected: 0x" +
utohexstr(Section->getFlags()));
-  if (Section->getEntrySize() != Size)
+  if ((Flags || Size || !TypeName.empty()) && Section->getEntrySize() != Size)
 Error(loc, "changed section entsize for " + SectionName +
", expected: " + Twine(Section->getEntrySize()));
 

diff  --git a/llvm/test/MC/ELF/section-flags-changed.s 
b/llvm/test/MC/ELF/section-flags-changed.s
index 65f52cc29a6d..d2964ef046d1 100644
--- a/llvm/test/MC/ELF/section-flags-changed.s
+++ b/llvm/test/MC/ELF/section-flags-changed.s
@@ -9,4 +9,7 @@ foo:
 # CHECK: {{.*}}.s:[[# @LINE+1]]:1: error: changed section flags for .foo, 
expected: 0x6
 .pushsection .foo,"a",@progbits
 
+# CHECK: {{.*}}.s:[[# @LINE+1]]:1: error: changed section flags for .foo, 
expected: 0x6
+.section .foo,"",@progbits
+
 .pushsection .foo,"ax",@progbits

diff  --git a/llvm/test/MC/ELF/section-omitted-attributes.s 
b/llvm/test/MC/ELF/section-omitted-attributes.s
new file mode 100644
index ..72b7c9121387
--- /dev/null
+++ b/llvm/test/MC/ELF/section-omitted-attributes.s
@@ -0,0 +1,11 @@
+# RUN: llvm-mc -triple=x86_64 %s -o - | FileCheck %s
+
+# If section flags and other attributes are omitted, don't error.
+
+# CHECK: .section.foo,"aM",@progbits,1
+
+.section .foo,"aM",@progbits,1
+
+.section .foo
+
+.pushsection .foo



___
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] 25067f1 - [LoopIdiomRecognize] Teach detectShiftUntilZeroIdiom to recognize loops where the counter is decrementing.

2020-12-14 Thread Craig Topper via llvm-branch-commits

Author: Craig Topper
Date: 2020-12-14T14:25:05-08:00
New Revision: 25067f179f33ba1b764ac7a7d83385c8fd73801f

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

LOG: [LoopIdiomRecognize] Teach detectShiftUntilZeroIdiom to recognize loops 
where the counter is decrementing.

This adds support for loops like

unsigned clz(unsigned x) {
unsigned w = sizeof (x) * CHAR_BIT;
while (x) {
w--;
x >>= 1;
}

return w;
}

and

unsigned clz(unsigned x) {
unsigned w = sizeof (x) * CHAR_BIT - 1;
while (x >>= 1) {
w--;
}

return w;
}

To support these we look for add x, -1 as well as add x, 1 that
we already matched. If the value was -1 we need to subtract from
the initial counter value instead of adding to it.

Fixes PR48404.

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

Added: 


Modified: 
llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
llvm/test/Transforms/LoopIdiom/X86/ctlz.ll
llvm/test/Transforms/LoopIdiom/X86/cttz.ll

Removed: 




diff  --git a/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp 
b/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
index 7e69cc5beffe..15d1e8da5baa 100644
--- a/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
@@ -1475,6 +1475,7 @@ static bool detectShiftUntilZeroIdiom(Loop *CurLoop, 
const DataLayout ,
 return false;
 
   // step 4: Find the instruction which count the CTLZ: cnt.next = cnt + 1
+  // or cnt.next = cnt + -1.
   // TODO: We can skip the step. If loop trip count is known (CTLZ),
   //   then all uses of "cnt.next" could be optimized to the trip count
   //   plus "cnt0". Currently it is not optimized.
@@ -1488,7 +1489,7 @@ static bool detectShiftUntilZeroIdiom(Loop *CurLoop, 
const DataLayout ,
   continue;
 
 ConstantInt *Inc = dyn_cast(Inst->getOperand(1));
-if (!Inc || !Inc->isOne())
+if (!Inc || (!Inc->isOne() && !Inc->isMinusOne()))
   continue;
 
 PHINode *Phi = getRecurrenceVar(Inst->getOperand(0), Inst, LoopEntry);
@@ -1751,11 +1752,18 @@ void LoopIdiomRecognize::transformLoopToCountable(
   NewCount = Builder.CreateZExtOrTrunc(NewCount,
cast(CntInst->getType()));
 
-  // If the counter's initial value is not zero, insert Add Inst.
   Value *CntInitVal = CntPhi->getIncomingValueForBlock(Preheader);
-  ConstantInt *InitConst = dyn_cast(CntInitVal);
-  if (!InitConst || !InitConst->isZero())
-NewCount = Builder.CreateAdd(NewCount, CntInitVal);
+  if (cast(CntInst->getOperand(1))->isOne()) {
+// If the counter was being incremented in the loop, add NewCount to the
+// counter's initial value, but only if the initial value is not zero.
+ConstantInt *InitConst = dyn_cast(CntInitVal);
+if (!InitConst || !InitConst->isZero())
+  NewCount = Builder.CreateAdd(NewCount, CntInitVal);
+  } else {
+// If the count was being decremented in the loop, subtract NewCount from
+// the counter's initial value.
+NewCount = Builder.CreateSub(CntInitVal, NewCount);
+  }
 
   // Step 2: Insert new IV and loop condition:
   // loop:

diff  --git a/llvm/test/Transforms/LoopIdiom/X86/ctlz.ll 
b/llvm/test/Transforms/LoopIdiom/X86/ctlz.ll
index 6d3863a0ee33..4724adb030a4 100644
--- a/llvm/test/Transforms/LoopIdiom/X86/ctlz.ll
+++ b/llvm/test/Transforms/LoopIdiom/X86/ctlz.ll
@@ -693,16 +693,21 @@ define i32 @ctlz_decrement(i32 %n) {
 ; ALL-NEXT:[[TOBOOL4:%.*]] = icmp eq i32 [[N:%.*]], 0
 ; ALL-NEXT:br i1 [[TOBOOL4]], label [[WHILE_END:%.*]], label 
[[WHILE_BODY_PREHEADER:%.*]]
 ; ALL:   while.body.preheader:
+; ALL-NEXT:[[TMP0:%.*]] = call i32 @llvm.ctlz.i32(i32 [[N]], i1 true)
+; ALL-NEXT:[[TMP1:%.*]] = sub i32 32, [[TMP0]]
+; ALL-NEXT:[[TMP2:%.*]] = sub i32 32, [[TMP1]]
 ; ALL-NEXT:br label [[WHILE_BODY:%.*]]
 ; ALL:   while.body:
+; ALL-NEXT:[[TCPHI:%.*]] = phi i32 [ [[TMP1]], [[WHILE_BODY_PREHEADER]] ], 
[ [[TCDEC:%.*]], [[WHILE_BODY]] ]
 ; ALL-NEXT:[[I_06:%.*]] = phi i32 [ [[INC:%.*]], [[WHILE_BODY]] ], [ 32, 
[[WHILE_BODY_PREHEADER]] ]
 ; ALL-NEXT:[[N_ADDR_05:%.*]] = phi i32 [ [[SHR:%.*]], [[WHILE_BODY]] ], [ 
[[N]], [[WHILE_BODY_PREHEADER]] ]
 ; ALL-NEXT:[[SHR]] = lshr i32 [[N_ADDR_05]], 1
 ; ALL-NEXT:[[INC]] = add nsw i32 [[I_06]], -1
-; ALL-NEXT:[[TOBOOL:%.*]] = icmp eq i32 [[SHR]], 0
+; ALL-NEXT:[[TCDEC]] = sub nsw i32 [[TCPHI]], 1
+; ALL-NEXT:[[TOBOOL:%.*]] = icmp eq i32 [[TCDEC]], 0
 ; ALL-NEXT:br i1 [[TOBOOL]], label [[WHILE_END_LOOPEXIT:%.*]], label 
[[WHILE_BODY]]
 ; ALL:   while.end.loopexit:
-; ALL-NEXT:[[INC_LCSSA:%.*]] = phi i32 [ [[INC]], [[WHILE_BODY]] ]
+; ALL-NEXT:[[INC_LCSSA:%.*]] = phi i32 [ [[TMP2]], 

[llvm-branch-commits] [mlir] b3ee7f1 - [mlir][OpDefGen] Add support for generating local functions for shared utilities

2020-12-14 Thread River Riddle via llvm-branch-commits

Author: River Riddle
Date: 2020-12-14T14:21:30-08:00
New Revision: b3ee7f1f312dd41a0ac883d78b71c14d96e78939

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

LOG: [mlir][OpDefGen] Add support for generating local functions for shared 
utilities

This revision adds a new `StaticVerifierFunctionEmitter` class that emits local 
static functions in the .cpp file for shared operation verification. This class 
deduplicates shared operation verification code by emitting static functions 
alongside the op definitions. These methods are local to the definition file, 
and are invoked within the operation verify methods. The first bit of shared 
verification is for the type constraints used when verifying operands and 
results. An example is shown below:

```
static LogicalResult localVerify(...) {
  ...
}

LogicalResult OpA::verify(...) {
  if (failed(localVerify(...)))
return failure();
  ...
}

LogicalResult OpB::verify(...) {
  if (failed(localVerify(...)))
return failure();
  ...
}
```

This allowed for saving >400kb of code size from a downstream TensorFlow 
project (~15% of MLIR code size).

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

Added: 


Modified: 
mlir/include/mlir/TableGen/Constraint.h
mlir/test/mlir-tblgen/predicate.td
mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp

Removed: 




diff  --git a/mlir/include/mlir/TableGen/Constraint.h 
b/mlir/include/mlir/TableGen/Constraint.h
index 775b3545a034..e5ced0361c16 100644
--- a/mlir/include/mlir/TableGen/Constraint.h
+++ b/mlir/include/mlir/TableGen/Constraint.h
@@ -52,6 +52,13 @@ class Constraint {
 
   Kind getKind() const { return kind; }
 
+  /// Get an opaque pointer to the constraint.
+  const void *getAsOpaquePointer() const { return def; }
+  /// Construct a constraint from the opaque pointer representation.
+  static Constraint getFromOpaquePointer(const void *ptr) {
+return Constraint(reinterpret_cast(ptr));
+  }
+
 protected:
   Constraint(Kind kind, const llvm::Record *record);
 

diff  --git a/mlir/test/mlir-tblgen/predicate.td 
b/mlir/test/mlir-tblgen/predicate.td
index e5d4ac853b50..386c61319b79 100644
--- a/mlir/test/mlir-tblgen/predicate.td
+++ b/mlir/test/mlir-tblgen/predicate.td
@@ -15,10 +15,22 @@ def OpA : 
NS_Op<"op_for_CPred_containing_multiple_same_placeholder", []> {
   let arguments = (ins I32OrF32:$x);
 }
 
+// CHECK: static ::mlir::LogicalResult 
[[$INTEGER_FLOAT_CONSTRAINT:__mlir_ods_local_type_constraint.*]](
+// CHECK:  if (!((type.isInteger(32) || type.isF32( {
+// CHECK:return op->emitOpError(valueKind) << " #" << valueGroupStartIndex 
<< " must be 32-bit integer or floating-point type, but got " << type;
+
+// CHECK: static ::mlir::LogicalResult 
[[$TENSOR_CONSTRAINT:__mlir_ods_local_type_constraint.*]](
+// CHECK:  if (!(((type.isa<::mlir::TensorType>())) && ((true {
+// CHECK:return op->emitOpError(valueKind) << " #" << valueGroupStartIndex 
<< " must be tensor of any type values, but got " << type;
+
+// CHECK: static ::mlir::LogicalResult 
[[$TENSOR_INTEGER_FLOAT_CONSTRAINT:__mlir_ods_local_type_constraint.*]](
+// CHECK:  if (!(((type.isa<::mlir::TensorType>())) && 
(((type.cast<::mlir::ShapedType>().getElementType().isF32())) || 
((type.cast<::mlir::ShapedType>().getElementType().isSignlessInteger(32)) {
+// CHECK:return op->emitOpError(valueKind) << " #" << valueGroupStartIndex 
<< " must be tensor of 32-bit float or 32-bit signless integer values, but got 
" << type;
+
 // CHECK-LABEL: OpA::verify
 // CHECK: auto valueGroup0 = getODSOperands(0);
 // CHECK: for (::mlir::Value v : valueGroup0) {
-// CHECK:   if (!((v.getType().isInteger(32) || v.getType().isF32(
+// CHECK:   if (::mlir::failed([[$INTEGER_FLOAT_CONSTRAINT]]
 
 def OpB : NS_Op<"op_for_And_PredOpTrait", [
 PredOpTrait<"both first and second holds",
@@ -93,4 +105,4 @@ def OpK : NS_Op<"op_for_AnyTensorOf", []> {
 // CHECK-LABEL: OpK::verify
 // CHECK: auto valueGroup0 = getODSOperands(0);
 // CHECK: for (::mlir::Value v : valueGroup0) {
-// CHECK: if (!(((v.getType().isa<::mlir::TensorType>())) && 
(((v.getType().cast<::mlir::ShapedType>().getElementType().isF32())) || 
((v.getType().cast<::mlir::ShapedType>().getElementType().isSignlessInteger(32))
+// CHECK: if (::mlir::failed([[$TENSOR_INTEGER_FLOAT_CONSTRAINT]]

diff  --git a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp 
b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
index f2a57fbbb00f..9a4ddbffac43 100644
--- a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
+++ b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
@@ -117,6 +117,144 @@ static const char *const opCommentHeader = R"(
 
 )";
 
+//===--===//
+// StaticVerifierFunctionEmitter

[llvm-branch-commits] [clang] 861b2a2 - [KernelAddressSanitizer] Fix globals exclusion for indirect aliases

2020-12-14 Thread Tom Stellard via llvm-branch-commits

Author: Marco Elver
Date: 2020-12-14T17:14:40-05:00
New Revision: 861b2a24bc49f8ad801df5035347d7073eaafee5

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

LOG: [KernelAddressSanitizer] Fix globals exclusion for indirect aliases

GlobalAlias::getAliasee() may not always point directly to a
GlobalVariable. In such cases, try to find the canonical GlobalVariable
that the alias refers to.

Link: https://github.com/ClangBuiltLinux/linux/issues/1208

Reviewed By: dvyukov, nickdesaulniers

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

(cherry picked from commit c28b18af19621e6b5cca257ef7139ba93833df0c)

Added: 


Modified: 
clang/test/CodeGen/asan-globals-alias.cpp
llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp

Removed: 




diff  --git a/clang/test/CodeGen/asan-globals-alias.cpp 
b/clang/test/CodeGen/asan-globals-alias.cpp
index faf160ac79c9..c859d2f2b44a 100644
--- a/clang/test/CodeGen/asan-globals-alias.cpp
+++ b/clang/test/CodeGen/asan-globals-alias.cpp
@@ -1,17 +1,42 @@
 // RUN: %clang_cc1 -triple x86_64-linux -fsanitize=address -emit-llvm -o - %s 
| FileCheck %s --check-prefixes=CHECK,ASAN
+// RUN: %clang_cc1 -triple x86_64-linux -O2 -fsanitize=address -emit-llvm -o - 
%s | FileCheck %s --check-prefixes=CHECK,ASAN
 // RUN: %clang_cc1 -triple x86_64-linux -fsanitize=kernel-address -emit-llvm 
-o - %s | FileCheck %s --check-prefixes=CHECK,KASAN
+// RUN: %clang_cc1 -triple x86_64-linux -O2 -fsanitize=kernel-address 
-emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,KASAN
 //
 // Not all platforms support aliases - test for Linux only.
 
-int global; // to 
generate ctor for at least 1 global
-int aliased_global; // KASAN - 
ignore globals prefixed by aliases with __-prefix (below)
-extern int __attribute__((alias("aliased_global"))) __global_alias; // KASAN - 
aliased_global ignored
+int global; // generate ctor for at least 1 global
+int aliased_global; // KASAN ignored
+extern int __attribute__((alias("aliased_global"))) __global_alias;
+
+// Recursive alias:
+int aliased_global_2; // KASAN ignored
+extern int __attribute__((alias("aliased_global_2"))) global_alias_2;
+extern int __attribute__((alias("global_alias_2"))) __global_alias_2_alias;
+
+// Potential indirect alias:
+struct input_device_id {
+  unsigned long keybit[24];
+  unsigned long driver_info;
+};
+struct input_device_id joydev_ids[] = { { {1}, 1234 } }; // KASAN ignored
+extern struct input_device_id __attribute__((alias("joydev_ids"))) 
__mod_joydev_ids_device_table;
 
 // ASAN: @aliased_global{{.*}} global { i32, [60 x i8] }{{.*}}, align 32
+// ASAN: @aliased_global_2{{.*}} global { i32, [60 x i8] }{{.*}}, align 32
+// ASAN: @joydev_ids{{.*}} global { {{.*}}[56 x i8] zeroinitializer }, align 32
 // KASAN: @aliased_global{{.*}} global i32
+// KASAN: @aliased_global_2{{.*}} global i32
+// KASAN: @joydev_ids{{.*}} global [1 x {{.*}}i64 1234 }], align 16
+
+// Check the aliases exist:
+// CHECK: @__global_alias = alias
+// CHECK: @global_alias_2 = alias
+// CHECK: @__global_alias_2_alias = alias
+// CHECK: @__mod_joydev_ids_device_table = alias
 
 // CHECK-LABEL: define internal void @asan.module_ctor
-// ASAN: call void @__asan_register_globals({{.*}}, i{{32|64}} 2)
+// ASAN: call void @__asan_register_globals({{.*}}, i{{32|64}} 4)
 // KASAN: call void @__asan_register_globals({{.*}}, i{{32|64}} 1)
 // CHECK-NEXT: ret void
 

diff  --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp 
b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
index ee09a4d9db7e..1557fad4d372 100644
--- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -792,7 +792,7 @@ class ModuleAddressSanitizer {
   StringRef InternalSuffix);
   Instruction *CreateAsanModuleDtor(Module );
 
-  bool canInstrumentAliasedGlobal(const GlobalAlias ) const;
+  const GlobalVariable *getExcludedAliasedGlobal(const GlobalAlias ) const;
   bool shouldInstrumentGlobal(GlobalVariable *G) const;
   bool ShouldUseMachOGlobalsSection() const;
   StringRef getGlobalMetadataSection() const;
@@ -1784,20 +1784,22 @@ void 
ModuleAddressSanitizer::createInitializerPoisonCalls(
   }
 }
 
-bool ModuleAddressSanitizer::canInstrumentAliasedGlobal(
-const GlobalAlias ) const {
+const GlobalVariable *
+ModuleAddressSanitizer::getExcludedAliasedGlobal(const GlobalAlias ) const {
   // In case this function should be expanded to include rules that do not just
   // apply when CompileKernel is true, either guard all existing rules with an
   // 'if (CompileKernel) { ... }' or be absolutely sure that all these rules
   

[llvm-branch-commits] [libcxx] 19d57b5 - [libc++] Refactor allocate_shared to use an allocation guard

2020-12-14 Thread Louis Dionne via llvm-branch-commits

Author: Louis Dionne
Date: 2020-12-14T17:10:05-05:00
New Revision: 19d57b5c42b4e80fcbd5b6a2167e4a5f4f7b64c3

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

LOG: [libc++] Refactor allocate_shared to use an allocation guard

This commit is a step towards making it easier to add support for arrays
in allocate_shared. Adding support for arrays will require writing multiple
functions, and the current complexity of writing allocate_shared is
prohibitive for understanding.

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

Added: 
libcxx/include/__memory/utilities.h

Modified: 
libcxx/include/CMakeLists.txt
libcxx/include/memory

Removed: 




diff  --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index 71361a9e53df..cd12f60a049c 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -14,6 +14,7 @@ set(files
   __memory/allocator_traits.h
   __memory/base.h
   __memory/pointer_traits.h
+  __memory/utilities.h
   __mutex_base
   __node_handle
   __nullptr

diff  --git a/libcxx/include/__memory/utilities.h 
b/libcxx/include/__memory/utilities.h
new file mode 100644
index ..ccbfbe78966c
--- /dev/null
+++ b/libcxx/include/__memory/utilities.h
@@ -0,0 +1,87 @@
+// -*- 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
+//
+//===--===//
+
+#ifndef _LIBCPP___MEMORY_UTILITIES_H
+#define _LIBCPP___MEMORY_UTILITIES_H
+
+#include <__config>
+#include <__memory/allocator_traits.h>
+#include 
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// Helper class to allocate memory using an Allocator in an exception safe
+// manner.
+//
+// The intended usage of this class is as follows:
+//
+// 0
+// 1 __allocation_guard guard(alloc, 10);
+// 2 do_some_initialization_that_may_throw(guard.__get());
+// 3 save_allocated_pointer_in_a_noexcept_operation(guard.__release_ptr());
+// 4
+//
+// If line (2) throws an exception during initialization of the memory, the
+// guard's destructor will be called, and the memory will be released using
+// Allocator deallocation. Otherwise, we release the memory from the guard on
+// line (3) in an operation that can't throw -- after that, the guard is not
+// responsible for the memory anymore.
+//
+// This is similar to a unique_ptr, except it's easier to use with a
+// custom allocator.
+template
+struct __allocation_guard {
+using _Pointer = typename allocator_traits<_Alloc>::pointer;
+using _Size = typename allocator_traits<_Alloc>::size_type;
+
+_LIBCPP_HIDE_FROM_ABI
+explicit __allocation_guard(_Alloc __alloc, _Size __n)
+: __alloc_(_VSTD::move(__alloc))
+, __n_(__n)
+, __ptr_(allocator_traits<_Alloc>::allocate(__alloc_, __n_)) // 
initialization order is important
+{ }
+
+_LIBCPP_HIDE_FROM_ABI
+~__allocation_guard() _NOEXCEPT {
+if (__ptr_ != nullptr) {
+allocator_traits<_Alloc>::deallocate(__alloc_, __ptr_, __n_);
+}
+}
+
+_LIBCPP_HIDE_FROM_ABI
+_Pointer __release_ptr() _NOEXCEPT { // not called __release() because 
it's a keyword in objective-c++
+_Pointer __tmp = __ptr_;
+__ptr_ = nullptr;
+return __tmp;
+}
+
+_LIBCPP_HIDE_FROM_ABI
+_Pointer __get() const _NOEXCEPT {
+return __ptr_;
+}
+
+private:
+_Alloc __alloc_;
+_Size __n_;
+_Pointer __ptr_;
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif  // _LIBCPP___MEMORY_UTILITIES_H

diff  --git a/libcxx/include/memory b/libcxx/include/memory
index f81ff6680f9f..24ad9e567b99 100644
--- a/libcxx/include/memory
+++ b/libcxx/include/memory
@@ -682,6 +682,7 @@ void* align(size_t alignment, size_t size, void*& ptr, 
size_t& space);
 #include <__memory/allocator_traits.h>
 #include <__memory/base.h>
 #include <__memory/pointer_traits.h>
+#include <__memory/utilities.h>
 #if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
 #  include 
 #endif
@@ -3299,28 +3300,21 @@ shared_ptr<_Tp>::reset(_Yp* __p, _Dp __d, _Alloc __a)
 shared_ptr(__p, __d, __a).swap(*this);
 }
 
-template
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
-!is_array<_Tp>::value,
-shared_ptr<_Tp>
->::type
-allocate_shared(const _Alloc& __a, _Args&& ...__args)
+//
+// std::allocate_shared and std::make_shared
+//
+template::value> >
+_LIBCPP_HIDE_FROM_ABI

[llvm-branch-commits] [llvm] 934376d - [NFC][InstCombine] Add test coverage for @llvm.uadd.sat canonicalization

2020-12-14 Thread Tom Stellard via llvm-branch-commits

Author: Roman Lebedev
Date: 2020-12-14T17:08:57-05:00
New Revision: 934376da585156885eca2f38f021367a4981d981

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

LOG: [NFC][InstCombine] Add test coverage for @llvm.uadd.sat canonicalization

The non-strict variants are already handled because they are canonicalized
to strict variants by swapping hands in both the select and icmp,
and the fold simply considers that strictness is irrelevant here.

But that isn't actually true for the last pattern, as PR48390 reports.

(cherry picked from commit f16320b90b8381f2e3aac1ec17f39eff06f09ea0)

Added: 


Modified: 
llvm/test/Transforms/InstCombine/saturating-add-sub.ll

Removed: 




diff  --git a/llvm/test/Transforms/InstCombine/saturating-add-sub.ll 
b/llvm/test/Transforms/InstCombine/saturating-add-sub.ll
index 7306bd42020e..3edafa17880b 100644
--- a/llvm/test/Transforms/InstCombine/saturating-add-sub.ll
+++ b/llvm/test/Transforms/InstCombine/saturating-add-sub.ll
@@ -1211,6 +1211,17 @@ define i32 @uadd_sat(i32 %x, i32 %y) {
   %r = select i1 %c, i32 -1, i32 %a
   ret i32 %r
 }
+define i32 @uadd_sat_nonstrict(i32 %x, i32 %y) {
+; CHECK-LABEL: @uadd_sat_nonstrict(
+; CHECK-NEXT:[[TMP1:%.*]] = call i32 @llvm.uadd.sat.i32(i32 [[X:%.*]], i32 
[[Y:%.*]])
+; CHECK-NEXT:ret i32 [[TMP1]]
+;
+  %notx = xor i32 %x, -1
+  %a = add i32 %y, %x
+  %c = icmp ule i32 %notx, %y
+  %r = select i1 %c, i32 -1, i32 %a
+  ret i32 %r
+}
 
 define i32 @uadd_sat_commute_add(i32 %xp, i32 %y) {
 ; CHECK-LABEL: @uadd_sat_commute_add(
@@ -1239,6 +1250,19 @@ define i32 @uadd_sat_ugt(i32 %x, i32 %yp) {
   %r = select i1 %c, i32 -1, i32 %a
   ret i32 %r
 }
+define i32 @uadd_sat_uge(i32 %x, i32 %yp) {
+; CHECK-LABEL: @uadd_sat_uge(
+; CHECK-NEXT:[[Y:%.*]] = sdiv i32 [[YP:%.*]], 2442
+; CHECK-NEXT:[[TMP1:%.*]] = call i32 @llvm.uadd.sat.i32(i32 [[X:%.*]], i32 
[[Y]])
+; CHECK-NEXT:ret i32 [[TMP1]]
+;
+  %y = sdiv i32 %yp, 2442 ; thwart complexity-based-canonicalization
+  %notx = xor i32 %x, -1
+  %a = add i32 %y, %x
+  %c = icmp uge i32 %y, %notx
+  %r = select i1 %c, i32 -1, i32 %a
+  ret i32 %r
+}
 
 define <2 x i32> @uadd_sat_ugt_commute_add(<2 x i32> %xp, <2 x i32> %yp) {
 ; CHECK-LABEL: @uadd_sat_ugt_commute_add(
@@ -1270,6 +1294,20 @@ define i32 @uadd_sat_commute_select(i32 %x, i32 %yp) {
   ret i32 %r
 }
 
+define i32 @uadd_sat_commute_select_nonstrict(i32 %x, i32 %yp) {
+; CHECK-LABEL: @uadd_sat_commute_select_nonstrict(
+; CHECK-NEXT:[[Y:%.*]] = sdiv i32 [[YP:%.*]], 2442
+; CHECK-NEXT:[[TMP1:%.*]] = call i32 @llvm.uadd.sat.i32(i32 [[X:%.*]], i32 
[[Y]])
+; CHECK-NEXT:ret i32 [[TMP1]]
+;
+  %y = sdiv i32 %yp, 2442 ; thwart complexity-based-canonicalization
+  %notx = xor i32 %x, -1
+  %a = add i32 %y, %x
+  %c = icmp ule i32 %y, %notx
+  %r = select i1 %c, i32 %a, i32 -1
+  ret i32 %r
+}
+
 define i32 @uadd_sat_commute_select_commute_add(i32 %xp, i32 %yp) {
 ; CHECK-LABEL: @uadd_sat_commute_select_commute_add(
 ; CHECK-NEXT:[[X:%.*]] = urem i32 42, [[XP:%.*]]
@@ -1357,6 +1395,19 @@ define i32 @uadd_sat_not(i32 %x, i32 %y) {
   ret i32 %r
 }
 
+define i32 @uadd_sat_not_nonstrict(i32 %x, i32 %y) {
+; CHECK-LABEL: @uadd_sat_not_nonstrict(
+; CHECK-NEXT:[[NOTX:%.*]] = xor i32 [[X:%.*]], -1
+; CHECK-NEXT:[[TMP1:%.*]] = call i32 @llvm.uadd.sat.i32(i32 [[NOTX]], i32 
[[Y:%.*]])
+; CHECK-NEXT:ret i32 [[TMP1]]
+;
+  %notx = xor i32 %x, -1
+  %a = add i32 %notx, %y
+  %c = icmp ule i32 %x, %y
+  %r = select i1 %c, i32 -1, i32 %a
+  ret i32 %r
+}
+
 define i32 @uadd_sat_not_commute_add(i32 %xp, i32 %yp) {
 ; CHECK-LABEL: @uadd_sat_not_commute_add(
 ; CHECK-NEXT:[[X:%.*]] = srem i32 42, [[XP:%.*]]
@@ -1387,6 +1438,19 @@ define i32 @uadd_sat_not_ugt(i32 %x, i32 %y) {
   ret i32 %r
 }
 
+define i32 @uadd_sat_not_uge(i32 %x, i32 %y) {
+; CHECK-LABEL: @uadd_sat_not_uge(
+; CHECK-NEXT:[[NOTX:%.*]] = xor i32 [[X:%.*]], -1
+; CHECK-NEXT:[[TMP1:%.*]] = call i32 @llvm.uadd.sat.i32(i32 [[NOTX]], i32 
[[Y:%.*]])
+; CHECK-NEXT:ret i32 [[TMP1]]
+;
+  %notx = xor i32 %x, -1
+  %a = add i32 %notx, %y
+  %c = icmp uge i32 %y, %x
+  %r = select i1 %c, i32 -1, i32 %a
+  ret i32 %r
+}
+
 define <2 x i32> @uadd_sat_not_ugt_commute_add(<2 x i32> %x, <2 x i32> %yp) {
 ; CHECK-LABEL: @uadd_sat_not_ugt_commute_add(
 ; CHECK-NEXT:[[Y:%.*]] = sdiv <2 x i32> [[YP:%.*]], 
@@ -1415,6 +1479,19 @@ define i32 @uadd_sat_not_commute_select(i32 %x, i32 %y) {
   ret i32 %r
 }
 
+define i32 @uadd_sat_not_commute_select_nonstrict(i32 %x, i32 %y) {
+; CHECK-LABEL: @uadd_sat_not_commute_select_nonstrict(
+; CHECK-NEXT:[[NOTX:%.*]] = xor i32 [[X:%.*]], -1
+; CHECK-NEXT:[[TMP1:%.*]] = call i32 @llvm.uadd.sat.i32(i32 [[NOTX]], i32 
[[Y:%.*]])
+; CHECK-NEXT:ret i32 [[TMP1]]
+;
+  %notx = 

[llvm-branch-commits] [llvm] 8511a8d - [InstCombine] canonicalizeSaturatedAdd(): last fold is only valid for strict comparison (PR48390)

2020-12-14 Thread Tom Stellard via llvm-branch-commits

Author: Roman Lebedev
Date: 2020-12-14T17:08:57-05:00
New Revision: 8511a8df838f8b2766e56c22af4992d9862835fc

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

LOG: [InstCombine] canonicalizeSaturatedAdd(): last fold is only valid for 
strict comparison (PR48390)

We could create uadd.sat under incorrect circumstances
if a select with -1 as the false value was canonicalized
by swapping the T/F values. Unlike the other transforms
in the same function, it is not invariant to equality.

Some alive proofs: https://alive2.llvm.org/ce/z/emmKKL

Based on original patch by David Green!

Fixes https://bugs.llvm.org/show_bug.cgi?id=48390

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

(cherry picked from commit e6f2a79d7aa01f8dd7f0194f97a50b480e8ede71)

Added: 


Modified: 
llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
llvm/test/Transforms/InstCombine/saturating-add-sub.ll

Removed: 




diff  --git a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp 
b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
index fa695c39cd1e..1e43014e7d32 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
@@ -782,25 +782,24 @@ static Value *canonicalizeSaturatedAdd(ICmpInst *Cmp, 
Value *TVal, Value *FVal,
 
   // Match unsigned saturated add of 2 variables with an unnecessary 'not'.
   // There are 8 commuted variants.
-  // Canonicalize -1 (saturated result) to true value of the select. Just
-  // swapping the compare operands is legal, because the selected value is the
-  // same in case of equality, so we can interchange u< and u<=.
+  // Canonicalize -1 (saturated result) to true value of the select.
   if (match(FVal, m_AllOnes())) {
 std::swap(TVal, FVal);
-std::swap(Cmp0, Cmp1);
+Pred = CmpInst::getInversePredicate(Pred);
   }
   if (!match(TVal, m_AllOnes()))
 return nullptr;
 
-  // Canonicalize predicate to 'ULT'.
-  if (Pred == ICmpInst::ICMP_UGT) {
-Pred = ICmpInst::ICMP_ULT;
+  // Canonicalize predicate to less-than or less-or-equal-than.
+  if (Pred == ICmpInst::ICMP_UGT || Pred == ICmpInst::ICMP_UGE) {
 std::swap(Cmp0, Cmp1);
+Pred = CmpInst::getSwappedPredicate(Pred);
   }
-  if (Pred != ICmpInst::ICMP_ULT)
+  if (Pred != ICmpInst::ICMP_ULT && Pred != ICmpInst::ICMP_ULE)
 return nullptr;
 
   // Match unsigned saturated add of 2 variables with an unnecessary 'not'.
+  // Strictness of the comparison is irrelevant.
   Value *Y;
   if (match(Cmp0, m_Not(m_Value(X))) &&
   match(FVal, m_c_Add(m_Specific(X), m_Value(Y))) && Y == Cmp1) {
@@ -809,6 +808,7 @@ static Value *canonicalizeSaturatedAdd(ICmpInst *Cmp, Value 
*TVal, Value *FVal,
 return Builder.CreateBinaryIntrinsic(Intrinsic::uadd_sat, X, Y);
   }
   // The 'not' op may be included in the sum but not the compare.
+  // Strictness of the comparison is irrelevant.
   X = Cmp0;
   Y = Cmp1;
   if (match(FVal, m_c_Add(m_Not(m_Specific(X)), m_Specific(Y {
@@ -819,7 +819,9 @@ static Value *canonicalizeSaturatedAdd(ICmpInst *Cmp, Value 
*TVal, Value *FVal,
 Intrinsic::uadd_sat, BO->getOperand(0), BO->getOperand(1));
   }
   // The overflow may be detected via the add wrapping round.
-  if (match(Cmp0, m_c_Add(m_Specific(Cmp1), m_Value(Y))) &&
+  // This is only valid for strict comparison!
+  if (Pred == ICmpInst::ICMP_ULT &&
+  match(Cmp0, m_c_Add(m_Specific(Cmp1), m_Value(Y))) &&
   match(FVal, m_c_Add(m_Specific(Cmp1), m_Specific(Y {
 // ((X + Y) u< X) ? -1 : (X + Y) --> uadd.sat(X, Y)
 // ((X + Y) u< Y) ? -1 : (X + Y) --> uadd.sat(X, Y)

diff  --git a/llvm/test/Transforms/InstCombine/saturating-add-sub.ll 
b/llvm/test/Transforms/InstCombine/saturating-add-sub.ll
index 3edafa17880b..ca45eb5bf429 100644
--- a/llvm/test/Transforms/InstCombine/saturating-add-sub.ll
+++ b/llvm/test/Transforms/InstCombine/saturating-add-sub.ll
@@ -1804,8 +1804,10 @@ define i32 @uadd_sat_via_add(i32 %x, i32 %y) {
 
 define i32 @uadd_sat_via_add_nonstrict(i32 %x, i32 %y) {
 ; CHECK-LABEL: @uadd_sat_via_add_nonstrict(
-; CHECK-NEXT:[[TMP1:%.*]] = call i32 @llvm.uadd.sat.i32(i32 [[Y:%.*]], i32 
[[X:%.*]])
-; CHECK-NEXT:ret i32 [[TMP1]]
+; CHECK-NEXT:[[A:%.*]] = add i32 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT:[[C_NOT:%.*]] = icmp ugt i32 [[A]], [[Y]]
+; CHECK-NEXT:[[R:%.*]] = select i1 [[C_NOT]], i32 [[A]], i32 -1
+; CHECK-NEXT:ret i32 [[R]]
 ;
   %a = add i32 %x, %y
   %c = icmp ule i32 %a, %y
@@ -1826,8 +1828,10 @@ define i32 @uadd_sat_via_add_swapped_select(i32 %x, i32 
%y) {
 
 define i32 @uadd_sat_via_add_swapped_select_strict(i32 %x, i32 %y) {
 ; CHECK-LABEL: @uadd_sat_via_add_swapped_select_strict(
-; CHECK-NEXT:[[TMP1:%.*]] = call i32 @llvm.uadd.sat.i32(i32 

[llvm-branch-commits] [clang] a29ecca - Revert "[DDG] Data Dependence Graph - DOT printer"

2020-12-14 Thread Bardia Mahjour via llvm-branch-commits

Author: Bardia Mahjour
Date: 2020-12-14T16:54:20-05:00
New Revision: a29ecca7819a6ed4250d3689b12b1f664bb790d7

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

LOG: Revert "[DDG] Data Dependence Graph - DOT printer"

This reverts commit fd4a10732c8bd646ccc621c0a9af512be252f33a, to
investigate the failure on windows: 
http://lab.llvm.org:8011/#/builders/127/builds/3274

Added: 


Modified: 
clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
llvm/include/llvm/Analysis/CFGPrinter.h
llvm/include/llvm/Analysis/DDG.h
llvm/include/llvm/Support/DOTGraphTraits.h
llvm/include/llvm/Support/GraphWriter.h
llvm/lib/Analysis/CFGPrinter.cpp
llvm/lib/Analysis/CMakeLists.txt
llvm/lib/Analysis/CallPrinter.cpp
llvm/lib/CodeGen/MachineScheduler.cpp
llvm/lib/CodeGen/ScheduleDAGPrinter.cpp
llvm/lib/Passes/PassBuilder.cpp
llvm/lib/Passes/PassRegistry.def

Removed: 
llvm/include/llvm/Analysis/DDGPrinter.h
llvm/lib/Analysis/DDGPrinter.cpp



diff  --git a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp 
b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
index f285b652c175..409741cdb6e4 100644
--- a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -3149,7 +3149,7 @@ struct DOTGraphTraits : public 
DefaultDOTGraphTraits {
   if (Stop(N))
 return true;
 
-  if (N->succ_size() != 1 || !isNodeHidden(N->getFirstSucc(), nullptr))
+  if (N->succ_size() != 1 || !isNodeHidden(N->getFirstSucc()))
 break;
   PostCallback(N);
 
@@ -3158,7 +3158,7 @@ struct DOTGraphTraits : public 
DefaultDOTGraphTraits {
 return false;
   }
 
-  static bool isNodeHidden(const ExplodedNode *N, const ExplodedGraph *G) {
+  static bool isNodeHidden(const ExplodedNode *N) {
 return N->isTrivial();
   }
 

diff  --git a/llvm/include/llvm/Analysis/CFGPrinter.h 
b/llvm/include/llvm/Analysis/CFGPrinter.h
index 53700798b6b3..bc6a19f2e2b9 100644
--- a/llvm/include/llvm/Analysis/CFGPrinter.h
+++ b/llvm/include/llvm/Analysis/CFGPrinter.h
@@ -295,7 +295,7 @@ struct DOTGraphTraits : public 
DefaultDOTGraphTraits {
 " fillcolor=\"" + Color + "70\"";
 return Attrs;
   }
-  bool isNodeHidden(const BasicBlock *Node, const DOTFuncInfo *CFGInfo);
+  bool isNodeHidden(const BasicBlock *Node);
   void computeHiddenNodes(const Function *F);
 };
 } // End llvm namespace

diff  --git a/llvm/include/llvm/Analysis/DDG.h 
b/llvm/include/llvm/Analysis/DDG.h
index 8d225c155cd4..9e2b7907eaec 100644
--- a/llvm/include/llvm/Analysis/DDG.h
+++ b/llvm/include/llvm/Analysis/DDG.h
@@ -290,12 +290,6 @@ template  class DependenceGraphInfo {
   bool getDependencies(const NodeType , const NodeType ,
DependenceList ) const;
 
-  /// Return a string representing the type of dependence that the dependence
-  /// analysis identified between the two given nodes. This function assumes
-  /// that there is a memory dependence between the given two nodes.
-  const std::string getDependenceString(const NodeType ,
-const NodeType ) const;
-
 protected:
   // Name of the graph.
   std::string Name;
@@ -469,26 +463,6 @@ bool DependenceGraphInfo::getDependencies(
   return !Deps.empty();
 }
 
-template 
-const std::string
-DependenceGraphInfo::getDependenceString(const NodeType ,
-   const NodeType ) const {
-  std::string Str;
-  raw_string_ostream OS(Str);
-  DependenceList Deps;
-  if (!getDependencies(Src, Dst, Deps))
-return OS.str();
-  interleaveComma(Deps, OS, [&](const std::unique_ptr ) {
-D->dump(OS);
-// Remove the extra new-line character printed by the dump
-// method
-if (OS.str().back() == '\n')
-  OS.str().pop_back();
-  });
-
-  return OS.str();
-}
-
 //======//
 // GraphTraits specializations for the DDG
 //======//

diff  --git a/llvm/include/llvm/Analysis/DDGPrinter.h 
b/llvm/include/llvm/Analysis/DDGPrinter.h
deleted file mode 100644
index 5cfe2ce33c99..
--- a/llvm/include/llvm/Analysis/DDGPrinter.h
+++ /dev/null
@@ -1,91 +0,0 @@
-//===- llvm/Analysis/DDGPrinter.h ---*- 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
-//
-//===--===//
-
-//===--===//
-//
-// This file defines the DOT printer for the 

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

2020-12-14 Thread Tom Stellard via llvm-branch-commits

Author: Bruno Cardoso Lopes
Date: 2020-12-14T16:56:27-05:00
New Revision: fc23bc9b30bff900cb279318e8e60050688606f9

URL: 
https://github.com/llvm/llvm-project/commit/fc23bc9b30bff900cb279318e8e60050688606f9
DIFF: 
https://github.com/llvm/llvm-project/commit/fc23bc9b30bff900cb279318e8e60050688606f9.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)

This is a re-commit of 8ac709578067f77a7036fe50610277516fa36d50 with
some modifications to avoid changing the clang API.

Added: 


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

Removed: 




diff  --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp 
b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index baec13ba627c..7e6efe6105bf 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -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);
@@ -5311,7 +5314,7 @@ void Sema::InstantiateVariableDefinition(SourceLocation 
PointOfInstantiation,
   TemplateArgs);
 Var = 
cast_or_null(Instantiator.VisitVarTemplateSpecializationDecl(
 VarSpec->getSpecializedTemplate(), Def, nullptr,
-VarSpec->getTemplateArgsInfo(), VarSpec->getTemplateArgs().asArray()));
+VarSpec->getTemplateArgsInfo(), VarSpec->getTemplateArgs().asArray(), 
VarSpec));
 if (Var) {
   llvm::PointerUnion PatternPtr =
@@ -5321,12 +5324,6 @@ void Sema::InstantiateVariableDefinition(SourceLocation 
PointOfInstantiation,
 cast(Var)->setInstantiationOf(
 Partial, >getTemplateInstantiationArgs());
 
-  // Merge the definition with the declaration.
-  LookupResult R(*this, Var->getDeclName(), Var->getLocation(),
- LookupOrdinaryName, forRedeclarationInCurContext());
-  R.addDecl(OldVar);
-  MergeVarDecl(Var, R);
-
   // Attach the initializer.
   InstantiateVariableInitializer(Var, Def, TemplateArgs);
 }

diff  --git a/clang/test/SemaTemplate/instantiate-var-template.cpp 
b/clang/test/SemaTemplate/instantiate-var-template.cpp
index b7b83e4afdd5..a24b205da596 100644
--- a/clang/test/SemaTemplate/instantiate-var-template.cpp
+++ b/clang/test/SemaTemplate/instantiate-var-template.cpp
@@ -40,3 +40,10 @@ namespace PR24483 {
   template A models;
   template<> struct B models<>; // expected-error {{incomplete type 'struct 
B'}} expected-note {{forward declaration}}
 }
+
+namespace InvalidInsertPos {
+  template T v;
+  template decltype(v) v;
+  template<> int v;
+  int k = 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] [mlir] 0cf7e4b - Revert "[mlir] Remove methods from mlir::OpState that just forward to mlir::Operation."

2020-12-14 Thread Christian Sigg via llvm-branch-commits

Author: Christian Sigg
Date: 2020-12-14T22:47:17+01:00
New Revision: 0cf7e4b252fe1458fddb8e3dbfcae43450e9c04c

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

LOG: Revert "[mlir] Remove methods from mlir::OpState that just forward to 
mlir::Operation."

This reverts commit 6f271e921ba48f4c4fa54bbd2c7a4c548ca5e59e.

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

Added: 


Modified: 
mlir/include/mlir/IR/OpDefinition.h

Removed: 




diff  --git a/mlir/include/mlir/IR/OpDefinition.h 
b/mlir/include/mlir/IR/OpDefinition.h
index 2edc48dd099e..9e4da63c3618 100644
--- a/mlir/include/mlir/IR/OpDefinition.h
+++ b/mlir/include/mlir/IR/OpDefinition.h
@@ -108,6 +108,28 @@ class OpState {
   /// Return the operation that this refers to.
   Operation *getOperation() { return state; }
 
+  /// Return the dialect that this refers to.
+  Dialect *getDialect() { return getOperation()->getDialect(); }
+
+  /// Return the parent Region of this operation.
+  Region *getParentRegion() { return getOperation()->getParentRegion(); }
+
+  /// Returns the closest surrounding operation that contains this operation
+  /// or nullptr if this is a top-level operation.
+  Operation *getParentOp() { return getOperation()->getParentOp(); }
+
+  /// Return the closest surrounding parent operation that is of type 'OpTy'.
+  template 
+  OpTy getParentOfType() {
+return getOperation()->getParentOfType();
+  }
+
+  /// Returns the closest surrounding parent operation with trait `Trait`.
+  template  class Trait>
+  Operation *getParentWithTrait() {
+return getOperation()->getParentWithTrait();
+  }
+
   /// Return the context this operation belongs to.
   MLIRContext *getContext() { return getOperation()->getContext(); }
 
@@ -134,6 +156,37 @@ class OpState {
   using dialect_attr_iterator = Operation::dialect_attr_iterator;
   using dialect_attr_range = Operation::dialect_attr_range;
 
+  /// Return a range corresponding to the dialect attributes for this 
operation.
+  dialect_attr_range getDialectAttrs() { return state->getDialectAttrs(); }
+  dialect_attr_iterator dialect_attr_begin() {
+return state->dialect_attr_begin();
+  }
+  dialect_attr_iterator dialect_attr_end() { return state->dialect_attr_end(); 
}
+
+  /// Return an attribute with the specified name.
+  Attribute getAttr(StringRef name) { return state->getAttr(name); }
+
+  /// If the operation has an attribute of the specified type, return it.
+  template 
+  AttrClass getAttrOfType(StringRef name) {
+return getAttr(name).dyn_cast_or_null();
+  }
+
+  /// If the an attribute exists with the specified name, change it to the new
+  /// value.  Otherwise, add a new attribute with the specified name/value.
+  void setAttr(Identifier name, Attribute value) {
+state->setAttr(name, value);
+  }
+  void setAttr(StringRef name, Attribute value) {
+setAttr(Identifier::get(name, getContext()), value);
+  }
+
+  /// Set the attributes held by this operation.
+  void setAttrs(ArrayRef attributes) {
+state->setAttrs(attributes);
+  }
+  void setAttrs(MutableDictionaryAttr newAttrs) { state->setAttrs(newAttrs); }
+
   /// Set the dialect attributes for this operation, and preserve all 
dependent.
   template  void setDialectAttrs(DialectAttrs &) {
 state->setDialectAttrs(std::move(attrs));



___
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] 3b3eb7f - Speculative fix for build bot failures

2020-12-14 Thread Philip Reames via llvm-branch-commits

Author: Philip Reames
Date: 2020-12-14T13:44:40-08:00
New Revision: 3b3eb7f07ff97feb64a1975587bb473f1f3efa6b

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

LOG: Speculative fix for build bot failures

(The clang build fails for me locally, so this is based on built bot output and 
a guess as to root cause.)

f5fe849 made the execution of LAA conditional, so I'm guessing that's the root 
cause.

Added: 


Modified: 
clang/test/CodeGen/thinlto-distributed-newpm.ll

Removed: 




diff  --git a/clang/test/CodeGen/thinlto-distributed-newpm.ll 
b/clang/test/CodeGen/thinlto-distributed-newpm.ll
index 75ea4064d6af..8fe53762837e 100644
--- a/clang/test/CodeGen/thinlto-distributed-newpm.ll
+++ b/clang/test/CodeGen/thinlto-distributed-newpm.ll
@@ -183,7 +183,6 @@
 ; CHECK-O: Running analysis: PostDominatorTreeAnalysis on main
 ; CHECK-O: Running analysis: DemandedBitsAnalysis on main
 ; CHECK-O: Running pass: LoopLoadEliminationPass on main
-; CHECK-O: Running analysis: LoopAccessAnalysis on Loop at depth 1 containing: 
%b
 ; CHECK-O: Running pass: InstCombinePass on main
 ; CHECK-O: Running pass: SimplifyCFGPass on main
 ; CHECK-O: Running pass: SLPVectorizerPass on main



___
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] fd4a107 - [DDG] Data Dependence Graph - DOT printer

2020-12-14 Thread Bardia Mahjour via llvm-branch-commits

Author: Bardia Mahjour
Date: 2020-12-14T16:41:14-05:00
New Revision: fd4a10732c8bd646ccc621c0a9af512be252f33a

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

LOG: [DDG] Data Dependence Graph - DOT printer

This patch implements a DDG printer pass that generates a graph in
the DOT description language, providing a more visually appealing
representation of the DDG. Similar to the CFG DOT printer, this
functionality is provided under an option called -dot-ddg and can
be generated in a less verbose mode under -dot-ddg-only option.

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

Added: 
llvm/include/llvm/Analysis/DDGPrinter.h
llvm/lib/Analysis/DDGPrinter.cpp

Modified: 
clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
llvm/include/llvm/Analysis/CFGPrinter.h
llvm/include/llvm/Analysis/DDG.h
llvm/include/llvm/Support/DOTGraphTraits.h
llvm/include/llvm/Support/GraphWriter.h
llvm/lib/Analysis/CFGPrinter.cpp
llvm/lib/Analysis/CMakeLists.txt
llvm/lib/Analysis/CallPrinter.cpp
llvm/lib/CodeGen/MachineScheduler.cpp
llvm/lib/CodeGen/ScheduleDAGPrinter.cpp
llvm/lib/Passes/PassBuilder.cpp
llvm/lib/Passes/PassRegistry.def

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp 
b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
index 409741cdb6e4..f285b652c175 100644
--- a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -3149,7 +3149,7 @@ struct DOTGraphTraits : public 
DefaultDOTGraphTraits {
   if (Stop(N))
 return true;
 
-  if (N->succ_size() != 1 || !isNodeHidden(N->getFirstSucc()))
+  if (N->succ_size() != 1 || !isNodeHidden(N->getFirstSucc(), nullptr))
 break;
   PostCallback(N);
 
@@ -3158,7 +3158,7 @@ struct DOTGraphTraits : public 
DefaultDOTGraphTraits {
 return false;
   }
 
-  static bool isNodeHidden(const ExplodedNode *N) {
+  static bool isNodeHidden(const ExplodedNode *N, const ExplodedGraph *G) {
 return N->isTrivial();
   }
 

diff  --git a/llvm/include/llvm/Analysis/CFGPrinter.h 
b/llvm/include/llvm/Analysis/CFGPrinter.h
index bc6a19f2e2b9..53700798b6b3 100644
--- a/llvm/include/llvm/Analysis/CFGPrinter.h
+++ b/llvm/include/llvm/Analysis/CFGPrinter.h
@@ -295,7 +295,7 @@ struct DOTGraphTraits : public 
DefaultDOTGraphTraits {
 " fillcolor=\"" + Color + "70\"";
 return Attrs;
   }
-  bool isNodeHidden(const BasicBlock *Node);
+  bool isNodeHidden(const BasicBlock *Node, const DOTFuncInfo *CFGInfo);
   void computeHiddenNodes(const Function *F);
 };
 } // End llvm namespace

diff  --git a/llvm/include/llvm/Analysis/DDG.h 
b/llvm/include/llvm/Analysis/DDG.h
index 9e2b7907eaec..8d225c155cd4 100644
--- a/llvm/include/llvm/Analysis/DDG.h
+++ b/llvm/include/llvm/Analysis/DDG.h
@@ -290,6 +290,12 @@ template  class DependenceGraphInfo {
   bool getDependencies(const NodeType , const NodeType ,
DependenceList ) const;
 
+  /// Return a string representing the type of dependence that the dependence
+  /// analysis identified between the two given nodes. This function assumes
+  /// that there is a memory dependence between the given two nodes.
+  const std::string getDependenceString(const NodeType ,
+const NodeType ) const;
+
 protected:
   // Name of the graph.
   std::string Name;
@@ -463,6 +469,26 @@ bool DependenceGraphInfo::getDependencies(
   return !Deps.empty();
 }
 
+template 
+const std::string
+DependenceGraphInfo::getDependenceString(const NodeType ,
+   const NodeType ) const {
+  std::string Str;
+  raw_string_ostream OS(Str);
+  DependenceList Deps;
+  if (!getDependencies(Src, Dst, Deps))
+return OS.str();
+  interleaveComma(Deps, OS, [&](const std::unique_ptr ) {
+D->dump(OS);
+// Remove the extra new-line character printed by the dump
+// method
+if (OS.str().back() == '\n')
+  OS.str().pop_back();
+  });
+
+  return OS.str();
+}
+
 //======//
 // GraphTraits specializations for the DDG
 //======//

diff  --git a/llvm/include/llvm/Analysis/DDGPrinter.h 
b/llvm/include/llvm/Analysis/DDGPrinter.h
new file mode 100644
index ..5cfe2ce33c99
--- /dev/null
+++ b/llvm/include/llvm/Analysis/DDGPrinter.h
@@ -0,0 +1,91 @@
+//===- llvm/Analysis/DDGPrinter.h ---*- 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
+//

[llvm-branch-commits] [llvm] ca8de9a - [X86] Fix crash with i64 bitreverse on 32-bit targets with XOP.

2020-12-14 Thread Tom Stellard via llvm-branch-commits

Author: Craig Topper
Date: 2020-12-14T16:41:26-05:00
New Revision: ca8de9ad8895ab1368135f6fc63f29fe92b75c76

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

LOG: [X86] Fix crash with i64 bitreverse on 32-bit targets with XOP.

We unconditionally marked i64 as Custom, but did not install a
handler in ReplaceNodeResults when i64 isn't legal type. This
leads to ReplaceNodeResults asserting.

We have two options to fix this. Only mark i64 as Custom on
64-bit targets and let it expand to two i32 bitreverses which
each need a VPPERM. Or the other option is to add the Custom
handling to ReplaceNodeResults. This is what I went with.

(cherry picked from commit 57c0c4a27575840ae0a48eb9f8455a5ed087c857)

Added: 


Modified: 
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/test/CodeGen/X86/bitreverse.ll

Removed: 




diff  --git a/llvm/lib/Target/X86/X86ISelLowering.cpp 
b/llvm/lib/Target/X86/X86ISelLowering.cpp
index f5b704ebbe9d..56690c3c555b 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -30285,6 +30285,13 @@ void X86TargetLowering::ReplaceNodeResults(SDNode *N,
 Results.push_back(V);
 return;
   }
+  case ISD::BITREVERSE:
+assert(N->getValueType(0) == MVT::i64 && "Unexpected VT!");
+assert(Subtarget.hasXOP() && "Expected XOP");
+// We can use VPPERM by copying to a vector register and back. We'll need
+// to move the scalar in two i32 pieces.
+Results.push_back(LowerBITREVERSE(SDValue(N, 0), Subtarget, DAG));
+return;
   }
 }
 

diff  --git a/llvm/test/CodeGen/X86/bitreverse.ll 
b/llvm/test/CodeGen/X86/bitreverse.ll
index 343d9fb2da2d..8e2f6f9b463b 100644
--- a/llvm/test/CodeGen/X86/bitreverse.ll
+++ b/llvm/test/CodeGen/X86/bitreverse.ll
@@ -1,6 +1,7 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
 ; RUN: llc < %s -mtriple=i686-unknown | FileCheck %s --check-prefix=X86
 ; RUN: llc < %s -mtriple=x86_64-unknown | FileCheck %s --check-prefix=X64
+; RUN: llc < %s -mtriple=i686-unknown -mattr=+xop | FileCheck %s 
--check-prefixes=X86XOP
 
 ; These tests just check that the plumbing is in place for @llvm.bitreverse. 
The
 ; actual output is massive at the moment as llvm.bitreverse is not yet legal.
@@ -75,6 +76,11 @@ define <2 x i16> @test_bitreverse_v2i16(<2 x i16> %a) 
nounwind {
 ; X64-NEXT:psrlw $1, %xmm0
 ; X64-NEXT:por %xmm1, %xmm0
 ; X64-NEXT:retq
+;
+; X86XOP-LABEL: test_bitreverse_v2i16:
+; X86XOP:   # %bb.0:
+; X86XOP-NEXT:vpperm {{\.LCPI.*}}, %xmm0, %xmm0, %xmm0
+; X86XOP-NEXT:retl
   %b = call <2 x i16> @llvm.bitreverse.v2i16(<2 x i16> %a)
   ret <2 x i16> %b
 }
@@ -145,6 +151,14 @@ define i64 @test_bitreverse_i64(i64 %a) nounwind {
 ; X64-NEXT:shrq %rdx
 ; X64-NEXT:leaq (%rdx,%rcx,2), %rax
 ; X64-NEXT:retq
+;
+; X86XOP-LABEL: test_bitreverse_i64:
+; X86XOP:   # %bb.0:
+; X86XOP-NEXT:vmovq {{.*#+}} xmm0 = mem[0],zero
+; X86XOP-NEXT:vpperm {{\.LCPI.*}}, %xmm0, %xmm0, %xmm0
+; X86XOP-NEXT:vmovd %xmm0, %eax
+; X86XOP-NEXT:vpextrd $1, %xmm0, %edx
+; X86XOP-NEXT:retl
   %b = call i64 @llvm.bitreverse.i64(i64 %a)
   ret i64 %b
 }
@@ -195,6 +209,13 @@ define i32 @test_bitreverse_i32(i32 %a) nounwind {
 ; X64-NEXT:shrl %eax
 ; X64-NEXT:leal (%rax,%rcx,2), %eax
 ; X64-NEXT:retq
+;
+; X86XOP-LABEL: test_bitreverse_i32:
+; X86XOP:   # %bb.0:
+; X86XOP-NEXT:vmovd {{.*#+}} xmm0 = mem[0],zero,zero,zero
+; X86XOP-NEXT:vpperm {{\.LCPI.*}}, %xmm0, %xmm0, %xmm0
+; X86XOP-NEXT:vmovd %xmm0, %eax
+; X86XOP-NEXT:retl
   %b = call i32 @llvm.bitreverse.i32(i32 %a)
   ret i32 %b
 }
@@ -247,6 +268,14 @@ define i24 @test_bitreverse_i24(i24 %a) nounwind {
 ; X64-NEXT:leal (%rax,%rcx,2), %eax
 ; X64-NEXT:shrl $8, %eax
 ; X64-NEXT:retq
+;
+; X86XOP-LABEL: test_bitreverse_i24:
+; X86XOP:   # %bb.0:
+; X86XOP-NEXT:vmovd {{.*#+}} xmm0 = mem[0],zero,zero,zero
+; X86XOP-NEXT:vpperm {{\.LCPI.*}}, %xmm0, %xmm0, %xmm0
+; X86XOP-NEXT:vmovd %xmm0, %eax
+; X86XOP-NEXT:shrl $8, %eax
+; X86XOP-NEXT:retl
   %b = call i24 @llvm.bitreverse.i24(i24 %a)
   ret i24 %b
 }
@@ -299,6 +328,14 @@ define i16 @test_bitreverse_i16(i16 %a) nounwind {
 ; X64-NEXT:leal (%rax,%rcx,2), %eax
 ; X64-NEXT:# kill: def $ax killed $ax killed $eax
 ; X64-NEXT:retq
+;
+; X86XOP-LABEL: test_bitreverse_i16:
+; X86XOP:   # %bb.0:
+; X86XOP-NEXT:vmovd {{.*#+}} xmm0 = mem[0],zero,zero,zero
+; X86XOP-NEXT:vpperm {{\.LCPI.*}}, %xmm0, %xmm0, %xmm0
+; X86XOP-NEXT:vmovd %xmm0, %eax
+; X86XOP-NEXT:# kill: def $ax killed $ax killed $eax
+; X86XOP-NEXT:retl
   %b = call i16 @llvm.bitreverse.i16(i16 %a)
   ret i16 %b
 }
@@ -342,6 +379,14 @@ define i8 @test_bitreverse_i8(i8 %a) 

[llvm-branch-commits] [mlir] aece4e2 - [mlir][ArmSVE][RFC] Add an ArmSVE dialect

2020-12-14 Thread Mehdi Amini via llvm-branch-commits

Author: Javier Setoain
Date: 2020-12-14T21:35:01Z
New Revision: aece4e2793ccf0d63d5e677a0ace83752b30979a

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

LOG: [mlir][ArmSVE][RFC] Add an ArmSVE dialect

This revision starts an Arm-specific ArmSVE dialect discussed in the discourse 
RFC thread:

https://llvm.discourse.group/t/rfc-vector-dialects-neon-and-sve/2284

Reviewed By: rriddle

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

Added: 
mlir/include/mlir/Conversion/ArmSVEToLLVM/ArmSVEToLLVM.h
mlir/include/mlir/Dialect/ArmSVE/ArmSVE.td
mlir/include/mlir/Dialect/ArmSVE/ArmSVEDialect.h
mlir/include/mlir/Dialect/ArmSVE/CMakeLists.txt
mlir/include/mlir/Dialect/LLVMIR/LLVMArmSVE.td
mlir/include/mlir/Dialect/LLVMIR/LLVMArmSVEDialect.h
mlir/lib/Conversion/ArmSVEToLLVM/ArmSVEToLLVM.cpp
mlir/lib/Conversion/ArmSVEToLLVM/CMakeLists.txt
mlir/lib/Dialect/ArmSVE/CMakeLists.txt
mlir/lib/Dialect/ArmSVE/IR/ArmSVEDialect.cpp
mlir/lib/Dialect/LLVMIR/IR/LLVMArmSVEDialect.cpp
mlir/lib/Target/LLVMIR/LLVMArmSVEIntr.cpp
mlir/test/Conversion/ArmSVEToLLVM/convert-to-llvm.mlir
mlir/test/Dialect/ArmSVE/roundtrip.mlir
mlir/test/Target/arm-sve.mlir

Modified: 
mlir/include/mlir/Conversion/Passes.td
mlir/include/mlir/Conversion/VectorToLLVM/ConvertVectorToLLVM.h
mlir/include/mlir/Dialect/CMakeLists.txt
mlir/include/mlir/Dialect/LLVMIR/CMakeLists.txt
mlir/include/mlir/InitAllDialects.h
mlir/include/mlir/InitAllTranslations.h
mlir/lib/Conversion/CMakeLists.txt
mlir/lib/Conversion/PassDetail.h
mlir/lib/Conversion/VectorToLLVM/CMakeLists.txt
mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVMPass.cpp
mlir/lib/Dialect/CMakeLists.txt
mlir/lib/Dialect/LLVMIR/CMakeLists.txt
mlir/lib/Target/CMakeLists.txt

Removed: 




diff  --git a/mlir/include/mlir/Conversion/ArmSVEToLLVM/ArmSVEToLLVM.h 
b/mlir/include/mlir/Conversion/ArmSVEToLLVM/ArmSVEToLLVM.h
new file mode 100644
index ..8cba4e9be5d5
--- /dev/null
+++ b/mlir/include/mlir/Conversion/ArmSVEToLLVM/ArmSVEToLLVM.h
@@ -0,0 +1,23 @@
+//===- ArmSVEToLLVM.h - Conversion Patterns from ArmSVE to LLVM 
---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef MLIR_CONVERSION_ARMSVETOLLVM_ARMSVETOLLVM_H_
+#define MLIR_CONVERSION_ARMSVETOLLVM_ARMSVETOLLVM_H_
+
+namespace mlir {
+
+class LLVMTypeConverter;
+class OwningRewritePatternList;
+
+/// Collect a set of patterns to convert from the ArmSVE dialect to LLVM.
+void populateArmSVEToLLVMConversionPatterns(LLVMTypeConverter ,
+OwningRewritePatternList 
);
+
+} // namespace mlir
+
+#endif // MLIR_CONVERSION_ARMSVETOLLVM_ARMSVETOLLVM_H_

diff  --git a/mlir/include/mlir/Conversion/Passes.td 
b/mlir/include/mlir/Conversion/Passes.td
index 56169d90c849..b364700bd849 100644
--- a/mlir/include/mlir/Conversion/Passes.td
+++ b/mlir/include/mlir/Conversion/Passes.td
@@ -396,8 +396,8 @@ def ConvertVectorToLLVM : Pass<"convert-vector-to-llvm", 
"ModuleOp"> {
 operations. The lowering pass provides several options to control
 the kinds of optimizations that are allowed. It also provides options
 that enable the use of one or more architectural-specific dialects
-(AVX512, ArmNeon, SVE, etc.) in combination with the architectural-neutral
-vector dialect lowering.
+(AVX512, ArmNeon, ArmSVE, etc.) in combination with the
+architectural-neutral vector dialect lowering.
 
   }];
   let constructor = "mlir::createConvertVectorToLLVMPass()";
@@ -418,7 +418,11 @@ def ConvertVectorToLLVM : Pass<"convert-vector-to-llvm", 
"ModuleOp"> {
 Option<"enableArmNeon", "enable-arm-neon",
"bool", /*default=*/"false",
"Enables the use of ArmNeon dialect while lowering the vector "
-  "dialect.">
+  "dialect.">,
+Option<"enableArmSVE", "enable-arm-sve",
+   "bool", /*default=*/"false",
+   "Enables the use of ArmSVE dialect while lowering the vector "
+   "dialect.">
   ];
 }
 

diff  --git a/mlir/include/mlir/Conversion/VectorToLLVM/ConvertVectorToLLVM.h 
b/mlir/include/mlir/Conversion/VectorToLLVM/ConvertVectorToLLVM.h
index 7ff061cb9d09..8d24803eeb1c 100644
--- a/mlir/include/mlir/Conversion/VectorToLLVM/ConvertVectorToLLVM.h
+++ b/mlir/include/mlir/Conversion/VectorToLLVM/ConvertVectorToLLVM.h
@@ -23,7 +23,7 @@ class OperationPass;
 struct LowerVectorToLLVMOptions {
   LowerVectorToLLVMOptions()
   : 

[llvm-branch-commits] [llvm] 2e0e03c - OpaquePtr: Require byval on x86_intrcc parameter 0

2020-12-14 Thread Matt Arsenault via llvm-branch-commits

Author: Matt Arsenault
Date: 2020-12-14T16:34:37-05:00
New Revision: 2e0e03c6a089da39039ec3f464f7cee5df86646b

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

LOG: OpaquePtr: Require byval on x86_intrcc parameter 0

Currently the backend special cases x86_intrcc and treats the first
parameter as byval. Make the IR require byval for this parameter to
remove this special case, and avoid the dependence on the pointee
element type.

Fixes bug 46672.

I'm not sure the IR is enforcing all the calling convention
constraints. clang seems to ignore the attribute for empty parameter
lists, but the IR tolerates it.

Added: 
llvm/test/Assembler/x86_intrcc.ll
llvm/test/Bitcode/Inputs/x86_intrcc_upgrade.bc
llvm/test/Bitcode/x86_intr-upgrade.test
llvm/test/Verifier/x86_intr.ll

Modified: 
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
llvm/lib/IR/AutoUpgrade.cpp
llvm/lib/IR/Verifier.cpp
llvm/test/Bitcode/compatibility-6.0.ll
llvm/test/Bitcode/compatibility.ll
llvm/test/CodeGen/X86/x86-32-intrcc.ll
llvm/test/CodeGen/X86/x86-64-intrcc-nosse.ll
llvm/test/CodeGen/X86/x86-64-intrcc.ll
llvm/test/CodeGen/X86/x86-interrupt_cc.ll
llvm/test/CodeGen/X86/x86-interrupt_cld.ll
llvm/test/CodeGen/X86/x86-interrupt_vzeroupper.ll
llvm/test/CodeGen/X86/x86-no_caller_saved_registers.ll

Removed: 




diff  --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp 
b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index 170f3f2c4e13..b9a53f34eb88 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -9846,14 +9846,6 @@ void SelectionDAGISel::LowerArguments(const Function ) 
{
   }
 
   Type *ArgMemTy = nullptr;
-  if (F.getCallingConv() == CallingConv::X86_INTR) {
-// IA Interrupt passes frame (1st parameter) by value in the stack.
-if (ArgNo == 0) {
-  Flags.setByVal();
-  // FIXME: Dependence on pointee element type. See bug 46672.
-  ArgMemTy = Arg.getType()->getPointerElementType();
-}
-  }
   if (Flags.isByVal() || Flags.isInAlloca() || Flags.isPreallocated() ||
   Flags.isByRef()) {
 if (!ArgMemTy)

diff  --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp
index 6d92f8cffee5..fe7b7eb8966a 100644
--- a/llvm/lib/IR/AutoUpgrade.cpp
+++ b/llvm/lib/IR/AutoUpgrade.cpp
@@ -4315,6 +4315,13 @@ void llvm::UpgradeFunctionAttributes(Function ) {
 StrictFPUpgradeVisitor SFPV;
 SFPV.visit(F);
   }
+
+  if (F.getCallingConv() == CallingConv::X86_INTR &&
+  !F.arg_empty() && !F.hasParamAttribute(0, Attribute::ByVal)) {
+Type *ByValTy = 
cast(F.getArg(0)->getType())->getElementType();
+Attribute NewAttr = Attribute::getWithByValType(F.getContext(), ByValTy);
+F.addParamAttr(0, NewAttr);
+  }
 }
 
 static bool isOldLoopArgument(Metadata *MD) {

diff  --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp
index e3a2828be41a..ac44a95d7da5 100644
--- a/llvm/lib/IR/Verifier.cpp
+++ b/llvm/lib/IR/Verifier.cpp
@@ -2327,6 +2327,11 @@ void Verifier::visitFunction(const Function ) {
   default:
   case CallingConv::C:
 break;
+  case CallingConv::X86_INTR: {
+Assert(F.arg_empty() || Attrs.hasParamAttribute(0, Attribute::ByVal),
+   "Calling convention parameter requires byval", );
+break;
+  }
   case CallingConv::AMDGPU_KERNEL:
   case CallingConv::SPIR_KERNEL:
 Assert(F.getReturnType()->isVoidTy(),

diff  --git a/llvm/test/Assembler/x86_intrcc.ll 
b/llvm/test/Assembler/x86_intrcc.ll
new file mode 100644
index ..b75fbb52b090
--- /dev/null
+++ b/llvm/test/Assembler/x86_intrcc.ll
@@ -0,0 +1,13 @@
+; RUN: llvm-as < %s | llvm-dis | FileCheck %s
+; RUN: verify-uselistorder %s
+
+; Make sure no arguments is accepted
+; CHECK: define x86_intrcc void @no_args() {
+define x86_intrcc void @no_args() {
+  ret void
+}
+
+; CHECK: define x86_intrcc void @byval_arg(i32* byval(i32) %0) {
+define x86_intrcc void @byval_arg(i32* byval(i32)) {
+  ret void
+}

diff  --git a/llvm/test/Bitcode/Inputs/x86_intrcc_upgrade.bc 
b/llvm/test/Bitcode/Inputs/x86_intrcc_upgrade.bc
new file mode 100644
index ..f6fb962d01bc
Binary files /dev/null and b/llvm/test/Bitcode/Inputs/x86_intrcc_upgrade.bc 
diff er

diff  --git a/llvm/test/Bitcode/compatibility-6.0.ll 
b/llvm/test/Bitcode/compatibility-6.0.ll
index 6018e9b2a8ca..980dd92563c7 100644
--- a/llvm/test/Bitcode/compatibility-6.0.ll
+++ b/llvm/test/Bitcode/compatibility-6.0.ll
@@ -436,7 +436,7 @@ declare cc82 void @f.cc82()
 ; CHECK: declare hhvm_ccc void @f.cc82()
 declare hhvm_ccc void @f.hhvm_ccc()
 ; CHECK: declare hhvm_ccc void @f.hhvm_ccc()
-declare cc83 void @f.cc83()
+declare cc83 void 

[llvm-branch-commits] [clang] ef4da3c - clang: Add byval on x86_intrcc parameter 0

2020-12-14 Thread Matt Arsenault via llvm-branch-commits

Author: Matt Arsenault
Date: 2020-12-14T16:34:37-05:00
New Revision: ef4da3c2ba8a812a695361d786e3de8a8b2cd482

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

LOG: clang: Add byval on x86_intrcc parameter 0

This will allow removing the special case treatment of the parameter
and avoid depending on the pointer's element type.

Added: 


Modified: 
clang/lib/CodeGen/TargetInfo.cpp
clang/test/CodeGen/attr-x86-interrupt.c
clang/test/CodeGenCXX/attr-x86-interrupt.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/TargetInfo.cpp 
b/clang/lib/CodeGen/TargetInfo.cpp
index 8d3a343ca2aa..e61daa7775f2 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -2097,6 +2097,23 @@ bool X86_32TargetCodeGenInfo::isStructReturnInRegABI(
   }
 }
 
+static void addX86InterruptAttrs(const FunctionDecl *FD, llvm::GlobalValue *GV,
+ CodeGen::CodeGenModule ) {
+  if (!FD->hasAttr())
+return;
+
+  llvm::Function *Fn = cast(GV);
+  Fn->setCallingConv(llvm::CallingConv::X86_INTR);
+  if (FD->getNumParams() == 0)
+return;
+
+  auto PtrTy = cast(FD->getParamDecl(0)->getType());
+  llvm::Type *ByValTy = CGM.getTypes().ConvertType(PtrTy->getPointeeType());
+  llvm::Attribute NewAttr = llvm::Attribute::getWithByValType(
+Fn->getContext(), ByValTy);
+  Fn->addParamAttr(0, NewAttr);
+}
+
 void X86_32TargetCodeGenInfo::setTargetAttributes(
 const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule ) const {
   if (GV->isDeclaration())
@@ -2106,10 +2123,8 @@ void X86_32TargetCodeGenInfo::setTargetAttributes(
   llvm::Function *Fn = cast(GV);
   Fn->addFnAttr("stackrealign");
 }
-if (FD->hasAttr()) {
-  llvm::Function *Fn = cast(GV);
-  Fn->setCallingConv(llvm::CallingConv::X86_INTR);
-}
+
+addX86InterruptAttrs(FD, GV, CGM);
   }
 }
 
@@ -2476,10 +2491,8 @@ class X86_64TargetCodeGenInfo : public TargetCodeGenInfo 
{
 llvm::Function *Fn = cast(GV);
 Fn->addFnAttr("stackrealign");
   }
-  if (FD->hasAttr()) {
-llvm::Function *Fn = cast(GV);
-Fn->setCallingConv(llvm::CallingConv::X86_INTR);
-  }
+
+  addX86InterruptAttrs(FD, GV, CGM);
 }
   }
 
@@ -2689,10 +2702,8 @@ void WinX86_64TargetCodeGenInfo::setTargetAttributes(
   llvm::Function *Fn = cast(GV);
   Fn->addFnAttr("stackrealign");
 }
-if (FD->hasAttr()) {
-  llvm::Function *Fn = cast(GV);
-  Fn->setCallingConv(llvm::CallingConv::X86_INTR);
-}
+
+addX86InterruptAttrs(FD, GV, CGM);
   }
 
   addStackProbeTargetAttributes(D, GV, CGM);

diff  --git a/clang/test/CodeGen/attr-x86-interrupt.c 
b/clang/test/CodeGen/attr-x86-interrupt.c
index 700a57524dca..d40f5f99580a 100644
--- a/clang/test/CodeGen/attr-x86-interrupt.c
+++ b/clang/test/CodeGen/attr-x86-interrupt.c
@@ -13,22 +13,22 @@ typedef __UINT32_TYPE__ uword;
 __attribute__((interrupt)) void foo7(int *a, uword b) {}
 __attribute__((interrupt)) void foo8(int *a) {}
 // X86_64_LINUX: @llvm.used = appending global [2 x i8*] [i8* bitcast (void 
(i32*, i64)* @foo7 to i8*), i8* bitcast (void (i32*)* @foo8 to i8*)], section 
"llvm.metadata"
-// X86_64_LINUX: define x86_intrcc void @foo7(i32* %{{.+}}, i64 %{{.+}})
-// X86_64_LINUX: define x86_intrcc void @foo8(i32* %{{.+}})
+// X86_64_LINUX: define x86_intrcc void @foo7(i32* byval(i32) %{{.+}}, i64 
%{{.+}})
+// X86_64_LINUX: define x86_intrcc void @foo8(i32* byval(i32) %{{.+}})
 // X86_64_LINUX: "disable-tail-calls"="true"
 // X86_64_LINUX-NOT: "disable-tail-calls"="false"
 // X86_LINUX: @llvm.used = appending global [2 x i8*] [i8* bitcast (void 
(i32*, i32)* @foo7 to i8*), i8* bitcast (void (i32*)* @foo8 to i8*)], section 
"llvm.metadata"
-// X86_LINUX: define x86_intrcc void @foo7(i32* %{{.+}}, i32 %{{.+}})
-// X86_LINUX: define x86_intrcc void @foo8(i32* %{{.+}})
+// X86_LINUX: define x86_intrcc void @foo7(i32* byval(i32) %{{.+}}, i32 
%{{.+}})
+// X86_LINUX: define x86_intrcc void @foo8(i32* byval(i32) %{{.+}})
 // X86_LINUX: "disable-tail-calls"="true"
 // X86_LINUX-NOT: "disable-tail-calls"="false"
 // X86_64_WIN: @llvm.used = appending global [2 x i8*] [i8* bitcast (void 
(i32*, i64)* @foo7 to i8*), i8* bitcast (void (i32*)* @foo8 to i8*)], section 
"llvm.metadata"
-// X86_64_WIN: define dso_local x86_intrcc void @foo7(i32* %{{.+}}, i64 
%{{.+}})
-// X86_64_WIN: define dso_local x86_intrcc void @foo8(i32* %{{.+}})
-// X86_64_Win: "disable-tail-calls"="true"
-// X86_64_Win-NOT: "disable-tail-calls"="false"
+// X86_64_WIN: define dso_local x86_intrcc void @foo7(i32* byval(i32) %{{.+}}, 
i64 %{{.+}})
+// X86_64_WIN: define dso_local x86_intrcc void @foo8(i32* byval(i32) %{{.+}})
+// X86_64_WIN: "disable-tail-calls"="true"
+// X86_64_WIN-NOT: 

[llvm-branch-commits] [libcxx] 7ad49ae - [libc++] Split allocator_traits and pointer_traits out of

2020-12-14 Thread Louis Dionne via llvm-branch-commits

Author: Louis Dionne
Date: 2020-12-14T16:13:57-05:00
New Revision: 7ad49aec125b3c1205b164331d0aa954d773f890

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

LOG: [libc++] Split allocator_traits and pointer_traits out of 

In addition to making the code a lot easier to grasp by localizing many
helper functions to the only file where they are actually needed, this
will allow creating helper functions that depend on allocator_traits
outside of .

This is done as part of implementing array support in allocate_shared,
which requires non-trivial array initialization algorithms that would be
better to keep out of  for sanity. It's also a first step towards
splitting up our monolithic headers into finer grained ones, which will
make it easier to reuse functionality across the library. For example,
it's just weird that we had to define `addressof` inside 
to avoid circular dependencies -- instead it's better to implement those
in true helper headers.

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

Added: 
libcxx/include/__memory/allocator_traits.h
libcxx/include/__memory/base.h
libcxx/include/__memory/pointer_traits.h

Modified: 
libcxx/include/CMakeLists.txt
libcxx/include/exception
libcxx/include/iterator
libcxx/include/memory
libcxx/include/type_traits

libcxx/test/std/containers/sequences/vector/vector.cons/copy.move_only.verify.cpp

libcxx/test/std/containers/sequences/vector/vector.modifiers/resize_not_move_insertable.fail.cpp

Removed: 




diff  --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index e0f05da65996..71361a9e53df 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -11,6 +11,9 @@ set(files
   __hash_table
   __libcpp_version
   __locale
+  __memory/allocator_traits.h
+  __memory/base.h
+  __memory/pointer_traits.h
   __mutex_base
   __node_handle
   __nullptr

diff  --git a/libcxx/include/__memory/allocator_traits.h 
b/libcxx/include/__memory/allocator_traits.h
new file mode 100644
index ..cdbdb9ef8e37
--- /dev/null
+++ b/libcxx/include/__memory/allocator_traits.h
@@ -0,0 +1,589 @@
+// -*- 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
+//
+//===--===//
+
+#ifndef _LIBCPP___MEMORY_ALLOCATOR_TRAITS_H
+#define _LIBCPP___MEMORY_ALLOCATOR_TRAITS_H
+
+#include <__config>
+#include <__memory/base.h>
+#include <__memory/pointer_traits.h>
+#include 
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template 
+struct __has_pointer_type : false_type {};
+
+template 
+struct __has_pointer_type<_Tp,
+  typename __void_t::type> : true_type {};
+
+namespace __pointer_type_imp
+{
+
+template ::value>
+struct __pointer_type
+{
+typedef _LIBCPP_NODEBUG_TYPE typename _Dp::pointer type;
+};
+
+template 
+struct __pointer_type<_Tp, _Dp, false>
+{
+typedef _LIBCPP_NODEBUG_TYPE _Tp* type;
+};
+
+}  // __pointer_type_imp
+
+template 
+struct __pointer_type
+{
+typedef _LIBCPP_NODEBUG_TYPE typename 
__pointer_type_imp::__pointer_type<_Tp, typename 
remove_reference<_Dp>::type>::type type;
+};
+
+template 
+struct __has_const_pointer : false_type {};
+
+template 
+struct __has_const_pointer<_Tp,
+typename __void_t::type> : true_type 
{};
+
+template ::value>
+struct __const_pointer
+{
+typedef _LIBCPP_NODEBUG_TYPE typename _Alloc::const_pointer type;
+};
+
+template 
+struct __const_pointer<_Tp, _Ptr, _Alloc, false>
+{
+#ifndef _LIBCPP_CXX03_LANG
+typedef _LIBCPP_NODEBUG_TYPE typename pointer_traits<_Ptr>::template 
rebind type;
+#else
+typedef typename pointer_traits<_Ptr>::template rebind::other 
type;
+#endif
+};
+
+template 
+struct __has_void_pointer : false_type {};
+
+template 
+struct __has_void_pointer<_Tp,
+   typename __void_t::type> : 
true_type {};
+
+template ::value>
+struct __void_pointer
+{
+typedef _LIBCPP_NODEBUG_TYPE typename _Alloc::void_pointer type;
+};
+
+template 
+struct __void_pointer<_Ptr, _Alloc, false>
+{
+#ifndef _LIBCPP_CXX03_LANG
+typedef _LIBCPP_NODEBUG_TYPE typename pointer_traits<_Ptr>::template 
rebind type;
+#else
+typedef _LIBCPP_NODEBUG_TYPE typename pointer_traits<_Ptr>::template 
rebind::other type;
+#endif
+};
+
+template 
+struct __has_const_void_pointer : false_type {};
+
+template 
+struct __has_const_void_pointer<_Tp,
+typename 

[llvm-branch-commits] [llvm] b6b522c - [NFC] cleanup cg-profile emission on TargetLowerinng

2020-12-14 Thread Zequan Wu via llvm-branch-commits

Author: Zequan Wu
Date: 2020-12-14T13:07:44-08:00
New Revision: b6b522c4db17157d871eff974e5283058bc616a1

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

LOG: [NFC] cleanup cg-profile emission on TargetLowerinng

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

Added: 


Modified: 
llvm/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h
llvm/include/llvm/Target/TargetLoweringObjectFile.h
llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
llvm/lib/Target/TargetLoweringObjectFile.cpp

Removed: 




diff  --git a/llvm/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h 
b/llvm/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h
index bd4bb1b23680..a7389bb21371 100644
--- a/llvm/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h
+++ b/llvm/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h
@@ -35,7 +35,6 @@ class TargetLoweringObjectFileELF : public 
TargetLoweringObjectFile {
 protected:
   MCSymbolRefExpr::VariantKind PLTRelativeVariantKind =
   MCSymbolRefExpr::VK_None;
-  const TargetMachine *TM = nullptr;
 
 public:
   TargetLoweringObjectFileELF();

diff  --git a/llvm/include/llvm/Target/TargetLoweringObjectFile.h 
b/llvm/include/llvm/Target/TargetLoweringObjectFile.h
index 90041f077523..ff27ceaeac35 100644
--- a/llvm/include/llvm/Target/TargetLoweringObjectFile.h
+++ b/llvm/include/llvm/Target/TargetLoweringObjectFile.h
@@ -63,6 +63,8 @@ class TargetLoweringObjectFile : public MCObjectFileInfo {
   /// This section contains the static destructor pointer list.
   MCSection *StaticDtorSection = nullptr;
 
+  const TargetMachine *TM = nullptr;
+
 public:
   TargetLoweringObjectFile() = default;
   TargetLoweringObjectFile(const TargetLoweringObjectFile &) = delete;
@@ -83,6 +85,9 @@ class TargetLoweringObjectFile : public MCObjectFileInfo {
   /// Emit the module-level metadata that the platform cares about.
   virtual void emitModuleMetadata(MCStreamer , Module ) const {}
 
+  /// Emit Call Graph Profile metadata.
+  void emitCGProfileMetadata(MCStreamer , Module ) const;
+
   /// Get the module-level metadata that the platform cares about.
   virtual void getModuleMetadata(Module ) {}
 

diff  --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp 
b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
index 6cbf21deb2db..b4d88fcb0702 100644
--- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -114,7 +114,6 @@ TargetLoweringObjectFileELF::TargetLoweringObjectFileELF()
 void TargetLoweringObjectFileELF::Initialize(MCContext ,
  const TargetMachine ) {
   TargetLoweringObjectFile::Initialize(Ctx, TgtM);
-  TM = 
 
   CodeModel::Model CM = TgtM.getCodeModel();
   InitializeELF(TgtM.Options.UseInitArray);
@@ -354,46 +353,7 @@ void 
TargetLoweringObjectFileELF::emitModuleMetadata(MCStreamer ,
 Streamer.AddBlankLine();
   }
 
-  SmallVector ModuleFlags;
-  M.getModuleFlagsMetadata(ModuleFlags);
-
-  MDNode *CFGProfile = nullptr;
-
-  for (const auto  : ModuleFlags) {
-StringRef Key = MFE.Key->getString();
-if (Key == "CG Profile") {
-  CFGProfile = cast(MFE.Val);
-  break;
-}
-  }
-
-  if (!CFGProfile)
-return;
-
-  auto GetSym = [this](const MDOperand ) -> MCSymbol * {
-if (!MDO)
-  return nullptr;
-auto V = cast(MDO);
-const Function *F = cast(V->getValue()->stripPointerCasts());
-return TM->getSymbol(F);
-  };
-
-  for (const auto  : CFGProfile->operands()) {
-MDNode *E = cast(Edge);
-const MCSymbol *From = GetSym(E->getOperand(0));
-const MCSymbol *To = GetSym(E->getOperand(1));
-// Skip null functions. This can happen if functions are dead stripped 
after
-// the CGProfile pass has been run.
-if (!From || !To)
-  continue;
-uint64_t Count = cast(E->getOperand(2))
- ->getValue()
- ->getUniqueInteger()
- .getZExtValue();
-Streamer.emitCGProfileEntry(
-MCSymbolRefExpr::create(From, MCSymbolRefExpr::VK_None, C),
-MCSymbolRefExpr::create(To, MCSymbolRefExpr::VK_None, C), Count);
-  }
+  emitCGProfileMetadata(Streamer, M);
 }
 
 MCSymbol *TargetLoweringObjectFileELF::getCFIPersonalitySymbol(
@@ -1696,49 +1656,7 @@ void 
TargetLoweringObjectFileCOFF::emitModuleMetadata(MCStreamer ,
 Streamer.AddBlankLine();
   }
 
-  auto  = getContext();
-  SmallVector ModuleFlags;
-  M.getModuleFlagsMetadata(ModuleFlags);
-
-  MDNode *CFGProfile = nullptr;
-
-  for (const auto  : ModuleFlags) {
-StringRef Key = MFE.Key->getString();
-if (Key == "CG Profile") {
-  CFGProfile = cast(MFE.Val);
-  break;
-}
-  }
-
-  if (!CFGProfile)
-return;
-
-  auto GetSym = [this](const 

[llvm-branch-commits] [clang] 670686a - Add initial support for multilibs in Baremetal toolchain.

2020-12-14 Thread Hafiz Abid Qadeer via llvm-branch-commits

Author: Hafiz Abid Qadeer
Date: 2020-12-14T20:49:45Z
New Revision: 670686ad8ecc80158a6ff87fff55e0ffa6fdff5d

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

LOG: Add initial support for multilibs in Baremetal toolchain.

This patch add support of riscv multilibs in the Baremetal toolchain. It is
a bit different to what is done in GNU.cpp as we are not iterating a
GNU sysroot to find the multilibs. This is intended for an llvm only
toolchain. We are not checking for the presence of any runtime bits to
enable a specific multilib.

I have structured the patch so that other targets for which
there is no multilibs support yet in Baremetal.cpp (e.g. arm-none-eabi)
will not be affected. Patch also allows some multilibs reuse.

Long term, I would like to go in the direction of data-driven specification of
multilib directories and flags.

Reviewed By: jroelofs

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/BareMetal.cpp
clang/lib/Driver/ToolChains/BareMetal.h
clang/test/Driver/baremetal.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/BareMetal.cpp 
b/clang/lib/Driver/ToolChains/BareMetal.cpp
index 7429c822b7e9..7619dd30da5a 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.cpp
+++ b/clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -12,6 +12,7 @@
 #include "InputInfo.h"
 #include "Gnu.h"
 
+#include "Arch/RISCV.h"
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/Driver.h"
 #include "clang/Driver/DriverDiagnostic.h"
@@ -27,12 +28,77 @@ using namespace clang::driver;
 using namespace clang::driver::tools;
 using namespace clang::driver::toolchains;
 
+static Multilib makeMultilib(StringRef commonSuffix) {
+  return Multilib(commonSuffix, commonSuffix, commonSuffix);
+}
+
+static bool findRISCVMultilibs(const Driver ,
+   const llvm::Triple ,
+   const ArgList , DetectedMultilibs ) 
{
+  Multilib::flags_list Flags;
+  StringRef Arch = riscv::getRISCVArch(Args, TargetTriple);
+  StringRef Abi = tools::riscv::getRISCVABI(Args, TargetTriple);
+
+  if (TargetTriple.getArch() == llvm::Triple::riscv64) {
+Multilib Imac = 
makeMultilib("").flag("+march=rv64imac").flag("+mabi=lp64");
+Multilib Imafdc = makeMultilib("/rv64imafdc/lp64d")
+  .flag("+march=rv64imafdc")
+  .flag("+mabi=lp64d");
+
+// Multilib reuse
+bool UseImafdc =
+(Arch == "rv64imafdc") || (Arch == "rv64gc"); // gc => imafdc
+
+addMultilibFlag((Arch == "rv64imac"), "march=rv64imac", Flags);
+addMultilibFlag(UseImafdc, "march=rv64imafdc", Flags);
+addMultilibFlag(Abi == "lp64", "mabi=lp64", Flags);
+addMultilibFlag(Abi == "lp64d", "mabi=lp64d", Flags);
+
+Result.Multilibs = MultilibSet().Either(Imac, Imafdc);
+return Result.Multilibs.select(Flags, Result.SelectedMultilib);
+  }
+  if (TargetTriple.getArch() == llvm::Triple::riscv32) {
+Multilib Imac =
+makeMultilib("").flag("+march=rv32imac").flag("+mabi=ilp32");
+Multilib I =
+makeMultilib("/rv32i/ilp32").flag("+march=rv32i").flag("+mabi=ilp32");
+Multilib Im =
+
makeMultilib("/rv32im/ilp32").flag("+march=rv32im").flag("+mabi=ilp32");
+Multilib Iac = makeMultilib("/rv32iac/ilp32")
+   .flag("+march=rv32iac")
+   .flag("+mabi=ilp32");
+Multilib Imafc = makeMultilib("/rv32imafc/ilp32f")
+ .flag("+march=rv32imafc")
+ .flag("+mabi=ilp32f");
+
+// Multilib reuse
+bool UseI = (Arch == "rv32i") || (Arch == "rv32ic");// ic => i
+bool UseIm = (Arch == "rv32im") || (Arch == "rv32imc"); // imc => im
+bool UseImafc = (Arch == "rv32imafc") || (Arch == "rv32imafdc") ||
+(Arch == "rv32gc"); // imafdc,gc => imafc
+
+addMultilibFlag(UseI, "march=rv32i", Flags);
+addMultilibFlag(UseIm, "march=rv32im", Flags);
+addMultilibFlag((Arch == "rv32iac"), "march=rv32iac", Flags);
+addMultilibFlag((Arch == "rv32imac"), "march=rv32imac", Flags);
+addMultilibFlag(UseImafc, "march=rv32imafc", Flags);
+addMultilibFlag(Abi == "ilp32", "mabi=ilp32", Flags);
+addMultilibFlag(Abi == "ilp32f", "mabi=ilp32f", Flags);
+
+Result.Multilibs = MultilibSet().Either(I, Im, Iac, Imac, Imafc);
+return Result.Multilibs.select(Flags, Result.SelectedMultilib);
+  }
+  return false;
+}
+
 BareMetal::BareMetal(const Driver , const llvm::Triple ,
const ArgList )
 : ToolChain(D, Triple, Args) {
   getProgramPaths().push_back(getDriver().getInstalledDir());
   if (getDriver().getInstalledDir() != getDriver().Dir)
 

[llvm-branch-commits] [llvm] d50d7c3 - [MBP] Prevent rotating a chain contains entry block

2020-12-14 Thread Guozhi Wei via llvm-branch-commits

Author: Guozhi Wei
Date: 2020-12-14T12:48:55-08:00
New Revision: d50d7c37a159802c89454a6c53c0ec2e7949d84a

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

LOG: [MBP] Prevent rotating a chain contains entry block

The entry block should always be the first BB in a function.
So we should not rotate a chain contains the entry block.

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

Added: 


Modified: 
llvm/lib/CodeGen/MachineBlockPlacement.cpp

Removed: 




diff  --git a/llvm/lib/CodeGen/MachineBlockPlacement.cpp 
b/llvm/lib/CodeGen/MachineBlockPlacement.cpp
index bd4640822a63..42586cbe06e0 100644
--- a/llvm/lib/CodeGen/MachineBlockPlacement.cpp
+++ b/llvm/lib/CodeGen/MachineBlockPlacement.cpp
@@ -2306,6 +2306,10 @@ void MachineBlockPlacement::rotateLoop(BlockChain 
,
   if (Bottom == ExitingBB)
 return;
 
+  // The entry block should always be the first BB in a function.
+  if (Top->isEntryBlock())
+return;
+
   bool ViableTopFallthrough = hasViableTopFallthrough(Top, LoopBlockSet);
 
   // If the header has viable fallthrough, check whether the current loop
@@ -2380,6 +2384,11 @@ void MachineBlockPlacement::rotateLoopWithProfile(
 BlockChain , const MachineLoop ,
 const BlockFilterSet ) {
   auto RotationPos = LoopChain.end();
+  MachineBasicBlock *ChainHeaderBB = *LoopChain.begin();
+
+  // The entry block should always be the first BB in a function.
+  if (ChainHeaderBB->isEntryBlock())
+return;
 
   BlockFrequency SmallestRotationCost = BlockFrequency::getMaxFrequency();
 
@@ -2398,7 +2407,6 @@ void MachineBlockPlacement::rotateLoopWithProfile(
   // chain head is not the loop header. As we only consider natural loops with
   // single header, this computation can be done only once.
   BlockFrequency HeaderFallThroughCost(0);
-  MachineBasicBlock *ChainHeaderBB = *LoopChain.begin();
   for (auto *Pred : ChainHeaderBB->predecessors()) {
 BlockChain *PredChain = BlockToChain[Pred];
 if (!LoopBlockSet.count(Pred) &&



___
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] f5fe849 - [LAA] Relax restrictions on early exits in loop structure

2020-12-14 Thread Philip Reames via llvm-branch-commits

Author: Philip Reames
Date: 2020-12-14T12:44:01-08:00
New Revision: f5fe8493e5acfd70da61993cd370816978b9ef85

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

LOG: [LAA] Relax restrictions on early exits in loop structure

his is a preparation patch for supporting multiple exits in the loop 
vectorizer, by itself it should be mostly NFC. This patch moves the loop 
structure checks from LAA to their respective consumers (where duplicates don't 
already exist).  Moving the checks does end up changing some of the 
optimization warnings and debug output slightly, but nothing that appears to be 
a regression.

Why do this? Well, after auditing the code, I can't actually find anything in 
LAA itself which relies on having all instructions within a loop execute an 
equal number of times. This patch simply makes this explicit so that if one 
consumer - say LV in the near future (hopefully) - wants to handle a broader 
class of loops, it can do so.

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

Added: 


Modified: 
llvm/lib/Analysis/LoopAccessAnalysis.cpp
llvm/lib/Transforms/Scalar/LoopDistribute.cpp
llvm/lib/Transforms/Scalar/LoopLoadElimination.cpp
llvm/lib/Transforms/Utils/LoopVersioning.cpp

Removed: 




diff  --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp 
b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
index 65d39161c1be..be340a3b3130 100644
--- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp
+++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
@@ -1781,26 +1781,6 @@ bool LoopAccessInfo::canAnalyzeLoop() {
 return false;
   }
 
-  // We must have a single exiting block.
-  if (!TheLoop->getExitingBlock()) {
-LLVM_DEBUG(
-dbgs() << "LAA: loop control flow is not understood by analyzer\n");
-recordAnalysis("CFGNotUnderstood")
-<< "loop control flow is not understood by analyzer";
-return false;
-  }
-
-  // We only handle bottom-tested loops, i.e. loop in which the condition is
-  // checked at the end of each iteration. With that we can assume that all
-  // instructions in the loop are executed the same number of times.
-  if (TheLoop->getExitingBlock() != TheLoop->getLoopLatch()) {
-LLVM_DEBUG(
-dbgs() << "LAA: loop control flow is not understood by analyzer\n");
-recordAnalysis("CFGNotUnderstood")
-<< "loop control flow is not understood by analyzer";
-return false;
-  }
-
   // ScalarEvolution needs to be able to find the exit count.
   const SCEV *ExitCount = PSE->getBackedgeTakenCount();
   if (isa(ExitCount)) {

diff  --git a/llvm/lib/Transforms/Scalar/LoopDistribute.cpp 
b/llvm/lib/Transforms/Scalar/LoopDistribute.cpp
index 98d67efef922..3dd7d9dce67a 100644
--- a/llvm/lib/Transforms/Scalar/LoopDistribute.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopDistribute.cpp
@@ -670,15 +670,17 @@ class LoopDistributeForLoop {
   << L->getHeader()->getParent()->getName()
   << "\" checking " << *L << "\n");
 
+// Having a single exit block implies there's also one exiting block.
 if (!L->getExitBlock())
   return fail("MultipleExitBlocks", "multiple exit blocks");
 if (!L->isLoopSimplifyForm())
   return fail("NotLoopSimplifyForm",
   "loop is not in loop-simplify form");
+if (!L->isRotatedForm())
+  return fail("NotBottomTested", "loop is not bottom tested");
 
 BasicBlock *PH = L->getLoopPreheader();
 
-// LAA will check that we only have a single exiting block.
 LAI = (*L);
 
 // Currently, we only distribute to isolate the part of the loop with

diff  --git a/llvm/lib/Transforms/Scalar/LoopLoadElimination.cpp 
b/llvm/lib/Transforms/Scalar/LoopLoadElimination.cpp
index 475448740ae4..56afddead619 100644
--- a/llvm/lib/Transforms/Scalar/LoopLoadElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopLoadElimination.cpp
@@ -632,6 +632,9 @@ eliminateLoadsAcrossLoops(Function , LoopInfo , 
DominatorTree ,
 
   // Now walk the identified inner loops.
   for (Loop *L : Worklist) {
+// Match historical behavior
+if (!L->isRotatedForm() || !L->getExitingBlock())
+  continue;
 // The actual work is performed by LoadEliminationForLoop.
 LoadEliminationForLoop LEL(L, , GetLAI(*L), , BFI, PSI);
 Changed |= LEL.processLoop();

diff  --git a/llvm/lib/Transforms/Utils/LoopVersioning.cpp 
b/llvm/lib/Transforms/Utils/LoopVersioning.cpp
index 03eb41b5ee0d..b605cb2fb865 100644
--- a/llvm/lib/Transforms/Utils/LoopVersioning.cpp
+++ b/llvm/lib/Transforms/Utils/LoopVersioning.cpp
@@ -269,8 +269,11 @@ bool runImpl(LoopInfo *LI, function_ref GetLAA,
   // Now walk the identified inner loops.
   bool Changed = false;
   for (Loop *L : Worklist) {
+if (!L->isLoopSimplifyForm() || !L->isRotatedForm() ||
+

[llvm-branch-commits] [mlir] 6af2c4c - [mlir] Change the internal representation of FrozenRewritePatternList to use shared_ptr

2020-12-14 Thread River Riddle via llvm-branch-commits

Author: River Riddle
Date: 2020-12-14T12:32:44-08:00
New Revision: 6af2c4ca9bdb37e56cfda8dae4f6c3c6ca21b8d7

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

LOG: [mlir] Change the internal representation of FrozenRewritePatternList to 
use shared_ptr

This will allow for caching pattern lists across multiple pass instances, such 
as when multithreading. This is an extremely important invariant for PDL 
patterns, which are compiled at runtime when the FrozenRewritePatternList is 
built.

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

Added: 


Modified: 
mlir/include/mlir/Rewrite/FrozenRewritePatternList.h
mlir/lib/Rewrite/FrozenRewritePatternList.cpp

Removed: 




diff  --git a/mlir/include/mlir/Rewrite/FrozenRewritePatternList.h 
b/mlir/include/mlir/Rewrite/FrozenRewritePatternList.h
index c2335b9dd5a1..0e583aab3dc4 100644
--- a/mlir/include/mlir/Rewrite/FrozenRewritePatternList.h
+++ b/mlir/include/mlir/Rewrite/FrozenRewritePatternList.h
@@ -18,34 +18,52 @@ class PDLByteCode;
 
 /// This class represents a frozen set of patterns that can be processed by a
 /// pattern applicator. This class is designed to enable caching pattern lists
-/// such that they need not be continuously recomputed.
+/// such that they need not be continuously recomputed. Note that all copies of
+/// this class share the same compiled pattern list, allowing for a reduction 
in
+/// the number of duplicated patterns that need to be created.
 class FrozenRewritePatternList {
   using NativePatternListT = std::vector>;
 
 public:
   /// Freeze the patterns held in `patterns`, and take ownership.
+  FrozenRewritePatternList();
   FrozenRewritePatternList(OwningRewritePatternList &);
-  FrozenRewritePatternList(FrozenRewritePatternList &);
+  FrozenRewritePatternList(FrozenRewritePatternList &) = default;
+  FrozenRewritePatternList(const FrozenRewritePatternList ) = default;
+  FrozenRewritePatternList &
+  operator=(const FrozenRewritePatternList ) = default;
+  FrozenRewritePatternList &
+  operator=(FrozenRewritePatternList &) = default;
   ~FrozenRewritePatternList();
 
   /// Return the native patterns held by this list.
   iterator_range>
   getNativePatterns() const {
+const NativePatternListT  = impl->nativePatterns;
 return llvm::make_pointee_range(nativePatterns);
   }
 
   /// Return the compiled PDL bytecode held by this list. Returns null if
   /// there are no PDL patterns within the list.
   const detail::PDLByteCode *getPDLByteCode() const {
-return pdlByteCode.get();
+return impl->pdlByteCode.get();
   }
 
 private:
-  /// The set of.
-  std::vector> nativePatterns;
+  /// The internal implementation of the frozen pattern list.
+  struct Impl {
+/// The set of native C++ rewrite patterns.
+NativePatternListT nativePatterns;
 
-  /// The bytecode containing the compiled PDL patterns.
-  std::unique_ptr pdlByteCode;
+/// The bytecode containing the compiled PDL patterns.
+std::unique_ptr pdlByteCode;
+  };
+
+  /// A pointer to the internal pattern list. This uses a shared_ptr to avoid
+  /// the need to compile the same pattern list multiple times. For example,
+  /// during multi-threaded pass execution, all copies of a pass can share the
+  /// same pattern list.
+  std::shared_ptr impl;
 };
 
 } // end namespace mlir

diff  --git a/mlir/lib/Rewrite/FrozenRewritePatternList.cpp 
b/mlir/lib/Rewrite/FrozenRewritePatternList.cpp
index 60f6dcea88f2..40d7fcde8f33 100644
--- a/mlir/lib/Rewrite/FrozenRewritePatternList.cpp
+++ b/mlir/lib/Rewrite/FrozenRewritePatternList.cpp
@@ -50,12 +50,16 @@ static LogicalResult convertPDLToPDLInterp(ModuleOp 
pdlModule) {
 // FrozenRewritePatternList
 
//===--===//
 
+FrozenRewritePatternList::FrozenRewritePatternList()
+: impl(std::make_shared()) {}
+
 FrozenRewritePatternList::FrozenRewritePatternList(
 OwningRewritePatternList &)
-: nativePatterns(std::move(patterns.getNativePatterns())) {
-  PDLPatternModule  = patterns.getPDLPatterns();
+: impl(std::make_shared()) {
+  impl->nativePatterns = std::move(patterns.getNativePatterns());
 
   // Generate the bytecode for the PDL patterns if any were provided.
+  PDLPatternModule  = patterns.getPDLPatterns();
   ModuleOp pdlModule = pdlPatterns.getModule();
   if (!pdlModule)
 return;
@@ -64,14 +68,9 @@ FrozenRewritePatternList::FrozenRewritePatternList(
 "failed to lower PDL pattern module to the PDL Interpreter");
 
   // Generate the pdl bytecode.
-  pdlByteCode = std::make_unique(
+  impl->pdlByteCode = std::make_unique(
   pdlModule, pdlPatterns.takeConstraintFunctions(),
   pdlPatterns.takeCreateFunctions(), pdlPatterns.takeRewriteFunctions());
 }
 

[llvm-branch-commits] [mlir] 6f271e9 - [mlir] Remove methods from mlir::OpState that just forward to mlir::Operation.

2020-12-14 Thread Christian Sigg via llvm-branch-commits

Author: Christian Sigg
Date: 2020-12-14T21:26:14+01:00
New Revision: 6f271e921ba48f4c4fa54bbd2c7a4c548ca5e59e

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

LOG: [mlir] Remove methods from mlir::OpState that just forward to 
mlir::Operation.

All call sites have been converted in previous changes.

Reviewed By: mehdi_amini

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

Added: 


Modified: 
mlir/include/mlir/IR/OpDefinition.h

Removed: 




diff  --git a/mlir/include/mlir/IR/OpDefinition.h 
b/mlir/include/mlir/IR/OpDefinition.h
index b200f7c2dc6c..2edc48dd099e 100644
--- a/mlir/include/mlir/IR/OpDefinition.h
+++ b/mlir/include/mlir/IR/OpDefinition.h
@@ -108,27 +108,6 @@ class OpState {
   /// Return the operation that this refers to.
   Operation *getOperation() { return state; }
 
-  /// Return the dialect that this refers to.
-  Dialect *getDialect() { return getOperation()->getDialect(); }
-
-  /// Return the parent Region of this operation.
-  Region *getParentRegion() { return getOperation()->getParentRegion(); }
-
-  /// Returns the closest surrounding operation that contains this operation
-  /// or nullptr if this is a top-level operation.
-  Operation *getParentOp() { return getOperation()->getParentOp(); }
-
-  /// Return the closest surrounding parent operation that is of type 'OpTy'.
-  template  OpTy getParentOfType() {
-return getOperation()->getParentOfType();
-  }
-
-  /// Returns the closest surrounding parent operation with trait `Trait`.
-  template  class Trait>
-  Operation *getParentWithTrait() {
-return getOperation()->getParentWithTrait();
-  }
-
   /// Return the context this operation belongs to.
   MLIRContext *getContext() { return getOperation()->getContext(); }
 
@@ -155,36 +134,6 @@ class OpState {
   using dialect_attr_iterator = Operation::dialect_attr_iterator;
   using dialect_attr_range = Operation::dialect_attr_range;
 
-  /// Return a range corresponding to the dialect attributes for this 
operation.
-  dialect_attr_range getDialectAttrs() { return state->getDialectAttrs(); }
-  dialect_attr_iterator dialect_attr_begin() {
-return state->dialect_attr_begin();
-  }
-  dialect_attr_iterator dialect_attr_end() { return state->dialect_attr_end(); 
}
-
-  /// Return an attribute with the specified name.
-  Attribute getAttr(StringRef name) { return state->getAttr(name); }
-
-  /// If the operation has an attribute of the specified type, return it.
-  template  AttrClass getAttrOfType(StringRef name) {
-return getAttr(name).dyn_cast_or_null();
-  }
-
-  /// If the an attribute exists with the specified name, change it to the new
-  /// value.  Otherwise, add a new attribute with the specified name/value.
-  void setAttr(Identifier name, Attribute value) {
-state->setAttr(name, value);
-  }
-  void setAttr(StringRef name, Attribute value) {
-setAttr(Identifier::get(name, getContext()), value);
-  }
-
-  /// Set the attributes held by this operation.
-  void setAttrs(ArrayRef attributes) {
-state->setAttrs(attributes);
-  }
-  void setAttrs(MutableDictionaryAttr newAttrs) { state->setAttrs(newAttrs); }
-
   /// Set the dialect attributes for this operation, and preserve all 
dependent.
   template  void setDialectAttrs(DialectAttrs &) {
 state->setDialectAttrs(std::move(attrs));



___
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] 2aa4335 - [flang] Fix copy elision assumption.

2020-12-14 Thread Michael Kruse via llvm-branch-commits

Author: Michael Kruse
Date: 2020-12-14T14:07:05-06:00
New Revision: 2aa43358060c6b34fb9cdc6c4321e958f62331e7

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

LOG: [flang] Fix copy elision assumption.

Before this patch, the Restorer depended on copy elision to happen.
Without copy elision, the function ScopedSet calls the move constructor
before its dtor. The dtor will prematurely restore the reference to the
original value.

Instead of relying the compiler to not use the Restorer's copy
constructor, delete its copy and assign operators. Hence, callers cannot
move or copy a Restorer object anymore, and have to explicitly provide
the reset state. ScopedSet avoids calling move/copy operations by
relying on unnamed return value optimization, which is mandatory in
C++17.

Reviewed By: klausler

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

Added: 


Modified: 
flang/include/flang/Common/restorer.h
flang/lib/Semantics/check-declarations.cpp

Removed: 




diff  --git a/flang/include/flang/Common/restorer.h 
b/flang/include/flang/Common/restorer.h
index 47e54237fe43..4d5f5e4e2c81 100644
--- a/flang/include/flang/Common/restorer.h
+++ b/flang/include/flang/Common/restorer.h
@@ -22,9 +22,16 @@
 namespace Fortran::common {
 template  class Restorer {
 public:
-  explicit Restorer(A ) : p_{p}, original_{std::move(p)} {}
+  explicit Restorer(A , A original) : p_{p}, original_{std::move(original)} 
{}
   ~Restorer() { p_ = std::move(original_); }
 
+  // Inhibit any recreation of this restorer that would result in two restorers
+  // trying to restore the same reference.
+  Restorer(const Restorer &) = delete;
+  Restorer(Restorer &) = delete;
+  const Restorer =(const Restorer &) = delete;
+  const Restorer =(Restorer &) = delete;
+
 private:
   A _;
   A original_;
@@ -32,15 +39,15 @@ template  class Restorer {
 
 template 
 common::IfNoLvalue, B> ScopedSet(A , B &) {
-  Restorer result{to};
+  A original{std::move(to)};
   to = std::move(from);
-  return result;
+  return Restorer{to, std::move(original)};
 }
 template 
 common::IfNoLvalue, B> ScopedSet(A , const B ) {
-  Restorer result{to};
+  A original{std::move(to)};
   to = from;
-  return result;
+  return Restorer{to, std::move(original)};
 }
 } // namespace Fortran::common
 #endif // FORTRAN_COMMON_RESTORER_H_

diff  --git a/flang/lib/Semantics/check-declarations.cpp 
b/flang/lib/Semantics/check-declarations.cpp
index 0d2e2e86241c..dd76f6710070 100644
--- a/flang/lib/Semantics/check-declarations.cpp
+++ b/flang/lib/Semantics/check-declarations.cpp
@@ -1498,7 +1498,7 @@ void CheckHelper::CheckProcBinding(
 
 void CheckHelper::Check(const Scope ) {
   scope_ = 
-  common::Restorer restorer{innermostSymbol_};
+  common::Restorer restorer{innermostSymbol_, 
innermostSymbol_};
   if (const Symbol * symbol{scope.symbol()}) {
 innermostSymbol_ = symbol;
   }



___
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] 6bc9439 - [mlir][OpAsmParser] Add support for parsing integer literals without going through IntegerAttr

2020-12-14 Thread River Riddle via llvm-branch-commits

Author: River Riddle
Date: 2020-12-14T12:00:43-08:00
New Revision: 6bc9439f59acbcc5e46a108c2f74a4d5ffe55a3b

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

LOG: [mlir][OpAsmParser] Add support for parsing integer literals without going 
through IntegerAttr

Some operations use integer literals as part of their custom format that don't 
necessarily map to an internal IntegerAttr. This revision exposes the same 
`parseInteger` functions as the DialectAsmParser to allow for these operations 
to parse integer literals without incurring the otherwise unnecessary roundtrip 
through IntegerAttr.

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

Added: 


Modified: 
mlir/include/mlir/IR/OpImplementation.h
mlir/lib/Parser/DialectSymbolParser.cpp
mlir/lib/Parser/Parser.cpp
mlir/lib/Parser/Parser.h
mlir/test/IR/parser.mlir
mlir/test/lib/Dialect/Test/TestDialect.cpp
mlir/test/lib/Dialect/Test/TestOps.td

Removed: 




diff  --git a/mlir/include/mlir/IR/OpImplementation.h 
b/mlir/include/mlir/IR/OpImplementation.h
index 31d3b42c8493..f74eb52aec6d 100644
--- a/mlir/include/mlir/IR/OpImplementation.h
+++ b/mlir/include/mlir/IR/OpImplementation.h
@@ -413,6 +413,35 @@ class OpAsmParser {
   /// Parse a `...` token if present;
   virtual ParseResult parseOptionalEllipsis() = 0;
 
+  /// Parse an integer value from the stream.
+  template  ParseResult parseInteger(IntT ) {
+auto loc = getCurrentLocation();
+OptionalParseResult parseResult = parseOptionalInteger(result);
+if (!parseResult.hasValue())
+  return emitError(loc, "expected integer value");
+return *parseResult;
+  }
+
+  /// Parse an optional integer value from the stream.
+  virtual OptionalParseResult parseOptionalInteger(uint64_t ) = 0;
+
+  template 
+  OptionalParseResult parseOptionalInteger(IntT ) {
+auto loc = getCurrentLocation();
+
+// Parse the unsigned variant.
+uint64_t uintResult;
+OptionalParseResult parseResult = parseOptionalInteger(uintResult);
+if (!parseResult.hasValue() || failed(*parseResult))
+  return parseResult;
+
+// Try to convert to the provided integer type.
+result = IntT(uintResult);
+if (uint64_t(result) != uintResult)
+  return emitError(loc, "integer value too large");
+return success();
+  }
+
   
//======//
   // Attribute Parsing
   
//======//

diff  --git a/mlir/lib/Parser/DialectSymbolParser.cpp 
b/mlir/lib/Parser/DialectSymbolParser.cpp
index 3bbc495cab65..11e7e237a192 100644
--- a/mlir/lib/Parser/DialectSymbolParser.cpp
+++ b/mlir/lib/Parser/DialectSymbolParser.cpp
@@ -82,20 +82,7 @@ class CustomDialectAsmParser : public DialectAsmParser {
 
   /// Parse an optional integer value from the stream.
   OptionalParseResult parseOptionalInteger(uint64_t ) override {
-Token curToken = parser.getToken();
-if (curToken.isNot(Token::integer, Token::minus))
-  return llvm::None;
-
-bool negative = parser.consumeIf(Token::minus);
-Token curTok = parser.getToken();
-if (parser.parseToken(Token::integer, "expected integer value"))
-  return failure();
-
-auto val = curTok.getUInt64IntegerValue();
-if (!val)
-  return emitError(curTok.getLoc(), "integer value too large");
-result = negative ? -*val : *val;
-return success();
+return parser.parseOptionalInteger(result);
   }
 
   
//======//

diff  --git a/mlir/lib/Parser/Parser.cpp b/mlir/lib/Parser/Parser.cpp
index 47fef1ca393c..58ed9004c56c 100644
--- a/mlir/lib/Parser/Parser.cpp
+++ b/mlir/lib/Parser/Parser.cpp
@@ -94,6 +94,24 @@ ParseResult Parser::parseToken(Token::Kind expectedToken,
   return emitError(message);
 }
 
+/// Parse an optional integer value from the stream.
+OptionalParseResult Parser::parseOptionalInteger(uint64_t ) {
+  Token curToken = getToken();
+  if (curToken.isNot(Token::integer, Token::minus))
+return llvm::None;
+
+  bool negative = consumeIf(Token::minus);
+  Token curTok = getToken();
+  if (parseToken(Token::integer, "expected integer value"))
+return failure();
+
+  auto val = curTok.getUInt64IntegerValue();
+  if (!val)
+return emitError(curTok.getLoc(), "integer value too large");
+  result = negative ? -*val : *val;
+  return success();
+}
+
 
//===--===//
 // OperationParser
 
//===--===//
@@ -1109,6 +1127,11 @@ class CustomOpAsmParser : public OpAsmParser {
 return success(parser.consumeIf(Token::star));
   }
 
+  /// 

[llvm-branch-commits] [mlir] c234b65 - [mlir][OpFormat] Add support for emitting newlines from the custom format of an operation

2020-12-14 Thread River Riddle via llvm-branch-commits

Author: River Riddle
Date: 2020-12-14T12:00:43-08:00
New Revision: c234b65cef07b38c91b9ab7dec6a35f8b390e658

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

LOG: [mlir][OpFormat] Add support for emitting newlines from the custom format 
of an operation

This revision adds a new `printNewline` hook to OpAsmPrinter that allows for 
printing a newline within the custom format of an operation, that is then 
indented to the start of the operation. Support for the declarative assembly 
format is also added, in the form of a `\n` literal.

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

Added: 


Modified: 
mlir/docs/OpDefinitions.md
mlir/include/mlir/IR/OpImplementation.h
mlir/lib/IR/AsmPrinter.cpp
mlir/test/lib/Dialect/Test/TestOps.td
mlir/test/mlir-tblgen/op-format-spec.td
mlir/test/mlir-tblgen/op-format.mlir
mlir/tools/mlir-tblgen/OpFormatGen.cpp

Removed: 




diff  --git a/mlir/docs/OpDefinitions.md b/mlir/docs/OpDefinitions.md
index a267a60adc3e..189cd0825af7 100644
--- a/mlir/docs/OpDefinitions.md
+++ b/mlir/docs/OpDefinitions.md
@@ -646,6 +646,30 @@ The following are the set of valid punctuation:
 
 `:`, `,`, `=`, `<`, `>`, `(`, `)`, `{`, `}`, `[`, `]`, `->`, `?`, `+`, `*`
 
+The following are valid whitespace punctuation:
+
+`\n`, ` `
+
+The `\n` literal emits a newline an indents to the start of the operation. An
+example is shown below:
+
+```tablegen
+let assemblyFormat = [{
+  `{` `\n` ` ` ` ` `this_is_on_a_newline` `\n` `}` attr-dict
+}];
+```
+
+```mlir
+%results = my.operation {
+  this_is_on_a_newline
+}
+```
+
+An empty literal \`\` may be used to remove a space that is inserted implicitly
+after certain literal elements, such as `)`/`]`/etc. For example, "`]`" may
+result in an output of `]` it is not the last element in the format. "`]` \`\`"
+would trim the trailing space in this situation.
+
  Variables
 
 A variable is an entity that has been registered on the operation itself, i.e.

diff  --git a/mlir/include/mlir/IR/OpImplementation.h 
b/mlir/include/mlir/IR/OpImplementation.h
index a7e87dc0ab06..31d3b42c8493 100644
--- a/mlir/include/mlir/IR/OpImplementation.h
+++ b/mlir/include/mlir/IR/OpImplementation.h
@@ -36,6 +36,10 @@ class OpAsmPrinter {
   virtual ~OpAsmPrinter();
   virtual raw_ostream () const = 0;
 
+  /// Print a newline and indent the printer to the start of the current
+  /// operation.
+  virtual void printNewline() = 0;
+
   /// Print implementations for various things an operation contains.
   virtual void printOperand(Value value) = 0;
   virtual void printOperand(Value value, raw_ostream ) = 0;

diff  --git a/mlir/lib/IR/AsmPrinter.cpp b/mlir/lib/IR/AsmPrinter.cpp
index 49e7048cfb13..1c2caa0bdfd6 100644
--- a/mlir/lib/IR/AsmPrinter.cpp
+++ b/mlir/lib/IR/AsmPrinter.cpp
@@ -429,6 +429,7 @@ class DummyAliasOperationPrinter : private OpAsmPrinter {
   /// The following are hooks of `OpAsmPrinter` that are not necessary for
   /// determining potential aliases.
   void printAffineMapOfSSAIds(AffineMapAttr, ValueRange) override {}
+  void printNewline() override {}
   void printOperand(Value) override {}
   void printOperand(Value, raw_ostream ) override {
 // Users expect the output string to have at least the prefixed % to signal
@@ -2218,6 +2219,13 @@ class OperationPrinter : public ModulePrinter, private 
OpAsmPrinter {
   /// Return the current stream of the printer.
   raw_ostream () const override { return os; }
 
+  /// Print a newline and indent the printer to the start of the current
+  /// operation.
+  void printNewline() override {
+os << newLine;
+os.indent(currentIndent);
+  }
+
   /// Print the given type.
   void printType(Type type) override { ModulePrinter::printType(type); }
 

diff  --git a/mlir/test/lib/Dialect/Test/TestOps.td 
b/mlir/test/lib/Dialect/Test/TestOps.td
index 6a7291abfec7..9a7eb5940fb9 100644
--- a/mlir/test/lib/Dialect/Test/TestOps.td
+++ b/mlir/test/lib/Dialect/Test/TestOps.td
@@ -1393,7 +1393,8 @@ def AsmDialectInterfaceOp : 
TEST_Op<"asm_dialect_interface_op"> {
 
 def FormatLiteralOp : TEST_Op<"format_literal_op"> {
   let assemblyFormat = [{
-`keyword_$.` `->` `:` `,` `=` `<` `>` `(` `)` `[` `]` `` `(` ` ` `)` `?` 
`+` `*` attr-dict
+`keyword_$.` `->` `:` `,` `=` `<` `>` `(` `)` `[` `]` `` `(` ` ` `)`
+`?` `+` `*` `{` `\n` `}` attr-dict
   }];
 }
 

diff  --git a/mlir/test/mlir-tblgen/op-format-spec.td 
b/mlir/test/mlir-tblgen/op-format-spec.td
index 7817920f8955..424dbb83c276 100644
--- a/mlir/test/mlir-tblgen/op-format-spec.td
+++ b/mlir/test/mlir-tblgen/op-format-spec.td
@@ -309,7 +309,7 @@ def LiteralInvalidB : TestFormat_Op<"literal_invalid_b", [{
 }]>;
 // CHECK-NOT: error
 def LiteralValid : TestFormat_Op<"literal_valid", [{
-  `_` `:` 

[llvm-branch-commits] [clang] 0936655 - [CUDA] Do not diagnose host/device variable access in dependent types.

2020-12-14 Thread Artem Belevich via llvm-branch-commits

Author: Artem Belevich
Date: 2020-12-14T11:53:18-08:00
New Revision: 0936655bac78f6e9cb84dc3feb30c32012100839

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

LOG: [CUDA] Do not diagnose host/device variable access in dependent types.

`isCUDADeviceBuiltinSurfaceType()`/`isCUDADeviceBuiltinTextureType()` do not
work on dependent types as they rely on specific type attributes.

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

Added: 


Modified: 
clang/include/clang/Basic/Attr.td
clang/test/SemaCUDA/device-use-host-var.cu

Removed: 




diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 51f654fc7613..79902c8f5b89 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -1079,6 +1079,7 @@ def CUDADeviceBuiltinSurfaceType : InheritableAttr {
   let LangOpts = [CUDA];
   let Subjects = SubjectList<[CXXRecord]>;
   let Documentation = [CUDADeviceBuiltinSurfaceTypeDocs];
+  let MeaningfulToClassTemplateDefinition = 1;
 }
 
 def CUDADeviceBuiltinTextureType : InheritableAttr {
@@ -1087,6 +1088,7 @@ def CUDADeviceBuiltinTextureType : InheritableAttr {
   let LangOpts = [CUDA];
   let Subjects = SubjectList<[CXXRecord]>;
   let Documentation = [CUDADeviceBuiltinTextureTypeDocs];
+  let MeaningfulToClassTemplateDefinition = 1;
 }
 
 def CUDAGlobal : InheritableAttr {

diff  --git a/clang/test/SemaCUDA/device-use-host-var.cu 
b/clang/test/SemaCUDA/device-use-host-var.cu
index cf5514610a42..c8ef7dbbb18d 100644
--- a/clang/test/SemaCUDA/device-use-host-var.cu
+++ b/clang/test/SemaCUDA/device-use-host-var.cu
@@ -158,3 +158,23 @@ void dev_lambda_capture_by_copy(int *out) {
   });
 }
 
+// Texture references are special. As far as C++ is concerned they are host
+// variables that are referenced from device code. However, they are handled
+// very 
diff erently by the compiler under the hood and such references are
+// allowed. Compiler should produce no warning here, but it should diagnose the
+// same case without the device_builtin_texture_type attribute.
+template 
+struct __attribute__((device_builtin_texture_type)) texture {
+  static texture ref;
+  __device__ int c() {
+auto  = ref;
+  }
+};
+
+template 
+struct  not_a_texture {
+  static not_a_texture ref;
+  __device__ int c() {
+auto  = ref; // dev-error {{reference to __host__ variable 'ref' in 
__device__ function}}
+  }
+};



___
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] 9c1765a - [VectorCombine] add test for load with offset; NFC

2020-12-14 Thread Sanjay Patel via llvm-branch-commits

Author: Sanjay Patel
Date: 2020-12-14T14:40:06-05:00
New Revision: 9c1765acabf10b7df7cf49456a06bbba2b33b364

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

LOG: [VectorCombine] add test for load with offset; NFC

Added: 


Modified: 
llvm/test/Transforms/VectorCombine/X86/load.ll

Removed: 




diff  --git a/llvm/test/Transforms/VectorCombine/X86/load.ll 
b/llvm/test/Transforms/VectorCombine/X86/load.ll
index 824a507ed103..ba2bf3f37d7b 100644
--- a/llvm/test/Transforms/VectorCombine/X86/load.ll
+++ b/llvm/test/Transforms/VectorCombine/X86/load.ll
@@ -535,3 +535,20 @@ define <8 x i32> 
@load_v1i32_extract_insert_v8i32_extra_use(<1 x i32>* align 16
   %r = insertelement <8 x i32> undef, i32 %s, i32 0
   ret <8 x i32> %r
 }
+
+; TODO: Can't safely load the offset vector, but can load+shuffle if it is 
profitable.
+
+define <8 x i16> @gep1_load_v2i16_extract_insert_v8i16(<2 x i16>* align 16 
dereferenceable(16) %p) {
+; CHECK-LABEL: @gep1_load_v2i16_extract_insert_v8i16(
+; CHECK-NEXT:[[GEP:%.*]] = getelementptr inbounds <2 x i16>, <2 x i16>* 
[[P:%.*]], i64 1
+; CHECK-NEXT:[[L:%.*]] = load <2 x i16>, <2 x i16>* [[GEP]], align 2
+; CHECK-NEXT:[[S:%.*]] = extractelement <2 x i16> [[L]], i32 0
+; CHECK-NEXT:[[R:%.*]] = insertelement <8 x i16> undef, i16 [[S]], i64 0
+; CHECK-NEXT:ret <8 x i16> [[R]]
+;
+  %gep = getelementptr inbounds <2 x i16>, <2 x i16>* %p, i64 1
+  %l = load <2 x i16>, <2 x i16>* %gep, align 2
+  %s = extractelement <2 x i16> %l, i32 0
+  %r = insertelement <8 x i16> undef, i16 %s, i64 0
+  ret <8 x i16> %r
+}



___
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] 55fc64b - [Hexagon] Tweak _MSC_VER workaround version

2020-12-14 Thread Reid Kleckner via llvm-branch-commits

Author: Reid Kleckner
Date: 2020-12-14T11:26:36-08:00
New Revision: 55fc64bce08a30f1bf7f7ebf83df776a40700fbe

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

LOG: [Hexagon] Tweak _MSC_VER workaround version

My bot runs VS 2019, but it could not compile this code.

Message:
[55/2465] Building CXX object 
lib\Target\Hexagon\CMakeFiles\LLVMHexagonCodeGen.dir\HexagonVectorCombine.cpp.obj
FAILED: 
lib/Target/Hexagon/CMakeFiles/LLVMHexagonCodeGen.dir/HexagonVectorCombine.cpp.obj
...
C:\Program Files (x86)\Microsoft Visual 
Studio\2019\Professional\VC\Tools\MSVC\14.23.28105\include\map(71): error 
C2976: 'std::map': too few template arguments
C:\Program Files (x86)\Microsoft Visual 
Studio\2019\Professional\VC\Tools\MSVC\14.23.28105\include\map(71): note: see 
declaration of 'std::map'

The version in the path, 14.23, corresponds to _MSC_VER 1923, so raise
the version floor to 1924.

I have not tested with versions between 1924 and 1928 (latest), but the
latest works with the variadic version.

Added: 


Modified: 
llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp

Removed: 




diff  --git a/llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp 
b/llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp
index 4c0c202be4be..2d90e37349e5 100644
--- a/llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp
@@ -292,7 +292,7 @@ template <> StoreInst *isCandidate(Instruction 
*In) {
   return getIfUnordered(dyn_cast(In));
 }
 
-#if !defined(_MSC_VER) || _MSC_VER >= 1920
+#if !defined(_MSC_VER) || _MSC_VER >= 1924
 // VS2017 has trouble compiling this:
 // error C2976: 'std::map': too few template arguments
 template 



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] 5a2d954 - [NFC] Remove stray comment.

2020-12-14 Thread Alina Sbirlea via llvm-branch-commits

Author: Alina Sbirlea
Date: 2020-12-14T11:19:17-08:00
New Revision: 5a2d954671e91e63e2f944cce31bdcc232c8ecc2

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

LOG: [NFC] Remove stray comment.

Added: 


Modified: 
llvm/include/llvm/Support/GenericDomTree.h

Removed: 




diff  --git a/llvm/include/llvm/Support/GenericDomTree.h 
b/llvm/include/llvm/Support/GenericDomTree.h
index 4bed550f44c0..d2d7c8c4481d 100644
--- a/llvm/include/llvm/Support/GenericDomTree.h
+++ b/llvm/include/llvm/Support/GenericDomTree.h
@@ -554,7 +554,6 @@ class DominatorTreeBase {
   /// obtained PostViewCFG is the desired end state.
   void applyUpdates(ArrayRef Updates,
 ArrayRef PostViewUpdates) {
-// GraphDiff *PostViewCFG = nullptr) {
 if (Updates.empty()) {
   GraphDiff PostViewCFG(PostViewUpdates);
   DomTreeBuilder::ApplyUpdates(*this, PostViewCFG, );



___
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] a1eb154 - [flang] Use mlir::OpState::operator->() to get to methods of mlir::Operation.

2020-12-14 Thread Christian Sigg via llvm-branch-commits

Author: Christian Sigg
Date: 2020-12-14T20:04:53+01:00
New Revision: a1eb154421a00d62f3a25057d262e1cac747e266

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

LOG: [flang] Use mlir::OpState::operator->() to get to methods of 
mlir::Operation.

This is a preparation step to remove those methods from OpState.

Reviewed By: ftynse

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

Added: 


Modified: 
flang/include/flang/Optimizer/Dialect/FIROps.td
flang/include/flang/Optimizer/Dialect/FIROpsSupport.h
flang/lib/Lower/CharacterRuntime.cpp
flang/lib/Lower/IO.cpp
flang/lib/Lower/IntrinsicCall.cpp
flang/lib/Lower/OpenACC.cpp
flang/lib/Optimizer/Dialect/FIROps.cpp
mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp
mlir/test/mlir-tblgen/op-attribute.td
mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
mlir/unittests/Pass/PassManagerTest.cpp

Removed: 




diff  --git a/flang/include/flang/Optimizer/Dialect/FIROps.td 
b/flang/include/flang/Optimizer/Dialect/FIROps.td
index 4ffca0395804..8d7a6d4af950 100644
--- a/flang/include/flang/Optimizer/Dialect/FIROps.td
+++ b/flang/include/flang/Optimizer/Dialect/FIROps.td
@@ -249,7 +249,7 @@ class fir_AllocatableOp 
traits = []> :
   }];
 
   let printer = [{
-p << getOperationName() << ' ' << getAttr(inType());
+p << getOperationName() << ' ' << (*this)->getAttr(inType());
 if (hasLenParams()) {
   // print the LEN parameters to a derived type in parens
   p << '(' << getLenParams() << " : " << getLenParams().getTypes() << ')';
@@ -267,7 +267,7 @@ class fir_AllocatableOp 
traits = []> :
 static constexpr llvm::StringRef lenpName() { return "len_param_count"; }
 mlir::Type getAllocatedType();
 
-bool hasLenParams() { return bool{getAttr(lenpName())}; }
+bool hasLenParams() { return bool{(*this)->getAttr(lenpName())}; }
 
 unsigned numLenParams() {
   if (auto val = (*this)->getAttrOfType(lenpName()))
@@ -688,7 +688,7 @@ class fir_IntegralSwitchTerminatorOp(getCasesAttr()).getValue();
+auto cases = 
(*this)->getAttrOfType(getCasesAttr()).getValue();
 auto count = getNumConditions();
 for (decltype(count) i = 0; i != count; ++i) {
   if (i)
@@ -711,7 +711,7 @@ class fir_IntegralSwitchTerminatorOp() ||
   getSelector().getType().isa()))
   return emitOpError("must be an integer");
-auto cases = getAttrOfType(getCasesAttr()).getValue();
+auto cases = 
(*this)->getAttrOfType(getCasesAttr()).getValue();
 auto count = getNumDest();
 if (count == 0)
   return emitOpError("must have at least one successor");
@@ -810,7 +810,7 @@ def fir_SelectCaseOp : 
fir_SwitchTerminatorOp<"select_case"> {
 p << getOperationName() << ' ';
 p.printOperand(getSelector());
 p << " : " << getSelector().getType() << " [";
-auto cases = getAttrOfType(getCasesAttr()).getValue();
+auto cases = 
(*this)->getAttrOfType(getCasesAttr()).getValue();
 auto count = getNumConditions();
 for (decltype(count) i = 0; i != count; ++i) {
   if (i)
@@ -839,7 +839,7 @@ def fir_SelectCaseOp : 
fir_SwitchTerminatorOp<"select_case"> {
   getSelector().getType().isa() ||
   getSelector().getType().isa()))
   return emitOpError("must be an integer, character, or logical");
-auto cases = getAttrOfType(getCasesAttr()).getValue();
+auto cases = 
(*this)->getAttrOfType(getCasesAttr()).getValue();
 auto count = getNumDest();
 if (count == 0)
   return emitOpError("must have at least one successor");
@@ -925,7 +925,7 @@ def fir_SelectTypeOp : 
fir_SwitchTerminatorOp<"select_type"> {
 p << getOperationName() << ' ';
 p.printOperand(getSelector());
 p << " : " << getSelector().getType() << " [";
-auto cases = getAttrOfType(getCasesAttr()).getValue();
+auto cases = 
(*this)->getAttrOfType(getCasesAttr()).getValue();
 auto count = getNumConditions();
 for (decltype(count) i = 0; i != count; ++i) {
   if (i)
@@ -941,7 +941,7 @@ def fir_SelectTypeOp : 
fir_SwitchTerminatorOp<"select_type"> {
   let verifier = [{
 if (!(getSelector().getType().isa()))
   return emitOpError("must be a boxed type");
-auto cases = getAttrOfType(getCasesAttr()).getValue();
+auto cases = 
(*this)->getAttrOfType(getCasesAttr()).getValue();
 auto count = getNumDest();
 if (count == 0)
   return emitOpError("must have at least one successor");
@@ -1056,7 +1056,7 @@ def fir_EmboxOp : fir_Op<"embox", [NoSideEffect]> {
 if (getNumOperands() == 2) {
   p << ", ";
   p.printOperands(dims());
-} else if (auto map = getAttr(layoutName())) {
+} else if (auto map = (*this)->getAttr(layoutName())) {
   p << " [" << map << ']';
 }
 

[llvm-branch-commits] [llvm] 0453047 - [RISCV] Move vtype decoding and printing from RISCVInstPrinter to RISCVBaseInfo. Share with the assembly parser's debug output

2020-12-14 Thread Craig Topper via llvm-branch-commits

Author: Craig Topper
Date: 2020-12-14T10:50:26-08:00
New Revision: 045304701bc60620c0c0f79126f7c36d883b63ff

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

LOG: [RISCV] Move vtype decoding and printing from RISCVInstPrinter to 
RISCVBaseInfo. Share with the assembly parser's debug output

This moves the vtype decoding and printing to RISCVBaseInfo. This keeps all of
the decoding code in the same area as the encoding code. This will make it
easier to change the decoding for the 1.0 spec in the future.

We're now sharing the printing with the debug output for operands in the
assembler. This also fixes that debug output to include the tail and mask
agnostic bits. Since the printing code works on the vtype immediate value, we
now encode the immediate during parsing and store just the immediate in the
operand.

Added: 


Modified: 
llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
llvm/lib/Target/RISCV/MCTargetDesc/RISCVInstPrinter.cpp
llvm/lib/Target/RISCV/Utils/RISCVBaseInfo.cpp
llvm/lib/Target/RISCV/Utils/RISCVBaseInfo.h

Removed: 




diff  --git a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp 
b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
index aa483041e635..cfbf3c51736c 100644
--- a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
+++ b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
@@ -280,10 +280,7 @@ struct RISCVOperand : public MCParsedAsmOperand {
   };
 
   struct VTypeOp {
-RISCVVSEW Sew;
-RISCVVLMUL Lmul;
-bool TailAgnostic;
-bool MaskAgnostic;
+unsigned Val;
   };
 
   SMLoc StartLoc, EndLoc;
@@ -720,7 +717,7 @@ struct RISCVOperand : public MCParsedAsmOperand {
   }
 
   StringRef getSysReg() const {
-assert(Kind == KindTy::SystemRegister && "Invalid access!");
+assert(Kind == KindTy::SystemRegister && "Invalid type access!");
 return StringRef(SysReg.Data, SysReg.Length);
   }
 
@@ -734,55 +731,9 @@ struct RISCVOperand : public MCParsedAsmOperand {
 return Tok;
   }
 
-  static StringRef getSEWStr(RISCVVSEW Sew) {
-switch (Sew) {
-case RISCVVSEW::SEW_8:
-  return "e8";
-case RISCVVSEW::SEW_16:
-  return "e16";
-case RISCVVSEW::SEW_32:
-  return "e32";
-case RISCVVSEW::SEW_64:
-  return "e64";
-case RISCVVSEW::SEW_128:
-  return "e128";
-case RISCVVSEW::SEW_256:
-  return "e256";
-case RISCVVSEW::SEW_512:
-  return "e512";
-case RISCVVSEW::SEW_1024:
-  return "e1024";
-}
-llvm_unreachable("Unknown SEW.");
-  }
-
-  static StringRef getLMULStr(RISCVVLMUL Lmul) {
-switch (Lmul) {
-case RISCVVLMUL::LMUL_1:
-  return "m1";
-case RISCVVLMUL::LMUL_2:
-  return "m2";
-case RISCVVLMUL::LMUL_4:
-  return "m4";
-case RISCVVLMUL::LMUL_8:
-  return "m8";
-case RISCVVLMUL::LMUL_F2:
-  return "mf2";
-case RISCVVLMUL::LMUL_F4:
-  return "mf4";
-case RISCVVLMUL::LMUL_F8:
-  return "mf8";
-}
-llvm_unreachable("Unknown LMUL.");
-  }
-
-  StringRef getVType(SmallString<32> ) const {
-assert(Kind == KindTy::VType && "Invalid access!");
-Buf.append(getSEWStr(VType.Sew));
-Buf.append(",");
-Buf.append(getLMULStr(VType.Lmul));
-
-return Buf.str();
+  unsigned getVType() const {
+assert(Kind == KindTy::VType && "Invalid type access!");
+return VType.Val;
   }
 
   void print(raw_ostream ) const override {
@@ -801,8 +752,9 @@ struct RISCVOperand : public MCParsedAsmOperand {
   OS << "';
   break;
 case KindTy::VType:
-  SmallString<32> VTypeBuf;
-  OS << "';
+  OS << "';
   break;
 }
   }
@@ -848,21 +800,10 @@ struct RISCVOperand : public MCParsedAsmOperand {
 return Op;
   }
 
-  static std::unique_ptr
-  createVType(unsigned Sew, unsigned Lmul, bool Fractional, bool TailAgnostic,
-  bool MaskAgnostic, SMLoc S, bool IsRV64) {
+  static std::unique_ptr createVType(unsigned VTypeI, SMLoc S,
+   bool IsRV64) {
 auto Op = std::make_unique(KindTy::VType);
-unsigned SewLog2 = Log2_32(Sew / 8);
-unsigned LmulLog2 = Log2_32(Lmul);
-Op->VType.Sew = static_cast(SewLog2);
-if (Fractional) {
-  unsigned Flmul = 8 - LmulLog2;
-  Op->VType.Lmul = static_cast(Flmul);
-} else {
-  Op->VType.Lmul = static_cast(LmulLog2);
-}
-Op->VType.TailAgnostic = TailAgnostic;
-Op->VType.MaskAgnostic = MaskAgnostic;
+Op->VType.Val = VTypeI;
 Op->StartLoc = S;
 Op->IsRV64 = IsRV64;
 return Op;
@@ -927,9 +868,7 @@ struct RISCVOperand : public MCParsedAsmOperand {
 
   void addVTypeIOperands(MCInst , unsigned N) const {
 assert(N == 1 && "Invalid number of operands!");
-unsigned VTypeI = RISCVVType::encodeVTYPE(
-

[llvm-branch-commits] [compiler-rt] f276c00 - [sanitizer] Restrict querying VM size on Darwin only to iOS devices

2020-12-14 Thread Kuba Mracek via llvm-branch-commits

Author: Kuba Mracek
Date: 2020-12-14T10:48:48-08:00
New Revision: f276c008984dd02bb54707b2ace858cac5412e7e

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

LOG: [sanitizer] Restrict querying VM size on Darwin only to iOS devices

We currently do this for SANITIZER_IOS, which includes devices *and* 
simulators. This change opts out the check for simulators to unify the behavior 
with macOS, because VM size is really a property of the host OS, and not the 
simulator.



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

Added: 


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

Removed: 




diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp 
b/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
index 62d422d043d7..6fe6991bc816 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
@@ -1066,7 +1066,7 @@ char **GetArgv() {
   return *_NSGetArgv();
 }
 
-#if SANITIZER_IOS
+#if SANITIZER_IOS && !SANITIZER_IOSSIM
 // The task_vm_info struct is normally provided by the macOS SDK, but we need
 // fields only available in 10.12+. Declare the struct manually to be able to
 // build against older SDKs.



___
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] 8955e9f - [mlir][linalg] Fix bug in elementwise vectorization

2020-12-14 Thread Thomas Raoux via llvm-branch-commits

Author: Thomas Raoux
Date: 2020-12-14T10:44:36-08:00
New Revision: 8955e9f6b75d436f92235531f003540401cd4b30

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

LOG: [mlir][linalg] Fix bug in elementwise vectorization

Fix a bug causing to pick the wrong vector size to broadcast to when the source
vectors have different ranks.

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

Added: 


Modified: 
mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp
mlir/test/Dialect/Linalg/vectorization.mlir

Removed: 




diff  --git a/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp 
b/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp
index a28b90b1d95c..2df1a9469eab 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp
@@ -216,6 +216,7 @@ class GenericVectorizer {
   if (!vecType)
 continue;
   if (maxSize < vecType.getNumElements()) {
+maxSize = vecType.getNumElements();
 largestShape.assign(vecType.getShape().begin(),
 vecType.getShape().end());
   }

diff  --git a/mlir/test/Dialect/Linalg/vectorization.mlir 
b/mlir/test/Dialect/Linalg/vectorization.mlir
index 1c3533275e49..6019dde49983 100644
--- a/mlir/test/Dialect/Linalg/vectorization.mlir
+++ b/mlir/test/Dialect/Linalg/vectorization.mlir
@@ -169,7 +169,7 @@ func @generic_vectorize(%arg0: memref<4x256xf32>, %arg1: 
memref<4x256xf32>,
 %11 = mulf %arg5, %8 : f32
 %12 = rsqrt %arg5 : f32
 %13 = select %7, %arg5, %arg6 : f32
-%14 = subf %arg5, %arg6 : f32
+%14 = subf %arg5, %arg4 : f32
 %15 = tanh %arg5 : f32
 linalg.yield %6, %8, %c1_f32, %9, %10, %11, %12, %13, %14, %15 : f32, f32,
   f32, f32, f32, f32, f32, f32, f32, f32
@@ -196,7 +196,8 @@ func @generic_vectorize(%arg0: memref<4x256xf32>, %arg1: 
memref<4x256xf32>,
 //   CHECK:   %[[MUL:.*]] = mulf %[[V3]], %[[CST0]] : vector<4x256xf32>
 //   CHECK:   %[[RSQRT:.*]] = rsqrt %[[V3]] : vector<4x256xf32>
 //   CHECK:   %[[SEL:.*]] = select %[[CMP]], %[[V3]], %[[V1]] : 
vector<4x256xi1>, vector<4x256xf32>
-//   CHECK:   %[[SUB:.*]] = subf %[[V3]], %[[V1]] : vector<4x256xf32>
+//   CHECK:   %[[V0B:.*]] = vector.broadcast %[[V0]] : vector<256xf32> to 
vector<4x256xf32>
+//   CHECK:   %[[SUB:.*]] = subf %[[V3]], %[[V0B]] : vector<4x256xf32>
 //   CHECK:   %[[TAN:.*]] = tanh %[[V3]] : vector<4x256xf32>
 //   CHECK:   vector.transfer_write %[[ADD]], %[[ARG0]][%[[C0]], %[[C0]]] 
{{.*}} : vector<4x256xf32>, memref<4x256xf32>
 //   CHECK:   vector.transfer_write %[[CST0]], %[[ARG0]][%[[C0]], %[[C0]]] 
{{.*}} : vector<4x256xf32>, memref<4x256xf32>



___
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] 653b976 - [SystemZ] Improve handling of backchain offset.

2020-12-14 Thread Jonas Paulsson via llvm-branch-commits

Author: Jonas Paulsson
Date: 2020-12-14T12:39:38-06:00
New Revision: 653b97690f0d5c26a93002fb94ddd86397ed6c1c

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

LOG: [SystemZ] Improve handling of backchain offset.

- New function SDValue getBackchainAddress() used by
  lowerDYNAMIC_STACKALLOC() and lowerSTACKRESTORE() to properly handle the
  backchain offset also with packed-stack.

- Make a common function getBackchainOffset() for the computation of the
  backchain offset and use in some places (NFC).

Review: Ulrich Weigand

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

Added: 


Modified: 
llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp
llvm/lib/Target/SystemZ/SystemZFrameLowering.h
llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
llvm/lib/Target/SystemZ/SystemZISelLowering.h
llvm/test/CodeGen/SystemZ/backchain.ll

Removed: 




diff  --git a/llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp 
b/llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp
index d9e030de5af8..994f471b75b1 100644
--- a/llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp
+++ b/llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp
@@ -511,13 +511,10 @@ void SystemZFrameLowering::emitPrologue(MachineFunction 
,
   .addReg(SystemZ::R1D, RegState::Define).addReg(SystemZ::R15D);
   emitIncrement(MBB, MBBI, DL, SystemZ::R15D, Delta, ZII);
   buildCFAOffs(MBB, MBBI, DL, SPOffsetFromCFA + Delta, ZII);
-  if (StoreBackchain) {
-// The back chain is stored topmost with packed-stack.
-int Offset = usePackedStack(MF) ? SystemZMC::CallFrameSize - 8 : 0;
+  if (StoreBackchain)
 BuildMI(MBB, MBBI, DL, ZII->get(SystemZ::STG))
   .addReg(SystemZ::R1D, RegState::Kill).addReg(SystemZ::R15D)
-  .addImm(Offset).addReg(0);
-  }
+  .addImm(getBackchainOffset(MF)).addReg(0);
 }
 SPOffsetFromCFA += Delta;
   }
@@ -709,13 +706,10 @@ void 
SystemZFrameLowering::inlineStackProbe(MachineFunction ,
   if (Residual)
 allocateAndProbe(*MBB, MBBI, Residual, true/*EmitCFI*/);
 
-  if (StoreBackchain) {
-// The back chain is stored topmost with packed-stack.
-int Offset = usePackedStack(MF) ? SystemZMC::CallFrameSize - 8 : 0;
+  if (StoreBackchain)
 BuildMI(*MBB, MBBI, DL, ZII->get(SystemZ::STG))
   .addReg(SystemZ::R1D, RegState::Kill).addReg(SystemZ::R15D)
-  .addImm(Offset).addReg(0);
-  }
+  .addImm(getBackchainOffset(MF)).addReg(0);
 
   StackAllocMI->eraseFromParent();
   if (DoneMBB != nullptr) {
@@ -790,8 +784,7 @@ getOrCreateFramePointerSaveIndex(MachineFunction ) const 
{
   int FI = ZFI->getFramePointerSaveIndex();
   if (!FI) {
 MachineFrameInfo  = MF.getFrameInfo();
-// The back chain is stored topmost with packed-stack.
-int Offset = usePackedStack(MF) ? -8 : -SystemZMC::CallFrameSize;
+int Offset = getBackchainOffset(MF) - SystemZMC::CallFrameSize;
 FI = MFFrame.CreateFixedObject(8, Offset, false);
 ZFI->setFramePointerSaveIndex(FI);
   }

diff  --git a/llvm/lib/Target/SystemZ/SystemZFrameLowering.h 
b/llvm/lib/Target/SystemZ/SystemZFrameLowering.h
index 001d26d4d3bb..085c31ca0f18 100644
--- a/llvm/lib/Target/SystemZ/SystemZFrameLowering.h
+++ b/llvm/lib/Target/SystemZ/SystemZFrameLowering.h
@@ -9,6 +9,7 @@
 #ifndef LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZFRAMELOWERING_H
 #define LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZFRAMELOWERING_H
 
+#include "MCTargetDesc/SystemZMCTargetDesc.h"
 #include "llvm/ADT/IndexedMap.h"
 #include "llvm/CodeGen/TargetFrameLowering.h"
 #include "llvm/Support/TypeSize.h"
@@ -63,6 +64,12 @@ class SystemZFrameLowering : public TargetFrameLowering {
   int getOrCreateFramePointerSaveIndex(MachineFunction ) const;
 
   bool usePackedStack(MachineFunction ) const;
+
+  // Return the offset of the backchain.
+  unsigned getBackchainOffset(MachineFunction ) const {
+// The back chain is stored topmost with packed-stack.
+return usePackedStack(MF) ? SystemZMC::CallFrameSize - 8 : 0;
+  }
 };
 } // end namespace llvm
 

diff  --git a/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp 
b/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
index 812fe80864ac..663af1d64943 100644
--- a/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
+++ b/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
@@ -3435,7 +3435,8 @@ lowerDYNAMIC_STACKALLOC(SDValue Op, SelectionDAG ) 
const {
   // If we need a backchain, save it now.
   SDValue Backchain;
   if (StoreBackchain)
-Backchain = DAG.getLoad(MVT::i64, DL, Chain, OldSP, MachinePointerInfo());
+Backchain = DAG.getLoad(MVT::i64, DL, Chain, getBackchainAddress(OldSP, 
DAG),
+MachinePointerInfo());
 
   // Add extra space for alignment if needed.
   if (ExtraAlignSpace)
@@ -3472,7 +3473,8 @@ 

[llvm-branch-commits] [clang] 5f53d28 - Revert "[clang-scan-deps] Support clang-cl"

2020-12-14 Thread Sylvain Audi via llvm-branch-commits

Author: Sylvain Audi
Date: 2020-12-14T13:32:38-05:00
New Revision: 5f53d28fa68142bbd9dfb2b33f955352b180d776

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

LOG: Revert "[clang-scan-deps] Support clang-cl"

Reverting, as it breaks build on mac.

This reverts commit 640ad769110f76d3391667249478ece88c835529.

Added: 


Modified: 
clang/test/ClangScanDeps/Inputs/has_include_if_elif.json
clang/test/ClangScanDeps/Inputs/header_stat_before_open_cdb.json
clang/test/ClangScanDeps/Inputs/headerwithdirname.json
clang/test/ClangScanDeps/Inputs/headerwithdirnamefollowedbyinclude.json
clang/test/ClangScanDeps/Inputs/no-werror.json
clang/test/ClangScanDeps/Inputs/static-analyzer-cdb.json
clang/test/ClangScanDeps/Inputs/strip_diag_serialize.json
clang/test/ClangScanDeps/Inputs/target-filename-cdb.json
clang/test/ClangScanDeps/Inputs/vfsoverlay_cdb.json
clang/test/ClangScanDeps/error.cpp
clang/test/ClangScanDeps/has_include_if_elif.cpp
clang/test/ClangScanDeps/header_stat_before_open.m
clang/test/ClangScanDeps/headerwithdirname.cpp
clang/test/ClangScanDeps/headerwithdirnamefollowedbyinclude.cpp
clang/test/ClangScanDeps/modules-full.cpp
clang/test/ClangScanDeps/modules.cpp
clang/test/ClangScanDeps/no-werror.cpp
clang/test/ClangScanDeps/regular_cdb.cpp
clang/test/ClangScanDeps/static-analyzer.c
clang/test/ClangScanDeps/strip_diag_serialize.cpp
clang/test/ClangScanDeps/target-filename.cpp
clang/test/ClangScanDeps/vfsoverlay.cpp
clang/tools/clang-scan-deps/ClangScanDeps.cpp

Removed: 
clang/test/ClangScanDeps/Inputs/modules_cdb_clangcl.json
clang/test/ClangScanDeps/Inputs/regular_cdb_clangcl.json



diff  --git a/clang/test/ClangScanDeps/Inputs/has_include_if_elif.json 
b/clang/test/ClangScanDeps/Inputs/has_include_if_elif.json
index 6959ce8986c9..36ca006b0329 100644
--- a/clang/test/ClangScanDeps/Inputs/has_include_if_elif.json
+++ b/clang/test/ClangScanDeps/Inputs/has_include_if_elif.json
@@ -3,10 +3,5 @@
   "directory": "DIR",
   "command": "clang -E DIR/has_include_if_elif2.cpp -IInputs",
   "file": "DIR/has_include_if_elif2.cpp"
-},
-{
-  "directory": "DIR",
-  "command": "clang-cl /E DIR/has_include_if_elif2_clangcl.cpp /IInputs",
-  "file": "DIR/has_include_if_elif2_clangcl.cpp"
 }
 ]

diff  --git a/clang/test/ClangScanDeps/Inputs/header_stat_before_open_cdb.json 
b/clang/test/ClangScanDeps/Inputs/header_stat_before_open_cdb.json
index 797966c5684a..c5f027e9fd28 100644
--- a/clang/test/ClangScanDeps/Inputs/header_stat_before_open_cdb.json
+++ b/clang/test/ClangScanDeps/Inputs/header_stat_before_open_cdb.json
@@ -3,10 +3,5 @@
   "directory": "DIR",
   "command": "clang -E DIR/header_stat_before_open_input.m -iframework 
Inputs/frameworks",
   "file": "DIR/header_stat_before_open_input.m"
-},
-{
-  "directory": "DIR",
-  "command": "clang-cl /E DIR/header_stat_before_open_input_clangcl.m -Xclang 
-iframework -Xclang Inputs/frameworks",
-  "file": "DIR/header_stat_before_open_input_clangcl.m"
 }
 ]

diff  --git a/clang/test/ClangScanDeps/Inputs/headerwithdirname.json 
b/clang/test/ClangScanDeps/Inputs/headerwithdirname.json
index 980fb3d34426..2ae561935bec 100644
--- a/clang/test/ClangScanDeps/Inputs/headerwithdirname.json
+++ b/clang/test/ClangScanDeps/Inputs/headerwithdirname.json
@@ -3,10 +3,5 @@
   "directory": "DIR",
   "command": "clang -c -IDIR -IDIR/foodir -IInputs 
DIR/headerwithdirname_input.cpp",
   "file": "DIR/headerwithdirname_input.cpp"
-},
-{
-  "directory": "DIR",
-  "command": "clang-cl /c /IDIR /IDIR/foodir -IInputs 
DIR/headerwithdirname_input_clangcl.cpp",
-  "file": "DIR/headerwithdirname_input_clangcl.cpp"
 }
 ]

diff  --git 
a/clang/test/ClangScanDeps/Inputs/headerwithdirnamefollowedbyinclude.json 
b/clang/test/ClangScanDeps/Inputs/headerwithdirnamefollowedbyinclude.json
index a69637358a13..de7759d0b110 100644
--- a/clang/test/ClangScanDeps/Inputs/headerwithdirnamefollowedbyinclude.json
+++ b/clang/test/ClangScanDeps/Inputs/headerwithdirnamefollowedbyinclude.json
@@ -3,10 +3,5 @@
   "directory": "DIR",
   "command": "clang -c -IDIR -IInputs DIR/headerwithdirname_input.cpp",
   "file": "DIR/headerwithdirname_input.cpp"
-},
-{
-  "directory": "DIR",
-  "command": "clang-cl /c /IDIR /IInputs 
DIR/headerwithdirname_input_clangcl.cpp",
-  "file": "DIR/headerwithdirname_input_clangcl.cpp"
 }
 ]

diff  --git a/clang/test/ClangScanDeps/Inputs/modules_cdb_clangcl.json 
b/clang/test/ClangScanDeps/Inputs/modules_cdb_clangcl.json
deleted file mode 100644
index 1d46af13c384..
--- a/clang/test/ClangScanDeps/Inputs/modules_cdb_clangcl.json
+++ /dev/null
@@ -1,22 +0,0 @@
-[
-{
-  "directory": "DIR",
-  

[llvm-branch-commits] [lld] e814013 - [Wasm][LTO][NPM] Use NPM for LTO with ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER

2020-12-14 Thread Arthur Eubanks via llvm-branch-commits

Author: Arthur Eubanks
Date: 2020-12-14T10:15:13-08:00
New Revision: e8140139328cfe50cfe7aa027a7b51c224ec7e7c

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

LOG: [Wasm][LTO][NPM] Use NPM for LTO with ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER

Reviewed By: MaskRay

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

Added: 


Modified: 
lld/wasm/Driver.cpp

Removed: 




diff  --git a/lld/wasm/Driver.cpp b/lld/wasm/Driver.cpp
index 0d84914c1295..c1e888466628 100644
--- a/lld/wasm/Driver.cpp
+++ b/lld/wasm/Driver.cpp
@@ -21,6 +21,7 @@
 #include "lld/Common/Strings.h"
 #include "lld/Common/Version.h"
 #include "llvm/ADT/Twine.h"
+#include "llvm/Config/llvm-config.h"
 #include "llvm/Object/Wasm.h"
 #include "llvm/Option/Arg.h"
 #include "llvm/Option/ArgList.h"
@@ -379,8 +380,9 @@ static void readConfigs(opt::InputArgList ) {
   config->importTable = args.hasArg(OPT_import_table);
   config->ltoo = args::getInteger(args, OPT_lto_O, 2);
   config->ltoPartitions = args::getInteger(args, OPT_lto_partitions, 1);
-  config->ltoNewPassManager = args.hasFlag(OPT_lto_new_pass_manager,
-   OPT_no_lto_new_pass_manager, false);
+  config->ltoNewPassManager =
+  args.hasFlag(OPT_lto_new_pass_manager, OPT_no_lto_new_pass_manager,
+   LLVM_ENABLE_NEW_PASS_MANAGER);
   config->ltoDebugPassManager = args.hasArg(OPT_lto_debug_pass_manager);
   config->mapFile = args.getLastArgValue(OPT_Map);
   config->optimize = args::getInteger(args, OPT_O, 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] 1fd1f63 - [amdgpu] Fix a crash case when `V_CNDMASK` could be simplified.

2020-12-14 Thread Michael Liao via llvm-branch-commits

Author: Michael Liao
Date: 2020-12-14T13:08:13-05:00
New Revision: 1fd1f638b68ca4a9cf3bd071a7cba0bac0b189c6

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

LOG: [amdgpu] Fix a crash case when `V_CNDMASK` could be simplified.

- Once an instruction is simplified, foldable candidates from it should
  be invalidated or skipped as the operand index is no longer valid.

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

Added: 
llvm/test/CodeGen/AMDGPU/fold-cndmask-wave32.mir

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

Removed: 




diff  --git a/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp 
b/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp
index 0df893ede7b8..bfba432848d4 100644
--- a/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp
+++ b/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp
@@ -1257,8 +1257,11 @@ void SIFoldOperands::foldInstOperand(MachineInstr ,
   for (MachineInstr *Copy : CopiesToReplace)
 Copy->addImplicitDefUseOperands(*MF);
 
+  SmallPtrSet Folded;
   for (FoldCandidate  : FoldList) {
 assert(!Fold.isReg() || Fold.OpToFold);
+if (Folded.count(Fold.UseMI))
+  continue;
 if (Fold.isReg() && Fold.OpToFold->getReg().isVirtual()) {
   Register Reg = Fold.OpToFold->getReg();
   MachineInstr *DefMI = Fold.OpToFold->getParent();
@@ -1278,7 +1281,8 @@ void SIFoldOperands::foldInstOperand(MachineInstr ,
   LLVM_DEBUG(dbgs() << "Folded source from " << MI << " into OpNo "
 << static_cast(Fold.UseOpNo) << " of "
 << *Fold.UseMI << '\n');
-  tryFoldInst(TII, Fold.UseMI);
+  if (tryFoldInst(TII, Fold.UseMI))
+Folded.insert(Fold.UseMI);
 } else if (Fold.isCommuted()) {
   // Restoring instruction's original operand order if fold has failed.
   TII->commuteInstruction(*Fold.UseMI, false);

diff  --git a/llvm/test/CodeGen/AMDGPU/fold-cndmask-wave32.mir 
b/llvm/test/CodeGen/AMDGPU/fold-cndmask-wave32.mir
new file mode 100644
index ..a921ce33682c
--- /dev/null
+++ b/llvm/test/CodeGen/AMDGPU/fold-cndmask-wave32.mir
@@ -0,0 +1,20 @@
+# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
+# RUN: llc -march=amdgcn -mcpu=gfx1030 -run-pass si-fold-operands 
-verify-machineinstrs -o - %s | FileCheck %s
+
+---
+name:fold_cndmask
+tracksRegLiveness: true
+registers:
+body: |
+  bb.0.entry:
+; CHECK-LABEL: name: fold_cndmask
+; CHECK: [[DEF:%[0-9]+]]:sreg_32_xm0_xexec = IMPLICIT_DEF
+; CHECK: [[S_MOV_B32_:%[0-9]+]]:sreg_32 = S_MOV_B32 0
+; CHECK: [[V_MOV_B32_e32_:%[0-9]+]]:vgpr_32 = V_MOV_B32_e32 0, implicit 
$exec
+; CHECK: [[COPY:%[0-9]+]]:vgpr_32 = COPY [[S_MOV_B32_]]
+%0:sreg_32_xm0_xexec = IMPLICIT_DEF
+%1:sreg_32 = S_MOV_B32 0
+%2:vgpr_32 = COPY %1:sreg_32
+%3:vgpr_32 = V_CNDMASK_B32_e64 0, %1:sreg_32, 0, %2:vgpr_32, 
%0:sreg_32_xm0_xexec, implicit $exec
+
+...



___
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] cae2d87 - [NFCI][Thumb2] Regenerate MVE tests i missed in 59560e85897afc50090b6c3d920bacfd28b49d06

2020-12-14 Thread Roman Lebedev via llvm-branch-commits

Author: Roman Lebedev
Date: 2020-12-14T21:01:00+03:00
New Revision: cae2d871c05ac5dcf15f0a8429dd730c1551cdbc

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

LOG: [NFCI][Thumb2] Regenerate MVE tests i missed in 
59560e85897afc50090b6c3d920bacfd28b49d06

Added: 


Modified: 
llvm/test/CodeGen/Thumb2/mve-float16regloops.ll
llvm/test/CodeGen/Thumb2/mve-float32regloops.ll
llvm/test/CodeGen/Thumb2/mve-postinc-lsr.ll

Removed: 




diff  --git a/llvm/test/CodeGen/Thumb2/mve-float16regloops.ll 
b/llvm/test/CodeGen/Thumb2/mve-float16regloops.ll
index fa58c72a0efb..5bf4ebf92f14 100644
--- a/llvm/test/CodeGen/Thumb2/mve-float16regloops.ll
+++ b/llvm/test/CodeGen/Thumb2/mve-float16regloops.ll
@@ -1077,34 +1077,36 @@ define void @fir(%struct.arm_fir_instance_f32* 
nocapture readonly %S, half* noca
 ; CHECK-NEXT:sub sp, #24
 ; CHECK-NEXT:cmp r3, #8
 ; CHECK-NEXT:blo.w .LBB16_12
-; CHECK-NEXT:  @ %bb.1: @ %entry
-; CHECK-NEXT:lsrs.w r12, r3, #2
+; CHECK-NEXT:  @ %bb.1: @ %if.then
+; CHECK-NEXT:movs r7, #0
+; CHECK-NEXT:cmp.w r7, r3, lsr #2
 ; CHECK-NEXT:beq.w .LBB16_12
 ; CHECK-NEXT:  @ %bb.2: @ %while.body.lr.ph
 ; CHECK-NEXT:ldrh r4, [r0]
-; CHECK-NEXT:movs r6, #1
-; CHECK-NEXT:ldrd r5, r3, [r0, #4]
+; CHECK-NEXT:lsr.w r9, r3, #2
+; CHECK-NEXT:ldrd r5, r12, [r0, #4]
+; CHECK-NEXT:movs r3, #1
 ; CHECK-NEXT:sub.w r0, r4, #8
 ; CHECK-NEXT:and r8, r0, #7
 ; CHECK-NEXT:add.w r7, r0, r0, lsr #29
-; CHECK-NEXT:asr.w lr, r7, #3
-; CHECK-NEXT:cmp.w lr, #1
+; CHECK-NEXT:asrs r6, r7, #3
+; CHECK-NEXT:cmp r6, #1
 ; CHECK-NEXT:it gt
-; CHECK-NEXT:asrgt r6, r7, #3
+; CHECK-NEXT:asrgt r3, r7, #3
 ; CHECK-NEXT:add.w r7, r5, r4, lsl #1
-; CHECK-NEXT:subs r7, #2
-; CHECK-NEXT:str r7, [sp, #20] @ 4-byte Spill
-; CHECK-NEXT:rsbs r7, r4, #0
-; CHECK-NEXT:str r7, [sp, #8] @ 4-byte Spill
-; CHECK-NEXT:add.w r7, r3, #16
-; CHECK-NEXT:str r6, [sp] @ 4-byte Spill
+; CHECK-NEXT:str r3, [sp] @ 4-byte Spill
+; CHECK-NEXT:subs r3, r7, #2
+; CHECK-NEXT:str r3, [sp, #20] @ 4-byte Spill
+; CHECK-NEXT:rsbs r3, r4, #0
+; CHECK-NEXT:str r3, [sp, #8] @ 4-byte Spill
+; CHECK-NEXT:add.w r3, r12, #16
 ; CHECK-NEXT:str r4, [sp, #12] @ 4-byte Spill
-; CHECK-NEXT:str r7, [sp, #4] @ 4-byte Spill
+; CHECK-NEXT:str r3, [sp, #4] @ 4-byte Spill
 ; CHECK-NEXT:b .LBB16_4
 ; CHECK-NEXT:  .LBB16_3: @ %while.end
 ; CHECK-NEXT:@ in Loop: Header=BB16_4 Depth=1
 ; CHECK-NEXT:ldr r0, [sp, #8] @ 4-byte Reload
-; CHECK-NEXT:subs.w r12, r12, #1
+; CHECK-NEXT:subs.w r9, r9, #1
 ; CHECK-NEXT:ldr r1, [sp, #16] @ 4-byte Reload
 ; CHECK-NEXT:vstrb.8 q0, [r2], #8
 ; CHECK-NEXT:add.w r0, r5, r0, lsl #1
@@ -1115,16 +1117,16 @@ define void @fir(%struct.arm_fir_instance_f32* 
nocapture readonly %S, half* noca
 ; CHECK-NEXT:@ Child Loop BB16_6 Depth 2
 ; CHECK-NEXT:@ Child Loop BB16_10 Depth 2
 ; CHECK-NEXT:vldrw.u32 q0, [r1], #8
-; CHECK-NEXT:ldrh.w lr, [r3, #14]
-; CHECK-NEXT:ldrh r0, [r3, #12]
+; CHECK-NEXT:ldrh.w lr, [r12, #14]
+; CHECK-NEXT:ldrh.w r0, [r12, #12]
 ; CHECK-NEXT:str r1, [sp, #16] @ 4-byte Spill
 ; CHECK-NEXT:ldr r1, [sp, #20] @ 4-byte Reload
-; CHECK-NEXT:ldrh r4, [r3, #10]
-; CHECK-NEXT:ldrh r7, [r3, #8]
-; CHECK-NEXT:ldrh r6, [r3, #6]
-; CHECK-NEXT:ldrh.w r9, [r3, #4]
-; CHECK-NEXT:ldrh.w r11, [r3, #2]
-; CHECK-NEXT:ldrh.w r10, [r3]
+; CHECK-NEXT:ldrh.w r4, [r12, #10]
+; CHECK-NEXT:ldrh.w r7, [r12, #8]
+; CHECK-NEXT:ldrh.w r3, [r12, #6]
+; CHECK-NEXT:ldrh.w r6, [r12, #4]
+; CHECK-NEXT:ldrh.w r11, [r12, #2]
+; CHECK-NEXT:ldrh.w r10, [r12]
 ; CHECK-NEXT:vstrb.8 q0, [r1], #8
 ; CHECK-NEXT:vldrw.u32 q0, [r5]
 ; CHECK-NEXT:str r1, [sp, #20] @ 4-byte Spill
@@ -1134,10 +1136,10 @@ define void @fir(%struct.arm_fir_instance_f32* 
nocapture readonly %S, half* noca
 ; CHECK-NEXT:adds r1, r5, #6
 ; CHECK-NEXT:vfma.f16 q0, q1, r11
 ; CHECK-NEXT:vldrw.u32 q1, [r5, #4]
-; CHECK-NEXT:vfma.f16 q0, q1, r9
+; CHECK-NEXT:vfma.f16 q0, q1, r6
 ; CHECK-NEXT:vldrw.u32 q1, [r1]
 ; CHECK-NEXT:add.w r1, r5, #10
-; CHECK-NEXT:vfma.f16 q0, q1, r6
+; CHECK-NEXT:vfma.f16 q0, q1, r3
 ; CHECK-NEXT:vldrw.u32 q1, [r5, #8]
 ; CHECK-NEXT:vfma.f16 q0, q1, r7
 ; CHECK-NEXT:vldrw.u32 q1, [r1]

diff  --git a/llvm/test/CodeGen/Thumb2/mve-float32regloops.ll 
b/llvm/test/CodeGen/Thumb2/mve-float32regloops.ll
index 3d0309d1579f..3986b53cab21 100644
--- a/llvm/test/CodeGen/Thumb2/mve-float32regloops.ll
+++ b/llvm/test/CodeGen/Thumb2/mve-float32regloops.ll
@@ -1049,34 +1049,36 @@ define void @fir(%struct.arm_fir_instance_f32* 
nocapture readonly %S, 

[llvm-branch-commits] [llvm] 90b951d - [NFC] Remove trailing whitespace in llvm/CMakeLists.txt

2020-12-14 Thread via llvm-branch-commits

Author: Tony
Date: 2020-12-14T17:48:16Z
New Revision: 90b951dd6801f981a8130b7d743b667066fc0ff5

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

LOG: [NFC] Remove trailing whitespace in llvm/CMakeLists.txt

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

Added: 


Modified: 
llvm/CMakeLists.txt

Removed: 




diff  --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index 9b5cadeed0c4..54009573ed43 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -378,13 +378,13 @@ option(LLVM_ENABLE_Z3_SOLVER
 
 if (LLVM_ENABLE_Z3_SOLVER)
   find_package(Z3 4.7.1)
-  
+
   if (LLVM_Z3_INSTALL_DIR)
 if (NOT Z3_FOUND)
   message(FATAL_ERROR "Z3 >= 4.7.1 has not been found in 
LLVM_Z3_INSTALL_DIR: ${LLVM_Z3_INSTALL_DIR}.")
 endif()
   endif()
-  
+
   if (NOT Z3_FOUND)
 message(FATAL_ERROR "LLVM_ENABLE_Z3_SOLVER cannot be enabled when Z3 is 
not available.")
   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] [lld] 92c6141 - lld/ELF: Parse MSP430 BFD/emulation names

2020-12-14 Thread Fangrui Song via llvm-branch-commits

Author: LemonBoy
Date: 2020-12-14T09:38:12-08:00
New Revision: 92c6141ce6a954aa866bba8e53850e7dd9d9abb6

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

LOG: lld/ELF: Parse MSP430 BFD/emulation names

Follow the naming set by TI's own GCC-based toolchain.
Also, force the `osabi` field to `ELFOSABI_STANDALONE`, this matches GNU LD's 
output (the patching is done in `elf32_msp430_post_process_headers`).

Reviewed By: MaskRay

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

Added: 
lld/test/ELF/emulation-msp430.s

Modified: 
lld/ELF/Driver.cpp
lld/ELF/ScriptParser.cpp

Removed: 




diff  --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index 0a399db02341..d7a6cd13ca11 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -161,10 +161,13 @@ static std::tuple 
parseEmulation(StringRef emul) {
   .Case("elf_i386", {ELF32LEKind, EM_386})
   .Case("elf_iamcu", {ELF32LEKind, EM_IAMCU})
   .Case("elf64_sparc", {ELF64BEKind, EM_SPARCV9})
+  .Case("msp430elf", {ELF32LEKind, EM_MSP430})
   .Default({ELFNoneKind, EM_NONE});
 
   if (ret.first == ELFNoneKind)
 error("unknown emulation: " + emul);
+  if (ret.second == EM_MSP430)
+osabi = ELFOSABI_STANDALONE;
   return std::make_tuple(ret.first, ret.second, osabi);
 }
 

diff  --git a/lld/ELF/ScriptParser.cpp b/lld/ELF/ScriptParser.cpp
index c68d7f4f62e1..82b98e5ddebe 100644
--- a/lld/ELF/ScriptParser.cpp
+++ b/lld/ELF/ScriptParser.cpp
@@ -425,6 +425,7 @@ static std::pair parseBfdName(StringRef 
s) {
   .Case("elf32-littleriscv", {ELF32LEKind, EM_RISCV})
   .Case("elf64-littleriscv", {ELF64LEKind, EM_RISCV})
   .Case("elf64-sparc", {ELF64BEKind, EM_SPARCV9})
+  .Case("elf32-msp430", {ELF32LEKind, EM_MSP430})
   .Default({ELFNoneKind, EM_NONE});
 }
 
@@ -443,6 +444,8 @@ void ScriptParser::readOutputFormat() {
 setError("unknown output format name: " + config->bfdname);
   if (s == "elf32-ntradlittlemips" || s == "elf32-ntradbigmips")
 config->mipsN32Abi = true;
+  if (config->emachine == EM_MSP430)
+config->osabi = ELFOSABI_STANDALONE;
 
   if (consume(")"))
 return;

diff  --git a/lld/test/ELF/emulation-msp430.s b/lld/test/ELF/emulation-msp430.s
new file mode 100644
index ..c747889d798c
--- /dev/null
+++ b/lld/test/ELF/emulation-msp430.s
@@ -0,0 +1,26 @@
+# REQUIRES: msp430
+# RUN: llvm-mc -filetype=obj -triple=msp430 %s -o %t.o
+# RUN: ld.lld %t.o -o %t1
+# RUN: llvm-readobj --file-headers %t1 | FileCheck %s
+# RUN: ld.lld -m msp430elf %t.o -o %t2
+# RUN: cmp %t1 %t2
+# RUN: echo 'OUTPUT_FORMAT(elf32-msp430)' > %t.lds
+# RUN: ld.lld -T %t.lds %t.o -o %t3
+# RUN: llvm-readobj --file-headers %t3 | FileCheck %s
+
+# CHECK:  ElfHeader {
+# CHECK-NEXT:   Ident {
+# CHECK-NEXT: Magic: (7F 45 4C 46)
+# CHECK-NEXT: Class: 32-bit (0x1)
+# CHECK-NEXT: DataEncoding: LittleEndian (0x1)
+# CHECK-NEXT: FileVersion: 1
+# CHECK-NEXT: OS/ABI: Standalone (0xFF)
+# CHECK-NEXT: ABIVersion: 0
+# CHECK-NEXT: Unused: (00 00 00 00 00 00 00)
+# CHECK-NEXT:   }
+# CHECK-NEXT:   Type: Executable (0x2)
+# CHECK-NEXT:   Machine: EM_MSP430 (0x69)
+# CHECK-NEXT:   Version: 1
+
+.globl _start
+_start:



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


  1   2   >