[llvm-branch-commits] [llvm] 384383e - [ARM] Common inverse constant predicates to VPNOT

2020-12-09 Thread David Green via llvm-branch-commits

Author: David Green
Date: 2020-12-09T07:56:44Z
New Revision: 384383e15c177cd0dddae6b0999e527663fb3e22

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

LOG: [ARM] Common inverse constant predicates to VPNOT

This scans through blocks looking for constants used as predicates in
MVE instructions. When two constants are found which are the inverse of
one another, the second can be replaced by a VPNOT of the first,
potentially allowing that not to be folded away into an else predicate
of a vpt block.

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

Added: 


Modified: 
llvm/lib/Target/ARM/MVEVPTOptimisationsPass.cpp
llvm/test/CodeGen/Thumb2/mve-pred-constfold.ll
llvm/test/CodeGen/Thumb2/mve-vpt-optimisations.mir

Removed: 




diff  --git a/llvm/lib/Target/ARM/MVEVPTOptimisationsPass.cpp 
b/llvm/lib/Target/ARM/MVEVPTOptimisationsPass.cpp
index ee3821d34025..e56c4ce36f7b 100644
--- a/llvm/lib/Target/ARM/MVEVPTOptimisationsPass.cpp
+++ b/llvm/lib/Target/ARM/MVEVPTOptimisationsPass.cpp
@@ -67,6 +67,7 @@ class MVEVPTOptimisations : public MachineFunctionPass {
 Register Target);
   bool ReduceOldVCCRValueUses(MachineBasicBlock &MBB);
   bool ReplaceVCMPsByVPNOTs(MachineBasicBlock &MBB);
+  bool ReplaceConstByVPNOTs(MachineBasicBlock &MBB, MachineDominatorTree *DT);
   bool ConvertVPSEL(MachineBasicBlock &MBB);
 };
 
@@ -646,6 +647,90 @@ bool 
MVEVPTOptimisations::ReplaceVCMPsByVPNOTs(MachineBasicBlock &MBB) {
   return !DeadInstructions.empty();
 }
 
+bool MVEVPTOptimisations::ReplaceConstByVPNOTs(MachineBasicBlock &MBB,
+   MachineDominatorTree *DT) {
+  // Scan through the block, looking for instructions that use constants moves
+  // into VPR that are the negative of one another. These are expected to be
+  // COPY's to VCCRRegClass, from a t2MOVi or t2MOVi16. The last seen constant
+  // mask is kept it or and VPNOT's of it are added or reused as we scan 
through
+  // the function.
+  unsigned LastVPTImm = 0;
+  Register LastVPTReg = 0;
+  SmallSet DeadInstructions;
+
+  for (MachineInstr &Instr : MBB.instrs()) {
+// Look for predicated MVE instructions.
+int PIdx = llvm::findFirstVPTPredOperandIdx(Instr);
+if (PIdx == -1)
+  continue;
+Register VPR = Instr.getOperand(PIdx + 1).getReg();
+if (!VPR.isVirtual())
+  continue;
+
+// From that we are looking for an instruction like %11:vccr = COPY 
%9:rgpr.
+MachineInstr *Copy = MRI->getVRegDef(VPR);
+if (!Copy || Copy->getOpcode() != TargetOpcode::COPY ||
+!Copy->getOperand(1).getReg().isVirtual() ||
+MRI->getRegClass(Copy->getOperand(1).getReg()) == &ARM::VCCRRegClass) {
+  LastVPTReg = 0;
+  continue;
+}
+Register GPR = Copy->getOperand(1).getReg();
+
+// Find the Immediate used by the copy.
+auto getImm = [&](Register GPR) -> unsigned {
+  MachineInstr *Def = MRI->getVRegDef(GPR);
+  if (Def && (Def->getOpcode() == ARM::t2MOVi ||
+  Def->getOpcode() == ARM::t2MOVi16))
+return Def->getOperand(1).getImm();
+  return -1U;
+};
+unsigned Imm = getImm(GPR);
+if (Imm == -1U) {
+  LastVPTReg = 0;
+  continue;
+}
+
+unsigned NotImm = ~Imm & 0x;
+if (LastVPTReg != 0 && LastVPTReg != VPR && LastVPTImm == Imm) {
+  Instr.getOperand(PIdx + 1).setReg(LastVPTReg);
+  if (MRI->use_empty(VPR)) {
+DeadInstructions.insert(Copy);
+if (MRI->hasOneUse(GPR))
+  DeadInstructions.insert(MRI->getVRegDef(GPR));
+  }
+  LLVM_DEBUG(dbgs() << "Reusing predicate: in  " << Instr);
+} else if (LastVPTReg != 0 && LastVPTImm == NotImm) {
+  // We have found the not of a previous constant. Create a VPNot of the
+  // earlier predicate reg and use it instead of the copy.
+  Register NewVPR = MRI->createVirtualRegister(&ARM::VCCRRegClass);
+  auto VPNot = BuildMI(MBB, &Instr, Instr.getDebugLoc(),
+   TII->get(ARM::MVE_VPNOT), NewVPR)
+   .addReg(LastVPTReg);
+  addUnpredicatedMveVpredNOp(VPNot);
+
+  // Use the new register and check if the def is now dead.
+  Instr.getOperand(PIdx + 1).setReg(NewVPR);
+  if (MRI->use_empty(VPR)) {
+DeadInstructions.insert(Copy);
+if (MRI->hasOneUse(GPR))
+  DeadInstructions.insert(MRI->getVRegDef(GPR));
+  }
+  LLVM_DEBUG(dbgs() << "Adding VPNot: " << *VPNot << "  to replace use at "
+<< Instr);
+  VPR = NewVPR;
+}
+
+LastVPTImm = Imm;
+LastVPTReg = VPR;
+  }
+
+  for (MachineInstr *DI : DeadInstructions)
+DI->eraseFromParent();
+
+  return !DeadInstructions.empty();
+}
+
 // Replace VPSEL w

[llvm-branch-commits] [clang] cf2bb22 - [clang][cli] CompilerInvocationTest: join two test fixtures into one

2020-12-09 Thread Jan Svoboda via llvm-branch-commits

Author: Jan Svoboda
Date: 2020-12-09T08:58:45+01:00
New Revision: cf2bb2239252c0e1970e646308ae6fb552fcb002

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

LOG: [clang][cli] CompilerInvocationTest: join two test fixtures into one

Reviewed By: dexonsmith

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

Added: 


Modified: 
clang/unittests/Frontend/CompilerInvocationTest.cpp

Removed: 




diff  --git a/clang/unittests/Frontend/CompilerInvocationTest.cpp 
b/clang/unittests/Frontend/CompilerInvocationTest.cpp
index cad27749c38e..0394308e8015 100644
--- a/clang/unittests/Frontend/CompilerInvocationTest.cpp
+++ b/clang/unittests/Frontend/CompilerInvocationTest.cpp
@@ -22,29 +22,22 @@ using ::testing::StrEq;
 using ::testing::StrNe;
 
 namespace {
-struct OptsPopulationTest : public ::testing::Test {
-  IntrusiveRefCntPtr Diags;
-  CompilerInvocation CInvok;
-
-  OptsPopulationTest()
-  : Diags(CompilerInstance::createDiagnostics(new DiagnosticOptions())) {}
-};
-
-class CC1CommandLineGenerationTest : public ::testing::Test {
+class CommandLineTest : public ::testing::Test {
 public:
   IntrusiveRefCntPtr Diags;
   SmallVector GeneratedArgs;
   SmallVector GeneratedArgsStorage;
+  CompilerInvocation CInvok;
 
   const char *operator()(const Twine &Arg) {
 return GeneratedArgsStorage.emplace_back(Arg.str()).c_str();
   }
 
-  CC1CommandLineGenerationTest()
+  CommandLineTest()
   : Diags(CompilerInstance::createDiagnostics(new DiagnosticOptions())) {}
 };
 
-TEST_F(OptsPopulationTest, OptIsInitializedWithCustomDefaultValue) {
+TEST_F(CommandLineTest, OptIsInitializedWithCustomDefaultValue) {
   const char *Args[] = {"clang", "-xc++"};
 
   CompilerInvocation::CreateFromArgs(CInvok, Args, *Diags);
@@ -52,7 +45,7 @@ TEST_F(OptsPopulationTest, 
OptIsInitializedWithCustomDefaultValue) {
   ASSERT_TRUE(CInvok.getFrontendOpts().UseTemporary);
 }
 
-TEST_F(OptsPopulationTest, OptOfNegativeFlagIsPopulatedWithFalse) {
+TEST_F(CommandLineTest, OptOfNegativeFlagIsPopulatedWithFalse) {
   const char *Args[] = {"clang", "-xc++", "-fno-temp-file"};
 
   CompilerInvocation::CreateFromArgs(CInvok, Args, *Diags);
@@ -60,7 +53,7 @@ TEST_F(OptsPopulationTest, 
OptOfNegativeFlagIsPopulatedWithFalse) {
   ASSERT_FALSE(CInvok.getFrontendOpts().UseTemporary);
 }
 
-TEST_F(OptsPopulationTest, OptsOfImpliedPositiveFlagArePopulatedWithTrue) {
+TEST_F(CommandLineTest, OptsOfImpliedPositiveFlagArePopulatedWithTrue) {
   const char *Args[] = {"clang", "-xc++", "-cl-unsafe-math-optimizations"};
 
   CompilerInvocation::CreateFromArgs(CInvok, Args, *Diags);
@@ -76,10 +69,9 @@ TEST_F(OptsPopulationTest, 
OptsOfImpliedPositiveFlagArePopulatedWithTrue) {
   ASSERT_TRUE(CInvok.getLangOpts()->AllowRecip);
 }
 
-TEST_F(CC1CommandLineGenerationTest, CanGenerateCC1CommandLineFlag) {
+TEST_F(CommandLineTest, CanGenerateCC1CommandLineFlag) {
   const char *Args[] = {"clang", "-xc++", "-fmodules-strict-context-hash", 
"-"};
 
-  CompilerInvocation CInvok;
   CompilerInvocation::CreateFromArgs(CInvok, Args, *Diags);
 
   CInvok.generateCC1CommandLine(GeneratedArgs, *this);
@@ -87,11 +79,10 @@ TEST_F(CC1CommandLineGenerationTest, 
CanGenerateCC1CommandLineFlag) {
   ASSERT_THAT(GeneratedArgs, Contains(StrEq("-fmodules-strict-context-hash")));
 }
 
-TEST_F(CC1CommandLineGenerationTest, CanGenerateCC1CommandLineSeparate) {
+TEST_F(CommandLineTest, CanGenerateCC1CommandLineSeparate) {
   const char *TripleCStr = "i686-apple-darwin9";
   const char *Args[] = {"clang", "-xc++", "-triple", TripleCStr, "-"};
 
-  CompilerInvocation CInvok;
   CompilerInvocation::CreateFromArgs(CInvok, Args, *Diags);
 
   CInvok.generateCC1CommandLine(GeneratedArgs, *this);
@@ -99,14 +90,12 @@ TEST_F(CC1CommandLineGenerationTest, 
CanGenerateCC1CommandLineSeparate) {
   ASSERT_THAT(GeneratedArgs, Contains(StrEq(TripleCStr)));
 }
 
-TEST_F(CC1CommandLineGenerationTest,
-   CanGenerateCC1CommandLineSeparateRequiredPresent) {
+TEST_F(CommandLineTest,  CanGenerateCC1CommandLineSeparateRequiredPresent) {
   const std::string DefaultTriple =
   llvm::Triple::normalize(llvm::sys::getDefaultTargetTriple());
   const char *Args[] = {"clang", "-xc++", "-triple", DefaultTriple.c_str(),
 "-"};
 
-  CompilerInvocation CInvok;
   CompilerInvocation::CreateFromArgs(CInvok, Args, *Diags);
 
   CInvok.generateCC1CommandLine(GeneratedArgs, *this);
@@ -115,13 +104,11 @@ TEST_F(CC1CommandLineGenerationTest,
   ASSERT_THAT(GeneratedArgs, Contains(StrEq(DefaultTriple.c_str(;
 }
 
-TEST_F(CC1CommandLineGenerationTest,
-   CanGenerateCC1CommandLineSeparateRequiredAbsent) {
+TEST_F(CommandLineTest, CanGenerateCC1CommandLineSeparateRequiredAbsent) {
   const std::string DefaultTriple =
   llvm::Triple::normalize(

[llvm-branch-commits] [clang] f825ec8 - [clang][cli] CompilerInvocationTest: rename member variable in fixture

2020-12-09 Thread Jan Svoboda via llvm-branch-commits

Author: Jan Svoboda
Date: 2020-12-09T08:58:45+01:00
New Revision: f825ec86e14b1369a9edf382d65259351eae679e

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

LOG: [clang][cli] CompilerInvocationTest: rename member variable in fixture

Depends on D92825.

Reviewed By: dexonsmith

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

Added: 


Modified: 
clang/unittests/Frontend/CompilerInvocationTest.cpp

Removed: 




diff  --git a/clang/unittests/Frontend/CompilerInvocationTest.cpp 
b/clang/unittests/Frontend/CompilerInvocationTest.cpp
index 0394308e8015..69a807056f29 100644
--- a/clang/unittests/Frontend/CompilerInvocationTest.cpp
+++ b/clang/unittests/Frontend/CompilerInvocationTest.cpp
@@ -27,7 +27,7 @@ class CommandLineTest : public ::testing::Test {
   IntrusiveRefCntPtr Diags;
   SmallVector GeneratedArgs;
   SmallVector GeneratedArgsStorage;
-  CompilerInvocation CInvok;
+  CompilerInvocation Invocation;
 
   const char *operator()(const Twine &Arg) {
 return GeneratedArgsStorage.emplace_back(Arg.str()).c_str();
@@ -40,41 +40,41 @@ class CommandLineTest : public ::testing::Test {
 TEST_F(CommandLineTest, OptIsInitializedWithCustomDefaultValue) {
   const char *Args[] = {"clang", "-xc++"};
 
-  CompilerInvocation::CreateFromArgs(CInvok, Args, *Diags);
+  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
-  ASSERT_TRUE(CInvok.getFrontendOpts().UseTemporary);
+  ASSERT_TRUE(Invocation.getFrontendOpts().UseTemporary);
 }
 
 TEST_F(CommandLineTest, OptOfNegativeFlagIsPopulatedWithFalse) {
   const char *Args[] = {"clang", "-xc++", "-fno-temp-file"};
 
-  CompilerInvocation::CreateFromArgs(CInvok, Args, *Diags);
+  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
-  ASSERT_FALSE(CInvok.getFrontendOpts().UseTemporary);
+  ASSERT_FALSE(Invocation.getFrontendOpts().UseTemporary);
 }
 
 TEST_F(CommandLineTest, OptsOfImpliedPositiveFlagArePopulatedWithTrue) {
   const char *Args[] = {"clang", "-xc++", "-cl-unsafe-math-optimizations"};
 
-  CompilerInvocation::CreateFromArgs(CInvok, Args, *Diags);
+  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
   // Explicitly provided flag.
-  ASSERT_TRUE(CInvok.getLangOpts()->CLUnsafeMath);
+  ASSERT_TRUE(Invocation.getLangOpts()->CLUnsafeMath);
 
   // Flags directly implied by explicitly provided flag.
-  ASSERT_TRUE(CInvok.getCodeGenOpts().LessPreciseFPMAD);
-  ASSERT_TRUE(CInvok.getLangOpts()->UnsafeFPMath);
+  ASSERT_TRUE(Invocation.getCodeGenOpts().LessPreciseFPMAD);
+  ASSERT_TRUE(Invocation.getLangOpts()->UnsafeFPMath);
 
   // Flag transitively implied by explicitly provided flag.
-  ASSERT_TRUE(CInvok.getLangOpts()->AllowRecip);
+  ASSERT_TRUE(Invocation.getLangOpts()->AllowRecip);
 }
 
 TEST_F(CommandLineTest, CanGenerateCC1CommandLineFlag) {
   const char *Args[] = {"clang", "-xc++", "-fmodules-strict-context-hash", 
"-"};
 
-  CompilerInvocation::CreateFromArgs(CInvok, Args, *Diags);
+  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
-  CInvok.generateCC1CommandLine(GeneratedArgs, *this);
+  Invocation.generateCC1CommandLine(GeneratedArgs, *this);
 
   ASSERT_THAT(GeneratedArgs, Contains(StrEq("-fmodules-strict-context-hash")));
 }
@@ -83,9 +83,9 @@ TEST_F(CommandLineTest, CanGenerateCC1CommandLineSeparate) {
   const char *TripleCStr = "i686-apple-darwin9";
   const char *Args[] = {"clang", "-xc++", "-triple", TripleCStr, "-"};
 
-  CompilerInvocation::CreateFromArgs(CInvok, Args, *Diags);
+  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
-  CInvok.generateCC1CommandLine(GeneratedArgs, *this);
+  Invocation.generateCC1CommandLine(GeneratedArgs, *this);
 
   ASSERT_THAT(GeneratedArgs, Contains(StrEq(TripleCStr)));
 }
@@ -96,9 +96,9 @@ TEST_F(CommandLineTest,  
CanGenerateCC1CommandLineSeparateRequiredPresent) {
   const char *Args[] = {"clang", "-xc++", "-triple", DefaultTriple.c_str(),
 "-"};
 
-  CompilerInvocation::CreateFromArgs(CInvok, Args, *Diags);
+  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
-  CInvok.generateCC1CommandLine(GeneratedArgs, *this);
+  Invocation.generateCC1CommandLine(GeneratedArgs, *this);
 
   // Triple should always be emitted even if it is the default
   ASSERT_THAT(GeneratedArgs, Contains(StrEq(DefaultTriple.c_str(;
@@ -109,9 +109,9 @@ TEST_F(CommandLineTest, 
CanGenerateCC1CommandLineSeparateRequiredAbsent) {
   llvm::Triple::normalize(llvm::sys::getDefaultTargetTriple());
   const char *Args[] = {"clang", "-xc++", "-"};
 
-  CompilerInvocation::CreateFromArgs(CInvok, Args, *Diags);
+  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
-  CInvok.generateCC1CommandLine(GeneratedArgs, *this);
+  Invocation.generateCC1CommandLine(GeneratedArgs, *this);
 
  

[llvm-branch-commits] [clang] 5afff86 - [clang][cli] CompilerInvocationTest: split enum test into two

2020-12-09 Thread Jan Svoboda via llvm-branch-commits

Author: Jan Svoboda
Date: 2020-12-09T08:58:45+01:00
New Revision: 5afff86d26163bc3ba93fb299ccfc2522d3fdc94

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

LOG: [clang][cli] CompilerInvocationTest: split enum test into two

Depends on D92826.

Reviewed By: dexonsmith

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

Added: 


Modified: 
clang/unittests/Frontend/CompilerInvocationTest.cpp

Removed: 




diff  --git a/clang/unittests/Frontend/CompilerInvocationTest.cpp 
b/clang/unittests/Frontend/CompilerInvocationTest.cpp
index 69a807056f29..39929b8fc032 100644
--- a/clang/unittests/Frontend/CompilerInvocationTest.cpp
+++ b/clang/unittests/Frontend/CompilerInvocationTest.cpp
@@ -17,9 +17,7 @@ using namespace llvm;
 using namespace clang;
 
 using ::testing::Contains;
-using ::testing::Each;
 using ::testing::StrEq;
-using ::testing::StrNe;
 
 namespace {
 class CommandLineTest : public ::testing::Test {
@@ -117,27 +115,26 @@ TEST_F(CommandLineTest, 
CanGenerateCC1CommandLineSeparateRequiredAbsent) {
   ASSERT_THAT(GeneratedArgs, Contains(StrEq(DefaultTriple.c_str(;
 }
 
-TEST_F(CommandLineTest, CanGenerateCC1CommandLineSeparateEnum) {
-  const char *RelocationModelCStr = "static";
-  const char *Args[] = {"clang", "-xc++", "-mrelocation-model",
-RelocationModelCStr, "-"};
+TEST_F(CommandLineTest, CanGenerateCC1CommandLineSeparateEnumNonDefault) {
+  const char *Args[] = {"clang", "-xc++", "-mrelocation-model", "static", "-"};
 
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
   Invocation.generateCC1CommandLine(GeneratedArgs, *this);
 
-  // Non default relocation model
-  ASSERT_THAT(GeneratedArgs, Contains(StrEq(RelocationModelCStr)));
-  GeneratedArgs.clear();
+  // Non default relocation model.
+  ASSERT_THAT(GeneratedArgs, Contains(StrEq("static")));
+}
+
+TEST_F(CommandLineTest, CanGenerateCC1COmmandLineSeparateEnumDefault) {
+  const char *Args[] = {"clang", "-xc++", "-mrelocation-model", "pic", "-"};
 
-  RelocationModelCStr = "pic";
-  Args[3] = RelocationModelCStr;
+  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
-  CompilerInvocation Invocation2;
-  CompilerInvocation::CreateFromArgs(Invocation2, Args, *Diags);
+  Invocation.generateCC1CommandLine(GeneratedArgs, *this);
 
-  Invocation2.generateCC1CommandLine(GeneratedArgs, *this);
-  ASSERT_THAT(GeneratedArgs, Each(StrNe(RelocationModelCStr)));
+  // Default relocation model.
+  ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("pic";
 }
 
 TEST_F(CommandLineTest, NotPresentNegativeFlagNotGenerated) {



___
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] 4894e42 - [clang][cli] CompilerInvocationTest: remove unnecessary command line arguments

2020-12-09 Thread Jan Svoboda via llvm-branch-commits

Author: Jan Svoboda
Date: 2020-12-09T08:58:45+01:00
New Revision: 4894e423e7b4b121bd4fb23cdba9870ff0f2a6b6

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

LOG: [clang][cli] CompilerInvocationTest: remove unnecessary command line 
arguments

Depends on D92827.

Reviewed By: dexonsmith

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

Added: 


Modified: 
clang/unittests/Frontend/CompilerInvocationTest.cpp

Removed: 




diff  --git a/clang/unittests/Frontend/CompilerInvocationTest.cpp 
b/clang/unittests/Frontend/CompilerInvocationTest.cpp
index 39929b8fc032..0eb76a13972c 100644
--- a/clang/unittests/Frontend/CompilerInvocationTest.cpp
+++ b/clang/unittests/Frontend/CompilerInvocationTest.cpp
@@ -36,7 +36,7 @@ class CommandLineTest : public ::testing::Test {
 };
 
 TEST_F(CommandLineTest, OptIsInitializedWithCustomDefaultValue) {
-  const char *Args[] = {"clang", "-xc++"};
+  const char *Args[] = {""};
 
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
@@ -44,7 +44,7 @@ TEST_F(CommandLineTest, 
OptIsInitializedWithCustomDefaultValue) {
 }
 
 TEST_F(CommandLineTest, OptOfNegativeFlagIsPopulatedWithFalse) {
-  const char *Args[] = {"clang", "-xc++", "-fno-temp-file"};
+  const char *Args[] = {"-fno-temp-file"};
 
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
@@ -52,7 +52,7 @@ TEST_F(CommandLineTest, 
OptOfNegativeFlagIsPopulatedWithFalse) {
 }
 
 TEST_F(CommandLineTest, OptsOfImpliedPositiveFlagArePopulatedWithTrue) {
-  const char *Args[] = {"clang", "-xc++", "-cl-unsafe-math-optimizations"};
+  const char *Args[] = {"-cl-unsafe-math-optimizations"};
 
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
@@ -68,7 +68,7 @@ TEST_F(CommandLineTest, 
OptsOfImpliedPositiveFlagArePopulatedWithTrue) {
 }
 
 TEST_F(CommandLineTest, CanGenerateCC1CommandLineFlag) {
-  const char *Args[] = {"clang", "-xc++", "-fmodules-strict-context-hash", 
"-"};
+  const char *Args[] = {"-fmodules-strict-context-hash"};
 
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
@@ -79,7 +79,7 @@ TEST_F(CommandLineTest, CanGenerateCC1CommandLineFlag) {
 
 TEST_F(CommandLineTest, CanGenerateCC1CommandLineSeparate) {
   const char *TripleCStr = "i686-apple-darwin9";
-  const char *Args[] = {"clang", "-xc++", "-triple", TripleCStr, "-"};
+  const char *Args[] = {"-triple", TripleCStr};
 
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
@@ -91,8 +91,7 @@ TEST_F(CommandLineTest, CanGenerateCC1CommandLineSeparate) {
 TEST_F(CommandLineTest,  CanGenerateCC1CommandLineSeparateRequiredPresent) {
   const std::string DefaultTriple =
   llvm::Triple::normalize(llvm::sys::getDefaultTargetTriple());
-  const char *Args[] = {"clang", "-xc++", "-triple", DefaultTriple.c_str(),
-"-"};
+  const char *Args[] = {"-triple", DefaultTriple.c_str()};
 
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
@@ -105,7 +104,7 @@ TEST_F(CommandLineTest,  
CanGenerateCC1CommandLineSeparateRequiredPresent) {
 TEST_F(CommandLineTest, CanGenerateCC1CommandLineSeparateRequiredAbsent) {
   const std::string DefaultTriple =
   llvm::Triple::normalize(llvm::sys::getDefaultTargetTriple());
-  const char *Args[] = {"clang", "-xc++", "-"};
+  const char *Args[] = {""};
 
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
@@ -116,7 +115,7 @@ TEST_F(CommandLineTest, 
CanGenerateCC1CommandLineSeparateRequiredAbsent) {
 }
 
 TEST_F(CommandLineTest, CanGenerateCC1CommandLineSeparateEnumNonDefault) {
-  const char *Args[] = {"clang", "-xc++", "-mrelocation-model", "static", "-"};
+  const char *Args[] = {"-mrelocation-model", "static"};
 
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
@@ -127,7 +126,7 @@ TEST_F(CommandLineTest, 
CanGenerateCC1CommandLineSeparateEnumNonDefault) {
 }
 
 TEST_F(CommandLineTest, CanGenerateCC1COmmandLineSeparateEnumDefault) {
-  const char *Args[] = {"clang", "-xc++", "-mrelocation-model", "pic", "-"};
+  const char *Args[] = {"-mrelocation-model", "pic"};
 
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
@@ -138,7 +137,7 @@ TEST_F(CommandLineTest, 
CanGenerateCC1COmmandLineSeparateEnumDefault) {
 }
 
 TEST_F(CommandLineTest, NotPresentNegativeFlagNotGenerated) {
-  const char *Args[] = {"clang", "-xc++"};
+  const char *Args[] = {""};
 
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
@@ -148,7 +147,7 @@ TEST_F(CommandLineTest, NotPresentNegativeFlagNotGenerated) 
{
 }
 
 TEST_F(CommandLineTest, PresentNegativeFlagGenerated) {
-  const char *Args[] = {"clang", "-xc++", "-fno-temp-file"};
+  const char *Args[] = {"-fno-temp-file"};
 
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
@@ -158,7 +157,7 

[llvm-branch-commits] [clang] 03692ba - [clang][cli] CompilerInvocationTest: check arg parsing does not produce diagnostics

2020-12-09 Thread Jan Svoboda via llvm-branch-commits

Author: Jan Svoboda
Date: 2020-12-09T08:58:45+01:00
New Revision: 03692bae1fc9b6232de7caea3b57ad2f3dc2a9d0

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

LOG: [clang][cli] CompilerInvocationTest: check arg parsing does not produce 
diagnostics

Depends on D92828.

Reviewed By: dexonsmith

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

Added: 


Modified: 
clang/unittests/Frontend/CompilerInvocationTest.cpp

Removed: 




diff  --git a/clang/unittests/Frontend/CompilerInvocationTest.cpp 
b/clang/unittests/Frontend/CompilerInvocationTest.cpp
index 0eb76a13972c..7712dd00b191 100644
--- a/clang/unittests/Frontend/CompilerInvocationTest.cpp
+++ b/clang/unittests/Frontend/CompilerInvocationTest.cpp
@@ -8,6 +8,7 @@
 
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/TextDiagnosticBuffer.h"
 #include "llvm/Support/Host.h"
 
 #include "gmock/gmock.h"
@@ -32,7 +33,9 @@ class CommandLineTest : public ::testing::Test {
   }
 
   CommandLineTest()
-  : Diags(CompilerInstance::createDiagnostics(new DiagnosticOptions())) {}
+  : Diags(CompilerInstance::createDiagnostics(new DiagnosticOptions(),
+  new TextDiagnosticBuffer())) 
{
+  }
 };
 
 TEST_F(CommandLineTest, OptIsInitializedWithCustomDefaultValue) {
@@ -40,6 +43,8 @@ TEST_F(CommandLineTest, 
OptIsInitializedWithCustomDefaultValue) {
 
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
+  ASSERT_FALSE(Diags->hasErrorOccurred());
+
   ASSERT_TRUE(Invocation.getFrontendOpts().UseTemporary);
 }
 
@@ -48,6 +53,8 @@ TEST_F(CommandLineTest, 
OptOfNegativeFlagIsPopulatedWithFalse) {
 
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
+  ASSERT_FALSE(Diags->hasErrorOccurred());
+
   ASSERT_FALSE(Invocation.getFrontendOpts().UseTemporary);
 }
 
@@ -56,6 +63,8 @@ TEST_F(CommandLineTest, 
OptsOfImpliedPositiveFlagArePopulatedWithTrue) {
 
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
+  ASSERT_FALSE(Diags->hasErrorOccurred());
+
   // Explicitly provided flag.
   ASSERT_TRUE(Invocation.getLangOpts()->CLUnsafeMath);
 
@@ -72,6 +81,8 @@ TEST_F(CommandLineTest, CanGenerateCC1CommandLineFlag) {
 
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
+  ASSERT_FALSE(Diags->hasErrorOccurred());
+
   Invocation.generateCC1CommandLine(GeneratedArgs, *this);
 
   ASSERT_THAT(GeneratedArgs, Contains(StrEq("-fmodules-strict-context-hash")));
@@ -83,6 +94,8 @@ TEST_F(CommandLineTest, CanGenerateCC1CommandLineSeparate) {
 
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
+  ASSERT_FALSE(Diags->hasErrorOccurred());
+
   Invocation.generateCC1CommandLine(GeneratedArgs, *this);
 
   ASSERT_THAT(GeneratedArgs, Contains(StrEq(TripleCStr)));
@@ -95,6 +108,8 @@ TEST_F(CommandLineTest,  
CanGenerateCC1CommandLineSeparateRequiredPresent) {
 
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
+  ASSERT_FALSE(Diags->hasErrorOccurred());
+
   Invocation.generateCC1CommandLine(GeneratedArgs, *this);
 
   // Triple should always be emitted even if it is the default
@@ -108,6 +123,8 @@ TEST_F(CommandLineTest, 
CanGenerateCC1CommandLineSeparateRequiredAbsent) {
 
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
+  ASSERT_FALSE(Diags->hasErrorOccurred());
+
   Invocation.generateCC1CommandLine(GeneratedArgs, *this);
 
   // Triple should always be emitted even if it is the default
@@ -119,6 +136,8 @@ TEST_F(CommandLineTest, 
CanGenerateCC1CommandLineSeparateEnumNonDefault) {
 
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
+  ASSERT_FALSE(Diags->hasErrorOccurred());
+
   Invocation.generateCC1CommandLine(GeneratedArgs, *this);
 
   // Non default relocation model.
@@ -130,6 +149,8 @@ TEST_F(CommandLineTest, 
CanGenerateCC1COmmandLineSeparateEnumDefault) {
 
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
+  ASSERT_FALSE(Diags->hasErrorOccurred());
+
   Invocation.generateCC1CommandLine(GeneratedArgs, *this);
 
   // Default relocation model.
@@ -141,6 +162,8 @@ TEST_F(CommandLineTest, NotPresentNegativeFlagNotGenerated) 
{
 
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
+  ASSERT_FALSE(Diags->hasErrorOccurred());
+
   Invocation.generateCC1CommandLine(GeneratedArgs, *this);
 
   ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fno-temp-file";
@@ -151,6 +174,8 @@ TEST_F(CommandLineTest, PresentNegativeFlagGenerated) {
 
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
+  ASSERT_FALSE(Diags->hasErrorOccurred());
+
   Invocation.generateCC1CommandLine(GeneratedArgs, *this);
 
   ASSERT_THAT(GeneratedArgs, Contains(StrEq("-fno-temp-file")));
@@ -161,

[llvm-branch-commits] [clang] 216d430 - [clang][cli] CompilerInvocationTest: join and add test cases

2020-12-09 Thread Jan Svoboda via llvm-branch-commits

Author: Jan Svoboda
Date: 2020-12-09T08:58:45+01:00
New Revision: 216d43053b4e7327e5f9eb5705a7c8e4f6ae850b

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

LOG: [clang][cli] CompilerInvocationTest: join and add test cases

Depends on D92829.

Reviewed By: dexonsmith

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

Added: 


Modified: 
clang/unittests/Frontend/CompilerInvocationTest.cpp

Removed: 




diff  --git a/clang/unittests/Frontend/CompilerInvocationTest.cpp 
b/clang/unittests/Frontend/CompilerInvocationTest.cpp
index 7712dd00b191..c3bdd6bff65c 100644
--- a/clang/unittests/Frontend/CompilerInvocationTest.cpp
+++ b/clang/unittests/Frontend/CompilerInvocationTest.cpp
@@ -38,42 +38,43 @@ class CommandLineTest : public ::testing::Test {
   }
 };
 
-TEST_F(CommandLineTest, OptIsInitializedWithCustomDefaultValue) {
+// Boolean option with a keypath that defaults to true.
+// The only flag with a negative spelling can set the keypath to false.
+
+TEST_F(CommandLineTest, BoolOptionDefaultTrueSingleFlagNotPresent) {
   const char *Args[] = {""};
 
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
   ASSERT_FALSE(Diags->hasErrorOccurred());
-
   ASSERT_TRUE(Invocation.getFrontendOpts().UseTemporary);
+
+  Invocation.generateCC1CommandLine(GeneratedArgs, *this);
+
+  ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fno-temp-file";
 }
 
-TEST_F(CommandLineTest, OptOfNegativeFlagIsPopulatedWithFalse) {
+TEST_F(CommandLineTest, BoolOptionDefaultTrueSingleFlagPresent) {
   const char *Args[] = {"-fno-temp-file"};
 
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
   ASSERT_FALSE(Diags->hasErrorOccurred());
-
   ASSERT_FALSE(Invocation.getFrontendOpts().UseTemporary);
-}
 
-TEST_F(CommandLineTest, OptsOfImpliedPositiveFlagArePopulatedWithTrue) {
-  const char *Args[] = {"-cl-unsafe-math-optimizations"};
-
-  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
+  Invocation.generateCC1CommandLine(GeneratedArgs, *this);
 
-  ASSERT_FALSE(Diags->hasErrorOccurred());
+  ASSERT_THAT(GeneratedArgs, Contains(StrEq("-fno-temp-file")));
+}
 
-  // Explicitly provided flag.
-  ASSERT_TRUE(Invocation.getLangOpts()->CLUnsafeMath);
+TEST_F(CommandLineTest, BoolOptionDefaultTrueSingleFlagUnknownPresent) {
+  const char *Args[] = {"-ftemp-file"};
 
-  // Flags directly implied by explicitly provided flag.
-  ASSERT_TRUE(Invocation.getCodeGenOpts().LessPreciseFPMAD);
-  ASSERT_TRUE(Invocation.getLangOpts()->UnsafeFPMath);
+  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
-  // Flag transitively implied by explicitly provided flag.
-  ASSERT_TRUE(Invocation.getLangOpts()->AllowRecip);
+  // Driver-only flag.
+  ASSERT_TRUE(Diags->hasErrorOccurred());
+  ASSERT_TRUE(Invocation.getFrontendOpts().UseTemporary);
 }
 
 TEST_F(CommandLineTest, CanGenerateCC1CommandLineFlag) {
@@ -157,75 +158,101 @@ TEST_F(CommandLineTest, 
CanGenerateCC1COmmandLineSeparateEnumDefault) {
   ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("pic";
 }
 
-TEST_F(CommandLineTest, NotPresentNegativeFlagNotGenerated) {
-  const char *Args[] = {""};
-
-  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
-
-  ASSERT_FALSE(Diags->hasErrorOccurred());
-
-  Invocation.generateCC1CommandLine(GeneratedArgs, *this);
-
-  ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fno-temp-file";
-}
-
-TEST_F(CommandLineTest, PresentNegativeFlagGenerated) {
-  const char *Args[] = {"-fno-temp-file"};
-
-  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
-
-  ASSERT_FALSE(Diags->hasErrorOccurred());
-
-  Invocation.generateCC1CommandLine(GeneratedArgs, *this);
-
-  ASSERT_THAT(GeneratedArgs, Contains(StrEq("-fno-temp-file")));
-}
+// Tree of boolean options that can be (directly or transitively) implied by
+// their parent:
+//
+//   * -cl-unsafe-math-optimizations
+// * -cl-mad-enable
+// * -menable-unsafe-fp-math
+//   * -freciprocal-math
 
-TEST_F(CommandLineTest, NotPresentAndNotImpliedNotGenerated) {
+TEST_F(CommandLineTest, ImpliedBoolOptionsNoFlagPresent) {
   const char *Args[] = {""};
 
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
   ASSERT_FALSE(Diags->hasErrorOccurred());
+  ASSERT_FALSE(Invocation.getLangOpts()->CLUnsafeMath);
+  ASSERT_FALSE(Invocation.getCodeGenOpts().LessPreciseFPMAD);
+  ASSERT_FALSE(Invocation.getLangOpts()->UnsafeFPMath);
+  ASSERT_FALSE(Invocation.getLangOpts()->AllowRecip);
 
   Invocation.generateCC1CommandLine(GeneratedArgs, *this);
 
-  // Missing options are not generated.
+  // Not generated - missing.
   ASSERT_THAT(GeneratedArgs,
   Not(Contains(StrEq("-cl-unsafe-math-optimizations";
   ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-cl-mad-enable";
   ASSE

[llvm-branch-commits] [clang] 35621cc - [clang][cli] CompilerInvocationTest: add tests for boolean options

2020-12-09 Thread Jan Svoboda via llvm-branch-commits

Author: Jan Svoboda
Date: 2020-12-09T08:58:46+01:00
New Revision: 35621cc2e3b3778abc2bacf37f3b1e9dfac52895

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

LOG: [clang][cli] CompilerInvocationTest: add tests for boolean options

Add more tests of the command line marshalling infrastructure.

The new tests now make a "round-trip": from arguments, to CompilerInvocation 
instance to arguments again in a single test case.

The TODOs are resolved in a follow-up patch.

Depends on D92830.

Reviewed By: dexonsmith

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

Added: 


Modified: 
clang/unittests/Frontend/CompilerInvocationTest.cpp

Removed: 




diff  --git a/clang/unittests/Frontend/CompilerInvocationTest.cpp 
b/clang/unittests/Frontend/CompilerInvocationTest.cpp
index c3bdd6bff65c..b0fe11dd8d5b 100644
--- a/clang/unittests/Frontend/CompilerInvocationTest.cpp
+++ b/clang/unittests/Frontend/CompilerInvocationTest.cpp
@@ -77,6 +77,150 @@ TEST_F(CommandLineTest, 
BoolOptionDefaultTrueSingleFlagUnknownPresent) {
   ASSERT_TRUE(Invocation.getFrontendOpts().UseTemporary);
 }
 
+// Boolean option with a keypath that defaults to true.
+// The flag with negative spelling can set the keypath to false.
+// The flag with positive spelling can reset the keypath to true.
+
+TEST_F(CommandLineTest, BoolOptionDefaultTruePresentNone) {
+  const char *Args[] = {""};
+
+  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
+  ASSERT_FALSE(Diags->hasErrorOccurred());
+  ASSERT_TRUE(Invocation.getCodeGenOpts().Autolink);
+
+  // TODO: Test argument generation.
+}
+
+TEST_F(CommandLineTest, BoolOptionDefaultTruePresentNegChange) {
+  const char *Args[] = {"-fno-autolink"};
+
+  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
+  ASSERT_FALSE(Diags->hasErrorOccurred());
+  ASSERT_FALSE(Invocation.getCodeGenOpts().Autolink);
+
+  // TODO: Test argument generation.
+}
+
+TEST_F(CommandLineTest, BoolOptionDefaultTruePresentPosReset) {
+  const char *Args[] = {"-fautolink"};
+
+  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
+  ASSERT_TRUE(Diags->hasErrorOccurred()); // Driver-only flag.
+  ASSERT_TRUE(Invocation.getCodeGenOpts().Autolink);
+}
+
+// Boolean option with a keypath that defaults to false.
+// The flag with negative spelling can set the keypath to true.
+// The flag with positive spelling can reset the keypath to false.
+
+TEST_F(CommandLineTest, BoolOptionDefaultFalsePresentNone) {
+  const char *Args[] = {""};
+
+  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
+  ASSERT_FALSE(Diags->hasErrorOccurred());
+  ASSERT_FALSE(Invocation.getCodeGenOpts().NoInlineLineTables);
+
+  // TODO: Test argument generation.
+}
+
+TEST_F(CommandLineTest, BoolOptionDefaultFalsePresentNegChange) {
+  const char *Args[] = {"-gno-inline-line-tables"};
+
+  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
+  ASSERT_FALSE(Diags->hasErrorOccurred());
+  ASSERT_TRUE(Invocation.getCodeGenOpts().NoInlineLineTables);
+
+  // TODO: Test argument generation.
+}
+
+TEST_F(CommandLineTest, BoolOptionDefaultFalsePresentPosReset) {
+  const char *Args[] = {"-ginline-line-tables"};
+
+  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
+  ASSERT_TRUE(Diags->hasErrorOccurred()); // Driver-only flag.
+  ASSERT_FALSE(Invocation.getCodeGenOpts().NoInlineLineTables);
+}
+
+// Boolean option with a keypath that defaults to false.
+// The flag with positive spelling can set the keypath to true.
+// The flag with negative spelling can reset the keypath to false.
+
+TEST_F(CommandLineTest, BoolOptionDefaultFalsePresentNoneX) {
+  const char *Args[] = {""};
+
+  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
+  ASSERT_FALSE(Diags->hasErrorOccurred());
+  ASSERT_FALSE(Invocation.getCodeGenOpts().CodeViewGHash);
+
+  // TODO: Test argument generation.
+}
+
+TEST_F(CommandLineTest, BoolOptionDefaultFalsePresentPosChange) {
+  const char *Args[] = {"-gcodeview-ghash"};
+
+  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
+  ASSERT_FALSE(Diags->hasErrorOccurred());
+  ASSERT_TRUE(Invocation.getCodeGenOpts().CodeViewGHash);
+
+  // TODO: Test argument generation.
+}
+
+TEST_F(CommandLineTest, BoolOptionDefaultFalsePresentNegReset) {
+  const char *Args[] = {"-gno-codeview-ghash"};
+
+  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
+  ASSERT_TRUE(Diags->hasErrorOccurred()); // Driver-only flag.
+  ASSERT_FALSE(Invocation.getCodeGenOpts().CodeViewGHash);
+}
+
+// Boolean option with a keypath that defaults to an arbitrary expression.
+// The flag with positive spelling can set the keypath to true.
+// The flag with negative spelling can set the keypath to false.
+
+// NOTE: The following tests need to be updated wh

[llvm-branch-commits] [lldb] ce14ffa - [lldb] Fix a failure test after 843f2dbf003f2a51d0d4ab8cf40647c99ded2e93.

2020-12-09 Thread Haojian Wu via llvm-branch-commits

Author: Haojian Wu
Date: 2020-12-09T09:32:13+01:00
New Revision: ce14ffa1bba2b609eaba81186c51cf26e9cd60ac

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

LOG: [lldb] Fix a failure test after 843f2dbf003f2a51d0d4ab8cf40647c99ded2e93.

The behavior of -gsplit-dwarf is changed because of the new commit.

Restore the old behavior by replacing -gsplit-dwarf with -gsplit-dwarf -g.

Added: 


Modified: 
lldb/test/Shell/SymbolFile/DWARF/split-dwarf-inlining.cpp

Removed: 




diff  --git a/lldb/test/Shell/SymbolFile/DWARF/split-dwarf-inlining.cpp 
b/lldb/test/Shell/SymbolFile/DWARF/split-dwarf-inlining.cpp
index 5873d896b19a..39c3fd643349 100644
--- a/lldb/test/Shell/SymbolFile/DWARF/split-dwarf-inlining.cpp
+++ b/lldb/test/Shell/SymbolFile/DWARF/split-dwarf-inlining.cpp
@@ -1,4 +1,4 @@
-// RUN: %clangxx -target x86_64-pc-linux -gsplit-dwarf -fsplit-dwarf-inlining \
+// RUN: %clangxx -target x86_64-pc-linux -gsplit-dwarf -g 
-fsplit-dwarf-inlining \
 // RUN:   -c %s -o %t
 // RUN: %lldb %t -o "breakpoint set -n foo" -b | FileCheck %s
 



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


[llvm-branch-commits] [llvm] 0ef0de6 - Fix typo in llvm/lib/Target/README.txt

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

Author: Siddhesh Poyarekar
Date: 2020-12-09T10:12:26+01:00
New Revision: 0ef0de65f14ea63a1800c56cbc2faad5b10e828f

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

LOG: Fix typo in llvm/lib/Target/README.txt

Trivial typo, replace __builtin_objectsize with __builtin_object_size.

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

Added: 


Modified: 
llvm/lib/Target/README.txt

Removed: 




diff  --git a/llvm/lib/Target/README.txt b/llvm/lib/Target/README.txt
index a4876f715c64..e172abbbd855 100644
--- a/llvm/lib/Target/README.txt
+++ b/llvm/lib/Target/README.txt
@@ -1840,7 +1840,7 @@ current definition always folds to a constant. We also 
should make sure that
 we remove checking in code like
 
   char *p = malloc(strlen(s)+1);
-  __strcpy_chk(p, s, __builtin_objectsize(p, 0));
+  __strcpy_chk(p, s, __builtin_object_size(p, 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] abae3c1 - [obj2yaml] - Support dumping objects that have multiple SHT_SYMTAB_SHNDX sections.

2020-12-09 Thread Georgii Rymar via llvm-branch-commits

Author: Georgii Rymar
Date: 2020-12-09T12:14:58+03:00
New Revision: abae3c11969defb6537dff99806668eacb6f0057

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

LOG: [obj2yaml] - Support dumping objects that have multiple SHT_SYMTAB_SHNDX 
sections.

It is allowed to have multiple `SHT_SYMTAB_SHNDX` sections, though
we currently don't implement it.

The current implementation assumes that there is a maximum of one 
SHT_SYMTAB_SHNDX
section and that it is always linked with .symtab section.

This patch drops this limitations.

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

Added: 


Modified: 
llvm/test/tools/obj2yaml/ELF/sht-symtab-shndx.yaml
llvm/tools/obj2yaml/elf2yaml.cpp

Removed: 




diff  --git a/llvm/test/tools/obj2yaml/ELF/sht-symtab-shndx.yaml 
b/llvm/test/tools/obj2yaml/ELF/sht-symtab-shndx.yaml
index 2b337538acba..1c1e95e5bacb 100644
--- a/llvm/test/tools/obj2yaml/ELF/sht-symtab-shndx.yaml
+++ b/llvm/test/tools/obj2yaml/ELF/sht-symtab-shndx.yaml
@@ -94,7 +94,7 @@ Symbols:
 # RUN: yaml2obj --docnum=4 %s -o %t4
 # RUN: not obj2yaml %t4 2>&1 | FileCheck %s -DFILE=%t4 --check-prefix=CASE4
 
-## CASE4: Error reading file: [[FILE]]: SHT_SYMTAB_SHNDX has 3 entries, but 
the symbol table associated has 2
+## CASE4: Error reading file: [[FILE]]: unable to read extended section 
indexes: SHT_SYMTAB_SHNDX has 3 entries, but the symbol table associated has 2
 
 --- !ELF
 FileHeader:
@@ -113,12 +113,14 @@ Symbols:
 Index: SHN_XINDEX
 
 ## ELF gABI allows having multiple SHT_SYMTAB_SHNDX sections.
-## We only support having one associated with .symtab now.
+## Only one is allowed to be linked with a corresponding symbol table section 
though.
+## Check we report an error when multiple SHT_SYMTAB_SHNDX sections are linked
+## to the same symbol table.
 
 # RUN: yaml2obj --docnum=5 %s -o %t5
 # RUN: not obj2yaml %t5 2>&1 | FileCheck %s -DFILE=%t5 --check-prefix=CASE5
 
-# CASE5: Error reading file: [[FILE]]: multiple SHT_SYMTAB_SHNDX sections are 
not supported
+# CASE5: Error reading file: [[FILE]]: multiple SHT_SYMTAB_SHNDX sections are 
linked to the same symbol table with index 5
 
 --- !ELF
 FileHeader:
@@ -128,14 +130,41 @@ FileHeader:
 Sections:
   - Name:.symtab_shndx1
 Type:SHT_SYMTAB_SHNDX
-Entries: [ 0 ]
+Entries: [ 0, 1 ]
 EntSize: 4
 Link:.symtab
   - Name:.symtab_shndx2
 Type:SHT_SYMTAB_SHNDX
-Entries: [ 0 ]
-Link:.symtab
-Symbols: []
+Entries: [ 0, 2 ]
+Link:[[LINK=.symtab]]
+Symbols:
+  - Type:  STT_SECTION
+Index: SHN_XINDEX
+DynamicSymbols:
+  - Type:  STT_SECTION
+Index: SHN_XINDEX
+
+## Check it is possible to dump an object that has multiple SHT_SYMTAB_SHNDX 
sections.
+## Check that yaml2obj can dump the object and dynamic symbols properly when
+## the SHT_SYMTAB_SHNDX section is associated with a SHT_DYNSYM section.
+
+# RUN: yaml2obj --docnum=5 -DLINK=.dynsym %s -o %t5.multiple
+# RUN: obj2yaml %t5.multiple | FileCheck %s --check-prefix=MULTIPLE-SYMTAB
+
+# MULTIPLE-SYMTAB:  - Name: .symtab_shndx1
+# MULTIPLE-SYMTAB-NEXT:   Type: SHT_SYMTAB_SHNDX
+# MULTIPLE-SYMTAB-NEXT:   Link: .symtab
+# MULTIPLE-SYMTAB:  - Name: .symtab_shndx2
+# MULTIPLE-SYMTAB-NEXT:   Type: SHT_SYMTAB_SHNDX
+# MULTIPLE-SYMTAB-NEXT:   Link: .dynsym
+# MULTIPLE-SYMTAB:  Symbols:
+# MULTIPLE-SYMTAB-NEXT:   - Name:  .symtab_shndx1
+# MULTIPLE-SYMTAB-NEXT: Type:  STT_SECTION
+# MULTIPLE-SYMTAB-NEXT: Index: SHN_XINDEX
+# MULTIPLE-SYMTAB-NEXT: DynamicSymbols:
+# MULTIPLE-SYMTAB-NEXT:   - Name:   .symtab_shndx2
+# MULTIPLE-SYMTAB-NEXT: Type:   STT_SECTION
+# MULTIPLE-SYMTAB-NEXT: Index:  SHN_XINDEX
 
 ## Check that yaml2obj can't dump the object if SHT_SYMTAB_SHNDX is
 ## not associated with a SHT_SYMTAB section (this case is illegal).
@@ -143,7 +172,7 @@ Symbols: []
 # RUN: yaml2obj --docnum=6 %s -o %t6
 # RUN: not obj2yaml %t6 2>&1 | FileCheck %s -DFILE=%t6 --check-prefix=CASE6
 
-# CASE6: Error reading file: [[FILE]]: only SHT_SYMTAB_SHNDX associated with 
SHT_SYMTAB are supported
+# CASE6: Error reading file: [[FILE]]: unable to read extended section 
indexes: SHT_SYMTAB_SHNDX section is linked with SHT_PROGBITS section (expected 
SHT_SYMTAB/SHT_DYNSYM)
 
 --- !ELF
 FileHeader:
@@ -157,25 +186,3 @@ Sections:
 Link:.foo
   - Name:.foo
 Type:SHT_PROGBITS
-
-## Check that yaml2obj can't dump the object if SHT_SYMTAB_SHNDX is
-## associated with a SHT_DYNSYM section (not implemented yet).
-
-# RUN: yaml2obj --docnum=7 %s -o %t7
-# RUN: not obj2yaml %t7 2>&1 | FileCheck %s -DFILE=%t7 --check-prefix=CASE7
-
-# CASE7: Error reading file: [[FILE]]: only SHT_SYMTAB_SHNDX associated with 
SHT_SYMTAB are supported
-
 !ELF
-FileHeader:
-  Class: ELFCLASS64
-  Da

[llvm-branch-commits] [mlir] d536569 - [MLIR] Expose target configuration for lowering to NVVM

2020-12-09 Thread Frederik Gossen via llvm-branch-commits

Author: Frederik Gossen
Date: 2020-12-09T10:29:38+01:00
New Revision: d53656900921de5bb26b849b5910efd05a233107

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

LOG: [MLIR] Expose target configuration for lowering to NVVM

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

Added: 


Modified: 
mlir/include/mlir/Conversion/GPUToNVVM/GPUToNVVMPass.h
mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp

Removed: 




diff  --git a/mlir/include/mlir/Conversion/GPUToNVVM/GPUToNVVMPass.h 
b/mlir/include/mlir/Conversion/GPUToNVVM/GPUToNVVMPass.h
index 1af13057f2ea..8be0a7cad017 100644
--- a/mlir/include/mlir/Conversion/GPUToNVVM/GPUToNVVMPass.h
+++ b/mlir/include/mlir/Conversion/GPUToNVVM/GPUToNVVMPass.h
@@ -14,6 +14,7 @@
 namespace mlir {
 class LLVMTypeConverter;
 class OwningRewritePatternList;
+class ConversionTarget;
 
 template  class OperationPass;
 
@@ -21,6 +22,9 @@ namespace gpu {
 class GPUModuleOp;
 }
 
+/// Configure target to convert from to convert from the GPU dialect to NVVM.
+void configureGpuToNVVMConversionLegality(ConversionTarget &target);
+
 /// Collect a set of patterns to convert from the GPU dialect to NVVM.
 void populateGpuToNVVMConversionPatterns(LLVMTypeConverter &converter,
  OwningRewritePatternList &patterns);

diff  --git a/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp 
b/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
index 467c622f8bde..a0fe48175636 100644
--- a/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
+++ b/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
@@ -135,14 +135,7 @@ struct LowerGpuOpsToNVVMOpsPass
 populateStdToLLVMConversionPatterns(converter, llvmPatterns);
 populateGpuToNVVMConversionPatterns(converter, llvmPatterns);
 LLVMConversionTarget target(getContext());
-target.addIllegalDialect();
-target.addIllegalOp();
-target.addIllegalOp();
-target.addLegalDialect();
-// TODO: Remove once we support replacing non-root ops.
-target.addLegalOp();
+configureGpuToNVVMConversionLegality(target);
 if (failed(applyPartialConversion(m, target, std::move(llvmPatterns
   signalPassFailure();
   }
@@ -150,6 +143,19 @@ struct LowerGpuOpsToNVVMOpsPass
 
 } // anonymous namespace
 
+void mlir::configureGpuToNVVMConversionLegality(ConversionTarget &target) {
+  target.addIllegalOp();
+  target.addLegalDialect<::mlir::LLVM::LLVMDialect>();
+  target.addLegalDialect<::mlir::NVVM::NVVMDialect>();
+  target.addIllegalDialect();
+  target.addIllegalOp();
+
+  // TODO: Remove once we support replacing non-root ops.
+  target.addLegalOp();
+}
+
 void mlir::populateGpuToNVVMConversionPatterns(
 LLVMTypeConverter &converter, OwningRewritePatternList &patterns) {
   populateWithGenerated(converter.getDialect()->getContext(), patterns);



___
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] bdfafc4 - [llvm-readelf/obj] - Improve diagnostics when printing NT_FILE notes.

2020-12-09 Thread Georgii Rymar via llvm-branch-commits

Author: Georgii Rymar
Date: 2020-12-09T12:31:46+03:00
New Revision: bdfafc4613bd2ff933c846708f4726128fb4b1ce

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

LOG: [llvm-readelf/obj] - Improve diagnostics when printing NT_FILE notes.

This changes the `printNotesHelper` to report warnings on its side when
there are errors when dumping notes.

With that we can provide more content when reporting warnings about broken 
notes.

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

Added: 


Modified: 
llvm/test/tools/llvm-readobj/ELF/note-core-ntfile-bad.test
llvm/tools/llvm-readobj/ELFDumper.cpp

Removed: 




diff  --git a/llvm/test/tools/llvm-readobj/ELF/note-core-ntfile-bad.test 
b/llvm/test/tools/llvm-readobj/ELF/note-core-ntfile-bad.test
index ca3033c7248a..5a497c23a795 100644
--- a/llvm/test/tools/llvm-readobj/ELF/note-core-ntfile-bad.test
+++ b/llvm/test/tools/llvm-readobj/ELF/note-core-ntfile-bad.test
@@ -9,7 +9,9 @@
 
 # RUN: yaml2obj --docnum=1 %s -o %t1.o
 # RUN: llvm-readelf -n %t1.o 2>&1 | FileCheck -DFILE=%t1.o %s 
--check-prefix=ERR-HEADER-SHORT
-# ERR-HEADER-SHORT: warning: '[[FILE]]': malformed note: header too short
+# RUN: llvm-readobj -n %t1.o 2>&1 | FileCheck -DFILE=%t1.o %s 
--check-prefix=ERR-HEADER-SHORT
+
+# ERR-HEADER-SHORT: warning: '[[FILE]]': unable to read note with index 0 from 
the PT_NOTE segment with index 1: the note of size 0x8 is too short, expected 
at least 0x10
 
 # .section ".note.foo", "a"
 #   .align 4
@@ -38,7 +40,9 @@ ProgramHeaders:
 
 # RUN: yaml2obj --docnum=2 %s -o %t2.o
 # RUN: llvm-readelf -n %t2.o 2>&1 | FileCheck -DFILE=%t2.o %s 
--check-prefix=ERR-NULL-TERM
-# ERR-NULL-TERM: warning: '[[FILE]]': malformed note: not NUL terminated
+# RUN: llvm-readobj -n %t2.o 2>&1 | FileCheck -DFILE=%t2.o %s 
--check-prefix=ERR-NULL-TERM
+
+# ERR-NULL-TERM: warning: '[[FILE]]': unable to read note with index 0 from 
the PT_NOTE segment with index 1: the note is not NUL terminated
 
 # .section ".note.foo", "a"
 #   .align 4
@@ -72,7 +76,9 @@ ProgramHeaders:
 
 # RUN: yaml2obj --docnum=3 %s -o %t3.o
 # RUN: llvm-readelf -n %t3.o 2>&1 | FileCheck -DFILE=%t3.o %s 
--check-prefix=ERR-FILE-COUNT
-# ERR-FILE-COUNT: warning: '[[FILE]]': malformed note: too short for number of 
files
+# RUN: llvm-readobj -n %t3.o 2>&1 | FileCheck -DFILE=%t3.o %s 
--check-prefix=ERR-FILE-COUNT
+
+# ERR-FILE-COUNT: warning: '[[FILE]]': unable to read note with index 0 from 
the PT_NOTE segment with index 1: unable to read file mappings (found 2): the 
note of size 0x2c is too short
 
 # .section ".note.foo", "a"
 #   .align 4
@@ -106,7 +112,9 @@ ProgramHeaders:
 
 # RUN: yaml2obj --docnum=4 %s -o %t4.o
 # RUN: llvm-readelf -n %t4.o 2>&1 | FileCheck -DFILE=%t4.o %s 
--check-prefix=ERR-FILE-END-EARLY
-# ERR-FILE-END-EARLY: warning: '[[FILE]]': malformed note: too few filenames
+# RUN: llvm-readobj -n %t4.o 2>&1 | FileCheck -DFILE=%t4.o %s 
--check-prefix=ERR-FILE-END-EARLY
+
+# ERR-FILE-END-EARLY: warning: '[[FILE]]': unable to read note with index 0 
from the PT_NOTE segment with index 1: unable to read the file name for the 
mapping with index 2: the note of size 0x44 is truncated
 
 # .section ".note.foo", "a"
 #   .align 4

diff  --git a/llvm/tools/llvm-readobj/ELFDumper.cpp 
b/llvm/tools/llvm-readobj/ELFDumper.cpp
index 2a286cb0b50d..279e406397d5 100644
--- a/llvm/tools/llvm-readobj/ELFDumper.cpp
+++ b/llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -5333,19 +5333,20 @@ static Expected readCoreNote(DataExtractor 
Desc) {
   const int Bytes = Desc.getAddressSize();
 
   if (!Desc.isValidOffsetForAddress(2))
-return createStringError(object_error::parse_failed,
- "malformed note: header too short");
+return createError("the note of size 0x" + Twine::utohexstr(Desc.size()) +
+   " is too short, expected at least 0x" +
+   Twine::utohexstr(Bytes * 2));
   if (Desc.getData().back() != 0)
-return createStringError(object_error::parse_failed,
- "malformed note: not NUL terminated");
+return createError("the note is not NUL terminated");
 
   uint64_t DescOffset = 0;
   uint64_t FileCount = Desc.getAddress(&DescOffset);
   Ret.PageSize = Desc.getAddress(&DescOffset);
 
   if (!Desc.isValidOffsetForAddress(3 * FileCount * Bytes))
-return createStringError(object_error::parse_failed,
- "malformed note: too short for number of files");
+return createError("unable to read file mappings (found " +
+   Twine(FileCount) + "): the note of size 0x" +
+   Twine::utohexstr(Desc.size()) + " is too short");
 
   uint64_t FilenamesOffset = 0;
   DataExtractor Filenames(
@@ -5353,10 +5354,1

[llvm-branch-commits] [clang] 13e4e5e - Revert "[clang][cli] CompilerInvocationTest: add tests for boolean options"

2020-12-09 Thread Jan Svoboda via llvm-branch-commits

Author: Jan Svoboda
Date: 2020-12-09T10:35:07+01:00
New Revision: 13e4e5ed59c92d81ee5fee55f20ecf1842ec8cf3

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

LOG: Revert "[clang][cli] CompilerInvocationTest: add tests for boolean options"

Differential Revision of original patch: https://reviews.llvm.org/D92774

Added: 


Modified: 
clang/unittests/Frontend/CompilerInvocationTest.cpp

Removed: 




diff  --git a/clang/unittests/Frontend/CompilerInvocationTest.cpp 
b/clang/unittests/Frontend/CompilerInvocationTest.cpp
index b0fe11dd8d5b..c3bdd6bff65c 100644
--- a/clang/unittests/Frontend/CompilerInvocationTest.cpp
+++ b/clang/unittests/Frontend/CompilerInvocationTest.cpp
@@ -77,150 +77,6 @@ TEST_F(CommandLineTest, 
BoolOptionDefaultTrueSingleFlagUnknownPresent) {
   ASSERT_TRUE(Invocation.getFrontendOpts().UseTemporary);
 }
 
-// Boolean option with a keypath that defaults to true.
-// The flag with negative spelling can set the keypath to false.
-// The flag with positive spelling can reset the keypath to true.
-
-TEST_F(CommandLineTest, BoolOptionDefaultTruePresentNone) {
-  const char *Args[] = {""};
-
-  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
-  ASSERT_FALSE(Diags->hasErrorOccurred());
-  ASSERT_TRUE(Invocation.getCodeGenOpts().Autolink);
-
-  // TODO: Test argument generation.
-}
-
-TEST_F(CommandLineTest, BoolOptionDefaultTruePresentNegChange) {
-  const char *Args[] = {"-fno-autolink"};
-
-  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
-  ASSERT_FALSE(Diags->hasErrorOccurred());
-  ASSERT_FALSE(Invocation.getCodeGenOpts().Autolink);
-
-  // TODO: Test argument generation.
-}
-
-TEST_F(CommandLineTest, BoolOptionDefaultTruePresentPosReset) {
-  const char *Args[] = {"-fautolink"};
-
-  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
-  ASSERT_TRUE(Diags->hasErrorOccurred()); // Driver-only flag.
-  ASSERT_TRUE(Invocation.getCodeGenOpts().Autolink);
-}
-
-// Boolean option with a keypath that defaults to false.
-// The flag with negative spelling can set the keypath to true.
-// The flag with positive spelling can reset the keypath to false.
-
-TEST_F(CommandLineTest, BoolOptionDefaultFalsePresentNone) {
-  const char *Args[] = {""};
-
-  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
-  ASSERT_FALSE(Diags->hasErrorOccurred());
-  ASSERT_FALSE(Invocation.getCodeGenOpts().NoInlineLineTables);
-
-  // TODO: Test argument generation.
-}
-
-TEST_F(CommandLineTest, BoolOptionDefaultFalsePresentNegChange) {
-  const char *Args[] = {"-gno-inline-line-tables"};
-
-  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
-  ASSERT_FALSE(Diags->hasErrorOccurred());
-  ASSERT_TRUE(Invocation.getCodeGenOpts().NoInlineLineTables);
-
-  // TODO: Test argument generation.
-}
-
-TEST_F(CommandLineTest, BoolOptionDefaultFalsePresentPosReset) {
-  const char *Args[] = {"-ginline-line-tables"};
-
-  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
-  ASSERT_TRUE(Diags->hasErrorOccurred()); // Driver-only flag.
-  ASSERT_FALSE(Invocation.getCodeGenOpts().NoInlineLineTables);
-}
-
-// Boolean option with a keypath that defaults to false.
-// The flag with positive spelling can set the keypath to true.
-// The flag with negative spelling can reset the keypath to false.
-
-TEST_F(CommandLineTest, BoolOptionDefaultFalsePresentNoneX) {
-  const char *Args[] = {""};
-
-  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
-  ASSERT_FALSE(Diags->hasErrorOccurred());
-  ASSERT_FALSE(Invocation.getCodeGenOpts().CodeViewGHash);
-
-  // TODO: Test argument generation.
-}
-
-TEST_F(CommandLineTest, BoolOptionDefaultFalsePresentPosChange) {
-  const char *Args[] = {"-gcodeview-ghash"};
-
-  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
-  ASSERT_FALSE(Diags->hasErrorOccurred());
-  ASSERT_TRUE(Invocation.getCodeGenOpts().CodeViewGHash);
-
-  // TODO: Test argument generation.
-}
-
-TEST_F(CommandLineTest, BoolOptionDefaultFalsePresentNegReset) {
-  const char *Args[] = {"-gno-codeview-ghash"};
-
-  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
-  ASSERT_TRUE(Diags->hasErrorOccurred()); // Driver-only flag.
-  ASSERT_FALSE(Invocation.getCodeGenOpts().CodeViewGHash);
-}
-
-// Boolean option with a keypath that defaults to an arbitrary expression.
-// The flag with positive spelling can set the keypath to true.
-// The flag with negative spelling can set the keypath to false.
-
-// NOTE: The following tests need to be updated when we start enabling the new
-// pass manager by default.
-
-TEST_F(CommandLineTest, BoolOptionDefaultArbitraryTwoFlagsPresentNone) {
-  const char *Args = {""};
-
-  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
-
-  ASSERT_FALSE(Diags->hasE

[llvm-branch-commits] [llvm] af5fd65 - [RISCV] Fix missing def operand when creating VSETVLI pseudos

2020-12-09 Thread Fraser Cormack via llvm-branch-commits

Author: Fraser Cormack
Date: 2020-12-09T09:35:28Z
New Revision: af5fd658952a7f1d9d2a1007217755bd04b4dd4e

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

LOG: [RISCV] Fix missing def operand when creating VSETVLI pseudos

The register operand was not being marked as a def when it should be. No tests
for this in the main branch as there are not yet any pseudos without a
non-negative VLIndex.

Also change the type of a virtual register operand from unsigned to Register
and adjust formatting.

Reviewed By: craig.topper

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

Added: 


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

Removed: 




diff  --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp 
b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index 2c2ae54dbd59..c58d44771f50 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -1942,13 +1942,13 @@ static MachineBasicBlock *addVSetVL(MachineInstr &MI, 
MachineBasicBlock *BB,
 
   if (VLIndex >= 0) {
 // Set VL (rs1 != X0).
-unsigned DestReg = MRI.createVirtualRegister(&RISCV::GPRRegClass);
+Register DestReg = MRI.createVirtualRegister(&RISCV::GPRRegClass);
 MIB.addReg(DestReg, RegState::Define | RegState::Dead)
-   .addReg(MI.getOperand(VLIndex).getReg());
+.addReg(MI.getOperand(VLIndex).getReg());
   } else
 // With no VL operator in the pseudo, do not modify VL (rd = X0, rs1 = X0).
-MIB.addReg(RISCV::X0, RegState::Dead)
-   .addReg(RISCV::X0, RegState::Kill);
+MIB.addReg(RISCV::X0, RegState::Define | RegState::Dead)
+.addReg(RISCV::X0, RegState::Kill);
 
   // For simplicity we reuse the vtype representation here.
   MIB.addImm(RISCVVType::encodeVTYPE(Multiplier, ElementWidth,



___
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] a2876ec - [NFC][Instructions] Refactor CmpInst::getFlippedStrictnessPredicate() in terms of is{, Non}StrictPredicate()/get{Non, }StrictPredicate()

2020-12-09 Thread Roman Lebedev via llvm-branch-commits

Author: Roman Lebedev
Date: 2020-12-09T12:43:08+03:00
New Revision: a2876ec74f8219e00d8e0e86e6296caa642eb811

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

LOG: [NFC][Instructions] Refactor CmpInst::getFlippedStrictnessPredicate() in 
terms of is{,Non}StrictPredicate()/get{Non,}StrictPredicate()

In particular, this creates getStrictPredicate() method,
to be symmetrical with already-existing getNonStrictPredicate().

Added: 


Modified: 
llvm/include/llvm/IR/InstrTypes.h
llvm/lib/IR/Instructions.cpp

Removed: 




diff  --git a/llvm/include/llvm/IR/InstrTypes.h 
b/llvm/include/llvm/IR/InstrTypes.h
index 23e030e94953..8af18e14c474 100644
--- a/llvm/include/llvm/IR/InstrTypes.h
+++ b/llvm/include/llvm/IR/InstrTypes.h
@@ -845,20 +845,38 @@ class CmpInst : public Instruction {
   /// Return the predicate as if the operands were swapped.
   static Predicate getSwappedPredicate(Predicate pred);
 
-  /// For predicate of kind "is X or equal to 0" returns the predicate "is X".
-  /// For predicate of kind "is X" returns the predicate "is X or equal to 0".
-  /// does not support other kind of predicates.
-  /// @returns the predicate that does not contains is equal to zero if
-  /// it had and vice versa.
-  /// Return the flipped strictness of predicate
-  Predicate getFlippedStrictnessPredicate() const {
-return getFlippedStrictnessPredicate(getPredicate());
+  /// This is a static version that you can use without an instruction
+  /// available.
+  /// @returns true if the comparison predicate is strict, false otherwise.
+  static bool isStrictPredicate(Predicate predicate);
+
+  /// @returns true if the comparison predicate is strict, false otherwise.
+  /// Determine if this instruction is using an strict comparison predicate.
+  bool isStrictPredicate() const { return isStrictPredicate(getPredicate()); }
+
+  /// This is a static version that you can use without an instruction
+  /// available.
+  /// @returns true if the comparison predicate is non-strict, false otherwise.
+  static bool isNonStrictPredicate(Predicate predicate);
+
+  /// @returns true if the comparison predicate is non-strict, false otherwise.
+  /// Determine if this instruction is using an non-strict comparison 
predicate.
+  bool isNonStrictPredicate() const {
+return isNonStrictPredicate(getPredicate());
+  }
+
+  /// For example, SGE -> SGT, SLE -> SLT, ULE -> ULT, UGE -> UGT.
+  /// Returns the strict version of non-strict comparisons.
+  Predicate getStrictPredicate() const {
+return getStrictPredicate(getPredicate());
   }
 
   /// This is a static version that you can use without an instruction
   /// available.
-  /// Return the flipped strictness of predicate
-  static Predicate getFlippedStrictnessPredicate(Predicate pred);
+  /// @returns the strict version of comparison provided in \p pred.
+  /// If \p pred is not a strict comparison predicate, returns \p pred.
+  /// Returns the strict version of non-strict comparisons.
+  static Predicate getStrictPredicate(Predicate pred);
 
   /// For example, SGT -> SGE, SLT -> SLE, ULT -> ULE, UGT -> UGE.
   /// Returns the non-strict version of strict comparisons.
@@ -873,6 +891,21 @@ class CmpInst : public Instruction {
   /// Returns the non-strict version of strict comparisons.
   static Predicate getNonStrictPredicate(Predicate pred);
 
+  /// This is a static version that you can use without an instruction
+  /// available.
+  /// Return the flipped strictness of predicate
+  static Predicate getFlippedStrictnessPredicate(Predicate pred);
+
+  /// For predicate of kind "is X or equal to 0" returns the predicate "is X".
+  /// For predicate of kind "is X" returns the predicate "is X or equal to 0".
+  /// does not support other kind of predicates.
+  /// @returns the predicate that does not contains is equal to zero if
+  /// it had and vice versa.
+  /// Return the flipped strictness of predicate
+  Predicate getFlippedStrictnessPredicate() const {
+return getFlippedStrictnessPredicate(getPredicate());
+  }
+
   /// Provide more efficient getOperand methods.
   DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
 

diff  --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp
index cfc6d05ecaba..282746619d22 100644
--- a/llvm/lib/IR/Instructions.cpp
+++ b/llvm/lib/IR/Instructions.cpp
@@ -3735,29 +3735,6 @@ ICmpInst::Predicate 
ICmpInst::getUnsignedPredicate(Predicate pred) {
   }
 }
 
-CmpInst::Predicate CmpInst::getFlippedStrictnessPredicate(Predicate pred) {
-  switch (pred) {
-default: llvm_unreachable("Unknown or unsupported cmp predicate!");
-case ICMP_SGT: return ICMP_SGE;
-case ICMP_SLT: return ICMP_SLE;
-case ICMP_SGE: return ICMP_SGT;
-case ICMP_SLE: return ICMP_SLT;
-case ICMP_UGT: return 

[llvm-branch-commits] [lldb] 6883042 - [lldb] Fix one more failure test after 843f2dbf003f2a51d0d4ab8cf40647c99ded2e93.

2020-12-09 Thread Haojian Wu via llvm-branch-commits

Author: Haojian Wu
Date: 2020-12-09T10:43:52+01:00
New Revision: 6883042528d0338b776bb2316e58999650e94892

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

LOG: [lldb] Fix one more failure test after 
843f2dbf003f2a51d0d4ab8cf40647c99ded2e93.

Added: 


Modified: 
lldb/test/Shell/SymbolFile/DWARF/split-dwarf-expression-eval-bug.cpp

Removed: 




diff  --git 
a/lldb/test/Shell/SymbolFile/DWARF/split-dwarf-expression-eval-bug.cpp 
b/lldb/test/Shell/SymbolFile/DWARF/split-dwarf-expression-eval-bug.cpp
index dcdc81b3e7eb..ef1aa257665d 100644
--- a/lldb/test/Shell/SymbolFile/DWARF/split-dwarf-expression-eval-bug.cpp
+++ b/lldb/test/Shell/SymbolFile/DWARF/split-dwarf-expression-eval-bug.cpp
@@ -7,9 +7,9 @@
 
 // UNSUPPORTED: system-darwin, system-windows
 
-// RUN: %clang_host -c -gsplit-dwarf %s -o %t1.o -DONE
-// RUN: %clang_host -c -gsplit-dwarf %s -o %t2.o -DTWO
-// RUN: %clang_host -c -gsplit-dwarf %s -o %t3.o -DTHREE
+// RUN: %clang_host -c -gsplit-dwarf -g %s -o %t1.o -DONE
+// RUN: %clang_host -c -gsplit-dwarf -g %s -o %t2.o -DTWO
+// RUN: %clang_host -c -gsplit-dwarf -g %s -o %t3.o -DTHREE
 // RUN: %clang_host %t1.o %t2.o %t3.o -o %t
 // RUN: %lldb %t -o "br set -n foo" -o run -o "p bool_in_first_cu" -o exit \
 // RUN:   | FileCheck %s



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


[llvm-branch-commits] [lldb] 85a3daa - [LLDB] Fix failing test dwp-separate-debug-file.cpp

2020-12-09 Thread Muhammad Omair Javaid via llvm-branch-commits

Author: Muhammad Omair Javaid
Date: 2020-12-09T14:57:50+05:00
New Revision: 85a3daa107fb0340f3b74f1719a3dc6cdb1586ee

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

LOG: [LLDB] Fix failing test dwp-separate-debug-file.cpp

Fix failure introduced by 843f2dbf003f2a51d0d4ab8cf40647c99ded2e93.

Added: 


Modified: 
lldb/test/Shell/SymbolFile/DWARF/dwp-separate-debug-file.cpp

Removed: 




diff  --git a/lldb/test/Shell/SymbolFile/DWARF/dwp-separate-debug-file.cpp 
b/lldb/test/Shell/SymbolFile/DWARF/dwp-separate-debug-file.cpp
index 26fd34d374a7..cda299260451 100644
--- a/lldb/test/Shell/SymbolFile/DWARF/dwp-separate-debug-file.cpp
+++ b/lldb/test/Shell/SymbolFile/DWARF/dwp-separate-debug-file.cpp
@@ -1,6 +1,6 @@
 // REQUIRES: lld
 
-// RUN: %clang -target x86_64-pc-linux -gsplit-dwarf -c %s -o %t.o
+// RUN: %clang -target x86_64-pc-linux -gsplit-dwarf -g -c %s -o %t.o
 // RUN: ld.lld %t.o -o %t
 // RUN: llvm-dwp %t.dwo -o %t.dwp
 // RUN: rm %t.dwo



___
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] 45de421 - AArch64: use correct operand for ubsantrap immediate.

2020-12-09 Thread Tim Northover via llvm-branch-commits

Author: Tim Northover
Date: 2020-12-09T10:17:16Z
New Revision: 45de42116e3f588bbead550ab8667388ba4f10ae

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

LOG: AArch64: use correct operand for ubsantrap immediate.

I accidentally pushed the wrong patch originally.

Added: 
llvm/test/CodeGen/AArch64/GlobalISel/ubsantrap.ll

Modified: 
llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp

Removed: 




diff  --git a/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp 
b/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
index 0834b0313453..4126017c6fbd 100644
--- a/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
+++ b/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
@@ -4879,7 +4879,7 @@ bool 
AArch64InstructionSelector::selectIntrinsicWithSideEffects(
 break;
   case Intrinsic::ubsantrap:
 MIRBuilder.buildInstr(AArch64::BRK, {}, {})
-.addImm(I.getOperand(0).getImm() | ('U' << 8));
+.addImm(I.getOperand(1).getImm() | ('U' << 8));
 break;
   }
 

diff  --git a/llvm/test/CodeGen/AArch64/GlobalISel/ubsantrap.ll 
b/llvm/test/CodeGen/AArch64/GlobalISel/ubsantrap.ll
new file mode 100644
index ..2b72381be35e
--- /dev/null
+++ b/llvm/test/CodeGen/AArch64/GlobalISel/ubsantrap.ll
@@ -0,0 +1,11 @@
+; RUN: llc -mtriple=arm64-apple-ios %s -o - -global-isel -global-isel-abort=1 
| FileCheck %s
+
+define void @test_ubsantrap() {
+; CHECK-LABEL: test_ubsantrap
+; CHECK: brk #0x550c
+; CHECK-GISEL: brk #0x550c
+  call void @llvm.ubsantrap(i8 12)
+  ret void
+}
+
+declare void @llvm.ubsantrap(i8)



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


[llvm-branch-commits] [llvm] f31704f - [OpenMPIRBuilder] Put the barrier in the exit block in createWorkshapeLoop

2020-12-09 Thread Alex Zinenko via llvm-branch-commits

Author: Alex Zinenko
Date: 2020-12-09T11:33:04+01:00
New Revision: f31704f8ae32a24147fac686f4e922c5c762cfe0

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

LOG: [OpenMPIRBuilder] Put the barrier in the exit block in createWorkshapeLoop

The original code was inserting the barrier at the location given by the
caller. Make sure it is always inserted at the end of the loop exit block
instead.

Reviewed By: Meinersbur

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

Added: 


Modified: 
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp

Removed: 




diff  --git a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp 
b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
index 6587a3637c90..609184af6ce8 100644
--- a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -1104,7 +1104,8 @@ CanonicalLoopInfo 
*OpenMPIRBuilder::createStaticWorkshareLoop(
 
   // Add the barrier if requested.
   if (NeedsBarrier)
-createBarrier(Loc, omp::Directive::OMPD_for, /* ForceSimpleCall */ false,
+createBarrier(LocationDescription(Builder.saveIP(), Loc.DL),
+  omp::Directive::OMPD_for, /* ForceSimpleCall */ false,
   /* CheckCancelFlag */ false);
 
   CLI->assertOK();

diff  --git a/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp 
b/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
index 1ad2264d3e39..6e69af725ccb 100644
--- a/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
+++ b/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
@@ -1155,6 +1155,13 @@ TEST_F(OpenMPIRBuilderTest, StaticWorkShareLoop) {
   // increment and in the statement that adds the lower bound to it.
   Value *IV = CLI->getIndVar();
   EXPECT_EQ(std::distance(IV->use_begin(), IV->use_end()), 3);
+
+  // The exit block should contain the "fini" call and the barrier call,
+  // plus the call to obtain the thread ID.
+  BasicBlock *ExitBlock = CLI->getExit();
+  size_t NumCallsInExitBlock =
+  count_if(*ExitBlock, [](Instruction &I) { return isa(I); });
+  EXPECT_EQ(NumCallsInExitBlock, 3u);
 }
 
 TEST_F(OpenMPIRBuilderTest, MasterDirective) {



___
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] 3ffbc79 - [VP] Build VP SDNodes

2020-12-09 Thread Simon Moll via llvm-branch-commits

Author: Simon Moll
Date: 2020-12-09T11:36:51+01:00
New Revision: 3ffbc7935718bd792f2947e90dfcf61e8cc5fb97

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

LOG: [VP] Build VP SDNodes

Translate VP intrinsics to VP_* SDNodes.  The tests check whether a
matching vp_* SDNode is emitted.

Reviewed By: craig.topper

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

Added: 
llvm/test/CodeGen/VE/Vector/vp_add.ll
llvm/test/CodeGen/VE/Vector/vp_and.ll
llvm/test/CodeGen/VE/Vector/vp_ashr.ll
llvm/test/CodeGen/VE/Vector/vp_lshr.ll
llvm/test/CodeGen/VE/Vector/vp_mul.ll
llvm/test/CodeGen/VE/Vector/vp_or.ll
llvm/test/CodeGen/VE/Vector/vp_sdiv.ll
llvm/test/CodeGen/VE/Vector/vp_shl.ll
llvm/test/CodeGen/VE/Vector/vp_srem.ll
llvm/test/CodeGen/VE/Vector/vp_sub.ll
llvm/test/CodeGen/VE/Vector/vp_udiv.ll
llvm/test/CodeGen/VE/Vector/vp_urem.ll
llvm/test/CodeGen/VE/Vector/vp_xor.ll

Modified: 
llvm/include/llvm/CodeGen/ISDOpcodes.h
llvm/include/llvm/IR/VPIntrinsics.def
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h
llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
llvm/lib/IR/IntrinsicInst.cpp

Removed: 




diff  --git a/llvm/include/llvm/CodeGen/ISDOpcodes.h 
b/llvm/include/llvm/CodeGen/ISDOpcodes.h
index adbcb7cc75b0..008fea45c6f4 100644
--- a/llvm/include/llvm/CodeGen/ISDOpcodes.h
+++ b/llvm/include/llvm/CodeGen/ISDOpcodes.h
@@ -1157,6 +1157,10 @@ enum NodeType {
   VECREDUCE_UMAX,
   VECREDUCE_UMIN,
 
+// Vector Predication
+#define BEGIN_REGISTER_VP_SDNODE(VPSDID, ...) VPSDID,
+#include "llvm/IR/VPIntrinsics.def"
+
   /// BUILTIN_OP_END - This must be the last enum value in this list.
   /// The target-specific pre-isel opcode values start here.
   BUILTIN_OP_END

diff  --git a/llvm/include/llvm/IR/VPIntrinsics.def 
b/llvm/include/llvm/IR/VPIntrinsics.def
index 68e7ea0c8069..3073866da4c9 100644
--- a/llvm/include/llvm/IR/VPIntrinsics.def
+++ b/llvm/include/llvm/IR/VPIntrinsics.def
@@ -17,68 +17,140 @@
 // Provide definitions of macros so that users of this file do not have to
 // define everything to use it...
 //
-#ifndef REGISTER_VP_INTRINSIC
-#define REGISTER_VP_INTRINSIC(VPID, MASKPOS, VLENPOS)
+// Register a VP intrinsic and begin its property scope.
+// All VP intrinsic scopes are top level, ie it is illegal to place a
+// BEGIN_REGISTER_VP_INTRINSIC within a VP intrinsic scope.
+// \p VPID The VP intrinsic id.
+// \p MASKPOS  The mask operand position.
+// \p EVLPOS   The explicit vector length operand position.
+#ifndef BEGIN_REGISTER_VP_INTRINSIC
+#define BEGIN_REGISTER_VP_INTRINSIC(VPID, MASKPOS, EVLPOS)
 #endif
 
-// Map this VP intrinsic to its functional Opcode
+// End the property scope of a VP intrinsic.
+#ifndef END_REGISTER_VP_INTRINSIC
+#define END_REGISTER_VP_INTRINSIC(VPID)
+#endif
+
+// Register a new VP SDNode and begin its property scope.
+// When the SDNode scope is nested within a VP intrinsic scope, it is 
implicitly registered as the canonical SDNode for this VP intrinsic.
+// There is one VP intrinsic that maps directly to one SDNode that goes by the
+// same name.  Since the operands are also the same, we open the property
+// scopes for both the VPIntrinsic and the SDNode at once.
+// \p SDOPC The SelectionDAG Node id (eg VP_ADD).
+// \p LEGALPOS The operand position of the SDNode that is used for legalizing
+// this SDNode. This can be `-1`, in which case the return type of
+// the SDNode is used.
+// \p TDNAME   The name of the TableGen definition of this SDNode.
+// \p MASKPOS  The mask operand position.
+// \p EVLPOS   The explicit vector length operand position.
+#ifndef BEGIN_REGISTER_VP_SDNODE
+#define BEGIN_REGISTER_VP_SDNODE(SDOPC, LEGALPOS, TDNAME, MASKPOS, EVLPOS)
+#endif
+
+// End the property scope of a new VP SDNode.
+#ifndef END_REGISTER_VP_SDNODE
+#define END_REGISTER_VP_SDNODE(SDOPC)
+#endif
+
+// Helper macros for the common "1:1 - Intrinsic : SDNode" case.
+//
+// There is one VP intrinsic that maps directly to one SDNode that goes by the
+// same name.  Since the operands are also the same, we open the property
+// scopes for both the VPIntrinsic and the SDNode at once.
+//
+// \p INTRIN   The canonical name (eg `vp_add`, which at the same time is the
+// name of the intrinsic and the TableGen def of the SDNode).
+// \p MASKPOS  The mask operand position.
+// \p EVLPOS   The explicit vector length operand position.
+// \p SDOPCThe SelectionDAG Node id (eg VP_ADD).
+// \p LEGALPOS The operand position of the SDNode that is used for legalizing
+// this SDNode. This can be `-1`, in which case the return type of
+// the SDNode is used.
+#define BE

[llvm-branch-commits] [llvm] 4167a02 - [IR] Support scalable vectors in CastInst::CreatePointerCast

2020-12-09 Thread Cullen Rhodes via llvm-branch-commits

Author: Cullen Rhodes
Date: 2020-12-09T10:39:36Z
New Revision: 4167a0259ec33a11530a6503e96acedaf3cb6a3d

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

LOG: [IR] Support scalable vectors in CastInst::CreatePointerCast

Reviewed By: sdesmalen

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

Added: 


Modified: 
llvm/lib/IR/Instructions.cpp
llvm/unittests/IR/InstructionsTest.cpp

Removed: 




diff  --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp
index 282746619d22..74a95da79932 100644
--- a/llvm/lib/IR/Instructions.cpp
+++ b/llvm/lib/IR/Instructions.cpp
@@ -3022,8 +3022,8 @@ CastInst *CastInst::CreatePointerCast(Value *S, Type *Ty,
  "Invalid cast");
   assert(Ty->isVectorTy() == S->getType()->isVectorTy() && "Invalid cast");
   assert((!Ty->isVectorTy() ||
-  cast(Ty)->getNumElements() ==
-  cast(S->getType())->getNumElements()) &&
+  cast(Ty)->getElementCount() ==
+  cast(S->getType())->getElementCount()) &&
  "Invalid cast");
 
   if (Ty->isIntOrIntVectorTy())
@@ -3041,8 +3041,8 @@ CastInst *CastInst::CreatePointerCast(Value *S, Type *Ty,
  "Invalid cast");
   assert(Ty->isVectorTy() == S->getType()->isVectorTy() && "Invalid cast");
   assert((!Ty->isVectorTy() ||
-  cast(Ty)->getNumElements() ==
-  cast(S->getType())->getNumElements()) &&
+  cast(Ty)->getElementCount() ==
+  cast(S->getType())->getElementCount()) &&
  "Invalid cast");
 
   if (Ty->isIntOrIntVectorTy())

diff  --git a/llvm/unittests/IR/InstructionsTest.cpp 
b/llvm/unittests/IR/InstructionsTest.cpp
index 7a4dad21ecc9..419cddc0c370 100644
--- a/llvm/unittests/IR/InstructionsTest.cpp
+++ b/llvm/unittests/IR/InstructionsTest.cpp
@@ -368,11 +368,19 @@ TEST(InstructionsTest, CastInst) {
   Constant *NullV2I32Ptr = Constant::getNullValue(V2Int32PtrTy);
   auto Inst1 = CastInst::CreatePointerCast(NullV2I32Ptr, V2Int32Ty, "foo", BB);
 
+  Constant *NullVScaleV2I32Ptr = Constant::getNullValue(VScaleV2Int32PtrTy);
+  auto Inst1VScale = CastInst::CreatePointerCast(
+  NullVScaleV2I32Ptr, VScaleV2Int32Ty, "foo.vscale", BB);
+
   // Second form
   auto Inst2 = CastInst::CreatePointerCast(NullV2I32Ptr, V2Int32Ty);
+  auto Inst2VScale =
+  CastInst::CreatePointerCast(NullVScaleV2I32Ptr, VScaleV2Int32Ty);
 
   delete Inst2;
+  delete Inst2VScale;
   Inst1->eraseFromParent();
+  Inst1VScale->eraseFromParent();
   delete BB;
 }
 



___
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] 80c33de - [SelectionDAG] Add llvm.vector.{extract, insert} intrinsics

2020-12-09 Thread Joe Ellis via llvm-branch-commits

Author: Joe Ellis
Date: 2020-12-09T11:08:41Z
New Revision: 80c33de2d3c59ca357c67b2b2475d27f79dd8a8b

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

LOG: [SelectionDAG] Add llvm.vector.{extract,insert} intrinsics

This commit adds two new intrinsics.

- llvm.experimental.vector.insert: used to insert a vector into another
  vector starting at a given index.

- llvm.experimental.vector.extract: used to extract a subvector from a
  larger vector starting from a given index.

The codegen work for these intrinsics has already been completed; this
commit is simply exposing the existing ISD nodes to LLVM IR.

Reviewed By: cameron.mcinally

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

Added: 
llvm/test/CodeGen/AArch64/sve-extract-vector.ll
llvm/test/CodeGen/AArch64/sve-insert-vector.ll
llvm/test/Transforms/InstCombine/canonicalize-vector-extract.ll
llvm/test/Transforms/InstCombine/canonicalize-vector-insert.ll
llvm/test/Verifier/extract-vector-mismatched-element-types.ll
llvm/test/Verifier/insert-vector-mismatched-element-types.ll

Modified: 
llvm/docs/LangRef.rst
llvm/include/llvm/IR/Intrinsics.td
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
llvm/lib/IR/Verifier.cpp
llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp

Removed: 




diff  --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index 6724a4019030..b29eb589e2d7 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -16095,6 +16095,81 @@ Arguments:
 ""
 The argument to this intrinsic must be a vector of floating-point values.
 
+'``llvm.experimental.vector.insert``' Intrinsic
+^^^
+
+Syntax:
+"""
+This is an overloaded intrinsic. You can use 
``llvm.experimental.vector.insert``
+to insert a fixed-width vector into a scalable vector, but not the other way
+around.
+
+::
+
+  declare  
@llvm.experimental.vector.insert.v4f32( %vec, <4 x float> 
%subvec, i64 %idx)
+  declare  
@llvm.experimental.vector.insert.v2f64( %vec, <2 x double> 
%subvec, i64 %idx)
+
+Overview:
+"
+
+The '``llvm.experimental.vector.insert.*``' intrinsics insert a vector into 
another vector
+starting from a given index. The return type matches the type of the vector we
+insert into. Conceptually, this can be used to build a scalable vector out of
+non-scalable vectors.
+
+Arguments:
+""
+
+The ``vec`` is the vector which ``subvec`` will be inserted into.
+The ``subvec`` is the vector that will be inserted.
+
+``idx`` represents the starting element number at which ``subvec`` will be
+inserted. ``idx`` must be a constant multiple of ``subvec``'s known minimum
+vector length. If ``subvec`` is a scalable vector, ``idx`` is first scaled by
+the runtime scaling factor of ``subvec``. The elements of ``vec`` starting at
+``idx`` are overwritten with ``subvec``. Elements ``idx`` through (``idx`` +
+num_elements(``subvec``) - 1) must be valid ``vec`` indices. If this condition
+cannot be determined statically but is false at runtime, then the result vector
+is undefined.
+
+
+'``llvm.experimental.vector.extract``' Intrinsic
+
+
+Syntax:
+"""
+This is an overloaded intrinsic. You can use
+``llvm.experimental.vector.extract`` to extract a fixed-width vector from a
+scalable vector, but not the other way around.
+
+::
+
+  declare <4 x float> @llvm.experimental.vector.extract.v4f32( %vec, i64 %idx)
+  declare <2 x double> @llvm.experimental.vector.extract.v2f64( %vec, i64 %idx)
+
+Overview:
+"
+
+The '``llvm.experimental.vector.extract.*``' intrinsics extract a vector from
+within another vector starting from a given index. The return type must be
+explicitly specified. Conceptually, this can be used to decompose a scalable
+vector into non-scalable parts.
+
+Arguments:
+""
+
+The ``vec`` is the vector from which we will extract a subvector.
+
+The ``idx`` specifies the starting element number within ``vec`` from which a
+subvector is extracted. ``idx`` must be a constant multiple of the 
known-minimum
+vector length of the result type. If the result type is a scalable vector,
+``idx`` is first scaled by the result type's runtime scaling factor. Elements
+``idx`` through (``idx`` + num_elements(result_type) - 1) must be valid vector
+indices. If this condition cannot be determined statically but is false at
+runtime, then the result vector is undefined. The ``idx`` parameter must be a
+vector index constant type (for most targets this will be an integer pointer
+type).
+
 Matrix Intrinsics
 -
 

diff  --git a/llvm/include/llvm/IR/Intrinsics.td 
b/llvm/include/llvm/IR/Intrinsics.td
index 710479103459..eb6c408b4f85 100644
--- a/llv

[llvm-branch-commits] [flang] 0bf4a82 - [mlir] Use mlir::OpState::operator->() to get to methods of mlir::Operation. This is a preparation step to remove the corresponding methods from OpState.

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

Author: Christian Sigg
Date: 2020-12-09T12:11:32+01:00
New Revision: 0bf4a82a5a2b11a07a7f7eac5e49b565cb041b13

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

LOG: [mlir] Use mlir::OpState::operator->() to get to methods of 
mlir::Operation. This is a preparation step to remove the corresponding methods 
from OpState.

Reviewed By: silvas, rriddle

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

Added: 


Modified: 
flang/include/flang/Optimizer/Dialect/FIROps.td
mlir/examples/toy/Ch2/mlir/Dialect.cpp
mlir/examples/toy/Ch3/mlir/Dialect.cpp
mlir/examples/toy/Ch4/mlir/Dialect.cpp
mlir/examples/toy/Ch5/mlir/Dialect.cpp
mlir/examples/toy/Ch6/mlir/Dialect.cpp
mlir/examples/toy/Ch7/mlir/Dialect.cpp
mlir/include/mlir/Dialect/GPU/GPUOps.td
mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
mlir/include/mlir/Dialect/LLVMIR/NVVMOps.td
mlir/include/mlir/Dialect/StandardOps/IR/Ops.h
mlir/include/mlir/Dialect/StandardOps/IR/Ops.td
mlir/include/mlir/Dialect/Vector/VectorOps.td
mlir/lib/Conversion/AsyncToLLVM/AsyncToLLVM.cpp
mlir/lib/Conversion/GPUCommon/ConvertLaunchFuncToRuntimeCalls.cpp
mlir/lib/Conversion/GPUToVulkan/ConvertLaunchFuncToVulkanCalls.cpp
mlir/lib/Conversion/SCFToGPU/SCFToGPU.cpp
mlir/lib/Conversion/SCFToOpenMP/SCFToOpenMP.cpp
mlir/lib/Conversion/SCFToSPIRV/SCFToSPIRV.cpp
mlir/lib/Conversion/SPIRVToLLVM/ConvertLaunchFuncToLLVMCalls.cpp
mlir/lib/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVM.cpp
mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp
mlir/lib/Dialect/Affine/IR/AffineOps.cpp
mlir/lib/Dialect/Affine/Utils/Utils.cpp
mlir/lib/Dialect/Async/IR/Async.cpp
mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
mlir/lib/Dialect/GPU/Transforms/AsyncRegionRewriter.cpp
mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp
mlir/lib/Dialect/GPU/Transforms/ParallelLoopMapper.cpp
mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp
mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
mlir/lib/Dialect/Linalg/Transforms/CodegenStrategy.cpp
mlir/lib/Dialect/Linalg/Transforms/Hoisting.cpp
mlir/lib/Dialect/PDL/IR/PDL.cpp
mlir/lib/Dialect/SCF/SCF.cpp
mlir/lib/Dialect/SCF/Transforms/StructuralTypeConversions.cpp
mlir/lib/Dialect/SCF/Transforms/Utils.cpp
mlir/lib/Dialect/SPIRV/SPIRVLowering.cpp
mlir/lib/Dialect/SPIRV/SPIRVOps.cpp
mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp
mlir/lib/Dialect/SPIRV/Transforms/DecorateSPIRVCompositeTypeLayoutPass.cpp
mlir/lib/Dialect/SPIRV/Transforms/LowerABIAttributesPass.cpp
mlir/lib/Dialect/Shape/IR/Shape.cpp
mlir/lib/Dialect/Shape/Transforms/ShapeToShapeLowering.cpp
mlir/lib/Dialect/StandardOps/IR/Ops.cpp
mlir/lib/Dialect/Vector/VectorTransferOpTransforms.cpp
mlir/lib/Dialect/Vector/VectorTransforms.cpp
mlir/lib/Target/LLVMIR/ConvertToROCDLIR.cpp
mlir/lib/Transforms/Inliner.cpp
mlir/lib/Transforms/LoopCoalescing.cpp
mlir/lib/Transforms/Utils/InliningUtils.cpp
mlir/lib/Transforms/Utils/LoopFusionUtils.cpp
mlir/lib/Transforms/Utils/LoopUtils.cpp
mlir/test/lib/Dialect/Shape/TestShapeFunctions.cpp
mlir/test/lib/Dialect/Test/TestDialect.cpp
mlir/test/lib/Dialect/Test/TestOps.td
mlir/test/lib/Dialect/Test/TestPatterns.cpp
mlir/test/lib/IR/TestFunc.cpp
mlir/test/lib/Transforms/TestAffineLoopParametricTiling.cpp
mlir/test/lib/Transforms/TestLinalgFusionTransforms.cpp
mlir/test/lib/Transforms/TestLoopMapping.cpp
mlir/test/lib/Transforms/TestLoopParametricTiling.cpp
mlir/test/mlir-tblgen/op-attribute.td
mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp

Removed: 




diff  --git a/flang/include/flang/Optimizer/Dialect/FIROps.td 
b/flang/include/flang/Optimizer/Dialect/FIROps.td
index 74471cf6f222..9f477aa81b0c 100644
--- a/flang/include/flang/Optimizer/Dialect/FIROps.td
+++ b/flang/include/flang/Optimizer/Dialect/FIROps.td
@@ -270,7 +270,7 @@ class fir_AllocatableOp 
traits = []> :
 bool hasLenParams() { return bool{getAttr(lenpName())}; }
 
 unsigned numLenParams() {
-  if (auto val = getAttrOfType(lenpName()))
+  if (auto val = (*this)->getAttrOfType(lenpName()))
 return val.getInt();
   return 0;
 }
@@ -291,7 +291,7 @@ class fir_AllocatableOp 
traits = []> :
 
 /// Get the input type of the allocation
 mlir::Type getInType() {
-  return getAttrOfType(inType()).getValue();
+  return (*this)->getAttrOfType(inType()).getValue();
 }
   }];
 
@@ -567,7 +567,7 @@ class fir_SwitchTerminatorOp 
traits = []> :
 
 // The number of destination conditions that may be tested
 unsigned getNu

[llvm-branch-commits] [llvm] 4519ff4 - [SVE][CodeGen] Add the ExtensionType flag to MGATHER

2020-12-09 Thread Kerry McLaughlin via llvm-branch-commits

Author: Kerry McLaughlin
Date: 2020-12-09T11:19:08Z
New Revision: 4519ff4b6f02defcb69ea49bc11607cee09cde7b

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

LOG: [SVE][CodeGen] Add the ExtensionType flag to MGATHER

Adds the ExtensionType flag, which reflects the LoadExtType of a 
MaskedGatherSDNode.
Also updated SelectionDAGDumper::print_details so that details of the gather
load (is signed, is scaled & extension type) are printed.

Reviewed By: sdesmalen

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

Added: 


Modified: 
llvm/include/llvm/CodeGen/SelectionDAG.h
llvm/include/llvm/CodeGen/SelectionDAGNodes.h
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
llvm/lib/Target/X86/X86ISelLowering.cpp

Removed: 




diff  --git a/llvm/include/llvm/CodeGen/SelectionDAG.h 
b/llvm/include/llvm/CodeGen/SelectionDAG.h
index d454c4ea8d9b..d73155aa2f2f 100644
--- a/llvm/include/llvm/CodeGen/SelectionDAG.h
+++ b/llvm/include/llvm/CodeGen/SelectionDAG.h
@@ -1362,7 +1362,7 @@ class SelectionDAG {
 ISD::MemIndexedMode AM);
   SDValue getMaskedGather(SDVTList VTs, EVT VT, const SDLoc &dl,
   ArrayRef Ops, MachineMemOperand *MMO,
-  ISD::MemIndexType IndexType);
+  ISD::MemIndexType IndexType, ISD::LoadExtType ExtTy);
   SDValue getMaskedScatter(SDVTList VTs, EVT VT, const SDLoc &dl,
ArrayRef Ops, MachineMemOperand *MMO,
ISD::MemIndexType IndexType,

diff  --git a/llvm/include/llvm/CodeGen/SelectionDAGNodes.h 
b/llvm/include/llvm/CodeGen/SelectionDAGNodes.h
index 1e71d110730e..aa81a31bf23a 100644
--- a/llvm/include/llvm/CodeGen/SelectionDAGNodes.h
+++ b/llvm/include/llvm/CodeGen/SelectionDAGNodes.h
@@ -512,6 +512,7 @@ BEGIN_TWO_BYTE_PACK()
   class LoadSDNodeBitfields {
 friend class LoadSDNode;
 friend class MaskedLoadSDNode;
+friend class MaskedGatherSDNode;
 
 uint16_t : NumLSBaseSDNodeBits;
 
@@ -2451,12 +2452,18 @@ class MaskedGatherSDNode : public 
MaskedGatherScatterSDNode {
 
   MaskedGatherSDNode(unsigned Order, const DebugLoc &dl, SDVTList VTs,
  EVT MemVT, MachineMemOperand *MMO,
- ISD::MemIndexType IndexType)
+ ISD::MemIndexType IndexType, ISD::LoadExtType ETy)
   : MaskedGatherScatterSDNode(ISD::MGATHER, Order, dl, VTs, MemVT, MMO,
-  IndexType) {}
+  IndexType) {
+LoadSDNodeBits.ExtTy = ETy;
+  }
 
   const SDValue &getPassThru() const { return getOperand(1); }
 
+  ISD::LoadExtType getExtensionType() const {
+return ISD::LoadExtType(LoadSDNodeBits.ExtTy);
+  }
+
   static bool classof(const SDNode *N) {
 return N->getOpcode() == ISD::MGATHER;
   }

diff  --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp 
b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 8f0c9542b3e7..ce4ee89103ce 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -9499,14 +9499,16 @@ SDValue DAGCombiner::visitMGATHER(SDNode *N) {
 SDValue Ops[] = {Chain, PassThru, Mask, BasePtr, Index, Scale};
 return DAG.getMaskedGather(DAG.getVTList(N->getValueType(0), MVT::Other),
PassThru.getValueType(), DL, Ops,
-   MGT->getMemOperand(), MGT->getIndexType());
+   MGT->getMemOperand(), MGT->getIndexType(),
+   MGT->getExtensionType());
   }
 
   if (refineIndexType(MGT, Index, MGT->isIndexScaled(), DAG)) {
 SDValue Ops[] = {Chain, PassThru, Mask, BasePtr, Index, Scale};
 return DAG.getMaskedGather(DAG.getVTList(N->getValueType(0), MVT::Other),
PassThru.getValueType(), DL, Ops,
-   MGT->getMemOperand(), MGT->getIndexType());
+   MGT->getMemOperand(), MGT->getIndexType(),
+   MGT->getExtensionType());
   }
 
   return SDValue();

diff  --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp 
b/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
index 8468f51a922c..5c8a562ed9d7 100644
--- a/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
@@ -679,12 +679,17 @@ SDValue 
DAGTypeLegalizer::PromoteIntRes_MGATHER(MaskedGatherSDNode *N) {
   

[llvm-branch-commits] [llvm] adc3714 - [LoopVectorizer] NFC: Remove unnecessary asserts that VF cannot be scalable.

2020-12-09 Thread Sander de Smalen via llvm-branch-commits

Author: Sander de Smalen
Date: 2020-12-09T11:25:21Z
New Revision: adc37145dec9cadf76af05326150ed22a3cc2fdd

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

LOG: [LoopVectorizer] NFC: Remove unnecessary asserts that VF cannot be 
scalable.

This patch removes a number of asserts that VF is not scalable, even though
the code where this assert lives does nothing that prevents VF being scalable.

Reviewed By: dmgreen

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

Added: 


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

Removed: 




diff  --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp 
b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 6ba14e942ff8..f504afd1ffc4 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -367,7 +367,6 @@ static Type *getMemInstValueType(Value *I) {
 /// type is irregular if its allocated size doesn't equal the store size of an
 /// element of the corresponding vector type at the given vectorization factor.
 static bool hasIrregularType(Type *Ty, const DataLayout &DL, ElementCount VF) {
-  assert(!VF.isScalable() && "scalable vectors not yet supported.");
   // Determine if an array of VF elements of type Ty is "bitcast compatible"
   // with a  vector.
   if (VF.isVector()) {
@@ -1387,9 +1386,7 @@ class LoopVectorizationCostModel {
   /// width \p VF. Return CM_Unknown if this instruction did not pass
   /// through the cost modeling.
   InstWidening getWideningDecision(Instruction *I, ElementCount VF) {
-assert(!VF.isScalable() && "scalable vectors not yet supported.");
-assert(VF.isVector() && "Expected VF >=2");
-
+assert(VF.isVector() && "Expected VF to be a vector VF");
 // Cost model is not run in the VPlan-native path - return conservative
 // result until this changes.
 if (EnableVPlanNativePath)
@@ -3902,8 +3899,10 @@ void InnerLoopVectorizer::fixVectorizedLoop() {
   // profile is not inherently precise anyway. Note also possible bypass of
   // vector code caused by legality checks is ignored, assigning all the weight
   // to the vector loop, optimistically.
-  assert(!VF.isScalable() &&
- "cannot use scalable ElementCount to determine unroll factor");
+  //
+  // For scalable vectorization we can't know at compile time how many 
iterations
+  // of the loop are handled in one vector iteration, so instead assume a 
pessimistic
+  // vscale of '1'.
   setProfileInfoAfterUnrolling(
   LI->getLoopFor(LoopScalarBody), LI->getLoopFor(LoopVectorBody),
   LI->getLoopFor(LoopScalarBody), VF.getKnownMinValue() * UF);
@@ -4709,7 +4708,6 @@ static bool mayDivideByZero(Instruction &I) {
 void InnerLoopVectorizer::widenInstruction(Instruction &I, VPValue *Def,
VPUser &User,
VPTransformState &State) {
-  assert(!VF.isScalable() && "scalable vectors not yet supported.");
   switch (I.getOpcode()) {
   case Instruction::Call:
   case Instruction::Br:
@@ -4797,7 +4795,6 @@ void InnerLoopVectorizer::widenInstruction(Instruction 
&I, VPValue *Def,
 setDebugLocFromInst(Builder, CI);
 
 /// Vectorize casts.
-assert(!VF.isScalable() && "VF is assumed to be non scalable.");
 Type *DestTy =
 (VF.isScalar()) ? CI->getType() : VectorType::get(CI->getType(), VF);
 
@@ -5099,7 +5096,6 @@ void 
LoopVectorizationCostModel::collectLoopScalars(ElementCount VF) {
 
 bool LoopVectorizationCostModel::isScalarWithPredication(Instruction *I,
  ElementCount VF) {
-  assert(!VF.isScalable() && "scalable vectors not yet supported.");
   if (!blockNeedsPredication(I->getParent()))
 return false;
   switch(I->getOpcode()) {
@@ -6420,7 +6416,6 @@ int LoopVectorizationCostModel::computePredInstDiscount(
 
 LoopVectorizationCostModel::VectorizationCostTy
 LoopVectorizationCostModel::expectedCost(ElementCount VF) {
-  assert(!VF.isScalable() && "scalable vectors not yet supported.");
   VectorizationCostTy Cost;
 
   // For each block.
@@ -7935,7 +7930,6 @@ VPRecipeBuilder::tryToWidenMemory(Instruction *I, VFRange 
&Range,
  "Must be called with either a load or store");
 
   auto willWiden = [&](ElementCount VF) -> bool {
-assert(!VF.isScalable() && "unexpected scalable ElementCount");
 if (VF.isScalar())
   return false;
 LoopVectorizationCostModel::InstWidening Decision =



___
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] d568cff - [LoopVectorizer][SVE] Vectorize a simple loop with with a scalable VF.

2020-12-09 Thread Sander de Smalen via llvm-branch-commits

Author: Sander de Smalen
Date: 2020-12-09T11:25:21Z
New Revision: d568cff696e8fb89ce1b040561c037412767af60

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

LOG: [LoopVectorizer][SVE] Vectorize a simple loop with with a scalable VF.

* Steps are scaled by `vscale`, a runtime value.
* Changes to circumvent the cost-model for now (temporary)
  so that the cost-model can be implemented separately.

This can vectorize the following loop [1]:

   void loop(int N, double *a, double *b) {
 #pragma clang loop vectorize_width(4, scalable)
 for (int i = 0; i < N; i++) {
   a[i] = b[i] + 1.0;
 }
   }

[1] This source-level example is based on the pragma proposed
separately in D89031. This patch only implements the LLVM part.

Reviewed By: dmgreen

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

Added: 

llvm/test/Transforms/LoopVectorize/scalable-loop-unpredicated-body-scalar-tail.ll

Modified: 
llvm/include/llvm/IR/IRBuilder.h
llvm/lib/IR/IRBuilder.cpp
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
llvm/lib/Transforms/Vectorize/VPlan.h
llvm/test/Transforms/LoopVectorize/metadata-width.ll

Removed: 




diff  --git a/llvm/include/llvm/IR/IRBuilder.h 
b/llvm/include/llvm/IR/IRBuilder.h
index db215094a7e49..c2b3446d159f2 100644
--- a/llvm/include/llvm/IR/IRBuilder.h
+++ b/llvm/include/llvm/IR/IRBuilder.h
@@ -879,6 +879,10 @@ class IRBuilderBase {
  Type *ResultType,
  const Twine &Name = "");
 
+  /// Create a call to llvm.vscale, multiplied by \p Scaling. The type of 
VScale
+  /// will be the same type as that of \p Scaling.
+  Value *CreateVScale(Constant *Scaling, const Twine &Name = "");
+
   /// Create a call to intrinsic \p ID with 1 operand which is mangled on its
   /// type.
   CallInst *CreateUnaryIntrinsic(Intrinsic::ID ID, Value *V,

diff  --git a/llvm/lib/IR/IRBuilder.cpp b/llvm/lib/IR/IRBuilder.cpp
index c0e4451f52003..f936f5756b6f0 100644
--- a/llvm/lib/IR/IRBuilder.cpp
+++ b/llvm/lib/IR/IRBuilder.cpp
@@ -80,6 +80,17 @@ static CallInst *createCallHelper(Function *Callee, 
ArrayRef Ops,
   return CI;
 }
 
+Value *IRBuilderBase::CreateVScale(Constant *Scaling, const Twine &Name) {
+  Module *M = GetInsertBlock()->getParent()->getParent();
+  assert(isa(Scaling) && "Expected constant integer");
+  Function *TheFn =
+  Intrinsic::getDeclaration(M, Intrinsic::vscale, {Scaling->getType()});
+  CallInst *CI = createCallHelper(TheFn, {}, this, Name);
+  return cast(Scaling)->getSExtValue() == 1
+ ? CI
+ : CreateMul(CI, Scaling);
+}
+
 CallInst *IRBuilderBase::CreateMemSet(Value *Ptr, Value *Val, Value *Size,
   MaybeAlign Align, bool isVolatile,
   MDNode *TBAATag, MDNode *ScopeTag,

diff  --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp 
b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index f504afd1ffc41..a91fb988badf6 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -1121,6 +1121,15 @@ static OptimizationRemarkAnalysis createLVAnalysis(const 
char *PassName,
   return R;
 }
 
+/// Return a value for Step multiplied by VF.
+static Value *createStepForVF(IRBuilder<> &B, Constant *Step, ElementCount VF) 
{
+  assert(isa(Step) && "Expected an integer step");
+  Constant *StepVal = ConstantInt::get(
+  Step->getType(),
+  cast(Step)->getSExtValue() * VF.getKnownMinValue());
+  return VF.isScalable() ? B.CreateVScale(StepVal) : StepVal;
+}
+
 namespace llvm {
 
 void reportVectorizationFailure(const StringRef DebugMsg,
@@ -2277,8 +2286,6 @@ void InnerLoopVectorizer::buildScalarSteps(Value 
*ScalarIV, Value *Step,
const InductionDescriptor &ID) {
   // We shouldn't have to build scalar steps if we aren't vectorizing.
   assert(VF.isVector() && "VF should be greater than one");
-  assert(!VF.isScalable() &&
- "the code below assumes a fixed number of elements at compile time");
   // Get the value type and ensure it and the step have the same integer type.
   Type *ScalarIVTy = ScalarIV->getType()->getScalarType();
   assert(ScalarIVTy == Step->getType() &&
@@ -2303,11 +2310,24 @@ void InnerLoopVectorizer::buildScalarSteps(Value 
*ScalarIV, Value *Step,
   Cost->isUniformAfterVectorization(cast(EntryVal), VF)
   ? 1
   : VF.getKnownMinValue();
+  assert((!VF.isScalable() || Lanes == 1) &&
+ "Should never scalarize a scalable vector");
   // Compute the scalar steps and save the results in VectorLoopValueMap.
   for (unsigned Part = 0; Part < UF; ++Part) {
 for (unsigned Lane = 0; Lane < Lanes; ++Lane) {
-  auto *StartIdx = g

[llvm-branch-commits] [llvm] 05edfc5 - [SVE][CodeGen] Add DAG combines for s/zext_masked_gather

2020-12-09 Thread Kerry McLaughlin via llvm-branch-commits

Author: Kerry McLaughlin
Date: 2020-12-09T11:53:19Z
New Revision: 05edfc54750bd539f5caa30b0cd4344f68677b00

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

LOG: [SVE][CodeGen] Add DAG combines for s/zext_masked_gather

This patch adds the following DAGCombines, which apply if 
isVectorLoadExtDesirable() returns true:
 - fold (and (masked_gather x)) -> (zext_masked_gather x)
 - fold (sext_inreg (masked_gather x)) -> (sext_masked_gather x)

LowerMGATHER has also been updated to fetch the LoadExtType associated with the
gather and also use this value to determine the correct masked gather opcode to 
use.

Reviewed By: sdesmalen

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

Added: 


Modified: 
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
llvm/test/CodeGen/AArch64/sve-masked-gather-32b-signed-scaled.ll
llvm/test/CodeGen/AArch64/sve-masked-gather-32b-signed-unscaled.ll
llvm/test/CodeGen/AArch64/sve-masked-gather-32b-unsigned-scaled.ll
llvm/test/CodeGen/AArch64/sve-masked-gather-32b-unsigned-unscaled.ll
llvm/test/CodeGen/AArch64/sve-masked-gather-64b-scaled.ll
llvm/test/CodeGen/AArch64/sve-masked-gather-64b-unscaled.ll
llvm/test/CodeGen/AArch64/sve-masked-gather-legalize.ll

Removed: 




diff  --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp 
b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index ce4ee89103ce..212e0a2ea988 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -932,6 +932,33 @@ bool DAGCombiner::isOneUseSetCC(SDValue N) const {
   return false;
 }
 
+static bool isConstantSplatVectorMaskForType(SDNode *N, EVT ScalarTy) {
+  if (!ScalarTy.isSimple())
+return false;
+
+  uint64_t MaskForTy = 0ULL;
+  switch (ScalarTy.getSimpleVT().SimpleTy) {
+  case MVT::i8:
+MaskForTy = 0xFFULL;
+break;
+  case MVT::i16:
+MaskForTy = 0xULL;
+break;
+  case MVT::i32:
+MaskForTy = 0xULL;
+break;
+  default:
+return false;
+break;
+  }
+
+  APInt Val;
+  if (ISD::isConstantSplatVector(N, Val))
+return Val.getLimitedValue() == MaskForTy;
+
+  return false;
+}
+
 // Returns the SDNode if it is a constant float BuildVector
 // or constant float.
 static SDNode *isConstantFPBuildVectorOrConstantFP(SDValue N) {
@@ -5622,6 +5649,28 @@ SDValue DAGCombiner::visitAND(SDNode *N) {
 }
   }
 
+  // fold (and (masked_gather x)) -> (zext_masked_gather x)
+  if (auto *GN0 = dyn_cast(N0)) {
+EVT MemVT = GN0->getMemoryVT();
+EVT ScalarVT = MemVT.getScalarType();
+
+if (SDValue(GN0, 0).hasOneUse() &&
+isConstantSplatVectorMaskForType(N1.getNode(), ScalarVT) &&
+TLI.isVectorLoadExtDesirable(SDValue(SDValue(GN0, 0 {
+  SDValue Ops[] = {GN0->getChain(),   GN0->getPassThru(), GN0->getMask(),
+   GN0->getBasePtr(), GN0->getIndex(),GN0->getScale()};
+
+  SDValue ZExtLoad = DAG.getMaskedGather(
+  DAG.getVTList(VT, MVT::Other), MemVT, SDLoc(N), Ops,
+  GN0->getMemOperand(), GN0->getIndexType(), ISD::ZEXTLOAD);
+
+  CombineTo(N, ZExtLoad);
+  AddToWorklist(ZExtLoad.getNode());
+  // Avoid recheck of N.
+  return SDValue(N, 0);
+}
+  }
+
   // fold (and (load x), 255) -> (zextload x, i8)
   // fold (and (extload x, i16), 255) -> (zextload x, i8)
   // fold (and (any_ext (extload x, i16)), 255) -> (zextload x, i8)
@@ -11597,6 +11646,25 @@ SDValue DAGCombiner::visitSIGN_EXTEND_INREG(SDNode *N) 
{
 }
   }
 
+  // fold (sext_inreg (masked_gather x)) -> (sext_masked_gather x)
+  if (auto *GN0 = dyn_cast(N0)) {
+if (SDValue(GN0, 0).hasOneUse() &&
+ExtVT == GN0->getMemoryVT() &&
+TLI.isVectorLoadExtDesirable(SDValue(SDValue(GN0, 0 {
+  SDValue Ops[] = {GN0->getChain(),   GN0->getPassThru(), GN0->getMask(),
+   GN0->getBasePtr(), GN0->getIndex(),GN0->getScale()};
+
+  SDValue ExtLoad = DAG.getMaskedGather(
+  DAG.getVTList(VT, MVT::Other), ExtVT, SDLoc(N), Ops,
+  GN0->getMemOperand(), GN0->getIndexType(), ISD::SEXTLOAD);
+
+  CombineTo(N, ExtLoad);
+  CombineTo(N0.getNode(), ExtLoad, ExtLoad.getValue(1));
+  AddToWorklist(ExtLoad.getNode());
+  return SDValue(N, 0); // Return N so it doesn't get rechecked!
+}
+  }
+
   // Form (sext_inreg (bswap >> 16)) or (sext_inreg (rotl (bswap) 16))
   if (ExtVTBits <= 16 && N0.getOpcode() == ISD::OR) {
 if (SDValue BSwap = MatchBSwapHWordLow(N0.getNode(), N0.getOperand(0),

diff  --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp 
b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
index 20f5ded99350..5d9c66e170ea 100644
--- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp

[llvm-branch-commits] [llvm] 163c223 - [Debuginfo] [CSInfo] Do not create CSInfo for undef arguments

2020-12-09 Thread Djordje Todorovic via llvm-branch-commits

Author: Djordje Todorovic
Date: 2020-12-09T12:54:59+01:00
New Revision: 163c223161b8cd33e812613b27fbc52ea6e0f880

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

LOG: [Debuginfo] [CSInfo] Do not create CSInfo for undef arguments

If a function parameter is marked as "undef", prevent creation
of CallSiteInfo for that parameter.
Without this patch, the parameter's call_site_value would be incorrect.
The incorrect call_value case reported in PR39716,
addressed in D85111.
​
Patch by Nikola Tesic
​
Differential revision: https://reviews.llvm.org/D92471

Added: 
llvm/test/DebugInfo/X86/dbg-call-site-undef-params.ll

Modified: 
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp

Removed: 




diff  --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp 
b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index 5054ed81fcfc..4ab0c60399f2 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -787,6 +787,16 @@ static void collectCallSiteParameters(const MachineInstr 
*CallMI,
 (void)InsertedReg;
   }
 
+  // Do not emit CSInfo for undef forwarding registers.
+  for (auto &MO : CallMI->uses()) {
+if (!MO.isReg() || !MO.isUndef())
+  continue;
+auto It = ForwardedRegWorklist.find(MO.getReg());
+if (It == ForwardedRegWorklist.end())
+  continue;
+ForwardedRegWorklist.erase(It);
+  }
+
   // We erase, from the ForwardedRegWorklist, those forwarding registers for
   // which we successfully describe a loaded value (by using
   // the describeLoadedValue()). For those remaining arguments in the working

diff  --git a/llvm/test/DebugInfo/X86/dbg-call-site-undef-params.ll 
b/llvm/test/DebugInfo/X86/dbg-call-site-undef-params.ll
new file mode 100644
index ..84248c33d9df
--- /dev/null
+++ b/llvm/test/DebugInfo/X86/dbg-call-site-undef-params.ll
@@ -0,0 +1,80 @@
+; RUN: llc -emit-call-site-info %s -filetype=obj -o - | llvm-dwarfdump - | 
FileCheck %s
+
+;; Compiled from source:
+;; extern int fn1 (long int x, long int y, long int z);
+;; __attribute__((noinline)) long int
+;; fn2 (long int a, long int b, long int c)
+;; {
+;;   long int q = 2 * a;
+;;   return fn1 (5, 6, 7);
+;; }
+;; int main(void) {
+;; return fn2(14, 23, 34);
+;; }
+;; Using command:
+;; clang -g -O2 m.c -emit-llvm -S -c -o m.ll
+
+;; Verify that call site info is not created for parameters marked as "undef".
+; CHECK: DW_TAG_GNU_call_site
+; CHECK: DW_AT_abstract_origin ({{.*}} "fn2")
+; CHECK-NOT: DW_TAG_GNU_call_site_parameter
+
+; ModuleID = 'm.c'
+source_filename = "m.c"
+target datalayout = 
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+; Function Attrs: noinline nounwind uwtable
+define dso_local i64 @fn2(i64 %a, i64 %b, i64 %c) local_unnamed_addr !dbg !7 {
+entry:
+  call void @llvm.dbg.value(metadata i64 undef, metadata !12, metadata 
!DIExpression()), !dbg !16
+  call void @llvm.dbg.value(metadata i64 undef, metadata !13, metadata 
!DIExpression()), !dbg !16
+  call void @llvm.dbg.value(metadata i64 undef, metadata !14, metadata 
!DIExpression()), !dbg !16
+  call void @llvm.dbg.value(metadata i64 undef, metadata !15, metadata 
!DIExpression()), !dbg !16
+  %call = tail call i32 @fn1(i64 5, i64 6, i64 7) #4, !dbg !16
+  %conv = sext i32 %call to i64, !dbg !16
+  ret i64 %conv, !dbg !16
+}
+
+declare !dbg !19 dso_local i32 @fn1(i64, i64, i64) local_unnamed_addr
+
+; Function Attrs: nounwind uwtable
+define dso_local i32 @main() local_unnamed_addr !dbg !23 {
+entry:
+  %call = tail call i64 @fn2(i64 undef, i64 undef, i64 undef), !dbg !26
+  %conv = trunc i64 %call to i32, !dbg !26
+  ret i32 %conv, !dbg !26
+}
+
+; Function Attrs: nounwind readnone speculatable willreturn
+declare void @llvm.dbg.value(metadata, metadata, metadata)
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3, !4, !5}
+!llvm.ident = !{!6}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang 
version 12.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, 
enums: !2, splitDebugInlining: false, nameTableKind: None)
+!1 = !DIFile(filename: "m.c", directory: "/dir")
+!2 = !{}
+!3 = !{i32 7, !"Dwarf Version", i32 4}
+!4 = !{i32 2, !"Debug Info Version", i32 3}
+!5 = !{i32 1, !"wchar_size", i32 4}
+!6 = !{!"clang version 12.0.0"}
+!7 = distinct !DISubprogram(name: "fn2", scope: !1, file: !1, line: 4, type: 
!8, scopeLine: 5, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: 
DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !11)
+!8 = !DISubroutineType(types: !9)
+!9 = !{!10, !10, !10, !10}
+!10 = !DIBasicType(name: "long int", size: 64, encoding: DW_ATE_signed)
+!11 = !{!12, !13, !14, !15}
+!12 = !DILocalVariable(name: "a", arg: 1,

[llvm-branch-commits] [llvm] e5bf2e8 - [SLP] Use the width of value truncated just before storing

2020-12-09 Thread Anton Afanasyev via llvm-branch-commits

Author: Anton Afanasyev
Date: 2020-12-09T16:38:45+03:00
New Revision: e5bf2e8989469ec328d910be26bd3ee0710326d9

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

LOG: [SLP] Use the width of value truncated just before storing

For stores chain vectorization we choose the size of vector
elements to ensure we fit to minimum and maximum vector register
size for the number of elements given. This patch corrects vector
element size choosing the width of value truncated just before
storing instead of the width of value stored.

Fixes PR46983

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

Added: 


Modified: 
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
llvm/test/Transforms/SLPVectorizer/X86/insert-after-bundle.ll
llvm/test/Transforms/SLPVectorizer/X86/pr46983.ll

Removed: 




diff  --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp 
b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index e3f6d8cc05f7..456485f45809 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -5536,10 +5536,15 @@ void BoUpSLP::scheduleBlock(BlockScheduling *BS) {
 }
 
 unsigned BoUpSLP::getVectorElementSize(Value *V) {
-  // If V is a store, just return the width of the stored value without
-  // traversing the expression tree. This is the common case.
-  if (auto *Store = dyn_cast(V))
-return DL->getTypeSizeInBits(Store->getValueOperand()->getType());
+  // If V is a store, just return the width of the stored value (or value
+  // truncated just before storing) without traversing the expression tree.
+  // This is the common case.
+  if (auto *Store = dyn_cast(V)) {
+if (auto *Trunc = dyn_cast(Store->getValueOperand()))
+  return DL->getTypeSizeInBits(Trunc->getSrcTy());
+else
+  return DL->getTypeSizeInBits(Store->getValueOperand()->getType());
+  }
 
   auto E = InstrElementSize.find(V);
   if (E != InstrElementSize.end())

diff  --git a/llvm/test/Transforms/SLPVectorizer/X86/insert-after-bundle.ll 
b/llvm/test/Transforms/SLPVectorizer/X86/insert-after-bundle.ll
index fa1183400cb0..23aa3536a88d 100644
--- a/llvm/test/Transforms/SLPVectorizer/X86/insert-after-bundle.ll
+++ b/llvm/test/Transforms/SLPVectorizer/X86/insert-after-bundle.ll
@@ -22,132 +22,304 @@ entry:
 }
 
 define void @bar(i8* noalias nocapture readonly %a, i8* noalias nocapture 
readonly %b, i8* noalias nocapture readonly %c, i8* noalias nocapture readonly 
%d, i8* noalias nocapture %e, i32 %w) local_unnamed_addr #1 {
-; CHECK-LABEL: @bar(
-; CHECK-NEXT:  entry:
-; CHECK-NEXT:[[TMP0:%.*]] = insertelement <16 x i32> undef, i32 [[W:%.*]], 
i32 0
-; CHECK-NEXT:[[TMP1:%.*]] = insertelement <16 x i32> [[TMP0]], i32 [[W]], 
i32 1
-; CHECK-NEXT:[[TMP2:%.*]] = insertelement <16 x i32> [[TMP1]], i32 [[W]], 
i32 2
-; CHECK-NEXT:[[TMP3:%.*]] = insertelement <16 x i32> [[TMP2]], i32 [[W]], 
i32 3
-; CHECK-NEXT:[[TMP4:%.*]] = insertelement <16 x i32> [[TMP3]], i32 [[W]], 
i32 4
-; CHECK-NEXT:[[TMP5:%.*]] = insertelement <16 x i32> [[TMP4]], i32 [[W]], 
i32 5
-; CHECK-NEXT:[[TMP6:%.*]] = insertelement <16 x i32> [[TMP5]], i32 [[W]], 
i32 6
-; CHECK-NEXT:[[TMP7:%.*]] = insertelement <16 x i32> [[TMP6]], i32 [[W]], 
i32 7
-; CHECK-NEXT:[[TMP8:%.*]] = insertelement <16 x i32> [[TMP7]], i32 [[W]], 
i32 8
-; CHECK-NEXT:[[TMP9:%.*]] = insertelement <16 x i32> [[TMP8]], i32 [[W]], 
i32 9
-; CHECK-NEXT:[[TMP10:%.*]] = insertelement <16 x i32> [[TMP9]], i32 [[W]], 
i32 10
-; CHECK-NEXT:[[TMP11:%.*]] = insertelement <16 x i32> [[TMP10]], i32 
[[W]], i32 11
-; CHECK-NEXT:[[TMP12:%.*]] = insertelement <16 x i32> [[TMP11]], i32 
[[W]], i32 12
-; CHECK-NEXT:[[TMP13:%.*]] = insertelement <16 x i32> [[TMP12]], i32 
[[W]], i32 13
-; CHECK-NEXT:[[TMP14:%.*]] = insertelement <16 x i32> [[TMP13]], i32 
[[W]], i32 14
-; CHECK-NEXT:[[TMP15:%.*]] = insertelement <16 x i32> [[TMP14]], i32 
[[W]], i32 15
-; CHECK-NEXT:br label [[FOR_BODY:%.*]]
-; CHECK:   for.body:
-; CHECK-NEXT:[[I_0356:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[INC:%.*]], 
[[FOR_BODY]] ]
-; CHECK-NEXT:[[A_ADDR_0355:%.*]] = phi i8* [ [[A:%.*]], [[ENTRY]] ], [ 
[[ADD_PTR:%.*]], [[FOR_BODY]] ]
-; CHECK-NEXT:[[E_ADDR_0354:%.*]] = phi i8* [ [[E:%.*]], [[ENTRY]] ], [ 
[[ADD_PTR192:%.*]], [[FOR_BODY]] ]
-; CHECK-NEXT:[[D_ADDR_0353:%.*]] = phi i8* [ [[D:%.*]], [[ENTRY]] ], [ 
[[ADD_PTR191:%.*]], [[FOR_BODY]] ]
-; CHECK-NEXT:[[C_ADDR_0352:%.*]] = phi i8* [ [[C:%.*]], [[ENTRY]] ], [ 
[[ADD_PTR190:%.*]], [[FOR_BODY]] ]
-; CHECK-NEXT:[[B_ADDR_0351:%.*]] = phi i8* [ [[B:%.*]], [[ENTRY]] ], [ 
[[ADD_PTR189:%.*]], [[FOR_BODY]] ]
-; CHECK-NEXT:[[ARRAYIDX9:%.*]] = getelementptr inbounds i8, i8* 
[[C_ADDR_0352]], i64 1
-; CH

[llvm-branch-commits] [lldb] 10edd10 - [LLDB] Temporarily incrase DEFAULT_TIMEOUT on gdbremote_testcase.py

2020-12-09 Thread Muhammad Omair Javaid via llvm-branch-commits

Author: Muhammad Omair Javaid
Date: 2020-12-09T18:44:21+05:00
New Revision: 10edd103483027fad1f106ae2d250136b83f1d4d

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

LOG: [LLDB] Temporarily incrase DEFAULT_TIMEOUT on gdbremote_testcase.py

TestLldbGdbServer.py testcases are timing out on LLDB/AArch64 Linux
buildbot since recent changes. I am temporarily increasing
DEFAULT_TIMEOUT to 20 seconds to see impact.

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py

Removed: 




diff  --git 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
index d7bfb7fbda327..2908ca2809a9d 100644
--- 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
+++ 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
@@ -32,7 +32,7 @@ class GdbRemoteTestCaseBase(TestBase):
 NO_DEBUG_INFO_TESTCASE = True
 
 # Default time out in seconds. The timeout is increased tenfold under Asan.
-DEFAULT_TIMEOUT =  10 * (10 if ('ASAN_OPTIONS' in os.environ) else 1)
+DEFAULT_TIMEOUT =  20 * (10 if ('ASAN_OPTIONS' in os.environ) else 1)
 # Default sleep time in seconds. The sleep time is doubled under Asan.
 DEFAULT_SLEEP   =  5  * (2  if ('ASAN_OPTIONS' in os.environ) else 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] [compiler-rt] 6f13445 - [DFSan] Add custom wrapper for epoll_wait.

2020-12-09 Thread Matt Morehouse via llvm-branch-commits

Author: Matt Morehouse
Date: 2020-12-09T06:05:29-08:00
New Revision: 6f13445fb601f2ad30cdd0b89492af8681bc6c70

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

LOG: [DFSan] Add custom wrapper for epoll_wait.

The wrapper clears shadow for any events written.

Reviewed By: stephan.yichao.zhao

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

Added: 


Modified: 
compiler-rt/lib/dfsan/dfsan_custom.cpp
compiler-rt/lib/dfsan/done_abilist.txt
compiler-rt/test/dfsan/custom.cpp

Removed: 




diff  --git a/compiler-rt/lib/dfsan/dfsan_custom.cpp 
b/compiler-rt/lib/dfsan/dfsan_custom.cpp
index 80031d96464c..7ba0bf0c2e2f 100644
--- a/compiler-rt/lib/dfsan/dfsan_custom.cpp
+++ b/compiler-rt/lib/dfsan/dfsan_custom.cpp
@@ -11,12 +11,6 @@
 // This file defines the custom functions listed in done_abilist.txt.
 
//===--===//
 
-#include "sanitizer_common/sanitizer_common.h"
-#include "sanitizer_common/sanitizer_internal_defs.h"
-#include "sanitizer_common/sanitizer_linux.h"
-
-#include "dfsan/dfsan.h"
-
 #include 
 #include 
 #include 
@@ -32,6 +26,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -40,6 +35,11 @@
 #include 
 #include 
 
+#include "dfsan/dfsan.h"
+#include "sanitizer_common/sanitizer_common.h"
+#include "sanitizer_common/sanitizer_internal_defs.h"
+#include "sanitizer_common/sanitizer_linux.h"
+
 using namespace __dfsan;
 
 #define CALL_WEAK_INTERCEPTOR_HOOK(f, ...) 
\
@@ -715,6 +715,18 @@ int __dfsw_getpwuid_r(id_t uid, struct passwd *pwd,
   return ret;
 }
 
+SANITIZER_INTERFACE_ATTRIBUTE
+int __dfsw_epoll_wait(int epfd, struct epoll_event *events, int maxevents,
+  int timeout, dfsan_label epfd_label,
+  dfsan_label events_label, dfsan_label maxevents_label,
+  dfsan_label timeout_label, dfsan_label *ret_label) {
+  int ret = epoll_wait(epfd, events, maxevents, timeout);
+  if (ret > 0)
+dfsan_set_label(0, events, ret * sizeof(*events));
+  *ret_label = 0;
+  return ret;
+}
+
 SANITIZER_INTERFACE_ATTRIBUTE
 int __dfsw_poll(struct pollfd *fds, nfds_t nfds, int timeout,
 dfsan_label dfs_label, dfsan_label nfds_label,

diff  --git a/compiler-rt/lib/dfsan/done_abilist.txt 
b/compiler-rt/lib/dfsan/done_abilist.txt
index 252ec52f1bd2..bf874d262be9 100644
--- a/compiler-rt/lib/dfsan/done_abilist.txt
+++ b/compiler-rt/lib/dfsan/done_abilist.txt
@@ -184,6 +184,7 @@ fun:uselocale=discard
 fun:calloc=custom
 fun:clock_gettime=custom
 fun:dlopen=custom
+fun:epoll_wait=custom
 fun:fgets=custom
 fun:fstat=custom
 fun:getcwd=custom

diff  --git a/compiler-rt/test/dfsan/custom.cpp 
b/compiler-rt/test/dfsan/custom.cpp
index 8f00b1e630f6..087a684f51b9 100644
--- a/compiler-rt/test/dfsan/custom.cpp
+++ b/compiler-rt/test/dfsan/custom.cpp
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -638,6 +639,46 @@ void test_getpwuid_r() {
   ASSERT_READ_ZERO_LABEL(&pwd, 4);
 }
 
+void test_epoll_wait() {
+  // Set up a pipe to monitor with epoll.
+  int pipe_fds[2];
+  int ret = pipe(pipe_fds);
+  assert(ret != -1);
+
+  // Configure epoll to monitor the pipe.
+  int epfd = epoll_create1(0);
+  assert(epfd != -1);
+  struct epoll_event event;
+  event.events = EPOLLIN;
+  event.data.fd = pipe_fds[0];
+  ret = epoll_ctl(epfd, EPOLL_CTL_ADD, pipe_fds[0], &event);
+  assert(ret != -1);
+
+  // Test epoll_wait when no events have occurred.
+  event = {};
+  dfsan_set_label(i_label, &event, sizeof(event));
+  ret = epoll_wait(epfd, &event, /*maxevents=*/1, /*timeout=*/0);
+  assert(ret == 0);
+  assert(event.events == 0);
+  assert(event.data.fd == 0);
+  ASSERT_ZERO_LABEL(ret);
+  ASSERT_READ_LABEL(&event, sizeof(event), i_label);
+
+  // Test epoll_wait when an event occurs.
+  write(pipe_fds[1], "x", 1);
+  ret = epoll_wait(epfd, &event, /*maxevents=*/1, /*timeout=*/0);
+  assert(ret == 1);
+  assert(event.events == EPOLLIN);
+  assert(event.data.fd == pipe_fds[0]);
+  ASSERT_ZERO_LABEL(ret);
+  ASSERT_READ_ZERO_LABEL(&event, sizeof(event));
+
+  // Clean up.
+  close(epfd);
+  close(pipe_fds[0]);
+  close(pipe_fds[1]);
+}
+
 void test_poll() {
   struct pollfd fd;
   fd.fd = 0;
@@ -1027,6 +1068,7 @@ int main(void) {
   test_dfsan_set_write_callback();
   test_dl_iterate_phdr();
   test_dlopen();
+  test_epoll_wait();
   test_fgets();
   test_fstat();
   test_get_current_dir_name();



___
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] 24184db - [X86] Fold CONCAT(VPERMV3(X, Y, M0), VPERMV3(Z, W, M1)) -> VPERMV3(CONCAT(X, Z), CONCAT(Y, W), CONCAT(M0, M1))

2020-12-09 Thread Simon Pilgrim via llvm-branch-commits

Author: Simon Pilgrim
Date: 2020-12-09T14:29:32Z
New Revision: 24184dbb82f9eac76c4ffe077fb957a526b1b963

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

LOG: [X86] Fold CONCAT(VPERMV3(X,Y,M0),VPERMV3(Z,W,M1)) -> 
VPERMV3(CONCAT(X,Z),CONCAT(Y,W),CONCAT(M0,M1))

Further prep work toward supporting different subvector sizes in 
combineX86ShufflesRecursively

Added: 


Modified: 
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/test/CodeGen/X86/vector-pack-512.ll

Removed: 




diff  --git a/llvm/lib/Target/X86/X86ISelLowering.cpp 
b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 135b13b34f33..53f30af8d38b 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -48813,6 +48813,38 @@ static SDValue combineConcatVectorOps(const SDLoc &DL, 
MVT VT,
 return DAG.getBitcast(VT, Res);
   }
   break;
+case X86ISD::VPERMV3:
+  if (!IsSplat && NumOps == 2 && VT.is512BitVector()) {
+MVT OpVT = Op0.getSimpleValueType();
+int NumSrcElts = OpVT.getVectorNumElements();
+SmallVector ConcatMask;
+for (unsigned i = 0; i != NumOps; ++i) {
+  bool IsUnary;
+  SmallVector SubMask;
+  SmallVector SubOps;
+  if (!getTargetShuffleMask(Ops[i].getNode(), OpVT, false, SubOps,
+SubMask, IsUnary))
+break;
+  for (int M : SubMask) {
+if (0 <= M) {
+  M += M < NumSrcElts ? 0 : NumSrcElts;
+  M += i * NumSrcElts;
+}
+ConcatMask.push_back(M);
+  }
+}
+if (ConcatMask.size() == (NumOps * NumSrcElts)) {
+  SDValue Src0 = concatSubVectors(Ops[0].getOperand(0),
+  Ops[1].getOperand(0), DAG, DL);
+  SDValue Src1 = concatSubVectors(Ops[0].getOperand(2),
+  Ops[1].getOperand(2), DAG, DL);
+  MVT IntMaskSVT = MVT::getIntegerVT(VT.getScalarSizeInBits());
+  MVT IntMaskVT = MVT::getVectorVT(IntMaskSVT, NumOps * NumSrcElts);
+  SDValue Mask = getConstVector(ConcatMask, IntMaskVT, DAG, DL, true);
+  return DAG.getNode(X86ISD::VPERMV3, DL, VT, Src0, Mask, Src1);
+}
+  }
+  break;
 case X86ISD::VSHLI:
 case X86ISD::VSRAI:
 case X86ISD::VSRLI:

diff  --git a/llvm/test/CodeGen/X86/vector-pack-512.ll 
b/llvm/test/CodeGen/X86/vector-pack-512.ll
index 0612e08e830a..432927d51061 100644
--- a/llvm/test/CodeGen/X86/vector-pack-512.ll
+++ b/llvm/test/CodeGen/X86/vector-pack-512.ll
@@ -145,11 +145,10 @@ define <32 x i16> @concat_trunc_packssdw_512(<16 x i32> 
%a0, <16 x i32> %a1) nou
 ; AVX512-NEXT:vpsrad $23, %zmm1, %zmm1
 ; AVX512-NEXT:vpmovdw %zmm0, %ymm0
 ; AVX512-NEXT:vpmovdw %zmm1, %ymm1
-; AVX512-NEXT:vmovdqa {{.*#+}} ymm2 = [2,6,3,7]
-; AVX512-NEXT:vpermi2q %ymm1, %ymm0, %ymm2
-; AVX512-NEXT:vmovdqa {{.*#+}} ymm3 = [0,4,1,5]
-; AVX512-NEXT:vpermi2q %ymm1, %ymm0, %ymm3
-; AVX512-NEXT:vinserti64x4 $1, %ymm2, %zmm3, %zmm0
+; AVX512-NEXT:vinserti64x4 $1, %ymm1, %zmm1, %zmm1
+; AVX512-NEXT:vinserti64x4 $1, %ymm0, %zmm0, %zmm2
+; AVX512-NEXT:vmovdqa64 {{.*#+}} zmm0 = [0,8,1,9,6,14,7,15]
+; AVX512-NEXT:vpermi2q %zmm1, %zmm2, %zmm0
 ; AVX512-NEXT:retq
   %1 = ashr <16 x i32> %a0, 
   %2 = ashr <16 x i32> %a1, 
@@ -166,11 +165,10 @@ define <32 x i16> @concat_trunc_packusdw_512(<16 x i32> 
%a0, <16 x i32> %a1) nou
 ; AVX512-NEXT:vpsrld $23, %zmm1, %zmm1
 ; AVX512-NEXT:vpmovdw %zmm0, %ymm0
 ; AVX512-NEXT:vpmovdw %zmm1, %ymm1
-; AVX512-NEXT:vmovdqa {{.*#+}} ymm2 = [2,6,3,7]
-; AVX512-NEXT:vpermi2q %ymm1, %ymm0, %ymm2
-; AVX512-NEXT:vmovdqa {{.*#+}} ymm3 = [0,4,1,5]
-; AVX512-NEXT:vpermi2q %ymm1, %ymm0, %ymm3
-; AVX512-NEXT:vinserti64x4 $1, %ymm2, %zmm3, %zmm0
+; AVX512-NEXT:vinserti64x4 $1, %ymm1, %zmm1, %zmm1
+; AVX512-NEXT:vinserti64x4 $1, %ymm0, %zmm0, %zmm2
+; AVX512-NEXT:vmovdqa64 {{.*#+}} zmm0 = [0,8,1,9,6,14,7,15]
+; AVX512-NEXT:vpermi2q %zmm1, %zmm2, %zmm0
 ; AVX512-NEXT:retq
   %1 = lshr <16 x i32> %a0, 
   %2 = lshr <16 x i32> %a1, 
@@ -183,26 +181,25 @@ define <32 x i16> @concat_trunc_packusdw_512(<16 x i32> 
%a0, <16 x i32> %a1) nou
 define <64 x i8> @concat_trunc_packsswb_512(<32 x i16> %a0, <32 x i16> %a1) 
nounwind {
 ; AVX512F-LABEL: concat_trunc_packsswb_512:
 ; AVX512F:   # %bb.0:
-; AVX512F-NEXT:vextracti64x4 $1, %zmm0, %ymm2
-; AVX512F-NEXT:vpsraw $15, %ymm2, %ymm2
+; AVX512F-NEXT:vpsraw $15, %ymm0, %ymm2
+; AVX512F-NEXT:vextracti64x4 $1, %zmm0, %ymm0
 ; AVX512F-NEXT:vpsraw $15, %ymm0, %ymm0
 ; AVX512F-NEXT:vpmovzxwd {{.*#+}} zmm0 = 
ymm0[0],zero,ymm0[1],zero,ymm0[2],zero

[llvm-branch-commits] [lld] 03a77d0 - [LLD][ELF] Fix typo in relocation-model-pic.ll

2020-12-09 Thread Yvan Roux via llvm-branch-commits

Author: Yvan Roux
Date: 2020-12-09T15:38:50+01:00
New Revision: 03a77d04b412df5cc2a43b9708466a4928df60b1

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

LOG: [LLD][ELF] Fix typo in relocation-model-pic.ll

Should fix non-x86 bot failures.

Added: 


Modified: 
lld/test/ELF/lto/relocation-model-pic.ll

Removed: 




diff  --git a/lld/test/ELF/lto/relocation-model-pic.ll 
b/lld/test/ELF/lto/relocation-model-pic.ll
index f0eae4685392..d3242fdb8d66 100644
--- a/lld/test/ELF/lto/relocation-model-pic.ll
+++ b/lld/test/ELF/lto/relocation-model-pic.ll
@@ -1,4 +1,4 @@
-; REQUIRE: x86
+; REQUIRES: x86
 ; RUN: llvm-as %s -o %t.o
 
 ; RUN: ld.lld %t.o -o %t -save-temps -shared



___
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] f16320b - [NFC][InstCombine] Add test coverage for @llvm.uadd.sat canonicalization

2020-12-09 Thread Roman Lebedev via llvm-branch-commits

Author: Roman Lebedev
Date: 2020-12-09T18:19:08+03:00
New Revision: f16320b90b8381f2e3aac1ec17f39eff06f09ea0

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

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 4585bc275001..c5504ccbb94a 100644
--- a/llvm/test/Transforms/InstCombine/saturating-add-sub.ll
+++ b/llvm/test/Transforms/InstCombine/saturating-add-sub.ll
@@ -1208,6 +1208,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(
@@ -1236,6 +1247,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(
@@ -1267,6 +1291,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:%.*]]
@@ -1354,6 +1392,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:%.*]]
@@ -1384,6 +1435,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:%.*]], 
@@ -1412,6 +1476,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 = xor i32 %x, -1
+  %a = add i32 %notx, %y
+  %c = icmp ule i32 %y, %x
+  

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

2020-12-09 Thread Roman Lebedev via llvm-branch-commits

Author: Roman Lebedev
Date: 2020-12-09T18:19:09+03:00
New Revision: e6f2a79d7aa01f8dd7f0194f97a50b480e8ede71

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

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 ea2a02a1bba7..397cb0b0e187 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
@@ -765,25 +765,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) {
@@ -792,6 +791,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 {
@@ -802,7 +802,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 c5504ccbb94a..b132e0bdb400 100644
--- a/llvm/test/Transforms/InstCombine/saturating-add-sub.ll
+++ b/llvm/test/Transforms/InstCombine/saturating-add-sub.ll
@@ -1801,8 +1801,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
@@ -1823,8 +1825,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 [[Y:%.*]], i32 
[[X:%.*]])
-; CHECK-NEXT:ret i32 [[TMP1]]
+; CHECK-NEXT: 

[llvm-branch-commits] [llvm] b2ef264 - [VectorCombine] allow peeking through an extractelt when creating a vector load

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

Author: Sanjay Patel
Date: 2020-12-09T10:36:14-05:00
New Revision: b2ef264096c045cf7147320a8bcdf8ec725ec534

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

LOG: [VectorCombine] allow peeking through an extractelt when creating a vector 
load

This is an enhancement to load vectorization that is motivated by
a pattern in https://llvm.org/PR16739.
Unfortunately, it's still not enough to make a difference there.
We will have to handle multi-use cases in some better way to avoid
creating multiple overlapping loads.

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

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 5f3d5c768a9e..0d0a338afca3 100644
--- a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
+++ b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
@@ -92,18 +92,25 @@ static void replaceValue(Value &Old, Value &New) {
 }
 
 bool VectorCombine::vectorizeLoadInsert(Instruction &I) {
-  // Match insert into fixed vector of scalar load.
+  // Match insert into fixed vector of scalar value.
   auto *Ty = dyn_cast(I.getType());
   Value *Scalar;
   if (!Ty || !match(&I, m_InsertElt(m_Undef(), m_Value(Scalar), m_ZeroInt())) 
||
   !Scalar->hasOneUse())
 return false;
 
+  // Optionally match an extract from another vector.
+  Value *X;
+  bool HasExtract = match(Scalar, m_ExtractElt(m_Value(X), m_ZeroInt()));
+  if (!HasExtract)
+X = Scalar;
+
+  // Match source value as load of scalar or vector.
   // Do not vectorize scalar load (widening) if atomic/volatile or under
   // asan/hwasan/memtag/tsan. The widened load may load data from dirty regions
   // or create data races non-existent in the source.
-  auto *Load = dyn_cast(Scalar);
-  if (!Load || !Load->isSimple() ||
+  auto *Load = dyn_cast(X);
+  if (!Load || !Load->isSimple() || !Load->hasOneUse() ||
   Load->getFunction()->hasFnAttribute(Attribute::SanitizeMemTag) ||
   mustSuppressSpeculation(*Load))
 return false;
@@ -134,10 +141,12 @@ bool VectorCombine::vectorizeLoadInsert(Instruction &I) {
 return false;
 
 
-  // Original pattern: insertelt undef, load [free casts of] ScalarPtr, 0
-  int OldCost = TTI.getMemoryOpCost(Instruction::Load, ScalarTy, Alignment, 
AS);
+  // Original pattern: insertelt undef, load [free casts of] PtrOp, 0
+  Type *LoadTy = Load->getType();
+  int OldCost = TTI.getMemoryOpCost(Instruction::Load, LoadTy, Alignment, AS);
   APInt DemandedElts = APInt::getOneBitSet(MinVecNumElts, 0);
-  OldCost += TTI.getScalarizationOverhead(MinVecTy, DemandedElts, true, false);
+  OldCost += TTI.getScalarizationOverhead(MinVecTy, DemandedElts,
+  /* Insert */ true, HasExtract);
 
   // New pattern: load VecPtr
   int NewCost = TTI.getMemoryOpCost(Instruction::Load, MinVecTy, Alignment, 
AS);

diff  --git a/llvm/test/Transforms/VectorCombine/X86/load.ll 
b/llvm/test/Transforms/VectorCombine/X86/load.ll
index 66b9f89dd8dd..824a507ed103 100644
--- a/llvm/test/Transforms/VectorCombine/X86/load.ll
+++ b/llvm/test/Transforms/VectorCombine/X86/load.ll
@@ -499,9 +499,8 @@ define void @PR47558_multiple_use_load(<2 x float>* 
nocapture nonnull %resultptr
 
 define <4 x float> @load_v2f32_extract_insert_v4f32(<2 x float>* align 16 
dereferenceable(16) %p) {
 ; CHECK-LABEL: @load_v2f32_extract_insert_v4f32(
-; CHECK-NEXT:[[L:%.*]] = load <2 x float>, <2 x float>* [[P:%.*]], align 4
-; CHECK-NEXT:[[S:%.*]] = extractelement <2 x float> [[L]], i32 0
-; CHECK-NEXT:[[R:%.*]] = insertelement <4 x float> undef, float [[S]], i32 0
+; CHECK-NEXT:[[TMP1:%.*]] = bitcast <2 x float>* [[P:%.*]] to <4 x float>*
+; CHECK-NEXT:[[R:%.*]] = load <4 x float>, <4 x float>* [[TMP1]], align 4
 ; CHECK-NEXT:ret <4 x float> [[R]]
 ;
   %l = load <2 x float>, <2 x float>* %p, align 4
@@ -512,9 +511,8 @@ define <4 x float> @load_v2f32_extract_insert_v4f32(<2 x 
float>* align 16 derefe
 
 define <4 x float> @load_v8f32_extract_insert_v4f32(<8 x float>* align 16 
dereferenceable(16) %p) {
 ; CHECK-LABEL: @load_v8f32_extract_insert_v4f32(
-; CHECK-NEXT:[[L:%.*]] = load <8 x float>, <8 x float>* [[P:%.*]], align 4
-; CHECK-NEXT:[[S:%.*]] = extractelement <8 x float> [[L]], i32 0
-; CHECK-NEXT:[[R:%.*]] = insertelement <4 x float> undef, float [[S]], i32 0
+; CHECK-NEXT:[[TMP1:%.*]] = bitcast <8 x float>* [[P:%.*]] to <4 x float>*
+; CHECK-NEXT:[[R:%.*]] = load <4 x float>, <4 x float>* [[TMP1]], align 4
 ; CHECK-NEXT:ret <4 x float> [[R]]
 ;
   %l = load <8 x float>, <8 x float>* %p, align 4




[llvm-branch-commits] [llvm] 6266f36 - [TableGen] Cache the vectors of records returned by getAllDerivedDefinitions().

2020-12-09 Thread Paul C. Anagnostopoulos via llvm-branch-commits

Author: Paul C. Anagnostopoulos
Date: 2020-12-09T10:54:04-05:00
New Revision: 6266f36226bb96e42015411048f3ed5afb751510

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

LOG: [TableGen] Cache the vectors of records returned by 
getAllDerivedDefinitions().

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

Added: 


Modified: 
llvm/include/llvm/TableGen/Record.h
llvm/lib/TableGen/Record.cpp
llvm/utils/TableGen/InstrInfoEmitter.cpp

Removed: 




diff  --git a/llvm/include/llvm/TableGen/Record.h 
b/llvm/include/llvm/TableGen/Record.h
index fe552331b385..3010b4dad09a 100644
--- a/llvm/include/llvm/TableGen/Record.h
+++ b/llvm/include/llvm/TableGen/Record.h
@@ -1703,6 +1703,7 @@ class RecordKeeper {
 
   std::string InputFilename;
   RecordMap Classes, Defs;
+  mutable StringMap> ClassRecordsMap;
   FoldingSet RecordTypePool;
   std::map> ExtraGlobals;
   unsigned AnonCounter = 0;
@@ -1801,17 +1802,14 @@ class RecordKeeper {
   
//======//
   // High-level helper methods, useful for tablegen backends.
 
-  /// Get all the concrete records that inherit from all the specified
-  /// classes. The classes must be defined.
-  std::vector getAllDerivedDefinitions(
-  const ArrayRef ClassNames) const;
-
   /// Get all the concrete records that inherit from the one specified
   /// class. The class must be defined.
-  std::vector getAllDerivedDefinitions(StringRef ClassName) const {
+  std::vector getAllDerivedDefinitions(StringRef ClassName) const;
 
-return getAllDerivedDefinitions(makeArrayRef(ClassName));
-  }
+  /// Get all the concrete records that inherit from all the specified
+  /// classes. The classes must be defined.
+  std::vector getAllDerivedDefinitions(
+  ArrayRef ClassNames) const;
 
   void dump() const;
 };

diff  --git a/llvm/lib/TableGen/Record.cpp b/llvm/lib/TableGen/Record.cpp
index 1e2d75f3fe8d..367c5590ea87 100644
--- a/llvm/lib/TableGen/Record.cpp
+++ b/llvm/lib/TableGen/Record.cpp
@@ -2595,8 +2595,20 @@ void RecordKeeper::stopBackendTimer() {
   }
 }
 
+// We cache the record vectors for single classes. Many backends request
+// the same vectors multiple times.
 std::vector RecordKeeper::getAllDerivedDefinitions(
-const ArrayRef ClassNames) const {
+StringRef ClassName) const {
+
+  auto Pair = ClassRecordsMap.try_emplace(ClassName);
+  if (Pair.second)
+Pair.first->second = getAllDerivedDefinitions(makeArrayRef(ClassName));
+
+  return Pair.first->second;
+}
+
+std::vector RecordKeeper::getAllDerivedDefinitions(
+ArrayRef ClassNames) const {
   SmallVector ClassRecs;
   std::vector Defs;
 

diff  --git a/llvm/utils/TableGen/InstrInfoEmitter.cpp 
b/llvm/utils/TableGen/InstrInfoEmitter.cpp
index ac1a8e09f1cb..025c5354514c 100644
--- a/llvm/utils/TableGen/InstrInfoEmitter.cpp
+++ b/llvm/utils/TableGen/InstrInfoEmitter.cpp
@@ -532,6 +532,7 @@ void InstrInfoEmitter::run(raw_ostream &OS) {
   unsigned ListNumber = 0;
 
   // Emit all of the instruction's implicit uses and defs.
+  Records.startTimer("Emit uses/defs");
   for (const CodeGenInstruction *II : Target.getInstructionsByEnumValue()) {
 Record *Inst = II->TheDef;
 std::vector Uses = Inst->getValueAsListOfDefs("Uses");
@@ -549,10 +550,12 @@ void InstrInfoEmitter::run(raw_ostream &OS) {
   OperandInfoMapTy OperandInfoIDs;
 
   // Emit all of the operand info records.
+  Records.startTimer("Emit operand info");
   EmitOperandInfo(OS, OperandInfoIDs);
 
   // Emit all of the MCInstrDesc records in their ENUM ordering.
   //
+  Records.startTimer("Emit InstrDesc records");
   OS << "\nextern const MCInstrDesc " << TargetName << "Insts[] = {\n";
   ArrayRef NumberedInstructions =
 Target.getInstructionsByEnumValue();
@@ -568,6 +571,7 @@ void InstrInfoEmitter::run(raw_ostream &OS) {
   OS << "};\n\n";
 
   // Emit the array of instruction names.
+  Records.startTimer("Emit instruction names");
   InstrNames.layout();
   InstrNames.emitStringLiteralDef(OS, Twine("extern const char ") + TargetName 
+
   "InstrNameData[]");
@@ -628,6 +632,7 @@ void InstrInfoEmitter::run(raw_ostream &OS) {
   }
 
   // MCInstrInfo initialization routine.
+  Records.startTimer("Emit initialization routine");
   OS << "static inline void Init" << TargetName
  << "MCInstrInfo(MCInstrInfo *II) {\n";
   OS << "  II->InitMCInstrInfo(" << TargetName << "Insts, " << TargetName
@@ -706,10 +711,13 @@ void InstrInfoEmitter::run(raw_ostream &OS) {
 
   OS << "#endif // GET_INSTRINFO_CTOR_DTOR\n\n";
 
+  Records.startTimer("Emit operand name mappings");
   emitOperandNameMappings(OS, Target, NumberedInstructions);
 
+  Records.startTimer("Emit operand type mappings");
   emitOperandType

[llvm-branch-commits] [clang] ba223fa - [Clang][CodeGen][RISCV] Add hard float ABI tests with empty struct

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

Author: LuĂ­s Marques
Date: 2020-12-09T11:02:27-05:00
New Revision: ba223fa19d35d41ad9eeade8978ab1a17d6aafe1

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

LOG: [Clang][CodeGen][RISCV] Add hard float ABI tests with empty struct

This patch adds tests that showcase a behavior that is currently buggy.
Fix in a follow-up patch.

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

(cherry picked from commit ca93f9abdc0abc96ca8fb7999549a50aadd95caf)

Added: 
clang/test/CodeGen/riscv32-ilp32d-abi.cpp

Modified: 


Removed: 




diff  --git a/clang/test/CodeGen/riscv32-ilp32d-abi.cpp 
b/clang/test/CodeGen/riscv32-ilp32d-abi.cpp
new file mode 100644
index ..ffebb057e230
--- /dev/null
+++ b/clang/test/CodeGen/riscv32-ilp32d-abi.cpp
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -triple riscv32 -target-feature +d -target-abi ilp32d \
+// RUN: -Wno-missing-declarations -emit-llvm %s -o - | FileCheck %s
+
+struct empty_float2 { struct {}; float f; float g; };
+
+// CHECK: define float @_Z14f_empty_float212empty_float2(float %0, float %1)
+// FIXME: Extraneous padding before the second float
+// CHECK: { [4 x i8], float, [4 x i8], float }
+float f_empty_float2(empty_float2 a) {
+return a.g;
+}
+
+struct empty_double2 { struct {}; double f; double g; };
+
+// CHECK: define double @_Z15f_empty_double213empty_double2(double %0, double 
%1)
+// FIXME: Extraneous padding before the second double
+// CHECK: { [8 x i8], double, [8 x i8], double }
+double f_empty_double2(empty_double2 a) {
+return a.g;
+}
+
+struct empty_float_double { struct {}; float f; double g; };
+
+// CHECK: define double @_Z20f_empty_float_double18empty_float_double(float 
%0, double %1)
+// CHECK: { [4 x i8], float, double }
+double f_empty_float_double(empty_float_double a) {
+return a.g;
+}
+
+struct empty_double_float { struct {}; double f; float g; };
+
+// CHECK: define double @_Z20f_empty_double_float18empty_double_float(double 
%0, float %1)
+// FIXME: Extraneous padding before the float
+// CHECK: { [8 x i8], double, [8 x i8], float }
+double f_empty_double_float(empty_double_float a) {
+return a.g;
+}



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


[llvm-branch-commits] [clang] a4eaecf - [Clang][CodeGen][RISCV] Fix hard float ABI test cases with empty struct

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

Author: LuĂ­s Marques
Date: 2020-12-09T11:02:27-05:00
New Revision: a4eaecf122e1abbc5bc0f2478e80c6bb7da67cb0

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

LOG: [Clang][CodeGen][RISCV] Fix hard float ABI test cases with empty struct

The code seemed not to account for the field 1 offset.

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

(cherry picked from commit fa8f5bfa4e8cff042c9730320c74e97fab152ae1)

Added: 


Modified: 
clang/lib/CodeGen/TargetInfo.cpp
clang/test/CodeGen/riscv32-ilp32d-abi.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/TargetInfo.cpp 
b/clang/lib/CodeGen/TargetInfo.cpp
index f10f8e58b78a..c5db0985c1bf 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -10490,7 +10490,7 @@ bool RISCVABIInfo::detectFPCCEligibleStruct(QualType 
Ty, llvm::Type *&Field1Ty,
 NeededArgFPRs++;
   else if (Field2Ty)
 NeededArgGPRs++;
-  return IsCandidate;
+  return true;
 }
 
 // Call getCoerceAndExpand for the two-element flattened struct described by
@@ -10516,15 +10516,15 @@ ABIArgInfo 
RISCVABIInfo::coerceAndExpandFPCCEligibleStruct(
 
   CharUnits Field2Align =
   CharUnits::fromQuantity(getDataLayout().getABITypeAlignment(Field2Ty));
-  CharUnits Field1Size =
+  CharUnits Field1End = Field1Off +
   CharUnits::fromQuantity(getDataLayout().getTypeStoreSize(Field1Ty));
-  CharUnits Field2OffNoPadNoPack = Field1Size.alignTo(Field2Align);
+  CharUnits Field2OffNoPadNoPack = Field1End.alignTo(Field2Align);
 
   CharUnits Padding = CharUnits::Zero();
   if (Field2Off > Field2OffNoPadNoPack)
 Padding = Field2Off - Field2OffNoPadNoPack;
-  else if (Field2Off != Field2Align && Field2Off > Field1Size)
-Padding = Field2Off - Field1Size;
+  else if (Field2Off != Field2Align && Field2Off > Field1End)
+Padding = Field2Off - Field1End;
 
   bool IsPacked = !Field2Off.isMultipleOf(Field2Align);
 

diff  --git a/clang/test/CodeGen/riscv32-ilp32d-abi.cpp 
b/clang/test/CodeGen/riscv32-ilp32d-abi.cpp
index ffebb057e230..1018c78e168b 100644
--- a/clang/test/CodeGen/riscv32-ilp32d-abi.cpp
+++ b/clang/test/CodeGen/riscv32-ilp32d-abi.cpp
@@ -4,8 +4,7 @@
 struct empty_float2 { struct {}; float f; float g; };
 
 // CHECK: define float @_Z14f_empty_float212empty_float2(float %0, float %1)
-// FIXME: Extraneous padding before the second float
-// CHECK: { [4 x i8], float, [4 x i8], float }
+// CHECK: { [4 x i8], float, float }
 float f_empty_float2(empty_float2 a) {
 return a.g;
 }
@@ -13,8 +12,7 @@ float f_empty_float2(empty_float2 a) {
 struct empty_double2 { struct {}; double f; double g; };
 
 // CHECK: define double @_Z15f_empty_double213empty_double2(double %0, double 
%1)
-// FIXME: Extraneous padding before the second double
-// CHECK: { [8 x i8], double, [8 x i8], double }
+// CHECK: { [8 x i8], double, double }
 double f_empty_double2(empty_double2 a) {
 return a.g;
 }
@@ -30,8 +28,7 @@ double f_empty_float_double(empty_float_double a) {
 struct empty_double_float { struct {}; double f; float g; };
 
 // CHECK: define double @_Z20f_empty_double_float18empty_double_float(double 
%0, float %1)
-// FIXME: Extraneous padding before the float
-// CHECK: { [8 x i8], double, [8 x i8], float }
+// CHECK: { [8 x i8], double, float }
 double f_empty_double_float(empty_double_float a) {
 return a.g;
 }



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


[llvm-branch-commits] [clang] b430f94 - [Clang][CodeGen][RISCV] Fix hard float ABI for struct with empty struct and complex

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

Author: LuĂ­s Marques
Date: 2020-12-09T11:02:27-05:00
New Revision: b430f94d005276c8588b86dde7759be37a7a3420

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

LOG: [Clang][CodeGen][RISCV] Fix hard float ABI for struct with empty struct 
and complex

Fixes bug 44904.

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

(cherry picked from commit 3af354e863f553ef727967dfc091a64a11500aa5)

Added: 


Modified: 
clang/lib/CodeGen/TargetInfo.cpp
clang/test/CodeGen/riscv32-ilp32d-abi.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/TargetInfo.cpp 
b/clang/lib/CodeGen/TargetInfo.cpp
index c5db0985c1bf..a061651d8b21 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -10395,7 +10395,6 @@ bool 
RISCVABIInfo::detectFPCCEligibleStructHelper(QualType Ty, CharUnits CurOff,
   return false;
 Field1Ty = CGT.ConvertType(EltTy);
 Field1Off = CurOff;
-assert(CurOff.isZero() && "Unexpected offset for first field");
 Field2Ty = Field1Ty;
 Field2Off = Field1Off + getContext().getTypeSizeInChars(EltTy);
 return true;

diff  --git a/clang/test/CodeGen/riscv32-ilp32d-abi.cpp 
b/clang/test/CodeGen/riscv32-ilp32d-abi.cpp
index 1018c78e168b..26d968be97df 100644
--- a/clang/test/CodeGen/riscv32-ilp32d-abi.cpp
+++ b/clang/test/CodeGen/riscv32-ilp32d-abi.cpp
@@ -32,3 +32,19 @@ struct empty_double_float { struct {}; double f; float g; };
 double f_empty_double_float(empty_double_float a) {
 return a.g;
 }
+
+struct empty_complex_f { struct {}; float _Complex fc; };
+
+// CHECK: define float @_Z17f_empty_complex_f15empty_complex_f(float %0, float 
%1)
+// CHECK: { [4 x i8], float, float }
+float f_empty_complex_f(empty_complex_f a) {
+return __imag__ a.fc;
+}
+
+struct empty_complex_d { struct {}; double _Complex fc; };
+
+// CHECK: define double @_Z17f_empty_complex_d15empty_complex_d(double %0, 
double %1)
+// CHECK: { [8 x i8], double, double }
+double f_empty_complex_d(empty_complex_d a) {
+return __imag__ a.fc;
+}



___
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] 0feb4bc - Fix missed SI_RETURN_TO_EPILOG in pre-emit peephole

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

Author: Carl Ritson
Date: 2020-12-09T11:11:31-05:00
New Revision: 0feb4bc5295b373876823972d4b33e62b305cd0a

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

LOG: Fix missed SI_RETURN_TO_EPILOG in pre-emit peephole

SIPreEmitPeephole does not process all terminators, which means
it can fail to handle SI_RETURN_TO_EPILOG if immediately preceeded
by a branch to the early exit block.

Reviewed By: rampitec

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

(cherry picked from commit d538c5837a2cfedbf274133e29612da76003beed)

Added: 


Modified: 
llvm/lib/Target/AMDGPU/SIPreEmitPeephole.cpp
llvm/test/CodeGen/AMDGPU/transform-block-with-return-to-epilog.ll

Removed: 




diff  --git a/llvm/lib/Target/AMDGPU/SIPreEmitPeephole.cpp 
b/llvm/lib/Target/AMDGPU/SIPreEmitPeephole.cpp
index f31c722db1b2..442be886a8ac 100644
--- a/llvm/lib/Target/AMDGPU/SIPreEmitPeephole.cpp
+++ b/llvm/lib/Target/AMDGPU/SIPreEmitPeephole.cpp
@@ -254,16 +254,24 @@ bool 
SIPreEmitPeephole::runOnMachineFunction(MachineFunction &MF) {
 
   for (MachineBasicBlock &MBB : MF) {
 MachineBasicBlock::iterator MBBE = MBB.getFirstTerminator();
-if (MBBE != MBB.end()) {
-  MachineInstr &MI = *MBBE;
+MachineBasicBlock::iterator TermI = MBBE;
+// Check first terminator for VCC branches to optimize
+if (TermI != MBB.end()) {
+  MachineInstr &MI = *TermI;
   switch (MI.getOpcode()) {
   case AMDGPU::S_CBRANCH_VCCZ:
   case AMDGPU::S_CBRANCH_VCCNZ:
 Changed |= optimizeVccBranch(MI);
 continue;
-  case AMDGPU::SI_RETURN_TO_EPILOG:
-// FIXME: This is not an optimization and should be
-// moved somewhere else.
+  default:
+break;
+  }
+}
+// Check all terminators for SI_RETURN_TO_EPILOG
+// FIXME: This is not an optimization and should be moved somewhere else.
+while (TermI != MBB.end()) {
+  MachineInstr &MI = *TermI;
+  if (MI.getOpcode() == AMDGPU::SI_RETURN_TO_EPILOG) {
 assert(!MF.getInfo()->returnsVoid());
 
 // Graphics shaders returning non-void shouldn't contain S_ENDPGM,
@@ -281,11 +289,11 @@ bool 
SIPreEmitPeephole::runOnMachineFunction(MachineFunction &MF) {
   .addMBB(EmptyMBBAtEnd);
   MI.eraseFromParent();
   MBBE = MBB.getFirstTerminator();
+  TermI = MBBE;
+  continue;
 }
-break;
-  default:
-break;
   }
+  TermI++;
 }
 
 if (!ST.hasVGPRIndexMode())

diff  --git a/llvm/test/CodeGen/AMDGPU/transform-block-with-return-to-epilog.ll 
b/llvm/test/CodeGen/AMDGPU/transform-block-with-return-to-epilog.ll
index c34a62bfc31d..416a72d51f99 100644
--- a/llvm/test/CodeGen/AMDGPU/transform-block-with-return-to-epilog.ll
+++ b/llvm/test/CodeGen/AMDGPU/transform-block-with-return-to-epilog.ll
@@ -78,4 +78,73 @@ else: ; preds = 
%else.if.cond
   unreachable
 }
 
+define amdgpu_ps { <4 x float> } 
@test_return_to_epilog_with_optimized_kill(float %val) #0 {
+  ; GCN-LABEL: name: test_return_to_epilog_with_optimized_kill
+  ; GCN: bb.0.entry:
+  ; GCN:   successors: %bb.1(0x4000), %bb.4(0x4000)
+  ; GCN:   liveins: $vgpr0
+  ; GCN:   renamable $vgpr1 = nofpexcept V_RCP_F32_e32 $vgpr0, implicit $mode, 
implicit $exec
+  ; GCN:   nofpexcept V_CMP_NGT_F32_e32 0, killed $vgpr1, implicit-def $vcc, 
implicit $mode, implicit $exec
+  ; GCN:   $sgpr0_sgpr1 = S_AND_SAVEEXEC_B64 killed $vcc, implicit-def $exec, 
implicit-def $scc, implicit $exec
+  ; GCN:   renamable $sgpr0_sgpr1 = S_XOR_B64 $exec, killed renamable 
$sgpr0_sgpr1, implicit-def dead $scc
+  ; GCN:   S_CBRANCH_EXECZ %bb.4, implicit $exec
+  ; GCN: bb.1.flow.preheader:
+  ; GCN:   successors: %bb.2(0x8000)
+  ; GCN:   liveins: $vgpr0, $sgpr0_sgpr1
+  ; GCN:   nofpexcept V_CMP_NGT_F32_e32 0, killed $vgpr0, implicit-def $vcc, 
implicit $mode, implicit $exec
+  ; GCN:   renamable $sgpr2_sgpr3 = S_MOV_B64 0
+  ; GCN: bb.2.flow:
+  ; GCN:   successors: %bb.3(0x0400), %bb.2(0x7c00)
+  ; GCN:   liveins: $vcc, $sgpr0_sgpr1, $sgpr2_sgpr3
+  ; GCN:   renamable $sgpr4_sgpr5 = S_AND_B64 $exec, renamable $vcc, 
implicit-def $scc
+  ; GCN:   renamable $sgpr2_sgpr3 = S_OR_B64 killed renamable $sgpr4_sgpr5, 
killed renamable $sgpr2_sgpr3, implicit-def $scc
+  ; GCN:   $exec = S_ANDN2_B64 $exec, renamable $sgpr2_sgpr3, implicit-def $scc
+  ; GCN:   S_CBRANCH_EXECNZ %bb.2, implicit $exec
+  ; GCN: bb.3.Flow:
+  ; GCN:   successors: %bb.4(0x8000)
+  ; GCN:   liveins: $sgpr0_sgpr1, $sgpr2_sgpr3
+  ; GCN:   $exec = S_OR_B64 $exec, killed renamable $sgpr2_sgpr3, implicit-def 
$scc
+  ; GCN: bb.4.Flow1:
+  ; GCN:   successors: %bb.5(0x4000), %bb.6(0x4000)
+  ; GCN:   liveins: $sgpr0_sgpr1
+  ; GCN:   re

[llvm-branch-commits] [llvm] 1a2147f - [VE] Add vsum and vfsum intrinsic instructions

2020-12-09 Thread Kazushi Marukawa via llvm-branch-commits

Author: Kazushi (Jam) Marukawa
Date: 2020-12-10T01:11:53+09:00
New Revision: 1a2147feadb80f3b0d4c4cb6892498b0bae549fe

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

LOG: [VE] Add vsum and vfsum intrinsic instructions

Add vsum and vfsum intrinsic instructions and regression tests.

Reviewed By: simoll

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

Added: 
llvm/test/CodeGen/VE/VELIntrinsics/vfsum.ll
llvm/test/CodeGen/VE/VELIntrinsics/vsum.ll

Modified: 
llvm/include/llvm/IR/IntrinsicsVEVL.gen.td
llvm/lib/Target/VE/VEInstrIntrinsicVL.gen.td

Removed: 




diff  --git a/llvm/include/llvm/IR/IntrinsicsVEVL.gen.td 
b/llvm/include/llvm/IR/IntrinsicsVEVL.gen.td
index 5e86a1b9a372..d2d965085526 100644
--- a/llvm/include/llvm/IR/IntrinsicsVEVL.gen.td
+++ b/llvm/include/llvm/IR/IntrinsicsVEVL.gen.td
@@ -1084,3 +1084,13 @@ let TargetPrefix = "ve" in def int_ve_vl_pvfmksgenan_Mvl 
: GCCBuiltin<"__builtin
 let TargetPrefix = "ve" in def int_ve_vl_pvfmksgenan_MvMl : 
GCCBuiltin<"__builtin_ve_vl_pvfmksgenan_MvMl">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType, LLVMType], [IntrNoMem]>;
 let TargetPrefix = "ve" in def int_ve_vl_pvfmkslenan_Mvl : 
GCCBuiltin<"__builtin_ve_vl_pvfmkslenan_Mvl">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType], [IntrNoMem]>;
 let TargetPrefix = "ve" in def int_ve_vl_pvfmkslenan_MvMl : 
GCCBuiltin<"__builtin_ve_vl_pvfmkslenan_MvMl">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType, LLVMType], [IntrNoMem]>;
+let TargetPrefix = "ve" in def int_ve_vl_vsumwsx_vvl : 
GCCBuiltin<"__builtin_ve_vl_vsumwsx_vvl">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType], [IntrNoMem]>;
+let TargetPrefix = "ve" in def int_ve_vl_vsumwsx_vvml : 
GCCBuiltin<"__builtin_ve_vl_vsumwsx_vvml">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType, LLVMType], [IntrNoMem]>;
+let TargetPrefix = "ve" in def int_ve_vl_vsumwzx_vvl : 
GCCBuiltin<"__builtin_ve_vl_vsumwzx_vvl">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType], [IntrNoMem]>;
+let TargetPrefix = "ve" in def int_ve_vl_vsumwzx_vvml : 
GCCBuiltin<"__builtin_ve_vl_vsumwzx_vvml">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType, LLVMType], [IntrNoMem]>;
+let TargetPrefix = "ve" in def int_ve_vl_vsuml_vvl : 
GCCBuiltin<"__builtin_ve_vl_vsuml_vvl">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType], [IntrNoMem]>;
+let TargetPrefix = "ve" in def int_ve_vl_vsuml_vvml : 
GCCBuiltin<"__builtin_ve_vl_vsuml_vvml">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType, LLVMType], [IntrNoMem]>;
+let TargetPrefix = "ve" in def int_ve_vl_vfsumd_vvl : 
GCCBuiltin<"__builtin_ve_vl_vfsumd_vvl">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType], [IntrNoMem]>;
+let TargetPrefix = "ve" in def int_ve_vl_vfsumd_vvml : 
GCCBuiltin<"__builtin_ve_vl_vfsumd_vvml">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType, LLVMType], [IntrNoMem]>;
+let TargetPrefix = "ve" in def int_ve_vl_vfsums_vvl : 
GCCBuiltin<"__builtin_ve_vl_vfsums_vvl">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType], [IntrNoMem]>;
+let TargetPrefix = "ve" in def int_ve_vl_vfsums_vvml : 
GCCBuiltin<"__builtin_ve_vl_vfsums_vvml">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType, LLVMType], [IntrNoMem]>;

diff  --git a/llvm/lib/Target/VE/VEInstrIntrinsicVL.gen.td 
b/llvm/lib/Target/VE/VEInstrIntrinsicVL.gen.td
index 8c1518edcfed..623eadce3d0a 100644
--- a/llvm/lib/Target/VE/VEInstrIntrinsicVL.gen.td
+++ b/llvm/lib/Target/VE/VEInstrIntrinsicVL.gen.td
@@ -1307,3 +1307,13 @@ def : Pat<(int_ve_vl_pvfmksgenan_Mvl v256f64:$vz, 
i32:$vl), (VFMKSyvl CC_GENAN,
 def : Pat<(int_ve_vl_pvfmksgenan_MvMl v256f64:$vz, v512i1:$vm, i32:$vl), 
(VFMKSyvyl CC_GENAN, v256f64:$vz, v512i1:$vm, i32:$vl)>;
 def : Pat<(int_ve_vl_pvfmkslenan_Mvl v256f64:$vz, i32:$vl), (VFMKSyvl 
CC_LENAN, v256f64:$vz, i32:$vl)>;
 def : Pat<(int_ve_vl_pvfmkslenan_MvMl v256f64:$vz, v512i1:$vm, i32:$vl), 
(VFMKSyvyl CC_LENAN, v256f64:$vz, v512i1:$vm, i32:$vl)>;
+def : Pat<(int_ve_vl_vsumwsx_vvl v256f64:$vy, i32:$vl), (VSUMWSXvl 
v256f64:$vy, i32:$vl)>;
+def : Pat<(int_ve_vl_vsumwsx_vvml v256f64:$vy, v256i1:$vm, i32:$vl), 
(VSUMWSXvml v256f64:$vy, v256i1:$vm, i32:$vl)>;
+def : Pat<(int_ve_vl_vsumwzx_vvl v256f64:$vy, i32:$vl), (VSUMWZXvl 
v256f64:$vy, i32:$vl)>;
+def : Pat<(int_ve_vl_vsumwzx_vvml v256f64:$vy, v256i1:$vm, i32:$vl), 
(VSUMWZXvml v256f64:$vy, v256i1:$vm, i32:$vl)>;
+def : Pat<(int_ve_vl_vsuml_vvl v256f64:$vy, i32:$vl), (VSUMLvl v256f64:$vy, 
i32:$vl)>;
+def : Pat<(int_ve_vl_vsuml_vvml v256f64:$vy, v256i1:$vm, i32:$vl), (VSUMLvml 
v256f64:$vy, v256i1:$vm, i32:$vl)>;
+def : Pat<(int_ve_vl_vfsumd_vvl v256f64:$vy, i32:$vl), (VFSUMDvl v256f64:$vy, 
i32:$vl)>;
+def : Pat<(int_ve_vl_vfsumd_vvml v256f64:$vy, v256i1:$vm, i32:$vl), (VFSUMDvml 
v256f64:$vy, v256i1:$vm, i32:$vl)>;
+def : Pat<(int_ve_vl_vfsums_vvl v256f64:$vy, i32:$vl), (VFSUMSvl v256f64:$vy, 
i32:$vl)>;
+def : Pat<(int_ve_vl_vfsums_

[llvm-branch-commits] [llvm] da1392e - [gn build] Port ac7864ec019

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

Author: LLVM GN Syncbot
Date: 2020-12-09T16:19:07Z
New Revision: da1392e1b963df88cdd10e5847088046efbbd706

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

LOG: [gn build] Port ac7864ec019

Added: 


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

Removed: 




diff  --git 
a/llvm/utils/gn/secondary/clang-tools-extra/clangd/unittests/BUILD.gn 
b/llvm/utils/gn/secondary/clang-tools-extra/clangd/unittests/BUILD.gn
index 69005b3902a6..30a22b454e3e 100644
--- a/llvm/utils/gn/secondary/clang-tools-extra/clangd/unittests/BUILD.gn
+++ b/llvm/utils/gn/secondary/clang-tools-extra/clangd/unittests/BUILD.gn
@@ -100,7 +100,6 @@ unittest("ClangdTests") {
 "TestIndex.cpp",
 "TestTU.cpp",
 "TestWorkspace.cpp",
-"TweakTesting.cpp",
 "TweakTests.cpp",
 "TypeHierarchyTests.cpp",
 "URITests.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] d75791e - [gn build] Port 5934a79196b

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

Author: LLVM GN Syncbot
Date: 2020-12-09T16:19:06Z
New Revision: d75791ec1eceb2849df6fbda8f664bbed5420271

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

LOG: [gn build] Port 5934a79196b

Added: 


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

Removed: 




diff  --git 
a/llvm/utils/gn/secondary/clang-tools-extra/clangd/unittests/BUILD.gn 
b/llvm/utils/gn/secondary/clang-tools-extra/clangd/unittests/BUILD.gn
index 1d5fdf8b3f42..69005b3902a6 100644
--- a/llvm/utils/gn/secondary/clang-tools-extra/clangd/unittests/BUILD.gn
+++ b/llvm/utils/gn/secondary/clang-tools-extra/clangd/unittests/BUILD.gn
@@ -113,5 +113,24 @@ unittest("ClangdTests") {
 "support/TestTracer.cpp",
 "support/ThreadingTests.cpp",
 "support/TraceTests.cpp",
+"tweaks/AddUsingTests.cpp",
+"tweaks/AnnotateHighlightingsTests.cpp",
+"tweaks/DefineInlineTests.cpp",
+"tweaks/DefineOutlineTests.cpp",
+"tweaks/DumpASTTests.cpp",
+"tweaks/DumpRecordLayoutTests.cpp",
+"tweaks/DumpSymbolTests.cpp",
+"tweaks/ExpandAutoTypeTests.cpp",
+"tweaks/ExpandMacroTests.cpp",
+"tweaks/ExtractFunctionTests.cpp",
+"tweaks/ExtractVariableTests.cpp",
+"tweaks/ObjCLocalizeStringLiteralTests.cpp",
+"tweaks/PopulateSwitchTests.cpp",
+"tweaks/RawStringLiteralTests.cpp",
+"tweaks/RemoveUsingNamespaceTests.cpp",
+"tweaks/ShowSelectionTreeTests.cpp",
+"tweaks/SwapIfBranchesTests.cpp",
+"tweaks/TweakTesting.cpp",
+"tweaks/TweakTests.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] cff1f4c - [gn build] Port b804eef0905

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

Author: LLVM GN Syncbot
Date: 2020-12-09T16:19:07Z
New Revision: cff1f4cbbcfe09584e208f05187ba16876e81cc1

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

LOG: [gn build] Port b804eef0905

Added: 


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

Removed: 




diff  --git 
a/llvm/utils/gn/secondary/clang-tools-extra/clangd/unittests/BUILD.gn 
b/llvm/utils/gn/secondary/clang-tools-extra/clangd/unittests/BUILD.gn
index 30a22b454e3e..3936f2b9dec6 100644
--- a/llvm/utils/gn/secondary/clang-tools-extra/clangd/unittests/BUILD.gn
+++ b/llvm/utils/gn/secondary/clang-tools-extra/clangd/unittests/BUILD.gn
@@ -100,7 +100,6 @@ unittest("ClangdTests") {
 "TestIndex.cpp",
 "TestTU.cpp",
 "TestWorkspace.cpp",
-"TweakTests.cpp",
 "TypeHierarchyTests.cpp",
 "URITests.cpp",
 "XRefsTests.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] a21e609 - [X86] Add broadcast merge test case for PR48215

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

Author: Simon Pilgrim
Date: 2020-12-09T11:29:51-05:00
New Revision: a21e609d6a255f893fa7cbd863a3bc5c017c478e

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

LOG: [X86] Add broadcast merge test case for PR48215

(cherry picked from commit 8270f8c252d7013761c54e5bf528ac3e4e3b517c)
Signed-off-by: Warren Ristow 

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

Modified: 


Removed: 




diff  --git a/llvm/test/CodeGen/X86/pr48215.ll 
b/llvm/test/CodeGen/X86/pr48215.ll
new file mode 100644
index 0..c825955a2970f
--- /dev/null
+++ b/llvm/test/CodeGen/X86/pr48215.ll
@@ -0,0 +1,75 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=x86_64-apple-darwin -mattr=+avx  | FileCheck %s 
--check-prefixes=AVX1
+; RUN: llc < %s -mtriple=x86_64-apple-darwin -mattr=+avx2 | FileCheck %s 
--check-prefixes=AVX2
+; RUN: llc < %s -mtriple=x86_64-apple-darwin -mattr=+avx512vl | FileCheck %s 
--check-prefixes=AVX512
+
+; FIXME: Ensure when we merge broadcasts to 
diff erent widths that they come from the same SDValue.
+define i32 @PR48215(i32 %a0, i32 %a1)  {
+; AVX1-LABEL: PR48215:
+; AVX1:   ## %bb.0:
+; AVX1-NEXT:movl %edi, %eax
+; AVX1-NEXT:cltd
+; AVX1-NEXT:idivl %esi
+; AVX1-NEXT:vmovd %edx, %xmm0
+; AVX1-NEXT:vpshufd {{.*#+}} xmm0 = xmm0[0,0,0,0]
+; AVX1-NEXT:vmovdqa {{.*#+}} xmm1 = [4,5,6,7]
+; AVX1-NEXT:vmovd %eax, %xmm2
+; AVX1-NEXT:vpshufd {{.*#+}} xmm2 = xmm2[0,0,0,0]
+; AVX1-NEXT:vpcmpgtd %xmm2, %xmm1, %xmm3
+; AVX1-NEXT:vmovdqa {{.*#+}} xmm4 = [0,1,2,3]
+; AVX1-NEXT:vpcmpgtd %xmm2, %xmm4, %xmm2
+; AVX1-NEXT:vinsertf128 $1, %xmm3, %ymm2, %ymm2
+; AVX1-NEXT:vmovmskps %ymm2, %ecx
+; AVX1-NEXT:vpcmpgtd %xmm0, %xmm1, %xmm0
+; AVX1-NEXT:vmovmskps %xmm0, %eax
+; AVX1-NEXT:addl %ecx, %eax
+; AVX1-NEXT:vzeroupper
+; AVX1-NEXT:retq
+;
+; AVX2-LABEL: PR48215:
+; AVX2:   ## %bb.0:
+; AVX2-NEXT:movl %edi, %eax
+; AVX2-NEXT:cltd
+; AVX2-NEXT:idivl %esi
+; AVX2-NEXT:vmovd %eax, %xmm0
+; AVX2-NEXT:vpbroadcastd %xmm0, %ymm0
+; AVX2-NEXT:vmovdqa {{.*#+}} ymm1 = [0,1,2,3,4,5,6,7]
+; AVX2-NEXT:vmovdqa {{.*#+}} xmm2 = [4,5,6,7]
+; AVX2-NEXT:vpcmpgtd %ymm0, %ymm1, %ymm1
+; AVX2-NEXT:vmovmskps %ymm1, %ecx
+; AVX2-NEXT:vpcmpgtd %xmm0, %xmm2, %xmm0
+; AVX2-NEXT:vmovmskps %xmm0, %eax
+; AVX2-NEXT:addl %ecx, %eax
+; AVX2-NEXT:vzeroupper
+; AVX2-NEXT:retq
+;
+; AVX512-LABEL: PR48215:
+; AVX512:   ## %bb.0:
+; AVX512-NEXT:movl %edi, %eax
+; AVX512-NEXT:cltd
+; AVX512-NEXT:idivl %esi
+; AVX512-NEXT:vpbroadcastd %eax, %ymm0
+; AVX512-NEXT:vpcmpltd {{.*}}(%rip), %ymm0, %k0
+; AVX512-NEXT:vpcmpltd {{.*}}(%rip), %xmm0, %k1
+; AVX512-NEXT:kmovw %k0, %eax
+; AVX512-NEXT:movzbl %al, %ecx
+; AVX512-NEXT:kmovw %k1, %eax
+; AVX512-NEXT:andl $15, %eax
+; AVX512-NEXT:addl %ecx, %eax
+; AVX512-NEXT:vzeroupper
+; AVX512-NEXT:retq
+  %d = sdiv i32 %a0, %a1
+  %r = srem i32 %a0, %a1
+  %dv0 = insertelement <8 x i32> undef, i32 %d, i32 0
+  %rv0 = insertelement <4 x i32> undef, i32 %r, i32 0
+  %dv1 = shufflevector <8 x i32> %dv0, <8 x i32> undef, <8 x i32> 
zeroinitializer
+  %rv1 = shufflevector <4 x i32> %rv0, <4 x i32> undef, <4 x i32> 
zeroinitializer
+  %dc0 = icmp slt <8 x i32> %dv1, 
+  %rc0 = icmp slt <4 x i32> %rv1, 
+  %db0 = bitcast <8 x i1> %dc0 to i8
+  %rb0 = bitcast <4 x i1> %rc0 to i4
+  %db1 = zext i8 %db0 to i32
+  %rb1 = zext i4 %rb0 to i32
+  %res = add i32 %db1, %rb1
+  ret i32 %res
+}



___
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] 14d60e9 - [X86][AVX] Only share broadcasts of different widths from the same SDValue of the same SDNode (PR48215)

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

Author: Simon Pilgrim
Date: 2020-12-09T11:29:51-05:00
New Revision: 14d60e9a80d40f9efc4b76524a07320d38994d2b

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

LOG: [X86][AVX] Only share broadcasts of different widths from the same SDValue 
of the same SDNode (PR48215)

D57663 allowed us to reuse broadcasts of the same scalar value by extracting 
low subvectors from the widest type.

Unfortunately we weren't ensuring the broadcasts were from the same SDValue, 
just the same SDNode - which failed on multiple-value nodes like ISD::SDIVREM

FYI: I intend to request this be merged into the 11.x release branch.

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

(cherry picked from commit 14ae02fb3397961bb5f99a0df60622375fc1976d)
Signed-off-by: Warren Ristow 

Added: 


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

Removed: 




diff  --git a/llvm/lib/Target/X86/X86ISelLowering.cpp 
b/llvm/lib/Target/X86/X86ISelLowering.cpp
index afe470cc6e0b7..f5b704ebbe9de 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -36018,8 +36018,10 @@ static SDValue combineTargetShuffle(SDValue N, 
SelectionDAG &DAG,
   return DAG.getNode(X86ISD::VBROADCAST, DL, VT, Src.getOperand(0));
 
 // Share broadcast with the longest vector and extract low subvector 
(free).
+// Ensure the same SDValue from the SDNode use is being used.
 for (SDNode *User : Src->uses())
   if (User != N.getNode() && User->getOpcode() == X86ISD::VBROADCAST &&
+  Src == User->getOperand(0) &&
   User->getValueSizeInBits(0) > VT.getSizeInBits()) {
 return extractSubVector(SDValue(User, 0), 0, DAG, DL,
 VT.getSizeInBits());

diff  --git a/llvm/test/CodeGen/X86/pr48215.ll 
b/llvm/test/CodeGen/X86/pr48215.ll
index c825955a2970f..125bde728c3f8 100644
--- a/llvm/test/CodeGen/X86/pr48215.ll
+++ b/llvm/test/CodeGen/X86/pr48215.ll
@@ -33,12 +33,14 @@ define i32 @PR48215(i32 %a0, i32 %a1)  {
 ; AVX2-NEXT:idivl %esi
 ; AVX2-NEXT:vmovd %eax, %xmm0
 ; AVX2-NEXT:vpbroadcastd %xmm0, %ymm0
-; AVX2-NEXT:vmovdqa {{.*#+}} ymm1 = [0,1,2,3,4,5,6,7]
+; AVX2-NEXT:vmovd %edx, %xmm1
+; AVX2-NEXT:vpbroadcastd %xmm1, %xmm1
+; AVX2-NEXT:vmovdqa {{.*#+}} ymm2 = [0,1,2,3,4,5,6,7]
+; AVX2-NEXT:vpcmpgtd %ymm0, %ymm2, %ymm0
 ; AVX2-NEXT:vmovdqa {{.*#+}} xmm2 = [4,5,6,7]
-; AVX2-NEXT:vpcmpgtd %ymm0, %ymm1, %ymm1
-; AVX2-NEXT:vmovmskps %ymm1, %ecx
-; AVX2-NEXT:vpcmpgtd %xmm0, %xmm2, %xmm0
-; AVX2-NEXT:vmovmskps %xmm0, %eax
+; AVX2-NEXT:vpcmpgtd %xmm1, %xmm2, %xmm1
+; AVX2-NEXT:vmovmskps %ymm0, %ecx
+; AVX2-NEXT:vmovmskps %xmm1, %eax
 ; AVX2-NEXT:addl %ecx, %eax
 ; AVX2-NEXT:vzeroupper
 ; AVX2-NEXT:retq
@@ -49,8 +51,9 @@ define i32 @PR48215(i32 %a0, i32 %a1)  {
 ; AVX512-NEXT:cltd
 ; AVX512-NEXT:idivl %esi
 ; AVX512-NEXT:vpbroadcastd %eax, %ymm0
+; AVX512-NEXT:vpbroadcastd %edx, %xmm1
 ; AVX512-NEXT:vpcmpltd {{.*}}(%rip), %ymm0, %k0
-; AVX512-NEXT:vpcmpltd {{.*}}(%rip), %xmm0, %k1
+; AVX512-NEXT:vpcmpltd {{.*}}(%rip), %xmm1, %k1
 ; AVX512-NEXT:kmovw %k0, %eax
 ; AVX512-NEXT:movzbl %al, %ecx
 ; AVX512-NEXT:kmovw %k1, %eax



___
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] 717b0da - [libc++] Run back-deployment CI on macOS 10.15 instead of 10.14

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

Author: Louis Dionne
Date: 2020-12-09T11:35:15-05:00
New Revision: 717b0da7a6ef0a8a03d7296324f76132118fcf54

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

LOG: [libc++] Run back-deployment CI on macOS 10.15 instead of 10.14

The goal was to add coverage for back-deployment over the filesystem
library, but it was added in macOS 10.15, not 10.14.

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

Added: 


Modified: 
libcxx/utils/ci/buildkite-pipeline.yml

Removed: 




diff  --git a/libcxx/utils/ci/buildkite-pipeline.yml 
b/libcxx/utils/ci/buildkite-pipeline.yml
index 10ac44d56647..d10c464f9d55 100644
--- a/libcxx/utils/ci/buildkite-pipeline.yml
+++ b/libcxx/utils/ci/buildkite-pipeline.yml
@@ -276,8 +276,8 @@ steps:
 - exit_status: -1  # Agent was lost
   limit: 2
 
-  - label: "Apple back-deployment macosx10.14"
-command: "libcxx/utils/ci/run-buildbot 
x86_64-apple-system-backdeployment-10.14"
+  - label: "Apple back-deployment macosx10.15"
+command: "libcxx/utils/ci/run-buildbot 
x86_64-apple-system-backdeployment-10.15"
 artifact_paths:
   - "**/test-results.xml"
 agents:



___
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] 634a377 - [clangd] Extract per-dir CDB cache to its own threadsafe class. NFC

2020-12-09 Thread Sam McCall via llvm-branch-commits

Author: Sam McCall
Date: 2020-12-09T17:40:12+01:00
New Revision: 634a377bd8cbaa515a58295cfd85dcb6a21381c1

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

LOG: [clangd] Extract per-dir CDB cache to its own threadsafe class. NFC

This is a step towards making compile_commands.json reloadable.

The idea is:
 - in addition to rare CDB loads we're soon going to have somewhat-rare CDB
   reloads and fairly-common stat() of files to validate the CDB
 - so stop doing all our work under a big global lock, instead using it to
   acquire per-directory structures with their own locks
 - each directory can be refreshed from disk every N seconds, like filecache
 - avoid locking these at all in the most common case: directory has no CDB

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

Added: 


Modified: 
clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
clang-tools-extra/clangd/GlobalCompilationDatabase.h

Removed: 




diff  --git a/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp 
b/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
index 23e8c9fe716d0..f867920c9d1fc 100644
--- a/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
+++ b/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
@@ -16,11 +16,13 @@
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/ScopeExit.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/FileUtilities.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Program.h"
+#include 
 #include 
 #include 
 #include 
@@ -58,10 +60,117 @@ GlobalCompilationDatabase::getFallbackCommand(PathRef 
File) const {
   return Cmd;
 }
 
+// Loads and caches the CDB from a single directory.
+//
+// This class is threadsafe, which is to say we have independent locks for each
+// directory we're searching for a CDB.
+// Loading is deferred until first access.
+//
+// The DirectoryBasedCDB keeps a map from path => DirectoryCache.
+// Typical usage is to:
+//  - 1) determine all the paths that might be searched
+//  - 2) acquire the map lock and get-or-create all the DirectoryCache entries
+//  - 3) release the map lock and query the caches as desired
+//
+// FIXME: this should revalidate the cache sometimes
+// FIXME: IO should go through a VFS
+class DirectoryBasedGlobalCompilationDatabase::DirectoryCache {
+  // Absolute canonical path that we're the cache for. (Not case-folded).
+  const std::string Path;
+
+  // True if we've looked for a CDB here and found none.
+  // (This makes it possible for get() to return without taking a lock)
+  // FIXME: this should have an expiry time instead of lasting forever.
+  std::atomic FinalizedNoCDB = {false};
+
+  // Guards following cache state.
+  std::mutex Mu;
+  // Has cache been filled from disk? FIXME: this should be an expiry time.
+  bool CachePopulated = false;
+  // Whether a new CDB has been loaded but not broadcast yet.
+  bool NeedsBroadcast = false;
+  // Last loaded CDB, meaningful if CachePopulated is set.
+  // shared_ptr so we can overwrite this when callers are still using the CDB.
+  std::shared_ptr CDB;
+
+public:
+  DirectoryCache(llvm::StringRef Path) : Path(Path) {
+assert(llvm::sys::path::is_absolute(Path));
+  }
+
+  // Get the CDB associated with this directory.
+  // ShouldBroadcast:
+  //  - as input, signals whether the caller is willing to broadcast a
+  //newly-discovered CDB. (e.g. to trigger background indexing)
+  //  - as output, signals whether the caller should do so.
+  // (If a new CDB is discovered and ShouldBroadcast is false, we mark the
+  // CDB as needing broadcast, and broadcast it next time we can).
+  std::shared_ptr
+  get(bool &ShouldBroadcast) {
+// Fast path for common case without taking lock.
+if (FinalizedNoCDB.load()) {
+  ShouldBroadcast = false;
+  return nullptr;
+}
+std::lock_guard Lock(Mu);
+auto RequestBroadcast = llvm::make_scope_exit([&, OldCDB(CDB.get())] {
+  // If we loaded a new CDB, it should be broadcast at some point.
+  if (CDB != nullptr && CDB.get() != OldCDB)
+NeedsBroadcast = true;
+  else if (CDB == nullptr) // nothing to broadcast anymore!
+NeedsBroadcast = false;
+  // If we have something to broadcast, then do so iff allowed.
+  if (!ShouldBroadcast)
+return;
+  ShouldBroadcast = NeedsBroadcast;
+  NeedsBroadcast = false;
+});
+
+// For now, we never actually attempt to revalidate a populated cache.
+if (CachePopulated)
+  return CDB;
+assert(CDB == nullptr);
+
+load();
+CachePopulated = true;
+
+if (!CDB)
+  FinalizedNoCDB.store(true);
+return CDB;
+  }
+
+  llvm::StringRef path() const {

[llvm-branch-commits] [llvm] f9a27df - [FileCheck] Enforce --allow-unused-prefixes=false for llvm/test/Transforms

2020-12-09 Thread Mircea Trofin via llvm-branch-commits

Author: Mircea Trofin
Date: 2020-12-09T08:51:38-08:00
New Revision: f9a27df16bc4c86eb9c81b0fed3d263876334572

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

LOG: [FileCheck] Enforce --allow-unused-prefixes=false for llvm/test/Transforms

Explicitly opt-out llvm/test/Transforms/Attributor.

Verified by flipping the default value of allow-unused-prefixes and
observing that none of the failures were under llvm/test/Transforms.

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

Added: 
llvm/test/Transforms/Attributor/lit.local.cfg
llvm/test/Transforms/lit.local.cfg

Modified: 
llvm/test/Transforms/ArgumentPromotion/crash.ll
llvm/test/Transforms/HardwareLoops/scalar-while.ll
llvm/test/Transforms/Inline/inline_stats.ll
llvm/test/Transforms/Inline/noalias2.ll
llvm/test/Transforms/LICM/pr23608.ll
llvm/test/Transforms/LoadStoreVectorizer/AMDGPU/merge-stores-private.ll
llvm/test/Transforms/LoopIdiom/X86/left-shift-until-bittest.ll
llvm/test/Transforms/LoopStrengthReduce/X86/lsr-insns-1.ll
llvm/test/Transforms/LowerTypeTests/export-inline.ll
llvm/test/Transforms/MemCpyOpt/memcpy-invoke-memcpy.ll
llvm/test/Transforms/PhaseOrdering/ARM/arm_fill_q7.ll
llvm/test/Transforms/PhaseOrdering/X86/loop-idiom-vs-indvars.ll
llvm/test/lit.cfg.py

Removed: 




diff  --git a/llvm/test/Transforms/ArgumentPromotion/crash.ll 
b/llvm/test/Transforms/ArgumentPromotion/crash.ll
index d79d906434bb..d55f4624e0c3 100644
--- a/llvm/test/Transforms/ArgumentPromotion/crash.ll
+++ b/llvm/test/Transforms/ArgumentPromotion/crash.ll
@@ -1,5 +1,5 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 
UTC_ARGS: --function-signature --scrub-attributes
-; RUN: opt -S < %s -inline -argpromotion | FileCheck %s 
--check-prefixes=ARGPROMOTION,ALL_OLDPM
+; RUN: opt -S < %s -inline -argpromotion | FileCheck %s 
--check-prefix=ARGPROMOTION
 ; RUN: opt -S < %s -passes=inline,argpromotion | FileCheck %s 
--check-prefixes=ARGPROMOTION,ALL_NEWPM
 
 %S = type { %S* }

diff  --git a/llvm/test/Transforms/Attributor/lit.local.cfg 
b/llvm/test/Transforms/Attributor/lit.local.cfg
new file mode 100644
index ..fad1a46e1d0f
--- /dev/null
+++ b/llvm/test/Transforms/Attributor/lit.local.cfg
@@ -0,0 +1,11 @@
+# -*- Python -*- vim: set ft=python ts=4 sw=4 expandtab tw=79:
+from lit.llvm.subst import ToolSubst
+
+fc = ToolSubst('FileCheck', unresolved='fatal')
+# the parent introduced the opposite rule, so we replace it if we see it.
+if len(config.substitutions) > 0 and config.substitutions[0] == (fc.regex, 
'FileCheck --allow-unused-prefixes=false'):
+config.substitutions[0] = (
+fc.regex, 'FileCheck --allow-unused-prefixes=true')
+else:
+config.substitutions.insert(0, (fc.regex, 
+'FileCheck --allow-unused-prefixes=true'))

diff  --git a/llvm/test/Transforms/HardwareLoops/scalar-while.ll 
b/llvm/test/Transforms/HardwareLoops/scalar-while.ll
index fb614ea275a0..0b99f74f0d98 100644
--- a/llvm/test/Transforms/HardwareLoops/scalar-while.ll
+++ b/llvm/test/Transforms/HardwareLoops/scalar-while.ll
@@ -1,9 +1,9 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
-; RUN: opt -hardware-loops -force-hardware-loops=true 
-hardware-loop-decrement=1 -hardware-loop-counter-bitwidth=32 -S %s -o - | 
FileCheck %s --check-prefixes=CHECK,CHECK-DEC
-; RUN: opt -hardware-loops -force-hardware-loops=true 
-hardware-loop-decrement=1 -hardware-loop-counter-bitwidth=32 
-force-hardware-loop-phi=true -S %s -o - | FileCheck %s 
--check-prefixes=CHECK,CHECK-PHI
-; RUN: opt -hardware-loops -force-hardware-loops=true 
-hardware-loop-decrement=1 -hardware-loop-counter-bitwidth=32 
-force-nested-hardware-loop=true -S %s -o - | FileCheck %s 
--check-prefixes=CHECK,CHECK-NESTED
-; RUN: opt -hardware-loops -force-hardware-loops=true 
-hardware-loop-decrement=1 -hardware-loop-counter-bitwidth=32 
-force-hardware-loop-guard=true -S %s -o - | FileCheck %s 
--check-prefixes=CHECK,CHECK-GUARD
-; RUN: opt -hardware-loops -force-hardware-loops=true 
-hardware-loop-decrement=1 -hardware-loop-counter-bitwidth=32 
-force-hardware-loop-phi=true -force-hardware-loop-guard=true -S %s -o - | 
FileCheck %s --check-prefixes=CHECK,CHECK-PHIGUARD
+; RUN: opt -hardware-loops -force-hardware-loops=true 
-hardware-loop-decrement=1 -hardware-loop-counter-bitwidth=32 -S %s -o - | 
FileCheck %s --check-prefix=CHECK-DEC
+; RUN: opt -hardware-loops -force-hardware-loops=true 
-hardware-loop-decrement=1 -hardware-loop-counter-bitwidth=32 
-force-hardware-loop-phi=true -S %s -o - | FileCheck %s --check-prefix=CHECK-PHI
+; RUN: opt -hardware-loops -force-hardware-loops=true 
-hardware-loop-decrement=1 -hardware-loop-counter-bitwidth=32

[llvm-branch-commits] [lld] fed7565 - [COFF][LTO][NPM] Use NPM for LTO with ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER

2020-12-09 Thread Arthur Eubanks via llvm-branch-commits

Author: Arthur Eubanks
Date: 2020-12-09T08:53:50-08:00
New Revision: fed7565ee2172fbb77c22b2362c76ffc1fdf39d7

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

LOG: [COFF][LTO][NPM] Use NPM for LTO with ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER

Reviewed By: hans

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

Added: 


Modified: 
lld/COFF/Driver.cpp

Removed: 




diff  --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp
index 35b253ded3ec..504c00584d9c 100644
--- a/lld/COFF/Driver.cpp
+++ b/lld/COFF/Driver.cpp
@@ -26,6 +26,7 @@
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/BinaryFormat/Magic.h"
+#include "llvm/Config/llvm-config.h"
 #include "llvm/LTO/LTO.h"
 #include "llvm/Object/ArchiveWriter.h"
 #include "llvm/Object/COFFImportFile.h"
@@ -1518,7 +1519,7 @@ void LinkerDriver::link(ArrayRef argsArr) {
   unsigned icfLevel =
   args.hasArg(OPT_profile) ? 0 : 1; // 0: off, 1: limited, 2: on
   unsigned tailMerge = 1;
-  bool ltoNewPM = false;
+  bool ltoNewPM = LLVM_ENABLE_NEW_PASS_MANAGER;
   bool ltoDebugPM = false;
   for (auto *arg : args.filtered(OPT_opt)) {
 std::string str = StringRef(arg->getValue()).lower();



___
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] 5861234 - [lldb] Track the API boundary using a thread_local variable.

2020-12-09 Thread Jonas Devlieghere via llvm-branch-commits

Author: Jonas Devlieghere
Date: 2020-12-09T08:58:40-08:00
New Revision: 5861234e72c035ad39b5fd843eef78ab4039351e

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

LOG: [lldb] Track the API boundary using a thread_local variable.

The reproducers currently use a static variable to track the API
boundary. This is obviously incorrect when the SB API is used
concurrently. While I do not plan to support that use-case (right now),
I do want to avoid us crashing. As a first step, correctly track API
boundaries across multiple threads.

Before this patch SB API calls made by the embedded script interpreter
would be considered "behind the API boundary" and correctly ignored.
After this patch, we need to tell the reproducers to ignore the
scripting thread as a "private thread".

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

Added: 


Modified: 
lldb/include/lldb/Utility/ReproducerInstrumentation.h
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
lldb/source/Utility/ReproducerInstrumentation.cpp

Removed: 




diff  --git a/lldb/include/lldb/Utility/ReproducerInstrumentation.h 
b/lldb/include/lldb/Utility/ReproducerInstrumentation.h
index 8e319d749231..e4c31522c4fc 100644
--- a/lldb/include/lldb/Utility/ReproducerInstrumentation.h
+++ b/lldb/include/lldb/Utility/ReproducerInstrumentation.h
@@ -841,6 +841,10 @@ class Recorder {
 
   bool ShouldCapture() { return m_local_boundary; }
 
+  /// Mark the current thread as a private thread and pretend that everything
+  /// on this thread is behind happening behind the API boundary.
+  static void PrivateThread() { g_global_boundary = true; }
+
 private:
   template  friend struct replay;
   void UpdateBoundary() {
@@ -868,7 +872,7 @@ class Recorder {
   bool m_result_recorded;
 
   /// Whether we're currently across the API boundary.
-  static bool g_global_boundary;
+  static thread_local bool g_global_boundary;
 };
 
 /// To be used as the "Runtime ID" of a constructor. It also invokes the

diff  --git 
a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp 
b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
index 0d13884e8089..5f950d42cac6 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -33,6 +33,7 @@
 #include "lldb/Interpreter/CommandReturnObject.h"
 #include "lldb/Target/Thread.h"
 #include "lldb/Target/ThreadPlan.h"
+#include "lldb/Utility/ReproducerInstrumentation.h"
 #include "lldb/Utility/Timer.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringRef.h"
@@ -437,6 +438,7 @@ ScriptInterpreterPythonImpl::Locker::Locker(
 : ScriptInterpreterLocker(),
   m_teardown_session((on_leave & TearDownSession) == TearDownSession),
   m_python_interpreter(py_interpreter) {
+  repro::Recorder::PrivateThread();
   DoAcquireLock();
   if ((on_entry & InitSession) == InitSession) {
 if (!DoInitSession(on_entry, in, out, err)) {

diff  --git a/lldb/source/Utility/ReproducerInstrumentation.cpp 
b/lldb/source/Utility/ReproducerInstrumentation.cpp
index 09aea69d8313..626120c9d71a 100644
--- a/lldb/source/Utility/ReproducerInstrumentation.cpp
+++ b/lldb/source/Utility/ReproducerInstrumentation.cpp
@@ -227,4 +227,4 @@ llvm::Optional 
&InstrumentationData::InstanceImpl() {
   return g_instrumentation_data;
 }
 
-bool lldb_private::repro::Recorder::g_global_boundary;
+thread_local bool lldb_private::repro::Recorder::g_global_boundary = false;



___
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] 59012b6 - [CUDA] Another attempt to fix early inclusion of from libstdc++

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

Author: Artem Belevich
Date: 2020-12-09T12:42:33-05:00
New Revision: 59012b685fd69d7350eb55166a8817688e413db8

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

LOG: [CUDA] Another attempt to fix early inclusion of  from libstdc++

Previous patch (9a465057a64dba) did not fix the problem.
https://bugs.llvm.org/show_bug.cgi?id=48228

If the  is included too early, before CUDA-specific defines are available,
just include-next the standard  and undo the include guard.  CUDA-specific
variants of operator new/delete will be declared if/when  is used from the
CUDA source itself, when all CUDA-related macros are available.

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

(cherry picked from commit 43267929423bf768bbbcc65e47a07e37af7f4e22)

Added: 


Modified: 
clang/lib/Headers/cuda_wrappers/new

Removed: 




diff  --git a/clang/lib/Headers/cuda_wrappers/new 
b/clang/lib/Headers/cuda_wrappers/new
index 47690f1152fe..7f255314056a 100644
--- a/clang/lib/Headers/cuda_wrappers/new
+++ b/clang/lib/Headers/cuda_wrappers/new
@@ -26,6 +26,13 @@
 
 #include_next 
 
+#if !defined(__device__)
+// The header has been included too early from the standard C++ library
+// and CUDA-specific macros are not available yet.
+// Undo the include guard and try again later.
+#undef __CLANG_CUDA_WRAPPERS_NEW
+#else
+
 #pragma push_macro("CUDA_NOEXCEPT")
 #if __cplusplus >= 201103L
 #define CUDA_NOEXCEPT noexcept
@@ -33,76 +40,67 @@
 #define CUDA_NOEXCEPT
 #endif
 
-#pragma push_macro("__DEVICE__")
-#if defined __device__
-#define __DEVICE__ __device__
-#else
-//  has been included too early from the standard libc++ headers and the
-// standard CUDA macros are not available yet. We have to define our own.
-#define __DEVICE__ __attribute__((device))
-#endif
-
 // Device overrides for non-placement new and delete.
-__DEVICE__ inline void *operator new(__SIZE_TYPE__ size) {
+__device__ inline void *operator new(__SIZE_TYPE__ size) {
   if (size == 0) {
 size = 1;
   }
   return ::malloc(size);
 }
-__DEVICE__ inline void *operator new(__SIZE_TYPE__ size,
+__device__ inline void *operator new(__SIZE_TYPE__ size,
  const std::nothrow_t &) CUDA_NOEXCEPT {
   return ::operator new(size);
 }
 
-__DEVICE__ inline void *operator new[](__SIZE_TYPE__ size) {
+__device__ inline void *operator new[](__SIZE_TYPE__ size) {
   return ::operator new(size);
 }
-__DEVICE__ inline void *operator new[](__SIZE_TYPE__ size,
+__device__ inline void *operator new[](__SIZE_TYPE__ size,
const std::nothrow_t &) {
   return ::operator new(size);
 }
 
-__DEVICE__ inline void operator delete(void* ptr) CUDA_NOEXCEPT {
+__device__ inline void operator delete(void* ptr) CUDA_NOEXCEPT {
   if (ptr) {
 ::free(ptr);
   }
 }
-__DEVICE__ inline void operator delete(void *ptr,
+__device__ inline void operator delete(void *ptr,
const std::nothrow_t &) CUDA_NOEXCEPT {
   ::operator delete(ptr);
 }
 
-__DEVICE__ inline void operator delete[](void* ptr) CUDA_NOEXCEPT {
+__device__ inline void operator delete[](void* ptr) CUDA_NOEXCEPT {
   ::operator delete(ptr);
 }
-__DEVICE__ inline void operator delete[](void *ptr,
+__device__ inline void operator delete[](void *ptr,
  const std::nothrow_t &) CUDA_NOEXCEPT 
{
   ::operator delete(ptr);
 }
 
 // Sized delete, C++14 only.
 #if __cplusplus >= 201402L
-__DEVICE__ inline void operator delete(void *ptr,
+__device__ inline void operator delete(void *ptr,
__SIZE_TYPE__ size) CUDA_NOEXCEPT {
   ::operator delete(ptr);
 }
-__DEVICE__ inline void operator delete[](void *ptr,
+__device__ inline void operator delete[](void *ptr,
  __SIZE_TYPE__ size) CUDA_NOEXCEPT {
   ::operator delete(ptr);
 }
 #endif
 
 // Device overrides for placement new and delete.
-__DEVICE__ inline void *operator new(__SIZE_TYPE__, void *__ptr) CUDA_NOEXCEPT 
{
+__device__ inline void *operator new(__SIZE_TYPE__, void *__ptr) CUDA_NOEXCEPT 
{
   return __ptr;
 }
-__DEVICE__ inline void *operator new[](__SIZE_TYPE__, void *__ptr) 
CUDA_NOEXCEPT {
+__device__ inline void *operator new[](__SIZE_TYPE__, void *__ptr) 
CUDA_NOEXCEPT {
   return __ptr;
 }
-__DEVICE__ inline void operator delete(void *, void *) CUDA_NOEXCEPT {}
-__DEVICE__ inline void operator delete[](void *, void *) CUDA_NOEXCEPT {}
+__device__ inline void operator delete(void *, void *) CUDA_NOEXCEPT {}
+__device__ inline void operator delete[](void *, void *) CUDA_NOEXCEPT {}
 
-#pragma pop_macro("__DEVICE__")
 #pragma pop_macro("CUDA_NOEXCEPT")
 
+#endif // __device__
 #endif // include guard




[llvm-branch-commits] [clang] aa29049 - [CUDA] Unbreak CUDA compilation with -std=c++20

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

Author: Artem Belevich
Date: 2020-12-09T12:42:33-05:00
New Revision: aa29049404efdc0134066839bc14d135d69ec225

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

LOG: [CUDA] Unbreak CUDA compilation with -std=c++20

Standard libc++ headers in stdc++ mode include  which picks up
cuda_wrappers/new before any of the CUDA macros have been defined.

We can not include CUDA headers that early, so the work-around is to define
__device__ in the wrapper header itself.

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

(cherry picked from commit 9a465057a64dba8a8614424d26136f5c0452bcc3)

Added: 


Modified: 
clang/lib/Headers/cuda_wrappers/new

Removed: 




diff  --git a/clang/lib/Headers/cuda_wrappers/new 
b/clang/lib/Headers/cuda_wrappers/new
index f49811c5a57c..47690f1152fe 100644
--- a/clang/lib/Headers/cuda_wrappers/new
+++ b/clang/lib/Headers/cuda_wrappers/new
@@ -33,66 +33,76 @@
 #define CUDA_NOEXCEPT
 #endif
 
+#pragma push_macro("__DEVICE__")
+#if defined __device__
+#define __DEVICE__ __device__
+#else
+//  has been included too early from the standard libc++ headers and the
+// standard CUDA macros are not available yet. We have to define our own.
+#define __DEVICE__ __attribute__((device))
+#endif
+
 // Device overrides for non-placement new and delete.
-__device__ inline void *operator new(__SIZE_TYPE__ size) {
+__DEVICE__ inline void *operator new(__SIZE_TYPE__ size) {
   if (size == 0) {
 size = 1;
   }
   return ::malloc(size);
 }
-__device__ inline void *operator new(__SIZE_TYPE__ size,
+__DEVICE__ inline void *operator new(__SIZE_TYPE__ size,
  const std::nothrow_t &) CUDA_NOEXCEPT {
   return ::operator new(size);
 }
 
-__device__ inline void *operator new[](__SIZE_TYPE__ size) {
+__DEVICE__ inline void *operator new[](__SIZE_TYPE__ size) {
   return ::operator new(size);
 }
-__device__ inline void *operator new[](__SIZE_TYPE__ size,
+__DEVICE__ inline void *operator new[](__SIZE_TYPE__ size,
const std::nothrow_t &) {
   return ::operator new(size);
 }
 
-__device__ inline void operator delete(void* ptr) CUDA_NOEXCEPT {
+__DEVICE__ inline void operator delete(void* ptr) CUDA_NOEXCEPT {
   if (ptr) {
 ::free(ptr);
   }
 }
-__device__ inline void operator delete(void *ptr,
+__DEVICE__ inline void operator delete(void *ptr,
const std::nothrow_t &) CUDA_NOEXCEPT {
   ::operator delete(ptr);
 }
 
-__device__ inline void operator delete[](void* ptr) CUDA_NOEXCEPT {
+__DEVICE__ inline void operator delete[](void* ptr) CUDA_NOEXCEPT {
   ::operator delete(ptr);
 }
-__device__ inline void operator delete[](void *ptr,
+__DEVICE__ inline void operator delete[](void *ptr,
  const std::nothrow_t &) CUDA_NOEXCEPT 
{
   ::operator delete(ptr);
 }
 
 // Sized delete, C++14 only.
 #if __cplusplus >= 201402L
-__device__ inline void operator delete(void *ptr,
+__DEVICE__ inline void operator delete(void *ptr,
__SIZE_TYPE__ size) CUDA_NOEXCEPT {
   ::operator delete(ptr);
 }
-__device__ inline void operator delete[](void *ptr,
+__DEVICE__ inline void operator delete[](void *ptr,
  __SIZE_TYPE__ size) CUDA_NOEXCEPT {
   ::operator delete(ptr);
 }
 #endif
 
 // Device overrides for placement new and delete.
-__device__ inline void *operator new(__SIZE_TYPE__, void *__ptr) CUDA_NOEXCEPT 
{
+__DEVICE__ inline void *operator new(__SIZE_TYPE__, void *__ptr) CUDA_NOEXCEPT 
{
   return __ptr;
 }
-__device__ inline void *operator new[](__SIZE_TYPE__, void *__ptr) 
CUDA_NOEXCEPT {
+__DEVICE__ inline void *operator new[](__SIZE_TYPE__, void *__ptr) 
CUDA_NOEXCEPT {
   return __ptr;
 }
-__device__ inline void operator delete(void *, void *) CUDA_NOEXCEPT {}
-__device__ inline void operator delete[](void *, void *) CUDA_NOEXCEPT {}
+__DEVICE__ inline void operator delete(void *, void *) CUDA_NOEXCEPT {}
+__DEVICE__ inline void operator delete[](void *, void *) CUDA_NOEXCEPT {}
 
+#pragma pop_macro("__DEVICE__")
 #pragma pop_macro("CUDA_NOEXCEPT")
 
 #endif // include guard



___
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] b4cbb87 - [CMake] Add llvm-profgen to LLVM_TEST_DEPENDS

2020-12-09 Thread Fangrui Song via llvm-branch-commits

Author: Fangrui Song
Date: 2020-12-09T09:34:51-08:00
New Revision: b4cbb87feab0ce5fe0658711cce0e71075206c6f

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

LOG: [CMake] Add llvm-profgen to LLVM_TEST_DEPENDS

Otherwise `check-llvm-*` may not rebuild llvm-profgen, causing llvm-profgen 
tests
to fail if llvm-profgen happens to be stale.

Added: 


Modified: 
llvm/test/CMakeLists.txt

Removed: 




diff  --git a/llvm/test/CMakeLists.txt b/llvm/test/CMakeLists.txt
index 4263937e3d8b..691a7e14b8ce 100644
--- a/llvm/test/CMakeLists.txt
+++ b/llvm/test/CMakeLists.txt
@@ -102,6 +102,7 @@ set(LLVM_TEST_DEPENDS
   llvm-opt-report
   llvm-pdbutil
   llvm-profdata
+  llvm-profgen
   llvm-ranlib
   llvm-rc
   llvm-readobj



___
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] 664b187 - Reland Pin -loop-reduce to legacy PM

2020-12-09 Thread Arthur Eubanks via llvm-branch-commits

Author: Arthur Eubanks
Date: 2020-12-09T09:57:57-08:00
New Revision: 664b187160dc951c2cea3b69f92decf358d8e75a

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

LOG: Reland Pin -loop-reduce to legacy PM

This was accidentally reverted by a later change.

LSR currently only runs in the codegen pass manager.
There are a couple issues with LSR and the NPM.
1) Lots of tests assume that LCSSA isn't run before LSR. This breaks a
bunch of tests' expected output. This is fixable with some time put in.
2) LSR doesn't preserve LCSSA. See
llvm/test/Analysis/MemorySSA/update-remove-deadblocks.ll. LSR's use of
SCEVExpander is the only use of SCEVExpander where the PreserveLCSSA option is
off. Turning it on causes some code sinking out of loops to fail due to
SCEVExpander's inability to handle the newly created trivial PHI nodes in the
broken critical edge (I was looking at
llvm/test/Transforms/LoopStrengthReduce/X86/2011-11-29-postincphi.ll).
I also tried simply just calling formLCSSA() at the end of LSR, but the extra
PHI nodes cause regressions in codegen tests.

We'll delay figuring these issues out until later.

This causes the number of check-llvm failures with -enable-new-pm true
by default to go from 60 to 29.

Reviewed By: asbirlea

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

Added: 


Modified: 
llvm/tools/opt/opt.cpp

Removed: 




diff  --git a/llvm/tools/opt/opt.cpp b/llvm/tools/opt/opt.cpp
index 276fab73650b..ad9dc2d0774a 100644
--- a/llvm/tools/opt/opt.cpp
+++ b/llvm/tools/opt/opt.cpp
@@ -485,7 +485,8 @@ static bool shouldPinPassToLegacyPM(StringRef Pass) {
   "expand-reductions",
   "indirectbr-expand",
   "generic-to-nvvm",
-  "expandmemcmp"};
+  "expandmemcmp",
+  "loop-reduce"};
   for (const auto &P : PassNamePrefix)
 if (Pass.startswith(P))
   return true;



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


[llvm-branch-commits] [llvm] be9b4bb - [MCJIT] Add cmake variables to customize ittapi git location and revision.

2020-12-09 Thread Alexey Bader via llvm-branch-commits

Author: Alexey Bader
Date: 2020-12-09T21:04:24+03:00
New Revision: be9b4bbdfc226c6387304552bbc0312ed60bd602

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

LOG: [MCJIT] Add cmake variables to customize ittapi git location and revision.

To support llorg builds this patch provides the following changes:

1)  Added cmake variable ITTAPI_GIT_REPOSITORY to control the location of 
ITTAPI repository.
 Default value of ITTAPI_GIT_REPOSITORY is github location: 
https://github.com/intel/ittapi.git
 Also, the separate cmake variable ITTAPI_GIT_TAG was added for repo tag.
2)  Added cmake variable ITTAPI_SOURCE_DIR to control the place where the repo 
will be cloned.
 Default value of ITTAPI_SOURCE_DIR is build area: PROJECT_BINARY_DIR

Reviewed By: etyurin, bader

Patch by ekovanov.

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

Added: 


Modified: 
llvm/lib/ExecutionEngine/IntelJITEvents/CMakeLists.txt

Removed: 




diff  --git a/llvm/lib/ExecutionEngine/IntelJITEvents/CMakeLists.txt 
b/llvm/lib/ExecutionEngine/IntelJITEvents/CMakeLists.txt
index 7f84b1505813..9fe3fe0b754e 100644
--- a/llvm/lib/ExecutionEngine/IntelJITEvents/CMakeLists.txt
+++ b/llvm/lib/ExecutionEngine/IntelJITEvents/CMakeLists.txt
@@ -1,25 +1,34 @@
 include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/.. )
 
-set(GIT_REPOSITORY https://github.com/intel/ittapi.git)
-set(GIT_TAG v3.18.8)
+if(NOT DEFINED ITTAPI_GIT_REPOSITORY)
+set(ITTAPI_GIT_REPOSITORY https://github.com/intel/ittapi.git)
+endif()
+
+if(NOT DEFINED ITTAPI_GIT_TAG)
+set(ITTAPI_GIT_TAG v3.18.8)
+endif()
+
+if(NOT DEFINED ITTAPI_SOURCE_DIR)
+set(ITTAPI_SOURCE_DIR ${PROJECT_BINARY_DIR})
+endif()
 
-if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/ittapi)
-execute_process(COMMAND ${GIT_EXECUTABLE} clone ${GIT_REPOSITORY}
-WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+if(NOT EXISTS ${ITTAPI_SOURCE_DIR}/ittapi)
+execute_process(COMMAND ${GIT_EXECUTABLE} clone ${ITTAPI_GIT_REPOSITORY}
+WORKING_DIRECTORY ${ITTAPI_SOURCE_DIR}
 RESULT_VARIABLE GIT_CLONE_RESULT)
 if(NOT GIT_CLONE_RESULT EQUAL "0")
-message(FATAL_ERROR "git clone ${GIT_REPOSITORY} failed with 
${GIT_CLONE_RESULT}, please clone ${GIT_REPOSITORY}")
+message(FATAL_ERROR "git clone ${ITTAPI_GIT_REPOSITORY} failed with 
${GIT_CLONE_RESULT}, please clone ${ITTAPI_GIT_REPOSITORY}")
 endif()
 endif()
 
-execute_process(COMMAND ${GIT_EXECUTABLE} checkout ${GIT_TAG}
-WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ittapi
+execute_process(COMMAND ${GIT_EXECUTABLE} checkout ${ITTAPI_GIT_TAG}
+WORKING_DIRECTORY ${ITTAPI_SOURCE_DIR}/ittapi
 RESULT_VARIABLE GIT_CHECKOUT_RESULT)
 if(NOT GIT_CHECKOUT_RESULT EQUAL "0")
-message(FATAL_ERROR "git checkout ${GIT_TAG} failed with 
${GIT_CHECKOUT_RESULT}, please checkout ${GIT_TAG} at 
${CMAKE_CURRENT_SOURCE_DIR}/ittapi")
+message(FATAL_ERROR "git checkout ${ITTAPI_GIT_TAG} failed with 
${GIT_CHECKOUT_RESULT}, please checkout ${ITTAPI_GIT_TAG} at 
${ITTAPI_SOURCE_DIR}/ittapi")
 endif()
 
-include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/ittapi/include/ )
+include_directories( ${ITTAPI_SOURCE_DIR}/ittapi/include/ )
 
 if( HAVE_LIBDL )
 set(LLVM_INTEL_JIT_LIBS ${CMAKE_DL_LIBS})
@@ -31,7 +40,7 @@ set(LLVM_INTEL_JIT_LIBS ${LLVM_PTHREAD_LIB} 
${LLVM_INTEL_JIT_LIBS})
 add_llvm_component_library(LLVMIntelJITEvents
   IntelJITEventListener.cpp
   jitprofiling.c
-  ittapi/src/ittnotify/ittnotify_static.c
+  ${ITTAPI_SOURCE_DIR}/ittapi/src/ittnotify/ittnotify_static.c
 
   LINK_LIBS ${LLVM_INTEL_JIT_LIBS}
 



___
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] e6a1187 - Limit the recursion depth of SelectionDAG::isSplatValue()

2020-12-09 Thread Justin Bogner via llvm-branch-commits

Author: Justin Bogner
Date: 2020-12-09T10:35:07-08:00
New Revision: e6a1187dd867cc0feea4041b22a9bb29aaa3ae48

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

LOG: Limit the recursion depth of SelectionDAG::isSplatValue()

This method previously always recursively checked both the left-hand
side and right-hand side of binary operations for splatted (broadcast)
vector values to determine if the parent DAG node is a splat.

Like several other SelectionDAG methods, limit the recursion depth to
MaxRecursionDepth (6). This prevents stack overflow.
See also https://issuetracker.google.com/173785481

Patch by Nicolas Capens. Thanks!

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

Added: 


Modified: 
llvm/include/llvm/CodeGen/SelectionDAG.h
llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Removed: 




diff  --git a/llvm/include/llvm/CodeGen/SelectionDAG.h 
b/llvm/include/llvm/CodeGen/SelectionDAG.h
index d73155aa2f2f..4ec870bb3f9b 100644
--- a/llvm/include/llvm/CodeGen/SelectionDAG.h
+++ b/llvm/include/llvm/CodeGen/SelectionDAG.h
@@ -1829,7 +1829,8 @@ class SelectionDAG {
   /// for \p DemandedElts.
   ///
   /// NOTE: The function will return true for a demanded splat of UNDEF values.
-  bool isSplatValue(SDValue V, const APInt &DemandedElts, APInt &UndefElts);
+  bool isSplatValue(SDValue V, const APInt &DemandedElts, APInt &UndefElts,
+unsigned Depth = 0);
 
   /// Test whether \p V has a splatted value.
   bool isSplatValue(SDValue V, bool AllowUndefs = false);

diff  --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp 
b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index 4661b0d9189b..83e8637b3840 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -2355,13 +2355,16 @@ bool SelectionDAG::MaskedValueIsAllOnes(SDValue V, 
const APInt &Mask,
 /// sense to specify which elements are demanded or undefined, therefore
 /// they are simply ignored.
 bool SelectionDAG::isSplatValue(SDValue V, const APInt &DemandedElts,
-APInt &UndefElts) {
+APInt &UndefElts, unsigned Depth) {
   EVT VT = V.getValueType();
   assert(VT.isVector() && "Vector type expected");
 
   if (!VT.isScalableVector() && !DemandedElts)
 return false; // No demanded elts, better to assume we don't know anything.
 
+  if (Depth >= MaxRecursionDepth)
+return false; // Limit search depth.
+
   // Deal with some common cases here that work for both fixed and scalable
   // vector types.
   switch (V.getOpcode()) {
@@ -2376,8 +2379,8 @@ bool SelectionDAG::isSplatValue(SDValue V, const APInt 
&DemandedElts,
 APInt UndefLHS, UndefRHS;
 SDValue LHS = V.getOperand(0);
 SDValue RHS = V.getOperand(1);
-if (isSplatValue(LHS, DemandedElts, UndefLHS) &&
-isSplatValue(RHS, DemandedElts, UndefRHS)) {
+if (isSplatValue(LHS, DemandedElts, UndefLHS, Depth + 1) &&
+isSplatValue(RHS, DemandedElts, UndefRHS, Depth + 1)) {
   UndefElts = UndefLHS | UndefRHS;
   return true;
 }
@@ -2386,7 +2389,7 @@ bool SelectionDAG::isSplatValue(SDValue V, const APInt 
&DemandedElts,
   case ISD::TRUNCATE:
   case ISD::SIGN_EXTEND:
   case ISD::ZERO_EXTEND:
-return isSplatValue(V.getOperand(0), DemandedElts, UndefElts);
+return isSplatValue(V.getOperand(0), DemandedElts, UndefElts, Depth + 1);
   }
 
   // We don't support other cases than those above for scalable vectors at
@@ -2441,7 +2444,7 @@ bool SelectionDAG::isSplatValue(SDValue V, const APInt 
&DemandedElts,
 unsigned NumSrcElts = Src.getValueType().getVectorNumElements();
 APInt UndefSrcElts;
 APInt DemandedSrcElts = DemandedElts.zextOrSelf(NumSrcElts).shl(Idx);
-if (isSplatValue(Src, DemandedSrcElts, UndefSrcElts)) {
+if (isSplatValue(Src, DemandedSrcElts, UndefSrcElts, Depth + 1)) {
   UndefElts = UndefSrcElts.extractBits(NumElts, Idx);
   return 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] [openmp] cab9f69 - [libomptarget][amdgpu] Improve diagnostics on arch mismatch

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

Author: Jon Chesterfield
Date: 2020-12-09T18:55:53Z
New Revision: cab9f6923522475e0d2137c66622c3fa70b01d3b

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

LOG: [libomptarget][amdgpu] Improve diagnostics on arch mismatch

Added: 
openmp/libomptarget/plugins/amdgpu/impl/get_elf_mach_gfx_name.cpp
openmp/libomptarget/plugins/amdgpu/impl/get_elf_mach_gfx_name.h

Modified: 
openmp/libomptarget/plugins/amdgpu/CMakeLists.txt
openmp/libomptarget/plugins/amdgpu/src/rtl.cpp

Removed: 




diff  --git a/openmp/libomptarget/plugins/amdgpu/CMakeLists.txt 
b/openmp/libomptarget/plugins/amdgpu/CMakeLists.txt
index 0c50ffdf2fa6..38f0afabf3ad 100644
--- a/openmp/libomptarget/plugins/amdgpu/CMakeLists.txt
+++ b/openmp/libomptarget/plugins/amdgpu/CMakeLists.txt
@@ -57,6 +57,7 @@ add_library(omptarget.rtl.amdgpu SHARED
   impl/atmi.cpp
   impl/atmi_interop_hsa.cpp
   impl/data.cpp
+  impl/get_elf_mach_gfx_name.cpp
   impl/machine.cpp
   impl/system.cpp
   impl/utils.cpp

diff  --git a/openmp/libomptarget/plugins/amdgpu/impl/get_elf_mach_gfx_name.cpp 
b/openmp/libomptarget/plugins/amdgpu/impl/get_elf_mach_gfx_name.cpp
new file mode 100644
index ..45af34684117
--- /dev/null
+++ b/openmp/libomptarget/plugins/amdgpu/impl/get_elf_mach_gfx_name.cpp
@@ -0,0 +1,53 @@
+#include "get_elf_mach_gfx_name.h"
+
+// This header conflicts with the system elf.h (macros vs enums of the same
+// identifier) and contains more up to date values for the enum checked here.
+// rtl.cpp uses the system elf.h.
+#include "llvm/BinaryFormat/ELF.h"
+
+const char *get_elf_mach_gfx_name(uint32_t EFlags) {
+  using namespace llvm::ELF;
+  uint32_t Gfx = (EFlags & EF_AMDGPU_MACH);
+  switch (Gfx) {
+  case EF_AMDGPU_MACH_AMDGCN_GFX801:
+return "gfx801";
+  case EF_AMDGPU_MACH_AMDGCN_GFX802:
+return "gfx802";
+  case EF_AMDGPU_MACH_AMDGCN_GFX803:
+return "gfx803";
+  case EF_AMDGPU_MACH_AMDGCN_GFX805:
+return "gfx805";
+  case EF_AMDGPU_MACH_AMDGCN_GFX810:
+return "gfx810";
+  case EF_AMDGPU_MACH_AMDGCN_GFX900:
+return "gfx900";
+  case EF_AMDGPU_MACH_AMDGCN_GFX902:
+return "gfx902";
+  case EF_AMDGPU_MACH_AMDGCN_GFX904:
+return "gfx904";
+  case EF_AMDGPU_MACH_AMDGCN_GFX906:
+return "gfx906";
+  case EF_AMDGPU_MACH_AMDGCN_GFX908:
+return "gfx908";
+  case EF_AMDGPU_MACH_AMDGCN_GFX909:
+return "gfx909";
+  case EF_AMDGPU_MACH_AMDGCN_GFX90C:
+return "gfx90c";
+  case EF_AMDGPU_MACH_AMDGCN_GFX1010:
+return "gfx1010";
+  case EF_AMDGPU_MACH_AMDGCN_GFX1011:
+return "gfx1011";
+  case EF_AMDGPU_MACH_AMDGCN_GFX1012:
+return "gfx1012";
+  case EF_AMDGPU_MACH_AMDGCN_GFX1030:
+return "gfx1030";
+  case EF_AMDGPU_MACH_AMDGCN_GFX1031:
+return "gfx1031";
+  case EF_AMDGPU_MACH_AMDGCN_GFX1032:
+return "gfx1032";
+  case EF_AMDGPU_MACH_AMDGCN_GFX1033:
+return "gfx1033";
+  default:
+return "--unknown gfx";
+  }
+}

diff  --git a/openmp/libomptarget/plugins/amdgpu/impl/get_elf_mach_gfx_name.h 
b/openmp/libomptarget/plugins/amdgpu/impl/get_elf_mach_gfx_name.h
new file mode 100644
index ..b1be90dc29d5
--- /dev/null
+++ b/openmp/libomptarget/plugins/amdgpu/impl/get_elf_mach_gfx_name.h
@@ -0,0 +1,8 @@
+#ifndef GET_ELF_MACH_GFX_NAME_H_INCLUDED
+#define GET_ELF_MACH_GFX_NAME_H_INCLUDED
+
+#include 
+
+const char *get_elf_mach_gfx_name(uint32_t EFlags);
+
+#endif

diff  --git a/openmp/libomptarget/plugins/amdgpu/src/rtl.cpp 
b/openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
index 252abca08944..60040d1c0da4 100644
--- a/openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
+++ b/openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
@@ -36,6 +36,7 @@
 #include "internal.h"
 
 #include "Debug.h"
+#include "get_elf_mach_gfx_name.h"
 #include "omptargetplugin.h"
 
 #include "llvm/Frontend/OpenMP/OMPGridValues.h"
@@ -92,14 +93,6 @@ uint32_t TgtStackItemSize = 0;
 
 #include "../../common/elf_common.c"
 
-static bool elf_machine_id_is_amdgcn(__tgt_device_image *image) {
-  const uint16_t amdgcnMachineID = 224;
-  int32_t r = elf_check_machine(image, amdgcnMachineID);
-  if (!r) {
-DP("Supported machine ID not found\n");
-  }
-  return r;
-}
 
 /// Keep entries table per device
 struct FuncOrGblEntryTy {
@@ -319,6 +312,7 @@ class RTLDeviceInfoTy {
   std::vector GroupsPerDevice;
   std::vector ThreadsPerGroup;
   std::vector WarpSize;
+  std::vector GPUName;
 
   // OpenMP properties
   std::vector NumTeams;
@@ -472,6 +466,7 @@ class RTLDeviceInfoTy {
 FuncGblEntries.resize(NumberOfDevices);
 ThreadsPerGroup.resize(NumberOfDevices);
 ComputeUnits.resize(NumberOfDevices);
+GPUName.resize(NumberOfDevices);
 GroupsPerDevice.resize(NumberOfDevices);
 WarpSize.resize(NumberOfDevices);
 NumTeams.resize(NumberOfD

[llvm-branch-commits] [lldb] 199ec40 - [lldb][NFC] Refactor _get_bool_config_skip_if_decorator

2020-12-09 Thread Raphael Isemann via llvm-branch-commits

Author: Raphael Isemann
Date: 2020-12-09T20:02:06+01:00
New Revision: 199ec40e7bcc8548282d803b1a43b1ae1d3b57ce

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

LOG: [lldb][NFC] Refactor _get_bool_config_skip_if_decorator

NFC preparation for another patch. Also add some documentation for why the
error value is true (and not false).

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/decorators.py

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/decorators.py 
b/lldb/packages/Python/lldbsuite/test/decorators.py
index 2013c5241007..bcf665f6cc4c 100644
--- a/lldb/packages/Python/lldbsuite/test/decorators.py
+++ b/lldb/packages/Python/lldbsuite/test/decorators.py
@@ -830,11 +830,20 @@ def skipIfAsan(func):
 """Skip this test if the environment is set up to run LLDB *itself* under 
ASAN."""
 return skipTestIfFn(is_running_under_asan)(func)
 
-def _get_bool_config_skip_if_decorator(key):
+def _get_bool_config(key, fail_value = True):
+"""
+Returns the current LLDB's build config value.
+:param key The key to lookup in LLDB's build configuration.
+:param fail_value The error value to return when the key can't be found.
+   Defaults to true so that if an unknown key is lookup up we rather
+   enable more tests (that then fail) than silently skipping them.
+"""
 config = lldb.SBDebugger.GetBuildConfiguration()
 value_node = config.GetValueForKey(key)
-fail_value = True # More likely to notice if something goes wrong
-have = value_node.GetValueForKey("value").GetBooleanValue(fail_value)
+return value_node.GetValueForKey("value").GetBooleanValue(fail_value)
+
+def _get_bool_config_skip_if_decorator(key):
+have = _get_bool_config(key)
 return unittest2.skipIf(not have, "requires " + key)
 
 def skipIfCursesSupportMissing(func):



___
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] b091768 - [LLD][COFF] Fix crash with /summary and PCH input files

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

Author: Tom Stellard
Date: 2020-12-09T14:12:58-05:00
New Revision: b091768e60e6807ae3806acaba1cbc9b1c96b388

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

LOG: [LLD][COFF] Fix crash with /summary and PCH input files

Before this patch /summary was crashing with some .PCH.OBJ files, because 
tpiMap[srcIdx++] was reading at the wrong location. When the TpiSource depends 
on a .PCH.OBJ file, the types should be offset by the previously merged PCH.OBJ 
set of indices.

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

(cherry picked from commit 4140f0744fb2deccb74e77282e23ff731f67821b)

Added: 
lld/test/COFF/Inputs/precomp2-a.yaml
lld/test/COFF/Inputs/precomp2.yaml
lld/test/COFF/precomp-summary-fail.test

Modified: 
lld/COFF/DebugTypes.cpp

Removed: 




diff  --git a/lld/COFF/DebugTypes.cpp b/lld/COFF/DebugTypes.cpp
index 4790b0166799..abe3bb9eef5b 100644
--- a/lld/COFF/DebugTypes.cpp
+++ b/lld/COFF/DebugTypes.cpp
@@ -202,6 +202,9 @@ Expected 
TpiSource::mergeDebugT(TypeMerger *m,
   BinaryStreamReader reader(file->debugTypes, support::little);
   cantFail(reader.readArray(types, reader.getLength()));
 
+  // When dealing with PCH.OBJ, some indices were already merged.
+  unsigned nbHeadIndices = indexMap->tpiMap.size();
+
   if (config->debugGHashes) {
 ArrayRef hashes;
 std::vector ownedHashes;
@@ -232,7 +235,7 @@ Expected 
TpiSource::mergeDebugT(TypeMerger *m,
 // collecting statistics.
 m->tpiCounts.resize(m->getTypeTable().size());
 m->ipiCounts.resize(m->getIDTable().size());
-uint32_t srcIdx = 0;
+uint32_t srcIdx = nbHeadIndices;
 for (CVType &ty : types) {
   TypeIndex dstIdx = indexMap->tpiMap[srcIdx++];
   // Type merging may fail, so a complex source type may become the simple

diff  --git a/lld/test/COFF/Inputs/precomp2-a.yaml 
b/lld/test/COFF/Inputs/precomp2-a.yaml
new file mode 100644
index ..a9d497ba10a3
--- /dev/null
+++ b/lld/test/COFF/Inputs/precomp2-a.yaml
@@ -0,0 +1,84 @@
+--- !COFF
+header:
+  Machine: IMAGE_FILE_MACHINE_AMD64
+  Characteristics: [  ]
+sections:
+  - Name:'.debug$S'
+Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, 
IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ]
+Alignment:   1
+Subsections:
+  - !Symbols
+Records:
+  - Kind:S_OBJNAME
+ObjNameSym:
+  Signature:   545589255
+  ObjectName:  
'D:\llvm-project\lld\test\COFF\Inputs\precomp2-a.obj'
+  - Kind:S_COMPILE3
+Compile3Sym:
+  Flags:   [ SecurityChecks, HotPatch ]
+  Machine: X64
+  FrontendMajor:   19
+  FrontendMinor:   13
+  FrontendBuild:   26131
+  FrontendQFE: 1
+  BackendMajor:19
+  BackendMinor:13
+  BackendBuild:26131
+  BackendQFE:  1
+  Version: 'Microsoft (R) Optimizing Compiler'
+  - !StringTable
+Strings:
+  - 'D:\llvm-project\lld\test\COFF\precomp\precomp.pch'
+  - 'D:\llvm-project\lld\test\COFF\precomp\precomp.h'
+  - 'D:\llvm-project\lld\test\COFF\precomp\a.cpp'
+  - Name:'.debug$T'
+Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, 
IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ]
+Alignment:   1
+Types:
+  - Kind:LF_PRECOMP
+Precomp:
+  StartTypeIndex:  4096
+  TypesCount:  3
+  Signature:   545589255
+  PrecompFilePath: 'D:\llvm-project\lld\test\COFF\Inputs\precomp2.obj'
+  - Kind:LF_STRING_ID
+StringId:
+  Id:  0
+  String:  'test test test test test'
+  - Kind:LF_STRING_ID
+StringId:
+  Id:  0
+  String:  'test test test test test'
+  - Kind:LF_STRING_ID
+StringId:
+  Id:  0
+  String:  'test test test test test'
+  - Kind:LF_BUILDINFO
+BuildInfo:
+  ArgIndices:  [ 4101, 4101, 4101, 4101, 4101 ]
+symbols:
+  - Name:'.debug$S'
+Value:   0
+SectionNumber:   1
+SimpleType:  IMAGE_SYM_TYPE_NULL
+ComplexType: IMAGE_SYM_DTYPE_NULL
+StorageClass:IMAGE_SYM_CLASS_STATIC
+SectionDefinition:
+  Length:  0
+  NumberOfRelocations: 0
+  NumberOfLinenumbers: 0
+  CheckSum:0
+  Number:  0
+  - Name:'.debug$T'
+Value:   0
+SectionNumber:   2
+SimpleType:  IMAGE_SYM_TYPE_NULL
+ComplexType: IMAGE_SYM_DTYPE_NULL
+StorageC

[llvm-branch-commits] [clang] d7098ff - De-templatify EmitCallArgs argument type checking, NFCI

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

Author: Reid Kleckner
Date: 2020-12-09T11:08:00-08:00
New Revision: d7098ff29c58dd08ede8314818b7de7fd2fea4cc

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

LOG: De-templatify EmitCallArgs argument type checking, NFCI

This template exists to abstract over FunctionPrototype and
ObjCMethodDecl, which have similar APIs for storing parameter types. In
place of a template, use a PointerUnion with two cases to handle this.
Hopefully this improves readability, since the type of the prototype is
easier to discover. This allows me to sink this code, which is mostly
assertions, out of the header file and into the cpp file. I can also
simplify the overloaded methods for computing isGenericMethod, and get
rid of the second EmitCallArgs overload.

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

Added: 


Modified: 
clang/lib/CodeGen/CGCall.cpp
clang/lib/CodeGen/CGExprCXX.cpp
clang/lib/CodeGen/CodeGenFunction.h

Removed: 




diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 2b9bfb6a6c88..83903af55ab3 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -3818,13 +3818,79 @@ void CodeGenFunction::EmitNonNullArgCheck(RValue RV, 
QualType ArgType,
   EmitCheck(std::make_pair(Cond, CheckKind), Handler, StaticData, None);
 }
 
+#ifndef NDEBUG
+// Determine whether the given argument is an Objective-C method
+// that may have type parameters in its signature.
+static bool isObjCMethodWithTypeParams(const ObjCMethodDecl *method) {
+  const DeclContext *dc = method->getDeclContext();
+  if (const ObjCInterfaceDecl *classDecl = dyn_cast(dc)) {
+return classDecl->getTypeParamListAsWritten();
+  }
+
+  if (const ObjCCategoryDecl *catDecl = dyn_cast(dc)) {
+return catDecl->getTypeParamList();
+  }
+
+  return false;
+}
+#endif
+
+/// EmitCallArgs - Emit call arguments for a function.
 void CodeGenFunction::EmitCallArgs(
-CallArgList &Args, ArrayRef ArgTypes,
+CallArgList &Args, PrototypeWrapper Prototype,
 llvm::iterator_range ArgRange,
 AbstractCallee AC, unsigned ParamsToSkip, EvaluationOrder Order) {
+  SmallVector ArgTypes;
+
+  assert((ParamsToSkip == 0 || Prototype.P) &&
+ "Can't skip parameters if type info is not provided");
+
+  // First, use the argument types that the type info knows about
+  bool IsVariadic = false;
+  if (Prototype.P) {
+const auto *MD = Prototype.P.dyn_cast();
+if (MD) {
+  IsVariadic = MD->isVariadic();
+  ArgTypes.assign(MD->param_type_begin() + ParamsToSkip,
+  MD->param_type_end());
+} else {
+  const auto *FPT = Prototype.P.get();
+  IsVariadic = FPT->isVariadic();
+  ArgTypes.assign(FPT->param_type_begin() + ParamsToSkip,
+  FPT->param_type_end());
+}
+
+#ifndef NDEBUG
+// Check that the prototyped types match the argument expression types.
+bool isGenericMethod = MD && isObjCMethodWithTypeParams(MD);
+CallExpr::const_arg_iterator Arg = ArgRange.begin();
+for (QualType Ty : ArgTypes) {
+  assert(Arg != ArgRange.end() && "Running over edge of argument list!");
+  assert(
+  (isGenericMethod || Ty->isVariablyModifiedType() ||
+   Ty.getNonReferenceType()->isObjCRetainableType() ||
+   getContext()
+   .getCanonicalType(Ty.getNonReferenceType())
+   .getTypePtr() ==
+   getContext().getCanonicalType((*Arg)->getType()).getTypePtr()) 
&&
+  "type mismatch in call argument!");
+  ++Arg;
+}
+
+// Either we've emitted all the call args, or we have a call to variadic
+// function.
+assert((Arg == ArgRange.end() || IsVariadic) &&
+   "Extra arguments in non-variadic function!");
+#endif
+  }
+
+  // If we still have any arguments, emit them using the type of the argument.
+  for (auto *A : llvm::make_range(std::next(ArgRange.begin(), ArgTypes.size()),
+  ArgRange.end()))
+ArgTypes.push_back(IsVariadic ? getVarArgType(A) : A->getType());
   assert((int)ArgTypes.size() == (ArgRange.end() - ArgRange.begin()));
 
-  // We *have* to evaluate arguments from right to left in the MS C++ ABI,
+  // We must evaluate arguments from right to left in the MS C++ ABI,
   // because arguments are destroyed left to right in the callee. As a special
   // case, there are certain language constructs that require left-to-right
   // evaluation, and in those cases we consider the evaluation order 
requirement

diff  --git a/clang/lib/CodeGen/CGExprCXX.cpp b/clang/lib/CodeGen/CGExprCXX.cpp
index c8b059fd7db0..e1907a6f0680 100644
--- a/clang/lib/CodeGen/CGExprCXX.cpp
+++ b/clang/lib/CodeGen/CGExprCXX.cpp
@@ -1329,7 +1329,7 @@ RValue CodeGenFunction::EmitBuil

[llvm-branch-commits] [clang] df28221 - Don't setup inalloca for swiftcc on i686-windows-msvc

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

Author: Reid Kleckner
Date: 2020-12-09T11:08:48-08:00
New Revision: df282215d497e15104ae9e182e083cdfa0bae3c2

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

LOG: Don't setup inalloca for swiftcc on i686-windows-msvc

Swiftcall does it's own target-independent argument type classification,
since it is not designed to be ABI compatible with anything local on the
target that isn't LLVM-based. This means it never uses inalloca.
However, we have duplicate logic for checking for inalloca parameters
that runs before call argument setup. This logic needs to know ahead of
time if inalloca will be used later, and we can't move the
CGFunctionInfo calculation earlier.

This change gets the calling convention from either the
FunctionProtoType or ObjCMethodDecl, checks if it is swift, and if so
skips the stackbase setup.

Depends on D92883.

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

Added: 
clang/test/CodeGenCXX/windows-x86-swiftcall.cpp

Modified: 
clang/lib/CodeGen/CGCall.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 83903af55ab3..5db34b693bf3 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -198,7 +198,8 @@ 
CodeGenTypes::arrangeFreeFunctionType(CanQual FTP) {
FTP);
 }
 
-static CallingConv getCallingConventionForDecl(const Decl *D, bool IsWindows) {
+static CallingConv getCallingConventionForDecl(const ObjCMethodDecl *D,
+   bool IsWindows) {
   // Set the appropriate calling convention for the Function.
   if (D->hasAttr())
 return CC_X86StdCall;
@@ -3818,6 +3819,24 @@ void CodeGenFunction::EmitNonNullArgCheck(RValue RV, 
QualType ArgType,
   EmitCheck(std::make_pair(Cond, CheckKind), Handler, StaticData, None);
 }
 
+// Check if the call is going to use the inalloca convention. This needs to
+// agree with CGFunctionInfo::usesInAlloca. The CGFunctionInfo is arranged
+// later, so we can't check it directly.
+static bool hasInAllocaArgs(CodeGenModule &CGM, CallingConv ExplicitCC,
+ArrayRef ArgTypes) {
+  // The Swift calling convention doesn't go through the target-specific
+  // argument classification, so it never uses inalloca.
+  // TODO: Consider limiting inalloca use to only calling conventions supported
+  // by MSVC.
+  if (ExplicitCC == CC_Swift)
+return false;
+  if (!CGM.getTarget().getCXXABI().isMicrosoft())
+return false;
+  return llvm::any_of(ArgTypes, [&](QualType Ty) {
+return isInAllocaArgument(CGM.getCXXABI(), Ty);
+  });
+}
+
 #ifndef NDEBUG
 // Determine whether the given argument is an Objective-C method
 // that may have type parameters in its signature.
@@ -3845,17 +3864,27 @@ void CodeGenFunction::EmitCallArgs(
   assert((ParamsToSkip == 0 || Prototype.P) &&
  "Can't skip parameters if type info is not provided");
 
-  // First, use the argument types that the type info knows about
+  // This variable only captures *explicitly* written conventions, not those
+  // applied by default via command line flags or target defaults, such as
+  // thiscall, aapcs, stdcall via -mrtd, etc. Computing that correctly would
+  // require knowing if this is a C++ instance method or being able to see
+  // unprototyped FunctionTypes.
+  CallingConv ExplicitCC = CC_C;
+
+  // First, if a prototype was provided, use those argument types.
   bool IsVariadic = false;
   if (Prototype.P) {
 const auto *MD = Prototype.P.dyn_cast();
 if (MD) {
   IsVariadic = MD->isVariadic();
+  ExplicitCC = getCallingConventionForDecl(
+  MD, CGM.getTarget().getTriple().isOSWindows());
   ArgTypes.assign(MD->param_type_begin() + ParamsToSkip,
   MD->param_type_end());
 } else {
   const auto *FPT = Prototype.P.get();
   IsVariadic = FPT->isVariadic();
+  ExplicitCC = FPT->getExtInfo().getCC();
   ArgTypes.assign(FPT->param_type_begin() + ParamsToSkip,
   FPT->param_type_end());
 }
@@ -3923,15 +3952,10 @@ void CodeGenFunction::EmitCallArgs(
   };
 
   // Insert a stack save if we're going to need any inalloca args.
-  bool HasInAllocaArgs = false;
-  if (CGM.getTarget().getCXXABI().isMicrosoft()) {
-for (ArrayRef::iterator I = ArgTypes.begin(), E = ArgTypes.end();
- I != E && !HasInAllocaArgs; ++I)
-  HasInAllocaArgs = isInAllocaArgument(CGM.getCXXABI(), *I);
-if (HasInAllocaArgs) {
-  assert(getTarget().getTriple().getArch() == llvm::Triple::x86);
-  Args.allocateArgumentMemory(*this);
-}
+  if (hasInAllocaArgs(CGM, ExplicitCC, ArgTypes)) {
+assert(getTarget().getTriple().getArch() == llvm::Triple::x86 &&
+   "inalloca only supported on x8

[llvm-branch-commits] [openmp] e191d31 - [libomptarget][amdgpu] Robust handling of device_environment symbol

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

Author: Jon Chesterfield
Date: 2020-12-09T19:21:51Z
New Revision: e191d3115921d9b5b6602747bff72a1f2cf565c4

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

LOG: [libomptarget][amdgpu] Robust handling of device_environment symbol

Added: 


Modified: 
openmp/libomptarget/plugins/amdgpu/src/rtl.cpp

Removed: 




diff  --git a/openmp/libomptarget/plugins/amdgpu/src/rtl.cpp 
b/openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
index 60040d1c0da4d..e13d769a16aad 100644
--- a/openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
+++ b/openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
@@ -891,6 +891,7 @@ const Elf64_Sym *elf_lookup(Elf *elf, char *base, 
Elf64_Shdr *section_hash,
 typedef struct {
   void *addr = nullptr;
   uint32_t size = UINT32_MAX;
+  uint32_t sh_type = SHT_NULL;
 } symbol_info;
 
 int get_symbol_info_without_loading(Elf *elf, char *base, const char *symname,
@@ -913,8 +914,23 @@ int get_symbol_info_without_loading(Elf *elf, char *base, 
const char *symname,
 return 1;
   }
 
-  res->size = static_cast(sym->st_size);
+  if (sym->st_shndx == SHN_UNDEF) {
+return 1;
+  }
+
+  Elf_Scn *section = elf_getscn(elf, sym->st_shndx);
+  if (!section) {
+return 1;
+  }
+
+  Elf64_Shdr *header = elf64_getshdr(section);
+  if (!header) {
+return 1;
+  }
+
   res->addr = sym->st_value + base;
+  res->size = static_cast(sym->st_size);
+  res->sh_type = header->sh_type;
   return 0;
 }
 
@@ -992,6 +1008,99 @@ __tgt_target_table *__tgt_rtl_load_binary(int32_t 
device_id,
   return res;
 }
 
+struct device_environment {
+  // initialise an omptarget_device_environmentTy in the deviceRTL
+  // patches around 
diff erences in the deviceRTL between trunk, aomp,
+  // rocmcc. Over time these 
diff erences will tend to zero and this class
+  // simplified.
+  // Symbol may be in .data or .bss, and may be missing fields:
+  //  - aomp has debug_level, num_devices, device_num
+  //  - trunk has debug_level
+  //  - under review in trunk is debug_level, device_num
+  //  - rocmcc matches aomp, patch to swap num_devices and device_num
+
+  // If the symbol is in .data (aomp, rocm) it can be written directly.
+  // If it is in .bss, we must wait for it to be allocated space on the
+  // gpu (trunk) and initialize after loading.
+  const char *sym() { return "omptarget_device_environment"; }
+
+  omptarget_device_environmentTy host_device_env;
+  symbol_info si;
+  bool valid = false;
+
+  __tgt_device_image *image;
+  const size_t img_size;
+
+  device_environment(int device_id, int number_devices,
+ __tgt_device_image *image, const size_t img_size)
+  : image(image), img_size(img_size) {
+
+host_device_env.num_devices = number_devices;
+host_device_env.device_num = device_id;
+host_device_env.debug_level = 0;
+#ifdef OMPTARGET_DEBUG
+if (char *envStr = getenv("LIBOMPTARGET_DEVICE_RTL_DEBUG")) {
+  host_device_env.debug_level = std::stoi(envStr);
+}
+#endif
+
+int rc = get_symbol_info_without_loading((char *)image->ImageStart,
+ img_size, sym(), &si);
+if (rc != 0) {
+  DP("Finding global device environment '%s' - symbol missing.\n", sym());
+  return;
+}
+
+if (si.size > sizeof(host_device_env)) {
+  DP("Symbol '%s' has size %u, expected at most %zu.\n", sym(), si.size,
+ sizeof(host_device_env));
+  return;
+}
+
+valid = true;
+  }
+
+  bool in_image() { return si.sh_type != SHT_NOBITS; }
+
+  atmi_status_t before_loading(void *data, size_t size) {
+assert(valid);
+if (in_image()) {
+  DP("Setting global device environment before load (%u bytes)\n", 
si.size);
+  uint64_t offset = (char *)si.addr - (char *)image->ImageStart;
+  void *pos = (char *)data + offset;
+  memcpy(pos, &host_device_env, si.size);
+}
+return ATMI_STATUS_SUCCESS;
+  }
+
+  atmi_status_t after_loading() {
+assert(valid);
+if (!in_image()) {
+  DP("Setting global device environment after load (%u bytes)\n", si.size);
+  int device_id = host_device_env.device_num;
+
+  void *state_ptr;
+  uint32_t state_ptr_size;
+  atmi_status_t err = atmi_interop_hsa_get_symbol_info(
+  get_gpu_mem_place(device_id), sym(), &state_ptr, &state_ptr_size);
+  if (err != ATMI_STATUS_SUCCESS) {
+DP("failed to find %s in loaded image\n", sym());
+return err;
+  }
+
+  if (state_ptr_size != si.size) {
+DP("Symbol had size %u before loading, %u after\n", state_ptr_size,
+   si.size);
+return ATMI_STATUS_ERROR;
+  }
+
+  return DeviceInfo.freesignalpool_memcpy_h2d(state_ptr, &host_device_env,
+  state_ptr_size, device_id);
+}

[llvm-branch-commits] [openmp] c9bc414 - [libomptarget][amdgpu] Let default number of teams equal number of CUs

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

Author: Jon Chesterfield
Date: 2020-12-09T19:35:34Z
New Revision: c9bc414840a41aff3e83a1529ba6dd98e13ce39d

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

LOG: [libomptarget][amdgpu] Let default number of teams equal number of CUs

Added: 


Modified: 
openmp/libomptarget/plugins/amdgpu/src/rtl.cpp

Removed: 




diff  --git a/openmp/libomptarget/plugins/amdgpu/src/rtl.cpp 
b/openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
index e13d769a16aa..18bf67f7fc8a 100644
--- a/openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
+++ b/openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
@@ -789,9 +789,17 @@ int32_t __tgt_rtl_init_device(int device_id) {
 DP("Default number of teams set according to environment %d\n",
DeviceInfo.EnvNumTeams);
   } else {
-DeviceInfo.NumTeams[device_id] = RTLDeviceInfoTy::DefaultNumTeams;
-DP("Default number of teams set according to library's default %d\n",
-   RTLDeviceInfoTy::DefaultNumTeams);
+char *TeamsPerCUEnvStr = getenv("OMP_TARGET_TEAMS_PER_PROC");
+int TeamsPerCU = 1; // default number of teams per CU is 1
+if (TeamsPerCUEnvStr) {
+  TeamsPerCU = std::stoi(TeamsPerCUEnvStr);
+}
+   
+DeviceInfo.NumTeams[device_id] =
+  TeamsPerCU * DeviceInfo.ComputeUnits[device_id];
+DP("Default number of teams = %d * number of compute units %d\n",
+   TeamsPerCU,
+   DeviceInfo.ComputeUnits[device_id]);
   }
 
   if (DeviceInfo.NumTeams[device_id] > DeviceInfo.GroupsPerDevice[device_id]) {
@@ -1548,11 +1556,12 @@ int32_t __tgt_rtl_data_delete(int device_id, void 
*tgt_ptr) {
 // loop_tripcount.
 void getLaunchVals(int &threadsPerGroup, int &num_groups, int ConstWGSize,
int ExecutionMode, int EnvTeamLimit, int EnvNumTeams,
-   int num_teams, int thread_limit, uint64_t loop_tripcount) {
+   int num_teams, int thread_limit, uint64_t loop_tripcount,
+   int32_t device_id) {
 
   int Max_Teams = DeviceInfo.EnvMaxTeamsDefault > 0
   ? DeviceInfo.EnvMaxTeamsDefault
-  : DeviceInfo.Max_Teams;
+  : DeviceInfo.NumTeams[device_id];
   if (Max_Teams > DeviceInfo.HardTeamLimit)
 Max_Teams = DeviceInfo.HardTeamLimit;
 
@@ -1752,7 +1761,8 @@ int32_t __tgt_rtl_run_target_team_region_locked(
 DeviceInfo.EnvNumTeams,
 num_teams, // From run_region arg
 thread_limit,  // From run_region arg
-loop_tripcount // From run_region arg
+loop_tripcount, // From run_region arg
+KernelInfo->device_id
   );
 
   if (print_kernel_trace == 4)



___
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] ea98116 - [dfsan] Track field/index-level shadow values in variables

2020-12-09 Thread Jianzhou Zhao via llvm-branch-commits

Author: Jianzhou Zhao
Date: 2020-12-09T19:38:35Z
New Revision: ea981165a4ef2d6e8be0655f04cc4b61604db6d4

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

LOG: [dfsan] Track field/index-level shadow values in variables

*
* The problem
*
See motivation examples in compiler-rt/test/dfsan/pair.cpp. The current
DFSan always uses a 16bit shadow value for a variable with any type by
combining all shadow values of all bytes of the variable. So it cannot
distinguish two fields of a struct: each field's shadow value equals the
combined shadow value of all fields. This introduces an overtaint issue.

Consider a parsing function

   std::pair get_token(char* p);

where p points to a buffer to parse, the returned pair includes the next
token and the pointer to the position in the buffer after the token.

If the token is tainted, then both the returned pointer and int ar
tainted. If the parser keeps on using get_token for the rest parsing,
all the following outputs are tainted because of the tainted pointer.

The CL is the first change to address the issue.

**
* The proposed improvement
**
Eventually all fields and indices have their own shadow values in
variables and memory.

For example, variables with type {i1, i3}, [2 x i1], {[2 x i4], i8},
[2 x {i1, i1}] have shadow values with type {i16, i16}, [2 x i16],
{[2 x i16], i16}, [2 x {i16, i16}] correspondingly; variables with
primary type still have shadow values i16.

***
* An potential implementation plan
***

The idea is to adopt the change incrementially.

1) This CL
Support field-level accuracy at variables/args/ret in TLS mode,
load/store/alloca still use combined shadow values.

After the alloca promotion and SSA construction phases (>=-O1), we
assume alloca and memory operations are reduced. So if struct
variables do not relate to memory, their tracking is accurate at
field level.

2) Support field-level accuracy at alloca
3) Support field-level accuracy at load/store

These two should make O0 and real memory access work.

4) Support vector if necessary.
5) Support Args mode if necessary.
6) Support passing more accurate shadow values via custom functions if
necessary.

***
* About this CL.
***
The CL did the following

1) extended TLS arg/ret to work with aggregate types. This is similar
to what MSan does.

2) implemented how to map between an original type/value/zero-const to
its shadow type/value/zero-const.

3) extended (insert|extract)value to use field/index-level progagation.

4) for other instructions, propagation rules are combining inputs by or.
The CL converts between aggragate and primary shadow values at the
cases.

5) Custom function interfaces also need such a conversion because
all existing custom functions use i16. It is unclear whether custome
functions need more accurate shadow propagation yet.

6) Added test cases for aggregate type related cases.

Reviewed-by: morehouse

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

Added: 
llvm/test/Instrumentation/DataFlowSanitizer/abilist_aggregate.ll
llvm/test/Instrumentation/DataFlowSanitizer/array.ll
llvm/test/Instrumentation/DataFlowSanitizer/struct.ll
llvm/test/Instrumentation/DataFlowSanitizer/vector.ll

Modified: 
compiler-rt/test/dfsan/pair.cpp
compiler-rt/test/dfsan/struct.c
llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
llvm/test/Instrumentation/DataFlowSanitizer/phi.ll
llvm/test/Instrumentation/DataFlowSanitizer/store.ll

Removed: 




diff  --git a/compiler-rt/test/dfsan/pair.cpp b/compiler-rt/test/dfsan/pair.cpp
index 830fe393b17b..52fa8bdde7e8 100644
--- a/compiler-rt/test/dfsan/pair.cpp
+++ b/compiler-rt/test/dfsan/pair.cpp
@@ -1,4 +1,5 @@
-// RUN: %clangxx_dfsan %s -mllvm -dfsan-fast-16-labels -mllvm 
-dfsan-track-select-control-flow=false -mllvm 
-dfsan-combine-pointer-labels-on-load=false -o %t && %run %t
+// RUN: %clangxx_dfsan %s -mllvm -dfsan-fast-16-labels -mllvm 
-dfsan-track-select-control-flow=false -mllvm 
-dfsan-combine-pointer-labels-on-load=false -O0 -DO0 -o %t && %run %t
+// RUN: %clangxx_dfsan %s -mllvm -dfsan-fast-16-labels -mllvm 
-dfsan-track-select-control-flow=false -mllvm 
-dfsan-combine-pointer-labels-on-load=false -O1 -o %t && %run %t
 
 #include 
 #include 
@@ -64,29 +65,49 @@ void test_simple_constructors() {
   int i1 = pair1.second;
   int *ptr1 = pair1.first;
 
+#ifdef O0
   assert(dfsan_read_label(&i1, sizeof(i1)) == 10);
   assert(dfsan_read_label(&ptr1, sizeof(ptr1)) == 10);
+#else
+  assert(dfsan_read_label(&i1, sizeof(i1)) == 8);
+  assert(dfsan_read_label(&ptr1, sizeof(ptr1)) == 2);
+#endif
 
   std::pair pair2 = copy_pair1(pair1);
   i

[llvm-branch-commits] [openmp] 7c59614 - [libomptarget][amdgpu] clang-format src/rtl.cpp

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

Author: Jon Chesterfield
Date: 2020-12-09T19:45:51Z
New Revision: 7c5961439485e59b8f463b17bf37dab8d8aa7c3a

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

LOG: [libomptarget][amdgpu] clang-format src/rtl.cpp

Added: 


Modified: 
openmp/libomptarget/plugins/amdgpu/src/rtl.cpp

Removed: 




diff  --git a/openmp/libomptarget/plugins/amdgpu/src/rtl.cpp 
b/openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
index 18bf67f7fc8a..5ec5f5e45e36 100644
--- a/openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
+++ b/openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
@@ -93,7 +93,6 @@ uint32_t TgtStackItemSize = 0;
 
 #include "../../common/elf_common.c"
 
-
 /// Keep entries table per device
 struct FuncOrGblEntryTy {
   __tgt_target_table Table;
@@ -708,7 +707,7 @@ int32_t __tgt_rtl_init_device(int device_id) {
 
   char GetInfoName[64]; // 64 max size returned by get info
   err = hsa_agent_get_info(agent, (hsa_agent_info_t)HSA_AGENT_INFO_NAME,
-  (void *) GetInfoName);
+   (void *)GetInfoName);
   if (err)
 DeviceInfo.GPUName[device_id] = "--unknown gpu--";
   else {
@@ -718,7 +717,7 @@ int32_t __tgt_rtl_init_device(int device_id) {
   if (print_kernel_trace == 4)
 fprintf(stderr, "Device#%-2d CU's: %2d %s\n", device_id,
 DeviceInfo.ComputeUnits[device_id],
-   DeviceInfo.GPUName[device_id].c_str());
+DeviceInfo.GPUName[device_id].c_str());
 
   // Query attributes to determine number of threads/block and blocks/grid.
   uint16_t workgroup_max_dim[3];
@@ -794,12 +793,11 @@ int32_t __tgt_rtl_init_device(int device_id) {
 if (TeamsPerCUEnvStr) {
   TeamsPerCU = std::stoi(TeamsPerCUEnvStr);
 }
-   
+
 DeviceInfo.NumTeams[device_id] =
-  TeamsPerCU * DeviceInfo.ComputeUnits[device_id];
+TeamsPerCU * DeviceInfo.ComputeUnits[device_id];
 DP("Default number of teams = %d * number of compute units %d\n",
-   TeamsPerCU,
-   DeviceInfo.ComputeUnits[device_id]);
+   TeamsPerCU, DeviceInfo.ComputeUnits[device_id]);
   }
 
   if (DeviceInfo.NumTeams[device_id] > DeviceInfo.GroupsPerDevice[device_id]) {
@@ -1183,7 +1181,7 @@ __tgt_target_table *__tgt_rtl_load_binary_locked(int32_t 
device_id,
   "Possible gpu arch mismatch: device:%s, image:%s please check"
   " compiler flag: -march=\n",
   DeviceInfo.GPUName[device_id].c_str(),
- get_elf_mach_gfx_name(elf_e_flags(image)));
+  get_elf_mach_gfx_name(elf_e_flags(image)));
   return NULL;
 }
 
@@ -1759,11 +1757,10 @@ int32_t __tgt_rtl_run_target_team_region_locked(
   getLaunchVals(threadsPerGroup, num_groups, KernelInfo->ConstWGSize,
 KernelInfo->ExecutionMode, DeviceInfo.EnvTeamLimit,
 DeviceInfo.EnvNumTeams,
-num_teams, // From run_region arg
-thread_limit,  // From run_region arg
+num_teams,  // From run_region arg
+thread_limit,   // From run_region arg
 loop_tripcount, // From run_region arg
-KernelInfo->device_id
-  );
+KernelInfo->device_id);
 
   if (print_kernel_trace == 4)
 // enum modes are SPMD, GENERIC, NONE 0,1,2



___
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] 77fd12a - [AArch64] Add aarch64_neon_vcmla{_rot{90, 180, 270}} intrinsics.

2020-12-09 Thread Florian Hahn via llvm-branch-commits

Author: Florian Hahn
Date: 2020-12-09T19:46:49Z
New Revision: 77fd12a66e4ccfb57a3e22ee18721aaeddbe4936

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

LOG: [AArch64] Add aarch64_neon_vcmla{_rot{90,180,270}} intrinsics.

Add builtins required to implement vcmla and rotated variants from
the ACLE

Reviewed By: t.p.northover

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

Added: 
llvm/test/CodeGen/AArch64/neon-vcmla.ll

Modified: 
llvm/include/llvm/IR/IntrinsicsAArch64.td
llvm/lib/Target/AArch64/AArch64InstrInfo.td

Removed: 




diff  --git a/llvm/include/llvm/IR/IntrinsicsAArch64.td 
b/llvm/include/llvm/IR/IntrinsicsAArch64.td
index f07e6d6a2999..255d293b646e 100644
--- a/llvm/include/llvm/IR/IntrinsicsAArch64.td
+++ b/llvm/include/llvm/IR/IntrinsicsAArch64.td
@@ -497,6 +497,11 @@ let TargetPrefix = "aarch64", IntrProperties = [IntrNoMem] 
in {
   // v8.3-A Floating-point complex add
   def int_aarch64_neon_vcadd_rot90  : AdvSIMD_2VectorArg_Intrinsic;
   def int_aarch64_neon_vcadd_rot270 : AdvSIMD_2VectorArg_Intrinsic;
+
+  def int_aarch64_neon_vcmla_rot0   : AdvSIMD_3VectorArg_Intrinsic;
+  def int_aarch64_neon_vcmla_rot90  : AdvSIMD_3VectorArg_Intrinsic;
+  def int_aarch64_neon_vcmla_rot180 : AdvSIMD_3VectorArg_Intrinsic;
+  def int_aarch64_neon_vcmla_rot270 : AdvSIMD_3VectorArg_Intrinsic;
 }
 
 let TargetPrefix = "aarch64" in {  // All intrinsics start with 
"llvm.aarch64.".

diff  --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.td 
b/llvm/lib/Target/AArch64/AArch64InstrInfo.td
index ca13729a54e6..564f5fdce6f1 100644
--- a/llvm/lib/Target/AArch64/AArch64InstrInfo.td
+++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.td
@@ -934,6 +934,27 @@ let Predicates = [HasComplxNum, HasNEON] in {
   }
 }
 
+multiclass FCMLA_PATS {
+  def : Pat<(ty (int_aarch64_neon_vcmla_rot0 (ty Reg:$Rd), (ty Reg:$Rn), (ty 
Reg:$Rm))),
+(!cast("FCMLA" # ty) $Rd, $Rn, $Rm, 0)>;
+  def : Pat<(ty (int_aarch64_neon_vcmla_rot90 (ty Reg:$Rd), (ty Reg:$Rn), (ty 
Reg:$Rm))),
+(!cast("FCMLA" # ty) $Rd, $Rn, $Rm, 1)>;
+  def : Pat<(ty (int_aarch64_neon_vcmla_rot180 (ty Reg:$Rd), (ty Reg:$Rn), (ty 
Reg:$Rm))),
+(!cast("FCMLA" # ty) $Rd, $Rn, $Rm, 2)>;
+  def : Pat<(ty (int_aarch64_neon_vcmla_rot270 (ty Reg:$Rd), (ty Reg:$Rn), (ty 
Reg:$Rm))),
+(!cast("FCMLA" # ty) $Rd, $Rn, $Rm, 3)>;
+}
+
+let Predicates = [HasComplxNum, HasNEON, HasFullFP16] in {
+  defm : FCMLA_PATS;
+  defm : FCMLA_PATS;
+}
+let Predicates = [HasComplxNum, HasNEON] in {
+  defm : FCMLA_PATS;
+  defm : FCMLA_PATS;
+  defm : FCMLA_PATS;
+}
+
 // v8.3a Pointer Authentication
 // These instructions inhabit part of the hint space and so can be used for
 // armv8 targets. Keeping the old HINT mnemonic when compiling without PA is

diff  --git a/llvm/test/CodeGen/AArch64/neon-vcmla.ll 
b/llvm/test/CodeGen/AArch64/neon-vcmla.ll
new file mode 100644
index ..11e2b869abf0
--- /dev/null
+++ b/llvm/test/CodeGen/AArch64/neon-vcmla.ll
@@ -0,0 +1,203 @@
+; RUN: llc %s -mtriple=aarch64 -mattr=+v8.3a,+fullfp16 -o - | FileCheck %s
+
+define <4 x half> @test_16x4(<4 x half> %a, <4 x half> %b, <4 x half> %c) {
+entry:
+; CHECK-LABEL: test_16x4
+; CHECK: fcmla v{{[0-9]+}}.4h, v{{[0-9]+}}.4h, v{{[0-9]+}}.4h, #0
+;
+  %res = tail call <4 x half> @llvm.aarch64.neon.vcmla.rot0.v4f16(<4 x half> 
%a, <4 x half> %b, <4 x half> %c)
+  ret <4 x half> %res
+}
+
+
+define <4 x half> @test_rot90_16x4(<4 x half> %a, <4 x half> %b, <4 x half> 
%c) {
+entry:
+; CHECK-LABEL: test_rot90_16x4
+; CHECK: fcmla v{{[0-9]+}}.4h, v{{[0-9]+}}.4h, v{{[0-9]+}}.4h, #90
+;
+  %res = tail call <4 x half> @llvm.aarch64.neon.vcmla.rot90.v4f16(<4 x half> 
%a, <4 x half> %b, <4 x half> %c)
+  ret <4 x half> %res
+}
+
+define <4 x half> @test_rot180_16x4(<4 x half> %a, <4 x half> %b, <4 x half> 
%c) {
+entry:
+; CHECK-LABEL: test_rot180_16x4
+; CHECK: fcmla v{{[0-9]+}}.4h, v{{[0-9]+}}.4h, v{{[0-9]+}}.4h, #180
+;
+  %res = tail call <4 x half> @llvm.aarch64.neon.vcmla.rot180.v4f16(<4 x half> 
%a, <4 x half> %b, <4 x half> %c)
+  ret <4 x half> %res
+}
+
+define <4 x half> @test_rot270_16x4(<4 x half> %a, <4 x half> %b, <4 x half> 
%c) {
+entry:
+; CHECK-LABEL: test_rot270_16x4
+; CHECK: fcmla v{{[0-9]+}}.4h, v{{[0-9]+}}.4h, v{{[0-9]+}}.4h, #270
+;
+  %res = tail call <4 x half> @llvm.aarch64.neon.vcmla.rot270.v4f16(<4 x half> 
%a, <4 x half> %b, <4 x half> %c)
+  ret <4 x half> %res
+}
+
+define <2 x float> @test_32x2(<2 x float> %a, <2 x float> %b, <2 x float> %c) {
+entry:
+; CHECK-LABEL: test_32x2
+; CHECK: fcmla v{{[0-9]+}}.2s, v{{[0-9]+}}.2s, v{{[0-9]+}}.2s, #0
+;
+  %res = tail call <2 x float> @llvm.aarch64.neon.vcmla.rot0.v2f32(<2 x float> 
%a, <2 x float> %b, <2 x float> %c)
+  ret <2 x float> %res
+}
+
+define <2 x float

[llvm-branch-commits] [compiler-rt] 9f8aeb0 - scudo: Split setRandomTag in two. NFCI.

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

Author: Peter Collingbourne
Date: 2020-12-09T11:48:41-08:00
New Revision: 9f8aeb0602935f7bb49fb093fedaad5ec4e87497

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

LOG: scudo: Split setRandomTag in two. NFCI.

Separate the IRG part from the STZG part since we will need to use
the latter on its own for some upcoming changes.

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

Added: 


Modified: 
compiler-rt/lib/scudo/standalone/memtag.h

Removed: 




diff  --git a/compiler-rt/lib/scudo/standalone/memtag.h 
b/compiler-rt/lib/scudo/standalone/memtag.h
index b9f8ccd41627..4b22c727849d 100644
--- a/compiler-rt/lib/scudo/standalone/memtag.h
+++ b/compiler-rt/lib/scudo/standalone/memtag.h
@@ -21,6 +21,9 @@
 
 namespace scudo {
 
+void setRandomTag(void *Ptr, uptr Size, uptr ExcludeMask, uptr *TaggedBegin,
+  uptr *TaggedEnd);
+
 #if defined(__aarch64__) || defined(SCUDO_FUZZ)
 
 inline constexpr bool archSupportsMemoryTagging() { return true; }
@@ -91,37 +94,32 @@ class ScopedDisableMemoryTagChecks {
   }
 };
 
-inline void setRandomTag(void *Ptr, uptr Size, uptr ExcludeMask,
- uptr *TaggedBegin, uptr *TaggedEnd) {
-  void *End;
+inline uptr selectRandomTag(uptr Ptr, uptr ExcludeMask) {
+  uptr TaggedPtr;
   __asm__ __volatile__(
-  R"(
-.arch_extension mte
-
-// Set a random tag for Ptr in TaggedPtr. This needs to happen even if
-// Size = 0 so that TaggedPtr ends up pointing at a valid address.
-irg %[TaggedPtr], %[Ptr], %[ExcludeMask]
-mov %[Cur], %[TaggedPtr]
-
-// Skip the loop if Size = 0. We don't want to do any tagging in this case.
-cbz %[Size], 2f
-
-// Set the memory tag of the region
-// [TaggedPtr, TaggedPtr + roundUpTo(Size, 16))
-// to the pointer tag stored in TaggedPtr.
-add %[End], %[TaggedPtr], %[Size]
-
-  1:
-stzg %[Cur], [%[Cur]], #16
-cmp %[Cur], %[End]
-b.lt 1b
+  ".arch_extension mte; irg %[TaggedPtr], %[Ptr], %[ExcludeMask]"
+  : [TaggedPtr] "=r"(TaggedPtr)
+  : [Ptr] "r"(Ptr), [ExcludeMask] "r"(ExcludeMask));
+  return TaggedPtr;
+}
 
-  2:
-  )"
-  :
-  [TaggedPtr] "=&r"(*TaggedBegin), [Cur] "=&r"(*TaggedEnd), [End] 
"=&r"(End)
-  : [Ptr] "r"(Ptr), [Size] "r"(Size), [ExcludeMask] "r"(ExcludeMask)
-  : "memory");
+inline uptr storeTags(uptr Begin, uptr End) {
+  DCHECK(Begin % 16 == 0);
+  if (Begin != End) {
+__asm__ __volatile__(
+R"(
+  .arch_extension mte
+
+1:
+  stzg %[Cur], [%[Cur]], #16
+  cmp %[Cur], %[End]
+  b.lt 1b
+)"
+: [Cur] "+&r"(Begin)
+: [End] "r"(End)
+: "memory");
+  }
+  return Begin;
 }
 
 inline void *prepareTaggedChunk(void *Ptr, uptr Size, uptr ExcludeMask,
@@ -224,13 +222,15 @@ struct ScopedDisableMemoryTagChecks {
   ScopedDisableMemoryTagChecks() {}
 };
 
-inline void setRandomTag(void *Ptr, uptr Size, uptr ExcludeMask,
- uptr *TaggedBegin, uptr *TaggedEnd) {
+inline uptr selectRandomTag(uptr Ptr, uptr ExcludeMask) {
   (void)Ptr;
-  (void)Size;
   (void)ExcludeMask;
-  (void)TaggedBegin;
-  (void)TaggedEnd;
+  UNREACHABLE("memory tagging not supported");
+}
+
+inline uptr storeTags(uptr Begin, uptr End) {
+  (void)Begin;
+  (void)End;
   UNREACHABLE("memory tagging not supported");
 }
 
@@ -257,6 +257,12 @@ inline uptr loadTag(uptr Ptr) {
 
 #endif
 
+inline void setRandomTag(void *Ptr, uptr Size, uptr ExcludeMask,
+ uptr *TaggedBegin, uptr *TaggedEnd) {
+  *TaggedBegin = selectRandomTag(reinterpret_cast(Ptr), ExcludeMask);
+  *TaggedEnd = storeTags(*TaggedBegin, *TaggedBegin + Size);
+}
+
 } // namespace scudo
 
 #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] [compiler-rt] e5a28e1 - scudo: Fix quarantine allocation when MTE enabled.

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

Author: Peter Collingbourne
Date: 2020-12-09T11:48:41-08:00
New Revision: e5a28e1261a0c42821cb3bd4dc40092c458fadfb

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

LOG: scudo: Fix quarantine allocation when MTE enabled.

Quarantines have always been broken when MTE is enabled because the
quarantine batch allocator fails to reset tags that may have been
left behind by a user allocation.

This was only noticed when running the Scudo unit tests with Scudo
as the system allocator because quarantines are turned off by
default on Android and the test binary turns them on by defining
__scudo_default_options, which affects the system allocator as well.

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

Added: 


Modified: 
compiler-rt/lib/scudo/standalone/combined.h

Removed: 




diff  --git a/compiler-rt/lib/scudo/standalone/combined.h 
b/compiler-rt/lib/scudo/standalone/combined.h
index 2a891e44579a..95988443d5b3 100644
--- a/compiler-rt/lib/scudo/standalone/combined.h
+++ b/compiler-rt/lib/scudo/standalone/combined.h
@@ -98,6 +98,12 @@ class Allocator {
   Header.State = Chunk::State::Allocated;
   Chunk::storeHeader(Allocator.Cookie, Ptr, &Header);
 
+  // Reset tag to 0 as this chunk may have been previously used for a 
tagged
+  // user allocation.
+  if (UNLIKELY(Allocator.useMemoryTagging()))
+storeTags(reinterpret_cast(Ptr),
+  reinterpret_cast(Ptr) + sizeof(QuarantineBatch));
+
   return Ptr;
 }
 



___
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] 8278922 - Frontend: Migrate to FileEntryRef in VerifyDiagnosticConsumer.cpp, NFC

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

Author: Duncan P. N. Exon Smith
Date: 2020-12-09T11:51:43-08:00
New Revision: 82789228c65317ceea3fdcc08c573c5ca780021e

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

LOG: Frontend: Migrate to FileEntryRef in VerifyDiagnosticConsumer.cpp, NFC

Add a `FileEntryRef` overload of `SourceManager::translateFile`, and
migrate `ParseDirective` in VerifyDiagnosticConsumer.cpp to use it and
the corresponding overload of `createFileID`.

No functionality change here.

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

Added: 


Modified: 
clang/include/clang/Basic/SourceManager.h
clang/lib/Frontend/VerifyDiagnosticConsumer.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/SourceManager.h 
b/clang/include/clang/Basic/SourceManager.h
index 459bd088f0d7..05edc98f9ec8 100644
--- a/clang/include/clang/Basic/SourceManager.h
+++ b/clang/include/clang/Basic/SourceManager.h
@@ -1582,6 +1582,9 @@ class SourceManager : public 
RefCountedBase {
   /// If the source file is included multiple times, the FileID will be the
   /// first inclusion.
   FileID translateFile(const FileEntry *SourceFile) const;
+  FileID translateFile(FileEntryRef SourceFile) const {
+return translateFile(&SourceFile.getFileEntry());
+  }
 
   /// Get the source location in \p FID for the given line:col.
   /// Returns null location if \p FID is not a file SLocEntry.

diff  --git a/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp 
b/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
index a10a3dd8a446..0503ae46a15f 100644
--- a/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
+++ b/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
@@ -554,10 +554,9 @@ static bool ParseDirective(StringRef S, ExpectedData *ED, 
SourceManager &SM,
 continue;
   }
 
-  const FileEntry *FE = &File->getFileEntry();
-  FileID FID = SM.translateFile(FE);
+  FileID FID = SM.translateFile(*File);
   if (FID.isInvalid())
-FID = SM.createFileID(FE, Pos, SrcMgr::C_User);
+FID = SM.createFileID(*File, Pos, SrcMgr::C_User);
 
   if (PH.Next(Line) && Line > 0)
 ExpectedLoc = SM.translateLineCol(FID, Line, 1);



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


[llvm-branch-commits] [lld] baef18d - [ELF] Reorganize "is only supported on" tests and fix some diagnostics

2020-12-09 Thread Fangrui Song via llvm-branch-commits

Author: Fangrui Song
Date: 2020-12-09T12:14:00-08:00
New Revision: baef18dffba1a2f91b47b484ac2233dfcf923f9b

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

LOG: [ELF] Reorganize "is only supported on" tests and fix some diagnostics

Added: 
lld/test/ELF/target-specific-options.s

Modified: 
lld/ELF/Driver.cpp

Removed: 
lld/test/ELF/aarch64-cortex-a53-843419-cli.s
lld/test/ELF/ppc64-tocopt-option.s



diff  --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index 2350a0e33638..4c183394ca89 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -317,10 +317,10 @@ static void checkOptions() {
 error("--fix-cortex-a8 is only supported on ARM targets");
 
   if (config->tocOptimize && config->emachine != EM_PPC64)
-error("--toc-optimize is only supported on the PowerPC64 target");
+error("--toc-optimize is only supported on PowerPC64 targets");
 
   if (config->pcRelOptimize && config->emachine != EM_PPC64)
-error("--pcrel--optimize is only supported on the PowerPC64 target");
+error("--pcrel-optimize is only supported on PowerPC64 targets");
 
   if (config->pie && config->shared)
 error("-shared and -pie may not be used together");

diff  --git a/lld/test/ELF/aarch64-cortex-a53-843419-cli.s 
b/lld/test/ELF/aarch64-cortex-a53-843419-cli.s
deleted file mode 100644
index b19f6c3cd251..
--- a/lld/test/ELF/aarch64-cortex-a53-843419-cli.s
+++ /dev/null
@@ -1,10 +0,0 @@
-// REQUIRES: x86
-// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
-// RUN: not ld.lld %t -fix-cortex-a53-843419 -o /dev/null 2>&1 | FileCheck %s
-
-// CHECK: --fix-cortex-a53-843419 is only supported on AArch64 targets
-.globl entry
-.text
-.quad 0
-entry:
-ret

diff  --git a/lld/test/ELF/ppc64-tocopt-option.s 
b/lld/test/ELF/ppc64-tocopt-option.s
deleted file mode 100644
index 78494346beb5..
--- a/lld/test/ELF/ppc64-tocopt-option.s
+++ /dev/null
@@ -1,14 +0,0 @@
-# REQUIRES: x86
-
-# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
-# RUN: not ld.lld %t --toc-optimize -o /dev/null 2>&1 | FileCheck %s
-
-# CHECK: error: --toc-optimize is only supported on the PowerPC64 target
-
- .global __start
- .type __start,@function
-
- .text
-.quad 0
- __start:
-

diff  --git a/lld/test/ELF/target-specific-options.s 
b/lld/test/ELF/target-specific-options.s
new file mode 100644
index ..76227803f935
--- /dev/null
+++ b/lld/test/ELF/target-specific-options.s
@@ -0,0 +1,14 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t
+
+# RUN: not ld.lld %t --fix-cortex-a53-843419 -o /dev/null 2>&1 | FileCheck %s 
--check-prefix=ERR-843419
+# ERR-843419: error: --fix-cortex-a53-843419 is only supported on AArch64 
targets
+
+# RUN: not ld.lld %t --pcrel-optimize -o /dev/null 2>&1 | FileCheck %s 
--check-prefix=ERR-PCREL
+# ERR-PCREL: error: --pcrel-optimize is only supported on PowerPC64 targets
+
+# RUN: not ld.lld %t --toc-optimize -o /dev/null 2>&1 | FileCheck %s 
--check-prefix=ERR-TOC
+# ERR-TOC: error: --toc-optimize is only supported on PowerPC64 targets
+
+.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


[llvm-branch-commits] [clang] 4ae8651 - Add another test for PR48434.

2020-12-09 Thread Richard Smith via llvm-branch-commits

Author: Richard Smith
Date: 2020-12-09T12:22:35-08:00
New Revision: 4ae8651c59241bca0c1ea5adaf8f06b292696b6f

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

LOG: Add another test for PR48434.

Added: 


Modified: 
clang/test/PCH/decl-attrs.cpp

Removed: 




diff  --git a/clang/test/PCH/decl-attrs.cpp b/clang/test/PCH/decl-attrs.cpp
index c89354d0c5de..249107001874 100644
--- a/clang/test/PCH/decl-attrs.cpp
+++ b/clang/test/PCH/decl-attrs.cpp
@@ -12,6 +12,18 @@ namespace preferred_name {
   Y y;
 }
 
+namespace aligned {
+  // PR48434: ensure attributes don't introduce deserialization cycles.
+  template struct X1;
+  using Y1 = X1;
+  template struct alignas(Y1*) X1 {};
+  Y1 y1;
+
+  template struct X2;
+  using Y2 = X2;
+  template struct alignas(Y2*) X2 {};
+}
+
 #else
 
 namespace preferred_name {
@@ -24,4 +36,11 @@ namespace preferred_name {
   }
 }
 
+namespace aligned {
+  extern Y1 y1;
+  extern Y2 y2;
+  static_assert(alignof(Y1) == alignof(Y1*), "");
+  static_assert(alignof(Y2) == alignof(Y2*), "");
+}
+
 #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] [clang] 2a2c228 - Add new 'preferred_name' attribute.

2020-12-09 Thread Richard Smith via llvm-branch-commits

Author: Richard Smith
Date: 2020-12-09T12:22:35-08:00
New Revision: 2a2c228c7ada0a5d77c48b4d445ab0013ca0ae19

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

LOG: Add new 'preferred_name' attribute.

This attribute permits a typedef to be associated with a class template
specialization as a preferred way of naming that class template
specialization. This permits us to specify that (for example) the
preferred way to express 'std::basic_string' is as 'std::string'.

The attribute is applied to the various class templates in libc++ that have
corresponding well-known typedef names.

This is a re-commit. The previous commit was reverted because it exposed
a pre-existing bug that has since been fixed / worked around; see
PR48434.

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

Added: 
clang/test/PCH/decl-attrs.cpp

Modified: 
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/AttrDocs.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/AST/TypePrinter.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/lib/Sema/SemaTemplate.cpp
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/test/SemaTemplate/attributes.cpp
clang/utils/TableGen/ClangAttrEmitter.cpp
libcxx/include/__config
libcxx/include/iosfwd
libcxx/include/regex
libcxx/include/string
libcxx/include/string_view

Removed: 




diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 52041201d22f..51f654fc7613 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -126,6 +126,9 @@ def FunctionTmpl
  FunctionDecl::TK_FunctionTemplate}],
 "function templates">;
 
+def ClassTmpl : SubsetSubjectgetDescribedClassTemplate()}],
+  "class templates">;
+
 // FIXME: this hack is needed because DeclNodes.td defines the base Decl node
 // type to be a class, not a definition. This makes it impossible to create an
 // attribute subject which accepts a Decl. Normally, this is not a problem,
@@ -2391,6 +2394,16 @@ def Pascal : DeclOrTypeAttr {
   let Documentation = [Undocumented];
 }
 
+def PreferredName : InheritableAttr {
+  let Spellings = [Clang<"preferred_name", /*AllowInC*/0>];
+  let Subjects = SubjectList<[ClassTmpl]>;
+  let Args = [TypeArgument<"TypedefType">];
+  let Documentation = [PreferredNameDocs];
+  let InheritEvenIfAlreadyPresent = 1;
+  let MeaningfulToClassTemplateDefinition = 1;
+  let TemplateDependent = 1;
+}
+
 def PreserveMost : DeclOrTypeAttr {
   let Spellings = [Clang<"preserve_most">];
   let Documentation = [PreserveMostDocs];

diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index e7e2805a9608..28f35cf2c0c7 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -4471,6 +4471,30 @@ the old mangled name and the new code will use the new 
mangled name with tags.
   }];
 }
 
+def PreferredNameDocs : Documentation {
+  let Category = DocCatDecl;
+  let Content = [{
+The ``preferred_name`` attribute can be applied to a class template, and
+specifies a preferred way of naming a specialization of the template. The
+preferred name will be used whenever the corresponding template specialization
+would otherwise be printed in a diagnostic or similar context.
+
+The preferred name must be a typedef or type alias declaration that refers to a
+specialization of the class template (not including any type qualifiers). In
+general this requires the template to be declared at least twice. For example:
+
+.. code-block:: c++
+
+  template struct basic_string;
+  using string = basic_string;
+  using wstring = basic_string;
+  template struct [[clang::preferred_name(string),
+clang::preferred_name(wstring)]] basic_string {
+// ...
+  };
+  }];
+}
+
 def PreserveMostDocs : Documentation {
   let Category = DocCatCallingConvs;
   let Content = [{

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 4a5402455301..97773d35a694 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -3941,6 +3941,9 @@ def note_protocol_decl : Note<
   "protocol is declared here">;
 def note_protocol_decl_undefined : Note<
   "protocol %0 has no definition">;
+def err_attribute_preferred_name_arg_invalid : Error<
+  "argument %0 to 'preferred_name' attribute is not a typedef for "
+  "a specialization of %1">;
 
 // objc_designated_initializer attribute diagnostics.
 def warn_objc_designated_init_missing_super_call : Warning<

diff  --git a/clang/lib/AST/TypePrinter.cpp b/clang/lib/AST/T

[llvm-branch-commits] [clang] 997a719 - PR48434: Work around crashes due to deserialization cycles via typedefs.

2020-12-09 Thread Richard Smith via llvm-branch-commits

Author: Richard Smith
Date: 2020-12-09T12:22:35-08:00
New Revision: 997a719d5a70100fcbbec1e51ce44cd66041bddc

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

LOG: PR48434: Work around crashes due to deserialization cycles via typedefs.

Ensure that we can deserialize a TypedefType even while in the middle of
deserializing its TypedefDecl, by removing the need to look at the
TypedefDecl while constructing the TypedefType.

This fixes all the currently-known failures for PR48434, but it's not a
complete fix, because we can still trigger deserialization cycles, which
are not supposed to happen.

Added: 


Modified: 
clang/include/clang/AST/ASTContext.h
clang/include/clang/AST/Type.h
clang/include/clang/AST/TypeProperties.td
clang/lib/AST/ASTContext.cpp
clang/lib/AST/Type.cpp
clang/test/PCH/cxx-templates.cpp
clang/test/PCH/cxx-templates.h

Removed: 




diff  --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 7d58b426a3df..0a635875207d 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -1430,7 +1430,7 @@ class ASTContext : public RefCountedBase {
   /// Return the unique reference to the type for the specified
   /// typedef-name decl.
   QualType getTypedefType(const TypedefNameDecl *Decl,
-  QualType Canon = QualType()) const;
+  QualType Underlying = QualType()) const;
 
   QualType getRecordType(const RecordDecl *Decl) const;
 

diff  --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 60b8ee0f1614..99cfa3ae76f5 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -4362,10 +4362,11 @@ class UnresolvedUsingType : public Type {
 class TypedefType : public Type {
   TypedefNameDecl *Decl;
 
-protected:
+private:
   friend class ASTContext; // ASTContext creates these.
 
-  TypedefType(TypeClass tc, const TypedefNameDecl *D, QualType can);
+  TypedefType(TypeClass tc, const TypedefNameDecl *D, QualType underlying,
+  QualType can);
 
 public:
   TypedefNameDecl *getDecl() const { return Decl; }

diff  --git a/clang/include/clang/AST/TypeProperties.td 
b/clang/include/clang/AST/TypeProperties.td
index a183ac0479c6..b582395c44a6 100644
--- a/clang/include/clang/AST/TypeProperties.td
+++ b/clang/include/clang/AST/TypeProperties.td
@@ -484,8 +484,12 @@ let Class = TagType in {
 let Read = [{ node->isDependentType() }];
   }
   def : Property<"declaration", DeclRef> {
-// Serializing a reference to the canonical declaration is apparently
-// necessary to make module-merging work.
+// We don't know which declaration was originally referenced here, and we
+// cannot reference a declaration that follows the use (because that can
+// introduce deserialization cycles), so conservatively generate a
+// reference to the first declaration.
+// FIXME: If this is a reference to a class template specialization, that
+// can still introduce a deserialization cycle.
 let Read = [{ node->getDecl()->getCanonicalDecl() }];
   }
 }

diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index c52369cd8a02..057574ec2b82 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -4449,15 +4449,15 @@ QualType ASTContext::getTypeDeclTypeSlow(const TypeDecl 
*Decl) const {
 
 /// getTypedefType - Return the unique reference to the type for the
 /// specified typedef name decl.
-QualType
-ASTContext::getTypedefType(const TypedefNameDecl *Decl,
-   QualType Canonical) const {
+QualType ASTContext::getTypedefType(const TypedefNameDecl *Decl,
+QualType Underlying) const {
   if (Decl->TypeForDecl) return QualType(Decl->TypeForDecl, 0);
 
-  if (Canonical.isNull())
-Canonical = getCanonicalType(Decl->getUnderlyingType());
+  if (Underlying.isNull())
+Underlying = Decl->getUnderlyingType();
+  QualType Canonical = getCanonicalType(Underlying);
   auto *newType = new (*this, TypeAlignment)
-TypedefType(Type::Typedef, Decl, Canonical);
+  TypedefType(Type::Typedef, Decl, Underlying, Canonical);
   Decl->TypeForDecl = newType;
   Types.push_back(newType);
   return QualType(newType, 0);

diff  --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index c07cab9a4006..aa623b000fb5 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -3369,8 +3369,9 @@ void FunctionProtoType::Profile(llvm::FoldingSetNodeID 
&ID,
   getExtProtoInfo(), Ctx, isCanonicalUnqualified());
 }
 
-TypedefType::TypedefType(TypeClass tc, const TypedefNameDecl *D, QualType can)
-: Type(tc, can, D->getUnderlyingType()->getDependence()),
+TypedefT

[llvm-branch-commits] [clang] a5e6590 - [ASTImporter] Support CXXDeductionGuideDecl with local typedef

2020-12-09 Thread Gabor Marton via llvm-branch-commits

Author: Gabor Marton
Date: 2020-12-09T21:25:04+01:00
New Revision: a5e6590b15b17793d7a82f8b39998381acb73109

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

LOG: [ASTImporter] Support CXXDeductionGuideDecl with local typedef

CXXDeductionGuideDecl with a local typedef has its own copy of the
TypedefDecl with the CXXDeductionGuideDecl as the DeclContext of that
TypedefDecl.
```
  template  struct A {
typedef T U;
A(U, T);
  };
  A a{(int)0, (int)0};
```
Related discussion on cfe-dev:
http://lists.llvm.org/pipermail/cfe-dev/2020-November/067252.html

Without this fix, when we import the CXXDeductionGuideDecl (via
VisitFunctionDecl) then before creating the Decl we must import the
FunctionType. However, the first parameter's type is the afore mentioned
local typedef. So, we then start importing the TypedefDecl whose
DeclContext is the CXXDeductionGuideDecl itself. The infinite loop is
formed.
```
 #0 
clang::ASTNodeImporter::VisitCXXDeductionGuideDecl(clang::CXXDeductionGuideDecl*)
 clang/lib/AST/ASTImporter.cpp:3543:0
 #1 clang::declvisitor::Base >::Visit(clang::Decl*) 
/home/egbomrt/WORK/llvm5/build/debug/tools/clang/include/clang/AST/DeclNodes.inc:405:0
 #2 clang::ASTImporter::ImportImpl(clang::Decl*) 
clang/lib/AST/ASTImporter.cpp:8038:0
 #3 clang::ASTImporter::Import(clang::Decl*) 
clang/lib/AST/ASTImporter.cpp:8200:0
 #4 clang::ASTImporter::ImportContext(clang::DeclContext*) 
clang/lib/AST/ASTImporter.cpp:8297:0
 #5 clang::ASTNodeImporter::ImportDeclContext(clang::Decl*, 
clang::DeclContext*&, clang::DeclContext*&) clang/lib/AST/ASTImporter.cpp:1852:0
 #6 clang::ASTNodeImporter::ImportDeclParts(clang::NamedDecl*, 
clang::DeclContext*&, clang::DeclContext*&, clang::DeclarationName&, 
clang::NamedDecl*&, clang::SourceLocation&) clang/lib/AST/ASTImporter.cpp:1628:0
 #7 clang::ASTNodeImporter::VisitTypedefNameDecl(clang::TypedefNameDecl*, bool) 
clang/lib/AST/ASTImporter.cpp:2419:0
 #8 clang::ASTNodeImporter::VisitTypedefDecl(clang::TypedefDecl*) 
clang/lib/AST/ASTImporter.cpp:2500:0
 #9 clang::declvisitor::Base >::Visit(clang::Decl*) 
/home/egbomrt/WORK/llvm5/build/debug/tools/clang/include/clang/AST/DeclNodes.inc:315:0
 #10 clang::ASTImporter::ImportImpl(clang::Decl*) 
clang/lib/AST/ASTImporter.cpp:8038:0
 #11 clang::ASTImporter::Import(clang::Decl*) 
clang/lib/AST/ASTImporter.cpp:8200:0
 #12 llvm::Expected 
clang::ASTNodeImporter::import(clang::TypedefNameDecl*) 
clang/lib/AST/ASTImporter.cpp:165:0
 #13 clang::ASTNodeImporter::VisitTypedefType(clang::TypedefType const*) 
clang/lib/AST/ASTImporter.cpp:1304:0
 #14 clang::TypeVisitor 
>::Visit(clang::Type const*) 
/home/egbomrt/WORK/llvm5/build/debug/tools/clang/include/clang/AST/TypeNodes.inc:74:0
 #15 clang::ASTImporter::Import(clang::QualType) 
clang/lib/AST/ASTImporter.cpp:8071:0
 #16 llvm::Expected 
clang::ASTNodeImporter::import(clang::QualType const&) 
clang/lib/AST/ASTImporter.cpp:179:0
 #17 clang::ASTNodeImporter::VisitFunctionProtoType(clang::FunctionProtoType 
const*) clang/lib/AST/ASTImporter.cpp:1244:0
 #18 clang::TypeVisitor 
>::Visit(clang::Type const*) 
/home/egbomrt/WORK/llvm5/build/debug/tools/clang/include/clang/AST/TypeNodes.inc:47:0
 #19 clang::ASTImporter::Import(clang::QualType) 
clang/lib/AST/ASTImporter.cpp:8071:0
 #20 llvm::Expected 
clang::ASTNodeImporter::import(clang::QualType const&) 
clang/lib/AST/ASTImporter.cpp:179:0
 #21 clang::QualType 
clang::ASTNodeImporter::importChecked(llvm::Error&, 
clang::QualType const&) clang/lib/AST/ASTImporter.cpp:198:0
 #22 clang::ASTNodeImporter::VisitFunctionDecl(clang::FunctionDecl*) 
clang/lib/AST/ASTImporter.cpp:3313:0
 #23 
clang::ASTNodeImporter::VisitCXXDeductionGuideDecl(clang::CXXDeductionGuideDecl*)
 clang/lib/AST/ASTImporter.cpp:3543:0
```

The fix is to first create the TypedefDecl and only then start to import
the DeclContext.
Basically, we could do this during the import of all other Decls (not
just for typedefs). But it seems, there is only one another AST
construct that has a similar cycle: a struct defined as a function
parameter:
```
int struct_in_proto(struct data_t{int a;int b;} *d);

```
In that case, however, we had decided to return simply with an error
back then because that seemed to be a very rare construct.

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

Added: 


Modified: 
clang/lib/AST/ASTImporter.cpp
clang/unittests/AST/ASTImporterTest.cpp

Removed: 




diff  --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index 50632efc281f..ea05f2ea4552 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -388,6 +388,8 @@ namespace clang {
 ExpectedType VisitObjCObjectPointerType(const ObjCObjectPointerType *T);
 
 // Importing declarations
+Err

[llvm-branch-commits] [openmp] 9b7d6a6 - [OpenMP] Fix too long name for shm segment on macOS

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

Author: Peyton, Jonathan L
Date: 2020-12-09T14:31:15-06:00
New Revision: 9b7d6a6bffce14c766eaa90c7a3d3b8d192cdfb0

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

LOG: [OpenMP] Fix too long name for shm segment on macOS

Remove the user id component to the shm segment name and just use
the pid like before.

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

Added: 


Modified: 
openmp/runtime/src/kmp_runtime.cpp

Removed: 




diff  --git a/openmp/runtime/src/kmp_runtime.cpp 
b/openmp/runtime/src/kmp_runtime.cpp
index cdcfdb0be178..f6d4524150f0 100644
--- a/openmp/runtime/src/kmp_runtime.cpp
+++ b/openmp/runtime/src/kmp_runtime.cpp
@@ -6356,11 +6356,12 @@ static char *__kmp_registration_str = NULL;
 // Value to be saved in env var __KMP_REGISTERED_LIB_.
 
 static inline char *__kmp_reg_status_name() {
-  /* On RHEL 3u5 if linked statically, getpid() returns 
diff erent values in
- each thread. If registration and unregistration go in 
diff erent threads
- (omp_misc_other_root_exit.cpp test case), the name of registered_lib_env
- env var can not be found, because the name will contain 
diff erent pid. */
-#if KMP_OS_UNIX && KMP_DYNAMIC_LIB // shared memory is with dynamic library
+/* On RHEL 3u5 if linked statically, getpid() returns 
diff erent values in
+   each thread. If registration and unregistration go in 
diff erent threads
+   (omp_misc_other_root_exit.cpp test case), the name of registered_lib_env
+   env var can not be found, because the name will contain 
diff erent pid. */
+// macOS* complains about name being too long with additional getuid()
+#if KMP_OS_UNIX && !KMP_OS_DARWIN && KMP_DYNAMIC_LIB
   return __kmp_str_format("__KMP_REGISTERED_LIB_%d_%d", (int)getpid(),
   (int)getuid());
 #else



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


[llvm-branch-commits] [openmp] fe3b244 - [OpenMP] Fix norespect affinity bug for Windows

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

Author: Peyton, Jonathan L
Date: 2020-12-09T14:32:48-06:00
New Revision: fe3b244ef7c2656c5876ff3f91232406f9854c42

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

LOG: [OpenMP] Fix norespect affinity bug for Windows

KMP_AFFINITY=norespect was triggering an error because the underlying
process affinity mask was not updated to include the entire machine.
The Windows documentation states that the thread affinities must be
subsets of the process affinity. This patch also moves the printing
(for KMP_AFFINITY=verbose) of whether the initial mask was respected
out of each topology detection function and to one location where the
initial affinity mask is read.

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

Added: 


Modified: 
openmp/runtime/src/kmp.h
openmp/runtime/src/kmp_affinity.cpp
openmp/runtime/src/kmp_affinity.h

Removed: 




diff  --git a/openmp/runtime/src/kmp.h b/openmp/runtime/src/kmp.h
index 7a8f7d28f461..e450b128a005 100644
--- a/openmp/runtime/src/kmp.h
+++ b/openmp/runtime/src/kmp.h
@@ -694,6 +694,9 @@ class KMPAffinity {
 virtual int begin() const { return 0; }
 virtual int end() const { return 0; }
 virtual int next(int previous) const { return 0; }
+#if KMP_OS_WINDOWS
+virtual int set_process_affinity(bool abort_on_error) const { return -1; }
+#endif
 // Set the system's affinity to this affinity mask's value
 virtual int set_system_affinity(bool abort_on_error) const { return -1; }
 // Set this affinity mask to the current system affinity

diff  --git a/openmp/runtime/src/kmp_affinity.cpp 
b/openmp/runtime/src/kmp_affinity.cpp
index 10ba3e5125dc..8f77f36ed5be 100644
--- a/openmp/runtime/src/kmp_affinity.cpp
+++ b/openmp/runtime/src/kmp_affinity.cpp
@@ -729,15 +729,7 @@ static int __kmp_affinity_create_hwloc_map(AddrUnsPair 
**address2os,
 __kmp_ncores = nPackages = 1;
 __kmp_nThreadsPerCore = nCoresPerPkg = 1;
 if (__kmp_affinity_verbose) {
-  char buf[KMP_AFFIN_MASK_PRINT_LEN];
-  __kmp_affinity_print_mask(buf, KMP_AFFIN_MASK_PRINT_LEN, oldMask);
-
   KMP_INFORM(AffUsingHwloc, "KMP_AFFINITY");
-  if (__kmp_affinity_respect_mask) {
-KMP_INFORM(InitOSProcSetRespect, "KMP_AFFINITY", buf);
-  } else {
-KMP_INFORM(InitOSProcSetNotRespect, "KMP_AFFINITY", buf);
-  }
   KMP_INFORM(AvailableOSProc, "KMP_AFFINITY", __kmp_avail_proc);
   KMP_INFORM(Uniform, "KMP_AFFINITY");
   KMP_INFORM(Topology, "KMP_AFFINITY", nPackages, nCoresPerPkg,
@@ -791,13 +783,6 @@ static int __kmp_affinity_create_hwloc_map(AddrUnsPair 
**address2os,
 
   // Print the machine topology summary.
   if (__kmp_affinity_verbose) {
-char mask[KMP_AFFIN_MASK_PRINT_LEN];
-__kmp_affinity_print_mask(mask, KMP_AFFIN_MASK_PRINT_LEN, oldMask);
-if (__kmp_affinity_respect_mask) {
-  KMP_INFORM(InitOSProcSetRespect, "KMP_AFFINITY", mask);
-} else {
-  KMP_INFORM(InitOSProcSetNotRespect, "KMP_AFFINITY", mask);
-}
 KMP_INFORM(AvailableOSProc, "KMP_AFFINITY", __kmp_avail_proc);
 if (uniform) {
   KMP_INFORM(Uniform, "KMP_AFFINITY");
@@ -898,16 +883,7 @@ static int __kmp_affinity_create_flat_map(AddrUnsPair 
**address2os,
   __kmp_ncores = nPackages = __kmp_avail_proc;
   __kmp_nThreadsPerCore = nCoresPerPkg = 1;
   if (__kmp_affinity_verbose) {
-char buf[KMP_AFFIN_MASK_PRINT_LEN];
-__kmp_affinity_print_mask(buf, KMP_AFFIN_MASK_PRINT_LEN,
-  __kmp_affin_fullMask);
-
 KMP_INFORM(AffCapableUseFlat, "KMP_AFFINITY");
-if (__kmp_affinity_respect_mask) {
-  KMP_INFORM(InitOSProcSetRespect, "KMP_AFFINITY", buf);
-} else {
-  KMP_INFORM(InitOSProcSetNotRespect, "KMP_AFFINITY", buf);
-}
 KMP_INFORM(AvailableOSProc, "KMP_AFFINITY", __kmp_avail_proc);
 KMP_INFORM(Uniform, "KMP_AFFINITY");
 KMP_INFORM(Topology, "KMP_AFFINITY", nPackages, nCoresPerPkg,
@@ -1273,15 +1249,7 @@ static int __kmp_affinity_create_apicid_map(AddrUnsPair 
**address2os,
 __kmp_ncores = nPackages = 1;
 __kmp_nThreadsPerCore = nCoresPerPkg = 1;
 if (__kmp_affinity_verbose) {
-  char buf[KMP_AFFIN_MASK_PRINT_LEN];
-  __kmp_affinity_print_mask(buf, KMP_AFFIN_MASK_PRINT_LEN, oldMask);
-
   KMP_INFORM(AffUseGlobCpuid, "KMP_AFFINITY");
-  if (__kmp_affinity_respect_mask) {
-KMP_INFORM(InitOSProcSetRespect, "KMP_AFFINITY", buf);
-  } else {
-KMP_INFORM(InitOSProcSetNotRespect, "KMP_AFFINITY", buf);
-  }
   KMP_INFORM(AvailableOSProc, "KMP_AFFINITY", __kmp_avail_proc);
   KMP_INFORM(Uniform, "KMP_AFFINITY");
   KMP_INFORM(Topology, "KMP_AFFINITY", nPackages, nCoresPerPkg,
@@ -1406,15 +1374,7 @@ static int __kmp_affinity_create_apicid_map(AddrUnsPair 
**address2os,
   // not enable

[llvm-branch-commits] [mlir] 2d3b9fd - [mlir][Affine] Fix vectorizability check for multiple load/stores

2020-12-09 Thread Diego Caballero via llvm-branch-commits

Author: Sergei Grechanik
Date: 2020-12-09T12:19:34-08:00
New Revision: 2d3b9fdc193fa835313f09f526b51bf6de3a54ef

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

LOG: [mlir][Affine] Fix vectorizability check for multiple load/stores

This patch fixes a bug that allowed vectorizing of loops with loads and
stores having indexing functions varying along different memory
dimensions.

Reviewed By: aartbik, dcaballe

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

Added: 


Modified: 
mlir/lib/Analysis/LoopAnalysis.cpp
mlir/test/Dialect/Affine/SuperVectorize/vectorize_1d.mlir

Removed: 




diff  --git a/mlir/lib/Analysis/LoopAnalysis.cpp 
b/mlir/lib/Analysis/LoopAnalysis.cpp
index 210b68eae3cb..932559cac197 100644
--- a/mlir/lib/Analysis/LoopAnalysis.cpp
+++ b/mlir/lib/Analysis/LoopAnalysis.cpp
@@ -327,11 +327,23 @@ isVectorizableLoopBodyWithOpCond(AffineForOp loop,
 
 bool mlir::isVectorizableLoopBody(AffineForOp loop, int *memRefDim,
   NestedPattern &vectorTransferMatcher) {
+  *memRefDim = -1;
   VectorizableOpFun fun([memRefDim](AffineForOp loop, Operation &op) {
 auto load = dyn_cast(op);
 auto store = dyn_cast(op);
-return load ? isContiguousAccess(loop.getInductionVar(), load, memRefDim)
-: isContiguousAccess(loop.getInductionVar(), store, memRefDim);
+int thisOpMemRefDim = -1;
+bool isContiguous = load ? isContiguousAccess(loop.getInductionVar(), load,
+  &thisOpMemRefDim)
+ : isContiguousAccess(loop.getInductionVar(), 
store,
+  &thisOpMemRefDim);
+if (thisOpMemRefDim != -1) {
+  // If memory accesses vary across 
diff erent dimensions then the loop is
+  // not vectorizable.
+  if (*memRefDim != -1 && *memRefDim != thisOpMemRefDim)
+return false;
+  *memRefDim = thisOpMemRefDim;
+}
+return isContiguous;
   });
   return isVectorizableLoopBodyWithOpCond(loop, fun, vectorTransferMatcher);
 }

diff  --git a/mlir/test/Dialect/Affine/SuperVectorize/vectorize_1d.mlir 
b/mlir/test/Dialect/Affine/SuperVectorize/vectorize_1d.mlir
index ca496b75432c..86749e2c7bab 100644
--- a/mlir/test/Dialect/Affine/SuperVectorize/vectorize_1d.mlir
+++ b/mlir/test/Dialect/Affine/SuperVectorize/vectorize_1d.mlir
@@ -397,6 +397,33 @@ func @vec_rejected_10(%A : memref, %B : 
memref) {
return
 }
 
+// CHECK-LABEL: func @vec_rejected_11
+func @vec_rejected_11(%A : memref, %B : memref) {
+  // CHECK-DAG: %[[C0:.*]] = constant 0 : index
+  // CHECK-DAG: %[[C1:.*]] = constant 1 : index
+  // CHECK-DAG: %[[C2:.*]] = constant 2 : index
+  // CHECK-DAG: [[ARG_M:%[0-9]+]] = dim %{{.*}}, %[[C0]] : memref
+  // CHECK-DAG: [[ARG_N:%[0-9]+]] = dim %{{.*}}, %[[C1]] : memref
+  // CHECK-DAG: [[ARG_P:%[0-9]+]] = dim %{{.*}}, %[[C2]] : memref
+  %c0 = constant 0 : index
+  %c1 = constant 1 : index
+  %c2 = constant 2 : index
+  %M = dim %A, %c0 : memref
+  %N = dim %A, %c1 : memref
+  %P = dim %B, %c2 : memref
+
+  // CHECK: for [[IV10:%[arg0-9]*]] = 0 to %{{[0-9]*}} {
+  // CHECK:   for [[IV11:%[arg0-9]*]] = 0 to %{{[0-9]*}} {
+  // This is similar to vec_rejected_5, but the order of indices is 
diff erent.
+  affine.for %i10 = 0 to %M { // not vectorized
+affine.for %i11 = 0 to %N { // not vectorized
+  %a11 = affine.load %A[%i11, %i10] : memref
+  affine.store %a11, %A[%i10, %i11] : memref
+}
+  }
+  return
+}
+
 // This should not vectorize due to the sequential dependence in the scf.
 // CHECK-LABEL: @vec_rejected_sequential
 func @vec_rejected_sequential(%A : memref) {



___
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] 5a1bc69 - [clangd] NFC: Add client-side logging for remote index requests

2020-12-09 Thread Kirill Bobyrev via llvm-branch-commits

Author: Kirill Bobyrev
Date: 2020-12-09T21:40:37+01:00
New Revision: 5a1bc69f811059b8f62d381e3526d92fffa7d91a

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

LOG: [clangd] NFC: Add client-side logging for remote index requests

Figuring out whether the server is responding and debugging issues with remote
index setup is no easy task: add verbose logging for client side RPC requests
to relieve some pain.

Reviewed By: sammccall

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

Added: 


Modified: 
clang-tools-extra/clangd/index/remote/Client.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/index/remote/Client.cpp 
b/clang-tools-extra/clangd/index/remote/Client.cpp
index 4980a4bee74e..bb19be54f6d2 100644
--- a/clang-tools-extra/clangd/index/remote/Client.cpp
+++ b/clang-tools-extra/clangd/index/remote/Client.cpp
@@ -15,6 +15,7 @@
 #include "support/Logger.h"
 #include "support/Trace.h"
 #include "clang/Basic/Version.h"
+#include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
 
@@ -42,10 +43,13 @@ class IndexClient : public clangd::SymbolIndex {
 SPAN_ATTACH(Tracer, "Request", RPCRequest.DebugString());
 grpc::ClientContext Context;
 Context.AddMetadata("version", clang::getClangToolFullVersion("clangd"));
-std::chrono::system_clock::time_point Deadline =
-std::chrono::system_clock::now() + DeadlineWaitingTime;
+std::chrono::system_clock::time_point StartTime =
+std::chrono::system_clock::now();
+auto Deadline = StartTime + DeadlineWaitingTime;
 Context.set_deadline(Deadline);
 auto Reader = (Stub.get()->*RPCCall)(&Context, RPCRequest);
+dlog("Sending {0}: {1}", RequestT::descriptor()->name(),
+ RPCRequest.DebugString());
 ReplyT Reply;
 unsigned Successful = 0;
 unsigned FailedToParse = 0;
@@ -65,6 +69,11 @@ class IndexClient : public clangd::SymbolIndex {
   Callback(*Response);
   ++Successful;
 }
+auto Millis = std::chrono::duration_cast(
+  std::chrono::system_clock::now() - StartTime)
+  .count();
+vlog("Remote index [{0}]: {1} => {2} results in {3}ms.", ServerAddress,
+ RequestT::descriptor()->name(), Successful, Millis);
 SPAN_ATTACH(Tracer, "Status", Reader->Finish().ok());
 SPAN_ATTACH(Tracer, "Successful", Successful);
 SPAN_ATTACH(Tracer, "Failed to parse", FailedToParse);
@@ -74,11 +83,12 @@ class IndexClient : public clangd::SymbolIndex {
 public:
   IndexClient(
   std::shared_ptr Channel, llvm::StringRef ProjectRoot,
+  llvm::StringRef Address,
   std::chrono::milliseconds DeadlineTime = std::chrono::milliseconds(1000))
   : Stub(remote::v1::SymbolIndex::NewStub(Channel)),
 ProtobufMarshaller(new Marshaller(/*RemoteIndexRoot=*/"",
   /*LocalIndexRoot=*/ProjectRoot)),
-DeadlineWaitingTime(DeadlineTime) {
+ServerAddress(Address), DeadlineWaitingTime(DeadlineTime) {
 assert(!ProjectRoot.empty());
   }
 
@@ -118,6 +128,7 @@ class IndexClient : public clangd::SymbolIndex {
 
 private:
   std::unique_ptr Stub;
+  llvm::SmallString<256> ServerAddress;
   std::unique_ptr ProtobufMarshaller;
   // Each request will be terminated if it takes too long.
   std::chrono::milliseconds DeadlineWaitingTime;
@@ -131,7 +142,7 @@ std::unique_ptr 
getClient(llvm::StringRef Address,
   grpc::CreateChannel(Address.str(), grpc::InsecureChannelCredentials());
   Channel->GetState(true);
   return std::unique_ptr(
-  new IndexClient(Channel, ProjectRoot));
+  new IndexClient(Channel, ProjectRoot, Address));
 }
 
 } // namespace remote



___
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] 55ea639 - [NFC] Removed unused prefixes in llvm/test/CodeGen/AArch64

2020-12-09 Thread Mircea Trofin via llvm-branch-commits

Author: Mircea Trofin
Date: 2020-12-09T12:47:51-08:00
New Revision: 55ea639d3c576f713041c3d1832e71d92f732ee3

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

LOG: [NFC] Removed unused prefixes in llvm/test/CodeGen/AArch64

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

Added: 


Modified: 
llvm/test/CodeGen/AArch64/GlobalISel/call-translator-tail-call-weak.ll
llvm/test/CodeGen/AArch64/GlobalISel/gisel-commandline-option.ll
llvm/test/CodeGen/AArch64/sve-fixed-length-fp-arith.ll
llvm/test/CodeGen/AArch64/sve-fixed-length-fp-converts.ll
llvm/test/CodeGen/AArch64/sve-fixed-length-fp-select.ll
llvm/test/CodeGen/AArch64/sve-fixed-length-int-div.ll
llvm/test/CodeGen/AArch64/sve-fixed-length-int-select.ll

Removed: 




diff  --git 
a/llvm/test/CodeGen/AArch64/GlobalISel/call-translator-tail-call-weak.ll 
b/llvm/test/CodeGen/AArch64/GlobalISel/call-translator-tail-call-weak.ll
index e8eb36bd1c34..9be8c043a929 100644
--- a/llvm/test/CodeGen/AArch64/GlobalISel/call-translator-tail-call-weak.ll
+++ b/llvm/test/CodeGen/AArch64/GlobalISel/call-translator-tail-call-weak.ll
@@ -1,5 +1,5 @@
 ; NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
-; RUN: llc %s -stop-after=irtranslator -verify-machineinstrs -mtriple 
aarch64-apple-darwin -global-isel -o - 2>&1 | FileCheck %s 
--check-prefixes=DARWIN,COMMON
+; RUN: llc %s -stop-after=irtranslator -verify-machineinstrs -mtriple 
aarch64-apple-darwin -global-isel -o - 2>&1 | FileCheck %s --check-prefix=DARWIN
 
 ; Shouldn't tail call when the OS doesn't support it.
 declare extern_weak void @extern_weak_fn()

diff  --git a/llvm/test/CodeGen/AArch64/GlobalISel/gisel-commandline-option.ll 
b/llvm/test/CodeGen/AArch64/GlobalISel/gisel-commandline-option.ll
index fc8802155054..48315532064f 100644
--- a/llvm/test/CodeGen/AArch64/GlobalISel/gisel-commandline-option.ll
+++ b/llvm/test/CodeGen/AArch64/GlobalISel/gisel-commandline-option.ll
@@ -1,22 +1,22 @@
 ; RUN: llc -mtriple=aarch64-- -debug-pass=Structure %s -o /dev/null 2>&1 \
 ; RUN:   --debugify-and-strip-all-safe=0 \
 ; RUN:   -verify-machineinstrs=0 -O0 \
-; RUN:   | FileCheck %s --check-prefixes=ENABLED,ENABLED-O0,FALLBACK
+; RUN:   | FileCheck %s --check-prefixes=ENABLED,FALLBACK
 
 ; RUN: llc -mtriple=aarch64-- -debug-pass=Structure %s -o /dev/null 2>&1 \
 ; RUN:   --debugify-and-strip-all-safe=0 \
 ; RUN:   -verify-machineinstrs -O0 \
-; RUN:   | FileCheck %s 
--check-prefixes=ENABLED,ENABLED-O0,FALLBACK,VERIFY,VERIFY-O0
+; RUN:   | FileCheck %s --check-prefixes=ENABLED,FALLBACK,VERIFY,VERIFY-O0
 
 ; RUN: llc -mtriple=aarch64-- -debug-pass=Structure %s -o /dev/null 2>&1 \
 ; RUN:   --debugify-and-strip-all-safe=0 \
 ; RUN:   -verify-machineinstrs=0 -O0 -aarch64-enable-global-isel-at-O=0 
-global-isel-abort=1 \
-; RUN:   | FileCheck %s --check-prefix ENABLED --check-prefix ENABLED-O0 
--check-prefix NOFALLBACK
+; RUN:   | FileCheck %s --check-prefixes=ENABLED,NOFALLBACK
 
 ; RUN: llc -mtriple=aarch64-- -debug-pass=Structure %s -o /dev/null 2>&1 \
 ; RUN:   --debugify-and-strip-all-safe=0 \
 ; RUN:   -verify-machineinstrs=0 -O0 -aarch64-enable-global-isel-at-O=0 
-global-isel-abort=2  \
-; RUN:   | FileCheck %s --check-prefix ENABLED --check-prefix ENABLED-O0 
--check-prefix FALLBACK
+; RUN:   | FileCheck %s --check-prefixes=ENABLED,FALLBACK
 
 ; RUN: llc -mtriple=aarch64-- -debug-pass=Structure %s -o /dev/null 2>&1 \
 ; RUN:   --debugify-and-strip-all-safe=0 \

diff  --git a/llvm/test/CodeGen/AArch64/sve-fixed-length-fp-arith.ll 
b/llvm/test/CodeGen/AArch64/sve-fixed-length-fp-arith.ll
index 1806b4945ec9..407b52714e64 100644
--- a/llvm/test/CodeGen/AArch64/sve-fixed-length-fp-arith.ll
+++ b/llvm/test/CodeGen/AArch64/sve-fixed-length-fp-arith.ll
@@ -1,19 +1,19 @@
 ; RUN: llc -aarch64-sve-vector-bits-min=128  < %s | FileCheck %s -D#VBYTES=16  
-check-prefix=NO_SVE
-; RUN: llc -aarch64-sve-vector-bits-min=256  < %s | FileCheck %s -D#VBYTES=32  
-check-prefixes=CHECK,VBITS_LE_1024,VBITS_LE_512,VBITS_LE_256
-; RUN: llc -aarch64-sve-vector-bits-min=384  < %s | FileCheck %s -D#VBYTES=32  
-check-prefixes=CHECK,VBITS_LE_1024,VBITS_LE_512,VBITS_LE_256
-; RUN: llc -aarch64-sve-vector-bits-min=512  < %s | FileCheck %s -D#VBYTES=64  
-check-prefixes=CHECK,VBITS_LE_1024,VBITS_LE_512
-; RUN: llc -aarch64-sve-vector-bits-min=640  < %s | FileCheck %s -D#VBYTES=64  
-check-prefixes=CHECK,VBITS_LE_1024,VBITS_LE_512
-; RUN: llc -aarch64-sve-vector-bits-min=768  < %s | FileCheck %s -D#VBYTES=64  
-check-prefixes=CHECK,VBITS_LE_1024,VBITS_LE_512
-; RUN: llc -aarch64-sve-vector-bits-min=896  < %s | FileCheck %s -D#VBYTES=64  
-check-prefixes=CHECK,VBITS_LE_1024,VBITS_LE_512
-; RUN: llc -aarch64-sve-vector-bits-min=1024 < %s | FileCheck %s -D#VBYTES=128 
-chec

[llvm-branch-commits] [llvm] 9a72d3e - [WebAssembly] Add support for named data sections in wasm binaries

2020-12-09 Thread Sam Clegg via llvm-branch-commits

Author: Sam Clegg
Date: 2020-12-09T12:57:07-08:00
New Revision: 9a72d3e3e456ffa9cfb4e0b2c2e81da78bb15dd3

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

LOG: [WebAssembly] Add support for named data sections in wasm binaries

Followup to https://reviews.llvm.org/D91769 which added support
for names globals.

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

Added: 


Modified: 
lld/test/wasm/call-indirect.ll
lld/test/wasm/data-segment-merging.ll
lld/test/wasm/gc-sections.ll
lld/test/wasm/local-symbols.ll
lld/test/wasm/locals-duplicate.test
lld/test/wasm/map-file.s
lld/test/wasm/signature-mismatch.ll
lld/test/wasm/weak-symbols.s
lld/wasm/SyntheticSections.cpp
lld/wasm/SyntheticSections.h
lld/wasm/Writer.cpp
llvm/include/llvm/BinaryFormat/Wasm.h
llvm/include/llvm/ObjectYAML/WasmYAML.h
llvm/lib/Object/WasmObjectFile.cpp
llvm/lib/ObjectYAML/WasmEmitter.cpp
llvm/lib/ObjectYAML/WasmYAML.cpp
llvm/tools/obj2yaml/wasm2yaml.cpp

Removed: 




diff  --git a/lld/test/wasm/call-indirect.ll b/lld/test/wasm/call-indirect.ll
index 84a84710f2ba..4acc1edae4f2 100644
--- a/lld/test/wasm/call-indirect.ll
+++ b/lld/test/wasm/call-indirect.ll
@@ -156,4 +156,7 @@ define void @call_ptr(i64 (i64)* %arg) {
 ; CHECK-NEXT: GlobalNames:
 ; CHECK-NEXT:   - Index:   0
 ; CHECK-NEXT: Name:__stack_pointer
+; CHECK-NEXT: DataSegmentNames:
+; CHECK-NEXT:   - Index:   0
+; CHECK-NEXT: Name:.data
 ; CHECK-NEXT: ...

diff  --git a/lld/test/wasm/data-segment-merging.ll 
b/lld/test/wasm/data-segment-merging.ll
index bc347d193574..1dee1ccbda29 100644
--- a/lld/test/wasm/data-segment-merging.ll
+++ b/lld/test/wasm/data-segment-merging.ll
@@ -31,7 +31,9 @@
 ; MERGE-NEXT:GlobalNames:
 ; MERGE-NEXT:  - Index:   0
 ; MERGE-NEXT:Name:__stack_pointer
-; MERGE-NOT:   - Index:
+; MERGE-NEXT:DataSegmentNames:
+; MERGE-NEXT:  - Index:   0
+; MERGE-NEXT:Name:.rodata
 
 ; RUN: wasm-ld -no-gc-sections --no-entry --no-merge-data-segments -o 
%t.separate.wasm %t.o
 ; RUN: obj2yaml %t.separate.wasm | FileCheck %s --check-prefix=SEPARATE
@@ -71,7 +73,9 @@
 ; SEPARATE-NEXT:GlobalNames:
 ; SEPARATE-NEXT:  - Index:   0
 ; SEPARATE-NEXT:Name:__stack_pointer
-; SEPARATE-NOT:   - Index:
+; SEPARATE-NEXT:DataSegmentNames:
+; SEPARATE-NEXT:  - Index:   0
+; SEPARATE-NEXT:Name:.rodata
 
 ; RUN: wasm-ld -no-gc-sections --no-entry --shared-memory --max-memory=131072 
-o %t.merged.passive.wasm %t.passive.o
 ; RUN: obj2yaml %t.merged.passive.wasm | FileCheck %s 
--check-prefix=PASSIVE-MERGE

diff  --git a/lld/test/wasm/gc-sections.ll b/lld/test/wasm/gc-sections.ll
index 8bac2fd07827..de8298697bf1 100644
--- a/lld/test/wasm/gc-sections.ll
+++ b/lld/test/wasm/gc-sections.ll
@@ -87,6 +87,9 @@ entry:
 ; CHECK-NEXT: Name:__stack_pointer
 ; CHECK-NEXT:   - Index:   1
 ; CHECK-NEXT: Name:used_global
+; CHECK-NEXT: DataSegmentNames:
+; CHECK-NEXT:   - Index:   0
+; CHECK-NEXT: Name:.data
 ; CHECK-NEXT: ...
 
 ; RUN: wasm-ld -print-gc-sections --no-gc-sections -o %t1.no-gc.wasm \
@@ -162,6 +165,9 @@ entry:
 ; NO-GC-NEXT: Name:unused_global
 ; NO-GC-NEXT:   - Index:   2
 ; NO-GC-NEXT: Name:used_global
+; NO-GC-NEXT: DataSegmentNames:
+; NO-GC-NEXT:   - Index:   0
+; NO-GC-NEXT: Name:.data
 ; NO-GC-NEXT: ...
 
 ; RUN: not wasm-ld --gc-sections --relocatable -o %t1.no-gc.wasm %t.o 2>&1 | 
FileCheck %s -check-prefix=CHECK-ERROR

diff  --git a/lld/test/wasm/local-symbols.ll b/lld/test/wasm/local-symbols.ll
index d0a520a950a2..13c200d648e9 100644
--- a/lld/test/wasm/local-symbols.ll
+++ b/lld/test/wasm/local-symbols.ll
@@ -97,4 +97,7 @@ entry:
 ; CHECK-NEXT: GlobalNames:
 ; CHECK-NEXT:   - Index:   0
 ; CHECK-NEXT: Name:__stack_pointer
+; CHECK-NEXT: DataSegmentNames:
+; CHECK-NEXT:   - Index:   0
+; CHECK-NEXT: Name:.data
 ; CHECK-NEXT: ...

diff  --git a/lld/test/wasm/locals-duplicate.test 
b/lld/test/wasm/locals-duplicate.test
index dc6b9c88be29..07abb7485381 100644
--- a/lld/test/wasm/locals-duplicate.test
+++ b/lld/test/wasm/locals-duplicate.test
@@ -212,6 +212,9 @@
 ; CHECK-NEXT: GlobalNames:
 ; CHECK-NEXT:   - Index:   0
 ; CHECK-NEXT: Name:__stack_pointer
+; CHECK-NEXT: DataSegmentNames:
+; CHECK-NEXT:   - Index:   0
+; CHECK-NEXT: Name:.data
 ; CHECK

[llvm-branch-commits] [compiler-rt] a3eb2fb - [DFSan] Add custom wrapper for recvmsg.

2020-12-09 Thread Matt Morehouse via llvm-branch-commits

Author: Matt Morehouse
Date: 2020-12-09T13:07:51-08:00
New Revision: a3eb2fb247686af0216337687e921118710b56f3

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

LOG: [DFSan] Add custom wrapper for recvmsg.

The wrapper clears shadow for anything written by recvmsg.

Reviewed By: stephan.yichao.zhao

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

Added: 


Modified: 
compiler-rt/lib/dfsan/dfsan_custom.cpp
compiler-rt/lib/dfsan/done_abilist.txt
compiler-rt/test/dfsan/custom.cpp

Removed: 




diff  --git a/compiler-rt/lib/dfsan/dfsan_custom.cpp 
b/compiler-rt/lib/dfsan/dfsan_custom.cpp
index 7ba0bf0c2e2f..24a0853bd14b 100644
--- a/compiler-rt/lib/dfsan/dfsan_custom.cpp
+++ b/compiler-rt/lib/dfsan/dfsan_custom.cpp
@@ -29,6 +29,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -879,6 +880,26 @@ SANITIZER_INTERFACE_ATTRIBUTE int __dfsw_nanosleep(const 
struct timespec *req,
   return ret;
 }
 
+SANITIZER_INTERFACE_ATTRIBUTE ssize_t __dfsw_recvmsg(
+int sockfd, struct msghdr *msg, int flags, dfsan_label sockfd_label,
+dfsan_label msg_label, dfsan_label flags_label, dfsan_label *ret_label) {
+  ssize_t ret = recvmsg(sockfd, msg, flags);
+  if (ret >= 0) {
+dfsan_set_label(0, msg, sizeof(*msg));
+dfsan_set_label(0, msg->msg_name, msg->msg_namelen);
+dfsan_set_label(0, msg->msg_control, msg->msg_controllen);
+for (size_t remaining = ret, i = 0; remaining > 0; ++i) {
+  assert(i < msg->msg_iovlen);
+  struct iovec *iov = &msg->msg_iov[i];
+  size_t written = remaining < iov->iov_len ? remaining : iov->iov_len;
+  dfsan_set_label(0, iov->iov_base, written);
+  remaining -= written;
+}
+  }
+  *ret_label = 0;
+  return ret;
+}
+
 SANITIZER_INTERFACE_ATTRIBUTE int
 __dfsw_socketpair(int domain, int type, int protocol, int sv[2],
   dfsan_label domain_label, dfsan_label type_label,

diff  --git a/compiler-rt/lib/dfsan/done_abilist.txt 
b/compiler-rt/lib/dfsan/done_abilist.txt
index bf874d262be9..dc37a08f92ec 100644
--- a/compiler-rt/lib/dfsan/done_abilist.txt
+++ b/compiler-rt/lib/dfsan/done_abilist.txt
@@ -116,6 +116,8 @@ fun:connect=discard
 fun:creat=discard
 fun:dladdr=discard
 fun:dlclose=discard
+fun:epoll_create=discard
+fun:epoll_create1=discard
 fun:epoll_ctl=discard
 fun:fclose=discard
 fun:feof=discard
@@ -195,6 +197,7 @@ fun:getrusage=custom
 fun:nanosleep=custom
 fun:pread=custom
 fun:read=custom
+fun:recvmsg=custom
 fun:socketpair=custom
 fun:stat=custom
 fun:time=custom

diff  --git a/compiler-rt/test/dfsan/custom.cpp 
b/compiler-rt/test/dfsan/custom.cpp
index 087a684f51b9..2f1da535c459 100644
--- a/compiler-rt/test/dfsan/custom.cpp
+++ b/compiler-rt/test/dfsan/custom.cpp
@@ -25,6 +25,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -336,6 +337,41 @@ void test_calloc() {
   free(crv);
 }
 
+void test_recvmsg() {
+  int sockfds[2];
+  int ret = socketpair(AF_UNIX, SOCK_DGRAM, 0, sockfds);
+  assert(ret != -1);
+
+  char sbuf[] = "abcdefghijkl";
+  struct iovec siovs[2] = {{&sbuf[0], 4}, {&sbuf[4], 4}};
+  struct msghdr smsg = {};
+  smsg.msg_iov = siovs;
+  smsg.msg_iovlen = 2;
+
+  ssize_t sent = sendmsg(sockfds[0], &smsg, 0);
+  assert(sent > 0);
+
+  char rbuf[128];
+  struct iovec riovs[2] = {{&rbuf[0], 4}, {&rbuf[4], 4}};
+  struct msghdr rmsg = {};
+  rmsg.msg_iov = riovs;
+  rmsg.msg_iovlen = 2;
+
+  dfsan_set_label(i_label, rbuf, sizeof(rbuf));
+  dfsan_set_label(i_label, &rmsg, sizeof(rmsg));
+
+  ssize_t received = recvmsg(sockfds[1], &rmsg, 0);
+  assert(received == sent);
+  assert(memcmp(sbuf, rbuf, 8) == 0);
+  ASSERT_ZERO_LABEL(received);
+  ASSERT_READ_ZERO_LABEL(&rmsg, sizeof(rmsg));
+  ASSERT_READ_ZERO_LABEL(&rbuf[0], 8);
+  ASSERT_READ_LABEL(&rbuf[8], 1, i_label);
+
+  close(sockfds[0]);
+  close(sockfds[1]);
+}
+
 void test_read() {
   char buf[16];
   dfsan_set_label(i_label, buf, 1);
@@ -1089,6 +1125,7 @@ int main(void) {
   test_pread();
   test_pthread_create();
   test_read();
+  test_recvmsg();
   test_sched_getaffinity();
   test_select();
   test_sigaction();



___
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] f5f4b8b - [AMDGPU][MC] Restore old error position for "too few operands"

2020-12-09 Thread Scott Linder via llvm-branch-commits

Author: Scott Linder
Date: 2020-12-09T21:09:47Z
New Revision: f5f4b8b60fc0931440c4f2549fbff0965c868d2c

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

LOG: [AMDGPU][MC] Restore old error position for "too few operands"

Revert part of https://reviews.llvm.org/D92084 to make it simpler to
start consuming the EndOfStatement token within AMDGPU's
ParseInstruction in a future patch. This also brings us back to what
every other target currently does.

A future change to move the position back to the end of the statement
would likely need to audit all of the AMDGPUOperand SMLoc ranges, and
determine the SMLoc for the last character of the last operand.

Reviewed By: dp

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

Added: 


Modified: 
llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
llvm/test/MC/AMDGPU/exp-err.s
llvm/test/MC/AMDGPU/gfx10_err_pos.s

Removed: 




diff  --git a/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp 
b/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
index 56d97588df6e..8bf6566d40dd 100644
--- a/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
+++ b/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
@@ -4040,7 +4040,7 @@ bool AMDGPUAsmParser::MatchAndEmitInstruction(SMLoc 
IDLoc, unsigned &Opcode,
 SMLoc ErrorLoc = IDLoc;
 if (ErrorInfo != ~0ULL) {
   if (ErrorInfo >= Operands.size()) {
-return Error(getLoc(), "too few operands for instruction");
+return Error(IDLoc, "too few operands for instruction");
   }
   ErrorLoc = ((AMDGPUOperand &)*Operands[ErrorInfo]).getStartLoc();
   if (ErrorLoc == SMLoc())

diff  --git a/llvm/test/MC/AMDGPU/exp-err.s b/llvm/test/MC/AMDGPU/exp-err.s
index b650a78627db..ee83bef0c50b 100644
--- a/llvm/test/MC/AMDGPU/exp-err.s
+++ b/llvm/test/MC/AMDGPU/exp-err.s
@@ -53,7 +53,7 @@ exp , v3, v2, v1, v0
 // GCN: :5: error: unknown token in expression
 
 exp
-// GCN: :4: error: too few operands for instruction
+// GCN: :1: error: too few operands for instruction
 
 exp mrt0 s0, v0, v0, v0
 // GCN: 10: error: invalid operand for instruction

diff  --git a/llvm/test/MC/AMDGPU/gfx10_err_pos.s 
b/llvm/test/MC/AMDGPU/gfx10_err_pos.s
index 8d0c3694b285..1d4e52d6c64a 100644
--- a/llvm/test/MC/AMDGPU/gfx10_err_pos.s
+++ b/llvm/test/MC/AMDGPU/gfx10_err_pos.s
@@ -992,12 +992,12 @@ s_getreg_b32 s2, hwreg(HW_REG_SHADER_CYCLES)
 tbuffer_store_format_xyzw v[1:4], off, ttmp[4:7]
 // CHECK: error: too few operands for instruction
 // CHECK-NEXT:{{^}}tbuffer_store_format_xyzw v[1:4], off, ttmp[4:7]
-// CHECK-NEXT:{{^}}^
+// CHECK-NEXT:{{^}}^
 
 v_add_f32_e64 v0, v1
 // CHECK: error: too few operands for instruction
 // CHECK-NEXT:{{^}}v_add_f32_e64 v0, v1
-// CHECK-NEXT:{{^}}^
+// CHECK-NEXT:{{^}}^
 
 
//==
 // too large value for expcnt



___
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] 8b23b3a - [NFCI] Add missing triple to several LTO tests

2020-12-09 Thread Yuanfang Chen via llvm-branch-commits

Author: Yuanfang Chen
Date: 2020-12-09T13:13:58-08:00
New Revision: 8b23b3ab3aea28b91e5aa48f29fe9eb1828515a3

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

LOG: [NFCI] Add missing triple to several LTO tests

Also remove the module triple of clang/test/CodeGenObjC/arc.ll, the
commandline tripe is all it needs.

Added: 


Modified: 
clang/test/CodeGenObjC/arc.ll
llvm/test/ThinLTO/X86/Inputs/distributed_import.ll
llvm/test/tools/gold/X86/Inputs/comdat.ll
llvm/test/tools/gold/X86/Inputs/type-merge2.ll
llvm/test/tools/gold/X86/Inputs/visibility.ll

Removed: 




diff  --git a/clang/test/CodeGenObjC/arc.ll b/clang/test/CodeGenObjC/arc.ll
index 7b903d05cd17..cfc88c3c7eb7 100644
--- a/clang/test/CodeGenObjC/arc.ll
+++ b/clang/test/CodeGenObjC/arc.ll
@@ -1,7 +1,5 @@
 ; RUN: %clang_cc1 -triple x86_64-apple-darwin10 -Os -emit-llvm -fobjc-arc -o - 
%s | FileCheck %s
 
-target triple = "x86_64-apple-darwin10"
-
 declare i8* @llvm.objc.retain(i8*)
 declare void @llvm.objc.release(i8*)
 

diff  --git a/llvm/test/ThinLTO/X86/Inputs/distributed_import.ll 
b/llvm/test/ThinLTO/X86/Inputs/distributed_import.ll
index 328603d20c46..d7d9bb6789af 100644
--- a/llvm/test/ThinLTO/X86/Inputs/distributed_import.ll
+++ b/llvm/test/ThinLTO/X86/Inputs/distributed_import.ll
@@ -1,4 +1,5 @@
 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
 
 @G = internal global i32 7
 define i32 @g() {

diff  --git a/llvm/test/tools/gold/X86/Inputs/comdat.ll 
b/llvm/test/tools/gold/X86/Inputs/comdat.ll
index e70b71815665..ca4bbb4bf81e 100644
--- a/llvm/test/tools/gold/X86/Inputs/comdat.ll
+++ b/llvm/test/tools/gold/X86/Inputs/comdat.ll
@@ -1,4 +1,5 @@
 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
 
 $c2 = comdat any
 $c1 = comdat any

diff  --git a/llvm/test/tools/gold/X86/Inputs/type-merge2.ll 
b/llvm/test/tools/gold/X86/Inputs/type-merge2.ll
index 7cdea6e82f37..7890c47a3004 100644
--- a/llvm/test/tools/gold/X86/Inputs/type-merge2.ll
+++ b/llvm/test/tools/gold/X86/Inputs/type-merge2.ll
@@ -1,4 +1,5 @@
 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
 
 %zed = type { i16 }
 define void @bar(%zed* %this)  {

diff  --git a/llvm/test/tools/gold/X86/Inputs/visibility.ll 
b/llvm/test/tools/gold/X86/Inputs/visibility.ll
index 42796a97bc87..37442469aa7e 100644
--- a/llvm/test/tools/gold/X86/Inputs/visibility.ll
+++ b/llvm/test/tools/gold/X86/Inputs/visibility.ll
@@ -1,4 +1,5 @@
 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
 
 define void @foo() {
   ret void



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


[llvm-branch-commits] [clang] a5c89bb - Frontend: Migrate to FileEntryRef in CompilerInstance::InitializeSourceManager, NFC

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

Author: Duncan P. N. Exon Smith
Date: 2020-12-09T13:28:29-08:00
New Revision: a5c89bb02195a97aa71a406d9864098c764f

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

LOG: Frontend: Migrate to FileEntryRef in 
CompilerInstance::InitializeSourceManager, NFC

Use `FileManager::getVirtualFileRef` to get the virtual file for stdin,
and add an overload of `SourceManager::overrideFileContents` that takes
a `FileEntryRef`, migrating `CompilerInstance::InitializeSourceManager`.

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

Added: 


Modified: 
clang/include/clang/Basic/SourceManager.h
clang/lib/Frontend/CompilerInstance.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/SourceManager.h 
b/clang/include/clang/Basic/SourceManager.h
index 05edc98f9ec8..e067cd8fad83 100644
--- a/clang/include/clang/Basic/SourceManager.h
+++ b/clang/include/clang/Basic/SourceManager.h
@@ -958,6 +958,10 @@ class SourceManager : public RefCountedBase 
{
   /// data in the given source file.
   void overrideFileContents(const FileEntry *SourceFile,
 std::unique_ptr Buffer);
+  void overrideFileContents(FileEntryRef SourceFile,
+std::unique_ptr Buffer) {
+overrideFileContents(&SourceFile.getFileEntry(), std::move(Buffer));
+  }
 
   /// Override the given source file with another one.
   ///

diff  --git a/clang/lib/Frontend/CompilerInstance.cpp 
b/clang/lib/Frontend/CompilerInstance.cpp
index fa3d50aeedfe..92e5208b193b 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -891,8 +891,8 @@ bool CompilerInstance::InitializeSourceManager(const 
FrontendInputFile &Input,
 }
 std::unique_ptr SB = std::move(SBOrErr.get());
 
-const FileEntry *File = FileMgr.getVirtualFile(SB->getBufferIdentifier(),
-   SB->getBufferSize(), 0);
+FileEntryRef File = FileMgr.getVirtualFileRef(SB->getBufferIdentifier(),
+  SB->getBufferSize(), 0);
 SourceMgr.setMainFileID(
 SourceMgr.createFileID(File, SourceLocation(), Kind));
 SourceMgr.overrideFileContents(File, std::move(SB));



___
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] 68ff3b3 - [LLD][gold] Add -plugin-opt=no-new-pass-manager

2020-12-09 Thread Fangrui Song via llvm-branch-commits

Author: Fangrui Song
Date: 2020-12-09T13:31:03-08:00
New Revision: 68ff3b3376f4242307a36ac035a512ec4e256628

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

LOG: [LLD][gold] Add -plugin-opt=no-new-pass-manager

-DENABLE_EXPERIMENTAL_NEW_PASS_MANAGER=on configured LLD and LLVMgold.so
will use the new pass manager by default. Add an option to
use the legacy pass manager. This will also be used by the Clang driver
when -fno-new-pass-manager (D92915) / -fno-experimental-new-pass-manager is set.

Reviewed By: aeubanks, tejohnson

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

Added: 


Modified: 
lld/ELF/Options.td
lld/test/ELF/lto/new-pass-manager.ll
llvm/test/tools/gold/X86/new-pm.ll
llvm/tools/gold/gold-plugin.cpp

Removed: 




diff  --git a/lld/ELF/Options.td b/lld/ELF/Options.td
index 0254b54eca1d8..c79578ce18fa5 100644
--- a/lld/ELF/Options.td
+++ b/lld/ELF/Options.td
@@ -598,6 +598,8 @@ def: J<"plugin-opt=lto-partitions=">, 
Alias, HelpText<"Alias for
 def plugin_opt_mcpu_eq: J<"plugin-opt=mcpu=">;
 def: F<"plugin-opt=new-pass-manager">,
   Alias, HelpText<"Alias for --lto-new-pass-manager">;
+def: F<"plugin-opt=no-new-pass-manager">,
+  Alias, HelpText<"Alias for 
--no-lto-new-pass-manager">;
 def: F<"plugin-opt=cs-profile-generate">,
   Alias, HelpText<"Alias for 
--lto-cs-profile-generate">;
 def: J<"plugin-opt=cs-profile-path=">,

diff  --git a/lld/test/ELF/lto/new-pass-manager.ll 
b/lld/test/ELF/lto/new-pass-manager.ll
index 941235b486307..6b6f6ce83cf00 100644
--- a/lld/test/ELF/lto/new-pass-manager.ll
+++ b/lld/test/ELF/lto/new-pass-manager.ll
@@ -7,6 +7,7 @@
 ; RUN: ld.lld --lto-new-pass-manager --plugin-opt=debug-pass-manager -o 
/dev/null %t.o 2>&1 | FileCheck %s
 ; RUN: ld.lld --lto-new-pass-manager --lto-debug-pass-manager -o /dev/null 
%t.o 2>&1 | FileCheck %s
 ; RUN: ld.lld --lto-new-pass-manager --no-lto-new-pass-manager 
--lto-debug-pass-manager -o /dev/null %t.o 2>&1 | FileCheck %s 
--check-prefix=LEGACY
+; RUN: ld.lld --plugin-opt=no-new-pass-manager --plugin-opt=debug-pass-manager 
-o /dev/null %t.o 2>&1 | FileCheck %s --check-prefix=LEGACY
 
 ; CHECK: Starting llvm::Module pass manager run
 ; CHECK: Finished llvm::Module pass manager run

diff  --git a/llvm/test/tools/gold/X86/new-pm.ll 
b/llvm/test/tools/gold/X86/new-pm.ll
index ee5e6ed53b135..05c7883b1403f 100644
--- a/llvm/test/tools/gold/X86/new-pm.ll
+++ b/llvm/test/tools/gold/X86/new-pm.ll
@@ -10,6 +10,12 @@
 
 ; CHECK: Starting llvm::Module pass manager run
 
+;; --plugin-opt=debug-pass-manager is a no-op for the legacy pass manager.
+; RUN: %gold -m elf_x86_64 -plugin %llvmshlibdir/LLVMgold%shlibext \
+; RUN: --plugin-opt=thinlto \
+; RUN: --plugin-opt=no-new-pass-manager --plugin-opt=debug-pass-manager \
+; RUN: -o /dev/null %t.o 2>&1 | count 0
+
 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
 

diff  --git a/llvm/tools/gold/gold-plugin.cpp b/llvm/tools/gold/gold-plugin.cpp
index adb77ca8219da..b479f8922dc6d 100644
--- a/llvm/tools/gold/gold-plugin.cpp
+++ b/llvm/tools/gold/gold-plugin.cpp
@@ -288,6 +288,8 @@ namespace options {
   cs_profile_path = std::string(opt);
 } else if (opt == "new-pass-manager") {
   new_pass_manager = true;
+} else if (opt == "no-new-pass-manager") {
+  new_pass_manager = false;
 } else if (opt == "debug-pass-manager") {
   debug_pass_manager = true;
 } else if (opt == "whole-program-visibility") {



___
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] 7ea9492 - [mlir] Allow RegionBranchOps in dependence analysis

2020-12-09 Thread Tres Popp via llvm-branch-commits

Author: Tres Popp
Date: 2020-12-09T22:32:04+01:00
New Revision: 7ea94922fa0d8ac6b041c0dc4cd9f8135f0e60bb

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

LOG: [mlir] Allow RegionBranchOps in dependence analysis

This is to prevent assertion failures on scf.if and shape.assuming
operations where this is not enough information currently to handle any
aliasing information.

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

Added: 


Modified: 
mlir/lib/Dialect/Linalg/Analysis/DependenceAnalysis.cpp

Removed: 




diff  --git a/mlir/lib/Dialect/Linalg/Analysis/DependenceAnalysis.cpp 
b/mlir/lib/Dialect/Linalg/Analysis/DependenceAnalysis.cpp
index 99e2e6ab07f2..ca2d16e8de86 100644
--- a/mlir/lib/Dialect/Linalg/Analysis/DependenceAnalysis.cpp
+++ b/mlir/lib/Dialect/Linalg/Analysis/DependenceAnalysis.cpp
@@ -43,6 +43,10 @@ Value Aliases::find(Value v) {
 if (!defOp)
   return v;
 
+// Treat RegionBranchOpInterfaces like an allocate and don't try to follow
+// the aliasing further.
+if (isa(defOp))
+  return v;
 if (isa(defOp))
   return 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] [lld] c8466a5 - Avoid a possible one-byte OOB read off of .drectve sections

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

Author: Reid Kleckner
Date: 2020-12-09T13:32:28-08:00
New Revision: c8466a57310a0f10563e4a5a511e8c6386599cfe

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

LOG: Avoid a possible one-byte OOB read off of .drectve sections

Pointed out by Ryan Prichard

Added: 


Modified: 
lld/COFF/DriverUtils.cpp

Removed: 




diff  --git a/lld/COFF/DriverUtils.cpp b/lld/COFF/DriverUtils.cpp
index f289e66dc6d5..19964428050b 100644
--- a/lld/COFF/DriverUtils.cpp
+++ b/lld/COFF/DriverUtils.cpp
@@ -883,8 +883,10 @@ ParsedDirectives ArgParser::parseDirectives(StringRef s) {
  tok.startswith_lower("-include:"))
   result.includes.push_back(tok.substr(strlen("/include:")));
 else {
-  // Save non-null-terminated strings to make proper C strings.
-  bool HasNul = tok.data()[tok.size()] == '\0';
+  // Copy substrings that are not valid C strings. The tokenizer may have
+  // already copied quoted arguments for us, so those do not need to be
+  // copied again.
+  bool HasNul = tok.end() != s.end() && tok.data()[tok.size()] == '\0';
   rest.push_back(HasNul ? tok.data() : saver.save(tok).data());
 }
   }



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


[llvm-branch-commits] [llvm] 5ff5cf8 - [X86] Use APInt::isSignedIntN instead of isIntN for 64-bit ANDs in X86DAGToDAGISel::IsProfitableToFold

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

Author: Craig Topper
Date: 2020-12-09T13:39:07-08:00
New Revision: 5ff5cf8e057782e3e648ecf5ccf1d9990b53ee90

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

LOG: [X86] Use APInt::isSignedIntN instead of isIntN for 64-bit ANDs in 
X86DAGToDAGISel::IsProfitableToFold

Pretty sure we meant to be checking signed 32 immediates here
rather than unsigned 32 bit. I suspect I messed this up because
in MathExtras.h we have isIntN and isUIntN so isIntN differs in
signedness depending on whether you're using APInt or plain integers.

This fixes a case where we didn't fold a constant created
by shrinkAndImmediate. Since shrinkAndImmediate doesn't topologically
sort constants it creates, we can fail to convert the Constant
to a TargetConstant. This leads to very strange behavior later.

Fixes PR48458.

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

Modified: 
llvm/lib/Target/X86/X86ISelDAGToDAG.cpp

Removed: 




diff  --git a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp 
b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
index de8c2f345fb5..a5cb078b2257 100644
--- a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
+++ b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
@@ -616,7 +616,7 @@ X86DAGToDAGISel::IsProfitableToFold(SDValue N, SDNode *U, 
SDNode *Root) const {
 // best of both worlds.
 if (U->getOpcode() == ISD::AND &&
 Imm->getAPIntValue().getBitWidth() == 64 &&
-Imm->getAPIntValue().isIntN(32))
+Imm->getAPIntValue().isSignedIntN(32))
   return false;
 
 // If this really a zext_inreg that can be represented with a movzx

diff  --git a/llvm/test/CodeGen/X86/pr48458.ll 
b/llvm/test/CodeGen/X86/pr48458.ll
new file mode 100644
index ..bca355961611
--- /dev/null
+++ b/llvm/test/CodeGen/X86/pr48458.ll
@@ -0,0 +1,17 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu | FileCheck %s
+
+define i1 @foo(i64* %0) {
+; CHECK-LABEL: foo:
+; CHECK:   # %bb.0: # %top
+; CHECK-NEXT:movq (%rdi), %rax
+; CHECK-NEXT:andq $-2147483648, %rax # imm = 0x8000
+; CHECK-NEXT:sete %al
+; CHECK-NEXT:retq
+top:
+  %1 = load i64, i64* %0, !range !0
+  %2 = icmp ult i64 %1, 2147483648
+  ret i1 %2
+}
+
+!0 = !{i64 0, i64 100}



___
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] 9260a99 - [MC][AMDGPU] Consume EndOfStatement in asm parser

2020-12-09 Thread Scott Linder via llvm-branch-commits

Author: Scott Linder
Date: 2020-12-09T21:45:55Z
New Revision: 9260a90cd8ee877e1cb9b517166579eca4f3

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

LOG: [MC][AMDGPU] Consume EndOfStatement in asm parser

Avoids spurious newlines showing up in the output when emitting assembly
via MC.

Reviewed By: MaskRay, arsenm

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

Added: 
llvm/test/MC/AMDGPU/round-trip.s

Modified: 
llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp

Removed: 




diff  --git a/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp 
b/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
index 8bf6566d40dd..22c32400ecbf 100644
--- a/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
+++ b/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
@@ -5020,9 +5020,11 @@ bool 
AMDGPUAsmParser::ParseInstruction(ParseInstructionInfo &Info,
   while (!getLexer().is(AsmToken::EndOfStatement)) {
 Parser.Lex();
   }
+  Parser.Lex();
   return true;
 }
   }
+  Parser.Lex();
 
   return false;
 }

diff  --git a/llvm/test/MC/AMDGPU/round-trip.s 
b/llvm/test/MC/AMDGPU/round-trip.s
new file mode 100644
index ..eb355ea544e0
--- /dev/null
+++ b/llvm/test/MC/AMDGPU/round-trip.s
@@ -0,0 +1,13 @@
+# RUN: llvm-mc -preserve-comments -triple amdgcn-amd-amdhsa %s >%t-1.s
+# RUN: llvm-mc -preserve-comments -triple amdgcn-amd-amdhsa %t-1.s >%t-2.s
+# RUN: 
diff  %t-1.s %t-2.s
+
+# Test that AMDGPU assembly round-trips when run through MC; the first
+# transition from hand-written to "canonical" output may introduce some small
+# 
diff erences, so we don't include the initial input in the comparison.
+
+.text
+
+# The AMDGPU asm parser didn't consume the end of statement
+# consistently, which led to extra empty lines in the output.
+s_nop 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] [compiler-rt] a779050 - scudo: Shrink secondary header and cache entry size by a word on Linux. NFCI.

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

Author: Peter Collingbourne
Date: 2020-12-09T14:14:49-08:00
New Revision: a7790508522fc277963df974dc95308e3c11

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

LOG: scudo: Shrink secondary header and cache entry size by a word on Linux. 
NFCI.

Normally compilers will allocate space for struct fields even if the
field is an empty struct. Use the [[no_unique_address]] attribute to
suppress that behavior. This attribute that was introduced in C++20,
but compilers that do not support [[no_unique_address]] will ignore
it since it uses C++11 attribute syntax.

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

Added: 


Modified: 
compiler-rt/lib/scudo/standalone/secondary.h

Removed: 




diff  --git a/compiler-rt/lib/scudo/standalone/secondary.h 
b/compiler-rt/lib/scudo/standalone/secondary.h
index eda88862cb07..ff41bd3e0722 100644
--- a/compiler-rt/lib/scudo/standalone/secondary.h
+++ b/compiler-rt/lib/scudo/standalone/secondary.h
@@ -31,7 +31,7 @@ struct Header {
   uptr BlockEnd;
   uptr MapBase;
   uptr MapSize;
-  MapPlatformData Data;
+  [[no_unique_address]] MapPlatformData Data;
 };
 
 constexpr uptr getHeaderSize() {
@@ -232,7 +232,7 @@ class MapAllocatorCache {
 uptr BlockEnd;
 uptr MapBase;
 uptr MapSize;
-MapPlatformData Data;
+[[no_unique_address]] MapPlatformData Data;
 u64 Time;
   };
 



___
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] 898d61b - ARCMigrate: Migrate ObjCMT.cpp over to FileEntryRef

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

Author: Duncan P. N. Exon Smith
Date: 2020-12-09T14:16:05-08:00
New Revision: 898d61b3cff5d79870d964c76d82764fef73efbb

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

LOG: ARCMigrate: Migrate ObjCMT.cpp over to FileEntryRef

Migrate ObjCMT.cpp from using `const FileEntry*` to `FileEntryRef`. This
is one of the blockers for changing `SourceManager` to use
`FileEntryRef`.

This adds an initial version of `SourceManager::getFileEntryRefForID`,
which uses to `FileEntry::getLastRef`; after `SourceManager` switches,
`SourceManager::getFileEntryForID` will need to call this function.

This also adds uses of `FileEntryRef` as a key in a `DenseMap`, and a
call to `hash_value(Optional)` in `DenseMapInfo`; support for
these were added in prep commits.

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

Added: 


Modified: 
clang/include/clang/Basic/SourceManager.h
clang/lib/ARCMigrate/ObjCMT.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/SourceManager.h 
b/clang/include/clang/Basic/SourceManager.h
index e067cd8fad83..a43b47662180 100644
--- a/clang/include/clang/Basic/SourceManager.h
+++ b/clang/include/clang/Basic/SourceManager.h
@@ -1033,6 +1033,13 @@ class SourceManager : public 
RefCountedBase {
 return nullptr;
   }
 
+  /// Returns the FileEntryRef for the provided FileID.
+  Optional getFileEntryRefForID(FileID FID) const {
+if (auto *Entry = getFileEntryForID(FID))
+  return Entry->getLastRef();
+return None;
+  }
+
   /// Returns the filename for the provided FileID, unless it's a built-in
   /// buffer that's not represented by a filename.
   ///

diff  --git a/clang/lib/ARCMigrate/ObjCMT.cpp b/clang/lib/ARCMigrate/ObjCMT.cpp
index dfc0d9353165..68a51a49c718 100644
--- a/clang/lib/ARCMigrate/ObjCMT.cpp
+++ b/clang/lib/ARCMigrate/ObjCMT.cpp
@@ -156,7 +156,7 @@ class ObjCMigrateASTConsumer : public ASTConsumer {
 return WhiteListFilenames.find(llvm::sys::path::filename(Path))
 != WhiteListFilenames.end();
   }
-  bool canModifyFile(const FileEntry *FE) {
+  bool canModifyFile(Optional FE) {
 if (!FE)
   return false;
 return canModifyFile(FE->getName());
@@ -164,7 +164,7 @@ class ObjCMigrateASTConsumer : public ASTConsumer {
   bool canModifyFile(FileID FID) {
 if (FID.isInvalid())
   return false;
-return canModifyFile(PP.getSourceManager().getFileEntryForID(FID));
+return canModifyFile(PP.getSourceManager().getFileEntryRefForID(FID));
   }
 
   bool canModify(const Decl *D) {
@@ -1964,7 +1964,7 @@ void 
ObjCMigrateASTConsumer::HandleTranslationUnit(ASTContext &Ctx) {
 I = rewriter.buffer_begin(), E = rewriter.buffer_end(); I != E; ++I) {
 FileID FID = I->first;
 RewriteBuffer &buf = I->second;
-const FileEntry *file = Ctx.getSourceManager().getFileEntryForID(FID);
+Optional file = 
Ctx.getSourceManager().getFileEntryRefForID(FID);
 assert(file);
 SmallString<512> newText;
 llvm::raw_svector_ostream vecOS(newText);
@@ -2034,7 +2034,7 @@ MigrateSourceAction::CreateASTConsumer(CompilerInstance 
&CI, StringRef InFile) {
 
 namespace {
 struct EditEntry {
-  const FileEntry *File = nullptr;
+  Optional File;
   unsigned Offset = 0;
   unsigned RemoveLen = 0;
   std::string Text;
@@ -2127,9 +2127,8 @@ class RemapFileParser {
   StringRef Val = ValueString->getValue(ValueStorage);
 
   if (Key == "file") {
-auto FE = FileMgr.getFile(Val);
-if (FE)
-  Entry.File = *FE;
+if (auto File = FileMgr.getOptionalFileRef(Val))
+  Entry.File = File;
 else
   Ignore = true;
   } else if (Key == "offset") {
@@ -2155,7 +2154,7 @@ static bool reportDiag(const Twine &Err, 
DiagnosticsEngine &Diag) {
   return true;
 }
 
-static std::string applyEditsToTemp(const FileEntry *FE,
+static std::string applyEditsToTemp(FileEntryRef FE,
 ArrayRef Edits,
 FileManager &FileMgr,
 DiagnosticsEngine &Diag) {
@@ -2199,8 +2198,8 @@ static std::string applyEditsToTemp(const FileEntry *FE,
 
   SmallString<64> TempPath;
   int FD;
-  if (fs::createTemporaryFile(path::filename(FE->getName()),
-  path::extension(FE->getName()).drop_front(), FD,
+  if (fs::createTemporaryFile(path::filename(FE.getName()),
+  path::extension(FE.getName()).drop_front(), FD,
   TempPath)) {
 reportDiag("Could not create file: " + TempPath.str(), Diag);
 return std::string();
@@ -2228,7 +2227,7 @@ bool arcmt::getFileRemappingsFromFileList(
   new DiagnosticsEngine(DiagID, new DiagnosticOptions,
 DiagClient, /*ShouldOwnClient=*/false)

[llvm-branch-commits] [lldb] 2cedc44 - Ignore DBGArchitecture from dsymForUUID's plist

2020-12-09 Thread Jason Molenda via llvm-branch-commits

Author: Jason Molenda
Date: 2020-12-09T14:19:55-08:00
New Revision: 2cedc44a92337ccc0e8173b4dbf4cfe5650da8cd

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

LOG: Ignore DBGArchitecture from dsymForUUID's plist

When the architecture from the returned plist differs from the
architecture lldb will pick when loading the binary file, lldb will
reject the binary as not matching.  We are working with UUID's in
this case, so an architecture is not disambiguating anything; it
just opens this possibility for failing to load the specified binary.
Stop reading the architecture from the plist.


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

Added: 


Modified: 
lldb/source/Symbol/LocateSymbolFileMacOSX.cpp
lldb/test/API/macosx/lc-note/firmware-corefile/TestFirmwareCorefiles.py

Removed: 




diff  --git a/lldb/source/Symbol/LocateSymbolFileMacOSX.cpp 
b/lldb/source/Symbol/LocateSymbolFileMacOSX.cpp
index 344bac8e0632..2655e4de9063 100644
--- a/lldb/source/Symbol/LocateSymbolFileMacOSX.cpp
+++ b/lldb/source/Symbol/LocateSymbolFileMacOSX.cpp
@@ -342,13 +342,6 @@ static bool 
GetModuleSpecInfoFromUUIDDictionary(CFDictionaryRef uuid_dict,
   }
 }
 
-cf_str = (CFStringRef)CFDictionaryGetValue((CFDictionaryRef)uuid_dict,
-   CFSTR("DBGArchitecture"));
-if (cf_str && CFGetTypeID(cf_str) == CFStringGetTypeID()) {
-  if (CFCString::FileSystemRepresentation(cf_str, str))
-module_spec.GetArchitecture().SetTriple(str.c_str());
-}
-
 std::string DBGBuildSourcePath;
 std::string DBGSourcePath;
 

diff  --git 
a/lldb/test/API/macosx/lc-note/firmware-corefile/TestFirmwareCorefiles.py 
b/lldb/test/API/macosx/lc-note/firmware-corefile/TestFirmwareCorefiles.py
index 79a79056476b..7055fa698382 100644
--- a/lldb/test/API/macosx/lc-note/firmware-corefile/TestFirmwareCorefiles.py
+++ b/lldb/test/API/macosx/lc-note/firmware-corefile/TestFirmwareCorefiles.py
@@ -85,7 +85,7 @@ def test_lc_note(self):
 'fi',
 'echo "$uuid"',
 '',
-'echo "DBGArchitecturex86_64"',
+'echo "DBGArchitecturei386"',
 'echo "DBGDSYMPath$dsym"',
 'echo 
"DBGSymbolRichExecutable$bin"',
 'echo ""',



___
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] b0d02b6 - [MLIR] Minor cleanup for Shape dialect.

2020-12-09 Thread Rahul Joshi via llvm-branch-commits

Author: Rahul Joshi
Date: 2020-12-09T14:21:35-08:00
New Revision: b0d02b698b94d2fc5f7fbd430f5e9d3b032f8523

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

LOG: [MLIR] Minor cleanup for Shape dialect.

- Remove some unused types from the Shape dialect
- Fix from_extent_tensor to only allow 1D index tensors
- Fix assuming_yield to only allow shape.assuming as the parent op.
- Fix some documentation typos and reword some things.

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

Added: 


Modified: 
mlir/include/mlir/Dialect/Shape/IR/Shape.h
mlir/include/mlir/Dialect/Shape/IR/ShapeBase.td
mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td
mlir/lib/Dialect/Shape/IR/Shape.cpp

Removed: 




diff  --git a/mlir/include/mlir/Dialect/Shape/IR/Shape.h 
b/mlir/include/mlir/Dialect/Shape/IR/Shape.h
index eab3c6f67ca0..db2862141ea9 100644
--- a/mlir/include/mlir/Dialect/Shape/IR/Shape.h
+++ b/mlir/include/mlir/Dialect/Shape/IR/Shape.h
@@ -31,18 +31,6 @@ namespace shape {
 /// Alias type for extent tensors.
 RankedTensorType getExtentTensorType(MLIRContext *ctx);
 
-/// The component type corresponding to shape, element type and attribute.
-class ComponentType : public Type::TypeBase {
-public:
-  using Base::Base;
-};
-
-/// The element type of the shaped type.
-class ElementType : public Type::TypeBase {
-public:
-  using Base::Base;
-};
-
 /// The shape descriptor type represents rank and dimension sizes.
 class ShapeType : public Type::TypeBase {
 public:

diff  --git a/mlir/include/mlir/Dialect/Shape/IR/ShapeBase.td 
b/mlir/include/mlir/Dialect/Shape/IR/ShapeBase.td
index c9103a2b8b63..a7868e74c65f 100644
--- a/mlir/include/mlir/Dialect/Shape/IR/ShapeBase.td
+++ b/mlir/include/mlir/Dialect/Shape/IR/ShapeBase.td
@@ -39,29 +39,11 @@ def ShapeDialect : Dialect {
   let hasConstantMaterializer = 1;
 }
 
-def Shape_ComponentType : DialectType()">, "component type">,
-BuildableType<"$_builder.getType<::mlir::shape::ComponentType>()"> {
-  let typeDescription = [{
-`shape.component_type` represents the tuple of shape, element type and
-attribute.
-  }];
-}
-
-def Shape_ElementType : DialectType()">, "element type">,
-BuildableType<"$_builder.getType<::mlir::shape::ElementType>()"> {
-  let typeDescription = [{
-`shape.element_type` represents the element type of the ShapedType. It may
-be unknown, error or regular element type supported by ShapedType.
-  }];
-}
-
 def Shape_ShapeType : DialectType()">, "shape">,
 BuildableType<"$_builder.getType<::mlir::shape::ShapeType>()"> {
   let typeDescription = [{
-`shape.type` represents either an unranked shape, a ranked shape with
+`shape.shape` represents either an unranked shape, a ranked shape with
 possibly unknown dimensions or an invalid shape. The rank is of type
 `shape.size` and, if rank is known, the extent is a 1D tensor of type
 `shape.size`.
@@ -96,12 +78,12 @@ def Shape_ValueShapeType : DialectType())"> {
   let typeDescription = [{
 The extent tensor is a tensor of rank one with arbitrarily many index
-elements. Like `!shape.shape`, it is used to represent shapes with the
-
diff erence that it is guaranteed to be error-free.
+elements (tensor). Like `!shape.shape`, it is used to represent
+shapes with the 
diff erence that it is guaranteed to be error-free.
   }];
 }
 

diff  --git a/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td 
b/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td
index 552de7e78f91..0cbb910e062c 100644
--- a/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td
+++ b/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td
@@ -34,7 +34,9 @@ def Shape_AddOp : Shape_Op<"add", [Commutative, 
NoSideEffect]> {
 Adds two sizes or indices. If either operand is an error it will be
 propagated to the result. The operands can be of type `size` or `index`. If
 at least one of the operands can hold an error, i.e. if it is of type 
`size`,
-then also the result must be of type `size`.
+the result must be of type `size`. If error propagation is not possible
+because both operands are of type `index` then the result may be of type
+`size` or `index`.
   }];
 
   let arguments = (ins Shape_SizeOrIndexType:$lhs, Shape_SizeOrIndexType:$rhs);
@@ -177,7 +179,7 @@ def Shape_FromExtentTensorOp : 
Shape_Op<"from_extent_tensor", [NoSideEffect]> {
 extents match the values of the elements.
   }];
 
-  let arguments = (ins IndexTensor:$input);
+  let arguments = (ins 1DTensorOf<[Index]>:$input);
   let results = (outs Shape_ShapeType:$result);
 
   let assemblyFormat = "$input attr-dict `:` type($input)";
@@ -247,7 +249,7 @@ def Shape_GetExtentOp : Shape_Op<"get_extent", 
[NoSideEffect]> {
   let summary = "Gets the specified extent from a shape or

[llvm-branch-commits] [compiler-rt] 4eedc2e - [DFSan] Add custom wrapper for getsockopt.

2020-12-09 Thread Matt Morehouse via llvm-branch-commits

Author: Matt Morehouse
Date: 2020-12-09T14:29:38-08:00
New Revision: 4eedc2e3af3aa01279c5131b527e452c34dde953

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

LOG: [DFSan] Add custom wrapper for getsockopt.

The wrapper clears shadow for optval and optlen when written.

Reviewed By: stephan.yichao.zhao, vitalybuka

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

Added: 


Modified: 
compiler-rt/lib/dfsan/dfsan_custom.cpp
compiler-rt/lib/dfsan/done_abilist.txt
compiler-rt/test/dfsan/custom.cpp

Removed: 




diff  --git a/compiler-rt/lib/dfsan/dfsan_custom.cpp 
b/compiler-rt/lib/dfsan/dfsan_custom.cpp
index 24a0853bd14b..0cb075ac632a 100644
--- a/compiler-rt/lib/dfsan/dfsan_custom.cpp
+++ b/compiler-rt/lib/dfsan/dfsan_custom.cpp
@@ -913,6 +913,20 @@ __dfsw_socketpair(int domain, int type, int protocol, int 
sv[2],
   return ret;
 }
 
+SANITIZER_INTERFACE_ATTRIBUTE int __dfsw_getsockopt(
+int sockfd, int level, int optname, void *optval, socklen_t *optlen,
+dfsan_label sockfd_label, dfsan_label level_label,
+dfsan_label optname_label, dfsan_label optval_label,
+dfsan_label optlen_label, dfsan_label *ret_label) {
+  int ret = getsockopt(sockfd, level, optname, optval, optlen);
+  if (ret != -1 && optval && optlen) {
+dfsan_set_label(0, optlen, sizeof(*optlen));
+dfsan_set_label(0, optval, *optlen);
+  }
+  *ret_label = 0;
+  return ret;
+}
+
 // Type of the trampoline function passed to the custom version of
 // dfsan_set_write_callback.
 typedef void (*write_trampoline_t)(

diff  --git a/compiler-rt/lib/dfsan/done_abilist.txt 
b/compiler-rt/lib/dfsan/done_abilist.txt
index dc37a08f92ec..13513cbb0f23 100644
--- a/compiler-rt/lib/dfsan/done_abilist.txt
+++ b/compiler-rt/lib/dfsan/done_abilist.txt
@@ -194,6 +194,7 @@ fun:get_current_dir_name=custom
 fun:gethostname=custom
 fun:getrlimit=custom
 fun:getrusage=custom
+fun:getsockopt=custom
 fun:nanosleep=custom
 fun:pread=custom
 fun:read=custom

diff  --git a/compiler-rt/test/dfsan/custom.cpp 
b/compiler-rt/test/dfsan/custom.cpp
index 2f1da535c459..b57f172d7e4c 100644
--- a/compiler-rt/test/dfsan/custom.cpp
+++ b/compiler-rt/test/dfsan/custom.cpp
@@ -931,6 +931,27 @@ void test_socketpair() {
   ASSERT_READ_ZERO_LABEL(fd, sizeof(fd));
 }
 
+void test_getsockopt() {
+  int sockfd = socket(AF_UNIX, SOCK_DGRAM, 0);
+  assert(sockfd != -1);
+
+  int optval[2] = {-1, -1};
+  socklen_t optlen = sizeof(optval);
+  dfsan_set_label(i_label, &optval, sizeof(optval));
+  dfsan_set_label(i_label, &optlen, sizeof(optlen));
+  int ret = getsockopt(sockfd, SOL_SOCKET, SO_KEEPALIVE, &optval, &optlen);
+  assert(ret != -1);
+  assert(optlen == sizeof(int));
+  assert(optval[0] == 0);
+  assert(optval[1] == -1);
+  ASSERT_ZERO_LABEL(ret);
+  ASSERT_ZERO_LABEL(optlen);
+  ASSERT_ZERO_LABEL(optval[0]);
+  ASSERT_LABEL(optval[1], i_label);
+
+  close(sockfd);
+}
+
 void test_write() {
   int fd = open("/dev/null", O_WRONLY);
 
@@ -1113,6 +1134,7 @@ int main(void) {
   test_getpwuid_r();
   test_getrlimit();
   test_getrusage();
+  test_getsockopt();
   test_gettimeofday();
   test_inet_pton();
   test_localtime_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] [clang] c3ff993 - Remove RemappedFiles param from ASTUnit::LoadFromASTFile, NFC

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

Author: Duncan P. N. Exon Smith
Date: 2020-12-09T14:44:31-08:00
New Revision: c3ff9939bf7efeb11da49f100a277b4d8bbeff9f

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

LOG: Remove RemappedFiles param from ASTUnit::LoadFromASTFile, NFC

This parameter is always set to `None`. Remove it.

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

Added: 


Modified: 
clang/include/clang/Frontend/ASTUnit.h
clang/lib/Frontend/ASTUnit.cpp
clang/tools/c-index-test/core_main.cpp
clang/tools/libclang/CIndex.cpp

Removed: 




diff  --git a/clang/include/clang/Frontend/ASTUnit.h 
b/clang/include/clang/Frontend/ASTUnit.h
index 5bee57042ca6..6cf9f3ff936f 100644
--- a/clang/include/clang/Frontend/ASTUnit.h
+++ b/clang/include/clang/Frontend/ASTUnit.h
@@ -688,14 +688,15 @@ class ASTUnit {
   /// lifetime is expected to extend past that of the returned ASTUnit.
   ///
   /// \returns - The initialized ASTUnit or null if the AST failed to load.
-  static std::unique_ptr LoadFromASTFile(
-  const std::string &Filename, const PCHContainerReader &PCHContainerRdr,
-  WhatToLoad ToLoad, IntrusiveRefCntPtr Diags,
-  const FileSystemOptions &FileSystemOpts, bool UseDebugInfo = false,
-  bool OnlyLocalDecls = false, ArrayRef RemappedFiles = None,
-  CaptureDiagsKind CaptureDiagnostics = CaptureDiagsKind::None,
-  bool AllowASTWithCompilerErrors = false,
-  bool UserFilesAreVolatile = false);
+  static std::unique_ptr
+  LoadFromASTFile(const std::string &Filename,
+  const PCHContainerReader &PCHContainerRdr, WhatToLoad ToLoad,
+  IntrusiveRefCntPtr Diags,
+  const FileSystemOptions &FileSystemOpts,
+  bool UseDebugInfo = false, bool OnlyLocalDecls = false,
+  CaptureDiagsKind CaptureDiagnostics = CaptureDiagsKind::None,
+  bool AllowASTWithCompilerErrors = false,
+  bool UserFilesAreVolatile = false);
 
 private:
   /// Helper function for \c LoadFromCompilerInvocation() and

diff  --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp
index d9154e9b459e..51851a5bac83 100644
--- a/clang/lib/Frontend/ASTUnit.cpp
+++ b/clang/lib/Frontend/ASTUnit.cpp
@@ -758,9 +758,8 @@ std::unique_ptr ASTUnit::LoadFromASTFile(
 const std::string &Filename, const PCHContainerReader &PCHContainerRdr,
 WhatToLoad ToLoad, IntrusiveRefCntPtr Diags,
 const FileSystemOptions &FileSystemOpts, bool UseDebugInfo,
-bool OnlyLocalDecls, ArrayRef RemappedFiles,
-CaptureDiagsKind CaptureDiagnostics, bool AllowASTWithCompilerErrors,
-bool UserFilesAreVolatile) {
+bool OnlyLocalDecls, CaptureDiagsKind CaptureDiagnostics,
+bool AllowASTWithCompilerErrors, bool UserFilesAreVolatile) {
   std::unique_ptr AST(new ASTUnit(true));
 
   // Recover resources if we crash before exiting this method.
@@ -793,9 +792,6 @@ std::unique_ptr ASTUnit::LoadFromASTFile(
  /*Target=*/nullptr));
   AST->PPOpts = std::make_shared();
 
-  for (const auto &RemappedFile : RemappedFiles)
-AST->PPOpts->addRemappedFile(RemappedFile.first, RemappedFile.second);
-
   // Gather Info for preprocessor construction later on.
 
   HeaderSearch &HeaderInfo = *AST->HeaderInfo;

diff  --git a/clang/tools/c-index-test/core_main.cpp 
b/clang/tools/c-index-test/core_main.cpp
index c6d59d703d17..ed0d99b9d199 100644
--- a/clang/tools/c-index-test/core_main.cpp
+++ b/clang/tools/c-index-test/core_main.cpp
@@ -262,7 +262,7 @@ static bool printSourceSymbolsFromModule(StringRef 
modulePath,
   std::unique_ptr AU = ASTUnit::LoadFromASTFile(
   std::string(modulePath), *pchRdr, ASTUnit::LoadASTOnly, Diags,
   FileSystemOpts, /*UseDebugInfo=*/false,
-  /*OnlyLocalDecls=*/true, None, CaptureDiagsKind::None,
+  /*OnlyLocalDecls=*/true, CaptureDiagsKind::None,
   /*AllowASTWithCompilerErrors=*/true,
   /*UserFilesAreVolatile=*/false);
   if (!AU) {

diff  --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp
index 95ff9aa35bfa..aa888a380048 100644
--- a/clang/tools/libclang/CIndex.cpp
+++ b/clang/tools/libclang/CIndex.cpp
@@ -3475,7 +3475,7 @@ enum CXErrorCode clang_createTranslationUnit2(CXIndex 
CIdx,
   std::unique_ptr AU = ASTUnit::LoadFromASTFile(
   ast_filename, CXXIdx->getPCHContainerOperations()->getRawReader(),
   ASTUnit::LoadEverything, Diags, FileSystemOpts, /*UseDebugInfo=*/false,
-  CXXIdx->getOnlyLocalDecls(), None, CaptureDiagsKind::All,
+  CXXIdx->getOnlyLocalDecls(), CaptureDiagsKind::All,
   /*AllowASTWithCompilerErrors=*/true,
   /*UserFilesAreVolatile=*/true);
   *out_TU = MakeCXTranslationUnit(CXXIdx, std::move(AU));



___

[llvm-branch-commits] [openmp] 540007b - [OpenMP] Add strict mode in num_tasks and grainsize

2020-12-09 Thread Nawrin Sultana via llvm-branch-commits

Author: Nawrin Sultana
Date: 2020-12-09T16:46:30-06:00
New Revision: 540007b42701b5ac9adba076824bfd648a265413

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

LOG: [OpenMP] Add strict mode in num_tasks and grainsize

This patch adds new API __kmpc_taskloop_5 to accomadate strict
modifier (introduced in OpenMP 5.1) in num_tasks and grainsize
clause.

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

Added: 
openmp/runtime/test/tasking/kmp_taskloop_5.c

Modified: 
openmp/runtime/src/dllexports
openmp/runtime/src/kmp.h
openmp/runtime/src/kmp_tasking.cpp

Removed: 




diff  --git a/openmp/runtime/src/dllexports b/openmp/runtime/src/dllexports
index 6e41376a16b9..1c29ca90657a 100644
--- a/openmp/runtime/src/dllexports
+++ b/openmp/runtime/src/dllexports
@@ -371,6 +371,7 @@ kmpc_set_defaults   224
 __kmpc_doacross_fini264
 __kmpc_taskloop 266
 __kmpc_critical_with_hint   270
+__kmpc_taskloop_5   285
 %endif
 kmpc_aligned_malloc 265
 kmpc_set_disp_num_buffers   267

diff  --git a/openmp/runtime/src/kmp.h b/openmp/runtime/src/kmp.h
index e450b128a005..64431a60aef3 100644
--- a/openmp/runtime/src/kmp.h
+++ b/openmp/runtime/src/kmp.h
@@ -3783,6 +3783,12 @@ KMP_EXPORT void __kmpc_taskloop(ident_t *loc, kmp_int32 
gtid, kmp_task_t *task,
 kmp_uint64 *ub, kmp_int64 st, kmp_int32 
nogroup,
 kmp_int32 sched, kmp_uint64 grainsize,
 void *task_dup);
+KMP_EXPORT void __kmpc_taskloop_5(ident_t *loc, kmp_int32 gtid,
+  kmp_task_t *task, kmp_int32 if_val,
+  kmp_uint64 *lb, kmp_uint64 *ub, kmp_int64 st,
+  kmp_int32 nogroup, kmp_int32 sched,
+  kmp_uint64 grainsize, kmp_int32 modifier,
+  void *task_dup);
 KMP_EXPORT void *__kmpc_task_reduction_init(int gtid, int num_data, void 
*data);
 KMP_EXPORT void *__kmpc_taskred_init(int gtid, int num_data, void *data);
 KMP_EXPORT void *__kmpc_task_reduction_get_th_data(int gtid, void *tg, void 
*d);

diff  --git a/openmp/runtime/src/kmp_tasking.cpp 
b/openmp/runtime/src/kmp_tasking.cpp
index 424576ed440f..f95a92d872d4 100644
--- a/openmp/runtime/src/kmp_tasking.cpp
+++ b/openmp/runtime/src/kmp_tasking.cpp
@@ -4142,6 +4142,7 @@ class kmp_taskloop_bounds_t {
 // num_tasks  Number of tasks to execute
 // grainsize  Number of loop iterations per task
 // extras Number of chunks with grainsize+1 iterations
+// last_chunk Reduction of grainsize for last task
 // tc Iterations count
 // task_dup   Tasks duplication routine
 // codeptr_ra Return address for OMPT events
@@ -4149,7 +4150,7 @@ void __kmp_taskloop_linear(ident_t *loc, int gtid, 
kmp_task_t *task,
kmp_uint64 *lb, kmp_uint64 *ub, kmp_int64 st,
kmp_uint64 ub_glob, kmp_uint64 num_tasks,
kmp_uint64 grainsize, kmp_uint64 extras,
-   kmp_uint64 tc,
+   kmp_int64 last_chunk, kmp_uint64 tc,
 #if OMPT_SUPPORT
void *codeptr_ra,
 #endif
@@ -4167,13 +4168,14 @@ void __kmp_taskloop_linear(ident_t *loc, int gtid, 
kmp_task_t *task,
   kmp_task_t *next_task;
   kmp_int32 lastpriv = 0;
 
-  KMP_DEBUG_ASSERT(tc == num_tasks * grainsize + extras);
+  KMP_DEBUG_ASSERT(
+  tc == num_tasks * grainsize + (last_chunk < 0 ? last_chunk : extras));
   KMP_DEBUG_ASSERT(num_tasks > extras);
   KMP_DEBUG_ASSERT(num_tasks > 0);
   KA_TRACE(20, ("__kmp_taskloop_linear: T#%d: %lld tasks, grainsize %lld, "
-"extras %lld, i=%lld,%lld(%d)%lld, dup %p\n",
-gtid, num_tasks, grainsize, extras, lower, upper, ub_glob, st,
-task_dup));
+"extras %lld, last_chunk %lld, i=%lld,%lld(%d)%lld, dup %p\n",
+gtid, num_tasks, grainsize, extras, last_chunk, lower, upper,
+ub_glob, st, task_dup));
 
   // Launch num_tasks tasks, assign grainsize iterations each task
   for (i = 0; i < num_tasks; ++i) {
@@ -4185,6 +4187,9 @@ void __kmp_taskloop_linear(ident_t *loc, int gtid, 
kmp_task_t *task,
   --extras; // first extras iterations get bigger chunk (grainsize+1)
 }
 upper = lower + st * chunk_minus_1;
+if (upper > *ub) {
+  upper = *ub;
+}
 if (i == num_tasks - 1) {
   // schedule the last task, set lastprivate flag if needed
   if (st == 1) { // most common case
@@ -4248,6 +4253,7 @@ typedef struct __taskloop_params {
   kmp_uint64

[llvm-branch-commits] [llvm] ee74d1b - X86: use a data driven configuration of Windows x86 libcalls (NFC)

2020-12-09 Thread Saleem Abdulrasool via llvm-branch-commits

Author: Saleem Abdulrasool
Date: 2020-12-09T22:49:11Z
New Revision: ee74d1b420369d1dbe18be43d71d3392536ce228

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

LOG: X86: use a data driven configuration of Windows x86 libcalls (NFC)

Rather than creating a series of associated calls and ensuring that
everything is lined up, use a table driven approach that ensures that
they two always stay in sync.

Added: 


Modified: 
llvm/lib/Target/X86/X86ISelLowering.cpp

Removed: 




diff  --git a/llvm/lib/Target/X86/X86ISelLowering.cpp 
b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 53f30af8d38b..5a77cc1f17fc 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -135,19 +135,24 @@ X86TargetLowering::X86TargetLowering(const 
X86TargetMachine &TM,
   addBypassSlowDiv(64, 32);
   }
 
-  if (Subtarget.isTargetWindowsMSVC() ||
-  Subtarget.isTargetWindowsItanium()) {
-// Setup Windows compiler runtime calls.
-setLibcallName(RTLIB::SDIV_I64, "_alldiv");
-setLibcallName(RTLIB::UDIV_I64, "_aulldiv");
-setLibcallName(RTLIB::SREM_I64, "_allrem");
-setLibcallName(RTLIB::UREM_I64, "_aullrem");
-setLibcallName(RTLIB::MUL_I64, "_allmul");
-setLibcallCallingConv(RTLIB::SDIV_I64, CallingConv::X86_StdCall);
-setLibcallCallingConv(RTLIB::UDIV_I64, CallingConv::X86_StdCall);
-setLibcallCallingConv(RTLIB::SREM_I64, CallingConv::X86_StdCall);
-setLibcallCallingConv(RTLIB::UREM_I64, CallingConv::X86_StdCall);
-setLibcallCallingConv(RTLIB::MUL_I64, CallingConv::X86_StdCall);
+  // Setup Windows compiler runtime calls.
+  if (Subtarget.isTargetWindowsMSVC() || Subtarget.isTargetWindowsItanium()) {
+static const struct {
+  const RTLIB::Libcall Op;
+  const char * const Name;
+  const CallingConv::ID CC;
+} LibraryCalls[] = {
+  { RTLIB::SDIV_I64, "_alldiv", CallingConv::X86_StdCall },
+  { RTLIB::UDIV_I64, "_aulldiv", CallingConv::X86_StdCall },
+  { RTLIB::SREM_I64, "_allrem", CallingConv::X86_StdCall },
+  { RTLIB::UREM_I64, "_aullrem", CallingConv::X86_StdCall },
+  { RTLIB::MUL_I64, "_allmul", CallingConv::X86_StdCall },
+};
+
+for (const auto &LC : LibraryCalls) {
+  setLibcallName(LC.Op, LC.Name);
+  setLibcallCallingConv(LC.Op, LC.CC);
+}
   }
 
   if (Subtarget.getTargetTriple().isOSMSVCRT()) {



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


  1   2   >