[llvm-branch-commits] [clang] 1ab9327 - [TargetMachine][CodeGenModule] Delete unneeded ppc32 special case from shouldAssumeDSOLocal

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

Author: Fangrui Song
Date: 2020-12-05T00:42:07-08:00
New Revision: 1ab9327d1c01645806394faa648f65e947b65177

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

LOG: [TargetMachine][CodeGenModule] Delete unneeded ppc32 special case from 
shouldAssumeDSOLocal

PPCMCInstLower does not actually call shouldAssumeDSOLocal for ppc32 so this is 
dead.
Actually Clang ppc32 does produce a pair of absolute relocations which match 
GCC.

This also fixes a comment (R_PPC_COPY and R_PPC64_COPY do exist).

Added: 


Modified: 
clang/lib/CodeGen/CodeGenModule.cpp
llvm/lib/Target/TargetMachine.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index ce5fb9434950..0bb9c91f2434 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -967,10 +967,8 @@ static bool shouldAssumeDSOLocal(const CodeGenModule &CGM,
   if (RM == llvm::Reloc::PIC_ && GV->hasExternalWeakLinkage())
 return false;
 
-  // PPC has no copy relocations and cannot use a plt entry as a symbol 
address.
-  llvm::Triple::ArchType Arch = TT.getArch();
-  if (Arch == llvm::Triple::ppc || Arch == llvm::Triple::ppc64 ||
-  Arch == llvm::Triple::ppc64le)
+  // PowerPC64 prefers TOC indirection to avoid copy relocations.
+  if (TT.isPPC64())
 return false;
 
   // If we can use copy relocations we can assume it is local.

diff  --git a/llvm/lib/Target/TargetMachine.cpp 
b/llvm/lib/Target/TargetMachine.cpp
index 30f588193def..e2fd4687d3c8 100644
--- a/llvm/lib/Target/TargetMachine.cpp
+++ b/llvm/lib/Target/TargetMachine.cpp
@@ -186,8 +186,8 @@ bool TargetMachine::shouldAssumeDSOLocal(const Module &M,
   return false;
 Triple::ArchType Arch = TT.getArch();
 
-// PowerPC prefers avoiding copy relocations.
-if (Arch == Triple::ppc || TT.isPPC64())
+// PowerPC64 prefers TOC indirection to avoid copy relocations.
+if (TT.isPPC64())
   return false;
 
 // dso_local is traditionally implied for Reloc::Static. Eventually we 
shall



___
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] 8925d23 - [BasicAA] Add recphi tests with nested loops (NFC)

2020-12-05 Thread Nikita Popov via llvm-branch-commits

Author: Nikita Popov
Date: 2020-12-05T11:09:15+01:00
New Revision: 8925d2347432b69d7e4b721a4ced85df0ad782b1

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

LOG: [BasicAA] Add recphi tests with nested loops (NFC)

Added: 


Modified: 
llvm/test/Analysis/BasicAA/recphi.ll

Removed: 




diff  --git a/llvm/test/Analysis/BasicAA/recphi.ll 
b/llvm/test/Analysis/BasicAA/recphi.ll
index 13a58fbcf118..7f8bc9d7b668 100644
--- a/llvm/test/Analysis/BasicAA/recphi.ll
+++ b/llvm/test/Analysis/BasicAA/recphi.ll
@@ -1,4 +1,5 @@
-; RUN: opt < %s -basic-aa -aa-eval -print-all-alias-modref-info 
-disable-output 2>&1 | FileCheck %s
+; RUN: opt < %s -basic-aa -aa-eval -print-all-alias-modref-info 
-disable-output 2>&1 | FileCheck %s --check-prefixes=CHECK,NO-PHI-VALUES
+; RUN: opt < %s -phi-values -basic-aa -aa-eval -print-all-alias-modref-info 
-disable-output 2>&1 | FileCheck %s --check-prefixes=CHECK,PHI-VALUES
 
 ; CHECK-LABEL: Function: simple: 5 pointers, 0 call sites
 ; CHECK: NoAlias:  float* %src1, float* %src2
@@ -232,5 +233,63 @@ exit:
   ret i32* %result
 }
 
+; CHECK-LABEL: Function: nested_loop
+; CHECK: NoAlias:  i8* %a, i8* %p.base
+; CHECK: NoAlias:  i8* %a, i8* %p.outer
+; CHECK: NoAlias:  i8* %a, i8* %p.outer.next
+; NO-PHI-VALUES: MayAlias: i8* %a, i8* %p.inner
+; PHI-VALUES: NoAlias: i8* %a, i8* %p.inner
+; CHECK: NoAlias:  i8* %a, i8* %p.inner.next
+define void @nested_loop(i1 %c, i1 %c2, i8* noalias %p.base) {
+entry:
+  %a = alloca i8
+  br label %outer_loop
+
+outer_loop:
+  %p.outer = phi i8* [ %p.base, %entry ], [ %p.outer.next, %outer_loop_latch ]
+  br label %inner_loop
+
+inner_loop:
+  %p.inner = phi i8* [ %p.outer, %outer_loop ], [ %p.inner.next, %inner_loop ]
+  %p.inner.next = getelementptr inbounds i8, i8* %p.inner, i64 1
+  br i1 %c, label %inner_loop, label %outer_loop_latch
+
+outer_loop_latch:
+  %p.outer.next = getelementptr inbounds i8, i8* %p.inner, i64 10
+  br i1 %c2, label %outer_loop, label %exit
+
+exit:
+  ret void
+}
+
+; Same as the previous test case, but avoiding phi of phi.
+; CHECK-LABEL: Function: nested_loop2
+; CHECK: NoAlias:  i8* %a, i8* %p.base
+; CHECK: NoAlias:  i8* %a, i8* %p.outer
+; CHECK: NoAlias:  i8* %a, i8* %p.outer.next
+; CHECK: MayAlias: i8* %a, i8* %p.inner
+; CHECK: NoAlias:  i8* %a, i8* %p.inner.next
+; TODO: (a, p.inner) could be NoAlias
+define void @nested_loop2(i1 %c, i1 %c2, i8* noalias %p.base) {
+entry:
+  %a = alloca i8
+  br label %outer_loop
+
+outer_loop:
+  %p.outer = phi i8* [ %p.base, %entry ], [ %p.outer.next, %outer_loop_latch ]
+  %p.outer.next = getelementptr inbounds i8, i8* %p.outer, i64 10
+  br label %inner_loop
+
+inner_loop:
+  %p.inner = phi i8* [ %p.outer.next, %outer_loop ], [ %p.inner.next, 
%inner_loop ]
+  %p.inner.next = getelementptr inbounds i8, i8* %p.inner, i64 1
+  br i1 %c, label %inner_loop, label %outer_loop_latch
+
+outer_loop_latch:
+  br i1 %c2, label %outer_loop, label %exit
+
+exit:
+  ret void
+}
 
 declare i16 @call(i32)



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


[llvm-branch-commits] [llvm] f8afba5 - [AA] Add statistics for alias results (NFC)

2020-12-05 Thread Nikita Popov via llvm-branch-commits

Author: Nikita Popov
Date: 2020-12-05T11:09:15+01:00
New Revision: f8afba5f7a25a69c12191d979d78d40fa6e5b684

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

LOG: [AA] Add statistics for alias results (NFC)

Count how many NoAlias/MustAlias/MayAlias we get from top-level
queries.

Added: 


Modified: 
llvm/include/llvm/Analysis/AliasAnalysis.h
llvm/lib/Analysis/AliasAnalysis.cpp

Removed: 




diff  --git a/llvm/include/llvm/Analysis/AliasAnalysis.h 
b/llvm/include/llvm/Analysis/AliasAnalysis.h
index 7a4338905129..05c01931766e 100644
--- a/llvm/include/llvm/Analysis/AliasAnalysis.h
+++ b/llvm/include/llvm/Analysis/AliasAnalysis.h
@@ -814,6 +814,9 @@ class AAResults {
 
   std::vector AADeps;
 
+  /// Query depth used to distinguish recursive queries.
+  unsigned Depth;
+
   friend class BatchAAResults;
 };
 

diff  --git a/llvm/lib/Analysis/AliasAnalysis.cpp 
b/llvm/lib/Analysis/AliasAnalysis.cpp
index 3d094a65a5e3..6635e5302e36 100644
--- a/llvm/lib/Analysis/AliasAnalysis.cpp
+++ b/llvm/lib/Analysis/AliasAnalysis.cpp
@@ -24,6 +24,7 @@
 
//===--===//
 
 #include "llvm/Analysis/AliasAnalysis.h"
+#include "llvm/ADT/Statistic.h"
 #include "llvm/Analysis/BasicAliasAnalysis.h"
 #include "llvm/Analysis/CFLAndersAliasAnalysis.h"
 #include "llvm/Analysis/CFLSteensAliasAnalysis.h"
@@ -54,8 +55,14 @@
 #include 
 #include 
 
+#define DEBUG_TYPE "aa"
+
 using namespace llvm;
 
+STATISTIC(NumNoAlias,   "Number of NoAlias results");
+STATISTIC(NumMayAlias,  "Number of MayAlias results");
+STATISTIC(NumMustAlias, "Number of MustAlias results");
+
 /// Allow disabling BasicAA from the AA results. This is particularly useful
 /// when testing to isolate a single AA implementation.
 cl::opt DisableBasicAA("disable-basic-aa", cl::Hidden, cl::init(false));
@@ -109,12 +116,25 @@ AliasResult AAResults::alias(const MemoryLocation &LocA,
 
 AliasResult AAResults::alias(const MemoryLocation &LocA,
  const MemoryLocation &LocB, AAQueryInfo &AAQI) {
+  AliasResult Result = MayAlias;
+
+  Depth++;
   for (const auto &AA : AAs) {
-auto Result = AA->alias(LocA, LocB, AAQI);
+Result = AA->alias(LocA, LocB, AAQI);
 if (Result != MayAlias)
-  return Result;
+  break;
+  }
+  Depth--;
+
+  if (Depth == 0) {
+if (Result == NoAlias)
+  ++NumNoAlias;
+else if (Result == MustAlias)
+  ++NumMustAlias;
+else
+  ++NumMayAlias;
   }
-  return MayAlias;
+  return Result;
 }
 
 bool AAResults::pointsToConstantMemory(const MemoryLocation &Loc,



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


[llvm-branch-commits] [clang] 0e226d0 - [clang-format] [NFC] keep clang-format tests clang-format clean

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

Author: mydeveloperday
Date: 2020-12-05T10:15:52Z
New Revision: 0e226d00d21cdefe82ef4d6531e4e73d3b5c0494

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

LOG: [clang-format] [NFC] keep clang-format tests clang-format clean

I use several of the clang-format clean directories as a test suite, this one 
had got slightly out of wack in a prior commit

Reviewed By: HazardyKnusperkeks

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

Added: 


Modified: 
clang/unittests/Format/MacroExpanderTest.cpp

Removed: 




diff  --git a/clang/unittests/Format/MacroExpanderTest.cpp 
b/clang/unittests/Format/MacroExpanderTest.cpp
index b2cd5112b820..7ec98a5e82b7 100644
--- a/clang/unittests/Format/MacroExpanderTest.cpp
+++ b/clang/unittests/Format/MacroExpanderTest.cpp
@@ -65,6 +65,7 @@ class MacroExpanderTest : public ::testing::Test {
   << Context << " in " << text(Tokens) << " at " << File << ":" << 
Line;
 }
   }
+
 protected:
   llvm::SpecificBumpPtrAllocator Allocator;
   std::vector> Buffers;



___
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] e97dd11 - [AMDGPU][MC] Corrected error position for invalid MOVREL src

2020-12-05 Thread Dmitry Preobrazhensky via llvm-branch-commits

Author: Dmitry Preobrazhensky
Date: 2020-12-05T13:23:14+03:00
New Revision: e97dd119776129e888ab3c02e1394b58b709fd1f

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

LOG: [AMDGPU][MC] Corrected error position for invalid MOVREL src

See bug 47518 (https://bugs.llvm.org/show_bug.cgi?id=47518)

Reviewers: rampitec

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

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 d1e5fe59e910..8128bbcaa65d 100644
--- a/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
+++ b/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
@@ -1401,7 +1401,7 @@ class AMDGPUAsmParser : public MCTargetAsmParser {
   bool validateIntClampSupported(const MCInst &Inst);
   bool validateMIMGAtomicDMask(const MCInst &Inst);
   bool validateMIMGGatherDMask(const MCInst &Inst);
-  bool validateMovrels(const MCInst &Inst);
+  bool validateMovrels(const MCInst &Inst, const OperandVector &Operands);
   bool validateMIMGDataSize(const MCInst &Inst);
   bool validateMIMGAddrSize(const MCInst &Inst);
   bool validateMIMGD16(const MCInst &Inst);
@@ -3337,7 +3337,8 @@ static bool IsMovrelsSDWAOpcode(const unsigned Opcode)
 // movrels* opcodes should only allow VGPRS as src0.
 // This is specified in .td description for vop1/vop3,
 // but sdwa is handled 
diff erently. See isSDWAOperand.
-bool AMDGPUAsmParser::validateMovrels(const MCInst &Inst) {
+bool AMDGPUAsmParser::validateMovrels(const MCInst &Inst,
+  const OperandVector &Operands) {
 
   const unsigned Opc = Inst.getOpcode();
   const MCInstrDesc &Desc = MII.get(Opc);
@@ -3348,13 +3349,20 @@ bool AMDGPUAsmParser::validateMovrels(const MCInst 
&Inst) {
   const int Src0Idx = AMDGPU::getNamedOperandIdx(Opc, AMDGPU::OpName::src0);
   assert(Src0Idx != -1);
 
+  SMLoc ErrLoc;
   const MCOperand &Src0 = Inst.getOperand(Src0Idx);
-  if (!Src0.isReg())
-return false;
+  if (Src0.isReg()) {
+auto Reg = mc2PseudoReg(Src0.getReg());
+const MCRegisterInfo *TRI = getContext().getRegisterInfo();
+if (!isSGPR(Reg, TRI))
+  return true;
+ErrLoc = getRegLoc(Reg, Operands);
+  } else {
+ErrLoc = getConstLoc(Operands);
+  }
 
-  auto Reg = Src0.getReg();
-  const MCRegisterInfo *TRI = getContext().getRegisterInfo();
-  return !isSGPR(mc2PseudoReg(Reg), TRI);
+  Error(ErrLoc, "source operand must be a VGPR");
+  return false;
 }
 
 bool AMDGPUAsmParser::validateMAIAccWrite(const MCInst &Inst,
@@ -3899,8 +3907,7 @@ bool AMDGPUAsmParser::validateInstruction(const MCInst 
&Inst,
   "invalid image_gather dmask: only one bit must be set");
 return false;
   }
-  if (!validateMovrels(Inst)) {
-Error(IDLoc, "source operand must be a VGPR");
+  if (!validateMovrels(Inst, Operands)) {
 return false;
   }
   if (!validateFlatOffset(Inst, Operands)) {
@@ -4033,7 +4040,7 @@ bool AMDGPUAsmParser::MatchAndEmitInstruction(SMLoc 
IDLoc, unsigned &Opcode,
 SMLoc ErrorLoc = IDLoc;
 if (ErrorInfo != ~0ULL) {
   if (ErrorInfo >= Operands.size()) {
-return Error(IDLoc, "too few operands for instruction");
+return Error(getLoc(), "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 ee83bef0c50b..b650a78627db 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: :1: error: too few operands for instruction
+// GCN: :4: 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 c1aa9f860b5c..f7c9bd914f46 100644
--- a/llvm/test/MC/AMDGPU/gfx10_err_pos.s
+++ b/llvm/test/MC/AMDGPU/gfx10_err_pos.s
@@ -938,7 +938,17 @@ s_mov_b64 s[10:11], [s2,s1]
 v_movrels_b32_sdwa v0, 1 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:DWORD
 // CHECK: error: source operand must be a VGPR
 // CHECK-NEXT:{{^}}v_movrels_b32_sdwa v0, 1 dst_sel:DWORD 
dst_unused:UNUSED_PAD src0_sel:DWORD
-// CHECK-NEXT:{{^}}^
+// CHECK-NEXT:{{^}}   ^
+
+v_movrels_b32_sdwa v0, s0
+// CHECK: error: source operand must be a VGPR
+// CHECK-NEXT:{{^}}v_movrels_b32_sdwa v0, s0
+// CHECK-NEXT:{{^}}   ^
+
+v_movrels_b32_sdwa v0, shared_base
+// CHECK: error: source op

[llvm-branch-commits] [llvm] 0003600 - [AA] Initialize Depth member

2020-12-05 Thread Nikita Popov via llvm-branch-commits

Author: Nikita Popov
Date: 2020-12-05T11:37:36+01:00
New Revision: 0003600aafd422ffb9dd86383d4828990476d45c

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

LOG: [AA] Initialize Depth member

Fix mistake introduced in f8afba5f7a25a69c12191d979d78d40fa6e5b684:
I failed to initialize the Depth member to zero.

Added: 


Modified: 
llvm/include/llvm/Analysis/AliasAnalysis.h

Removed: 




diff  --git a/llvm/include/llvm/Analysis/AliasAnalysis.h 
b/llvm/include/llvm/Analysis/AliasAnalysis.h
index 05c01931766e..ce4ebab3efa4 100644
--- a/llvm/include/llvm/Analysis/AliasAnalysis.h
+++ b/llvm/include/llvm/Analysis/AliasAnalysis.h
@@ -815,7 +815,7 @@ class AAResults {
   std::vector AADeps;
 
   /// Query depth used to distinguish recursive queries.
-  unsigned Depth;
+  unsigned Depth = 0;
 
   friend class BatchAAResults;
 };



___
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] a0b3a93 - [AMDGPU][MC] Improved diagnostics message for sym/expr operands

2020-12-05 Thread Dmitry Preobrazhensky via llvm-branch-commits

Author: Dmitry Preobrazhensky
Date: 2020-12-05T14:05:53+03:00
New Revision: a0b3a9391cd8cfff2ad1741f12e5ed10acc97869

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

LOG: [AMDGPU][MC] Improved diagnostics message for sym/expr operands

See bug 48295 (https://bugs.llvm.org/show_bug.cgi?id=48295)

Reviewers: rampitec

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

Added: 


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

Removed: 




diff  --git a/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp 
b/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
index 8128bbcaa65d..45774935287b 100644
--- a/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
+++ b/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
@@ -1438,7 +1438,7 @@ class AMDGPUAsmParser : public MCTargetAsmParser {
 
   void peekTokens(MutableArrayRef Tokens);
   AsmToken::TokenKind getTokenKind() const;
-  bool parseExpr(int64_t &Imm);
+  bool parseExpr(int64_t &Imm, StringRef Expected = "");
   bool parseExpr(OperandVector &Operands);
   StringRef getTokenStr() const;
   AsmToken peekToken();
@@ -5683,8 +5683,8 @@ AMDGPUAsmParser::parseHwregBody(OperandInfoTy &HwReg,
   if (isToken(AsmToken::Identifier) &&
   (HwReg.Id = getHwregId(getTokenStr())) >= 0) {
 HwReg.IsSymbolic = true;
-lex(); // skip message name
-  } else if (!parseExpr(HwReg.Id)) {
+lex(); // skip register name
+  } else if (!parseExpr(HwReg.Id, "a register name")) {
 return false;
   }
 
@@ -5753,7 +5753,7 @@ AMDGPUAsmParser::parseHwreg(OperandVector &Operands) {
 } else {
   return MatchOperand_ParseFail;
 }
-  } else if (parseExpr(ImmVal)) {
+  } else if (parseExpr(ImmVal, "a hwreg macro")) {
 if (ImmVal < 0 || !isUInt<16>(ImmVal)) {
   Error(Loc, "invalid immediate: only 16-bit values are legal");
   return MatchOperand_ParseFail;
@@ -5784,7 +5784,7 @@ AMDGPUAsmParser::parseSendMsgBody(OperandInfoTy &Msg,
   if (isToken(AsmToken::Identifier) && (Msg.Id = getMsgId(getTokenStr())) >= 
0) {
 Msg.IsSymbolic = true;
 lex(); // skip message name
-  } else if (!parseExpr(Msg.Id)) {
+  } else if (!parseExpr(Msg.Id, "a message name")) {
 return false;
   }
 
@@ -5794,7 +5794,7 @@ AMDGPUAsmParser::parseSendMsgBody(OperandInfoTy &Msg,
 if (isToken(AsmToken::Identifier) &&
 (Op.Id = getMsgOpId(Msg.Id, getTokenStr())) >= 0) {
   lex(); // skip operation name
-} else if (!parseExpr(Op.Id)) {
+} else if (!parseExpr(Op.Id, "an operation name")) {
   return false;
 }
 
@@ -5864,7 +5864,7 @@ AMDGPUAsmParser::parseSendMsgOp(OperandVector &Operands) {
 } else {
   return MatchOperand_ParseFail;
 }
-  } else if (parseExpr(ImmVal)) {
+  } else if (parseExpr(ImmVal, "a sendmsg macro")) {
 if (ImmVal < 0 || !isUInt<16>(ImmVal)) {
   Error(Loc, "invalid immediate: only 16-bit values are legal");
   return MatchOperand_ParseFail;
@@ -6082,8 +6082,23 @@ AMDGPUAsmParser::skipToken(const AsmToken::TokenKind 
Kind,
 }
 
 bool
-AMDGPUAsmParser::parseExpr(int64_t &Imm) {
-  return !getParser().parseAbsoluteExpression(Imm);
+AMDGPUAsmParser::parseExpr(int64_t &Imm, StringRef Expected) {
+  SMLoc S = getLoc();
+
+  const MCExpr *Expr;
+  if (Parser.parseExpression(Expr))
+return false;
+
+  if (Expr->evaluateAsAbsolute(Imm))
+return true;
+
+  if (Expected.empty()) {
+Error(S, "expected absolute expression");
+  } else {
+Error(S, Twine("expected ", Expected) +
+ Twine(" or an absolute expression"));
+  }
+  return false;
 }
 
 bool
@@ -6400,7 +6415,7 @@ AMDGPUAsmParser::parseSwizzleOffset(int64_t &Imm) {
 
   SMLoc OffsetLoc = Parser.getTok().getLoc();
 
-  if (!parseExpr(Imm)) {
+  if (!parseExpr(Imm, "a swizzle macro")) {
 return false;
   }
   if (!isUInt<16>(Imm)) {

diff  --git a/llvm/test/MC/AMDGPU/ds-err.s b/llvm/test/MC/AMDGPU/ds-err.s
index 507bcbc1c4da..5d0a7463544a 100644
--- a/llvm/test/MC/AMDGPU/ds-err.s
+++ b/llvm/test/MC/AMDGPU/ds-err.s
@@ -46,7 +46,7 @@ ds_swizzle_b32 v8, v2 offset:
 // CHECK: error: expected a colon
 ds_swizzle_b32 v8, v2 offset-
 
-// CHECK: error: expected absolute expression
+// CHECK: error: expected a swizzle macro or an absolute expression
 ds_swizzle_b32 v8, v2 offset:SWIZZLE(QUAD_PERM, 0, 1, 2, 3)
 
 // CHECK: error: expected a swizzle mode

diff  --git a/llvm/test/MC/AMDGPU/gfx10_err_pos.s 
b/llvm/test/MC/AMDGPU/gfx10_err_pos.s
index f7c9bd914f46..8d0c3694b285 100644
--- a/llvm/test/MC/AMDGPU/gfx10_err_pos.s
+++ b/llvm/test/MC/AMDGPU/gfx10_err_pos.s
@@ -331,26 +331,6 @@ ds_swizzle_b32 v8, v2 offset:swizzle(XXX,1)
 
//===

[llvm-branch-commits] [llvm] 4ceecc8 - [ConstraintElimination] Handle constraints with all zero var coeffs.

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

Author: Florian Hahn
Date: 2020-12-05T12:06:53Z
New Revision: 4ceecc820b7197c2f302aa235875eb6619a397c3

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

LOG: [ConstraintElimination] Handle constraints with all zero var coeffs.

Constraints where all variable coefficients are 0 do not add any useful
information. When checking, we can check if they are always true/false.

Added: 
llvm/test/Transforms/ConstraintElimination/empty-constraint.ll

Modified: 
llvm/include/llvm/Analysis/ConstraintSystem.h
llvm/lib/Analysis/ConstraintSystem.cpp
llvm/lib/Transforms/Scalar/ConstraintElimination.cpp

Removed: 




diff  --git a/llvm/include/llvm/Analysis/ConstraintSystem.h 
b/llvm/include/llvm/Analysis/ConstraintSystem.h
index f4e6dfbefc82..2e55d5d45674 100644
--- a/llvm/include/llvm/Analysis/ConstraintSystem.h
+++ b/llvm/include/llvm/Analysis/ConstraintSystem.h
@@ -11,6 +11,7 @@
 
 #include "llvm/ADT/APInt.h"
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallVector.h"
 
 #include 
@@ -39,22 +40,28 @@ class ConstraintSystem {
   bool mayHaveSolutionImpl();
 
 public:
-  void addVariableRow(const SmallVector &R) {
+  bool addVariableRow(const SmallVector &R) {
 assert(Constraints.empty() || R.size() == Constraints.back().size());
+// If all variable coefficients are 0, the constraint does not provide any
+// usable information.
+if (all_of(makeArrayRef(R).drop_front(1), [](int64_t C) { return C == 0; 
}))
+  return false;
+
 for (const auto &C : R) {
   auto A = std::abs(C);
   GCD = APIntOps::GreatestCommonDivisor({32, (uint32_t)A}, {32, GCD})
 .getZExtValue();
 }
 Constraints.push_back(R);
+return true;
   }
 
-  void addVariableRowFill(const SmallVector &R) {
+  bool addVariableRowFill(const SmallVector &R) {
 for (auto &CR : Constraints) {
   while (CR.size() != R.size())
 CR.push_back(0);
 }
-addVariableRow(R);
+return addVariableRow(R);
   }
 
   /// Returns true if there may be a solution for the constraints in the 
system.

diff  --git a/llvm/lib/Analysis/ConstraintSystem.cpp 
b/llvm/lib/Analysis/ConstraintSystem.cpp
index d5b15e7587b3..3df118495209 100644
--- a/llvm/lib/Analysis/ConstraintSystem.cpp
+++ b/llvm/lib/Analysis/ConstraintSystem.cpp
@@ -140,6 +140,11 @@ bool ConstraintSystem::mayHaveSolution() {
 }
 
 bool ConstraintSystem::isConditionImplied(SmallVector R) {
+  // If all variable coefficients are 0, we have 'C >= 0'. If the constant is 
>=
+  // 0, R is always true, regardless of the system.
+  if (all_of(makeArrayRef(R).drop_front(1), [](int64_t C) { return C == 0; }))
+return R[0] >= 0;
+
   // If there is no solution with the negation of R added to the system, the
   // condition must hold based on the existing constraints.
   R = ConstraintSystem::negate(R);

diff  --git a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp 
b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
index b2465d2721ef..616518cbcfdc 100644
--- a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
@@ -346,8 +346,10 @@ static bool eliminateConstraints(Function &F, 
DominatorTree &DT) {
 if (CB.Not)
   R = ConstraintSystem::negate(R);
 
-CS.addVariableRowFill(R);
-DFSInStack.emplace_back(CB.NumIn, CB.NumOut, CB.Condition, CB.Not);
+// If R has been added to the system, queue it for removal once it goes
+// out-of-scope.
+if (CS.addVariableRowFill(R))
+  DFSInStack.emplace_back(CB.NumIn, CB.NumOut, CB.Condition, CB.Not);
   }
 
   return Changed;

diff  --git a/llvm/test/Transforms/ConstraintElimination/empty-constraint.ll 
b/llvm/test/Transforms/ConstraintElimination/empty-constraint.ll
new file mode 100644
index ..cc30da08f08c
--- /dev/null
+++ b/llvm/test/Transforms/ConstraintElimination/empty-constraint.ll
@@ -0,0 +1,47 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -constraint-elimination -S %s | FileCheck %s
+
+; Make sure constraints where all variable coefficients are 0 are handled
+; properly.
+
+define i1 @test_1_always_false(i32 %A, i32 %B) {
+; CHECK-LABEL: @test_1_always_false(
+; CHECK-NEXT:[[C_1:%.*]] = icmp ugt i32 [[A:%.*]], [[A]]
+; CHECK-NEXT:br i1 [[C_1]], label [[IF_END_I16:%.*]], label 
[[IF_THEN_I10:%.*]]
+; CHECK:   if.then.i10:
+; CHECK-NEXT:ret i1 false
+; CHECK:   if.end.i16:
+; CHECK-NEXT:[[C_2:%.*]] = icmp ugt i32 [[A]], [[A]]
+; CHECK-NEXT:ret i1 false
+;
+  %c.1 = icmp ugt i32 %A, %A
+  br i1 %c.1, label %if.end.i16, label %if.then.i10
+
+if.then.i10:
+  ret i1 false
+
+if.end.i16:
+  %c.2 = icmp ugt i32 %A, %A
+  ret i1 %c.2
+}
+
+define i1 @test_2_al

[llvm-branch-commits] [llvm] 4e5c0c2 - [ConstraintElimination] Wrap dump() call in LLVM_DEBUG (NFC).

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

Author: Florian Hahn
Date: 2020-12-05T13:14:53Z
New Revision: 4e5c0c2a63e2dff804a32b22d7d815a35a47c8d7

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

LOG: [ConstraintElimination] Wrap dump() call in LLVM_DEBUG (NFC).

ConstraintSystem::dump only generates output with -debug, but there's no
need to call it without -debug.

Added: 


Modified: 
llvm/lib/Analysis/ConstraintSystem.cpp

Removed: 




diff  --git a/llvm/lib/Analysis/ConstraintSystem.cpp 
b/llvm/lib/Analysis/ConstraintSystem.cpp
index 3df118495209..f3a28347ded4 100644
--- a/llvm/lib/Analysis/ConstraintSystem.cpp
+++ b/llvm/lib/Analysis/ConstraintSystem.cpp
@@ -133,7 +133,7 @@ void ConstraintSystem::dump() const {
 }
 
 bool ConstraintSystem::mayHaveSolution() {
-  dump();
+  LLVM_DEBUG(dump());
   bool HasSolution = mayHaveSolutionImpl();
   LLVM_DEBUG(dbgs() << (HasSolution ? "sat" : "unsat") << "\n");
   return HasSolution;



___
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] f687b4a - [NFC][clang-tidy] Fixes comment typos.

2020-12-05 Thread Mark de Wever via llvm-branch-commits

Author: Mark de Wever
Date: 2020-12-05T16:31:16+01:00
New Revision: f687b4ac84a3f76ec850dccb675ac2b5c00f8661

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

LOG: [NFC][clang-tidy] Fixes comment typos.

Added: 


Modified: 
clang-tools-extra/clang-tidy/bugprone/SignedCharMisuseCheck.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/bugprone/SignedCharMisuseCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/SignedCharMisuseCheck.cpp
index 555f8e11dff9..f776621e3339 100644
--- a/clang-tools-extra/clang-tidy/bugprone/SignedCharMisuseCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/SignedCharMisuseCheck.cpp
@@ -84,14 +84,14 @@ void SignedCharMisuseCheck::registerMatchers(MatchFinder 
*Finder) {
   const auto UnSignedCharCastExpr =
   charCastExpression(false, IntegerType, "unsignedCastExpression");
 
-  // Catch assignments with singed char -> integer conversion.
+  // Catch assignments with signed char -> integer conversion.
   const auto AssignmentOperatorExpr =
   expr(binaryOperator(hasOperatorName("="), hasLHS(hasType(IntegerType)),
   hasRHS(SignedCharCastExpr)));
 
   Finder->addMatcher(AssignmentOperatorExpr, this);
 
-  // Catch declarations with singed char -> integer conversion.
+  // Catch declarations with signed char -> integer conversion.
   const auto Declaration = varDecl(isDefinition(), hasType(IntegerType),
hasInitializer(SignedCharCastExpr));
 



___
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] ce6269f - [NFC][libc++] Update C++20 issues status.

2020-12-05 Thread Mark de Wever via llvm-branch-commits

Author: Mark de Wever
Date: 2020-12-05T16:36:19+01:00
New Revision: ce6269f9ba6cc81062bb8634447dc6e1d1c381e6

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

LOG: [NFC][libc++] Update C++20 issues status.

Properly mark LWG1203 as completed and move the version number to the
version column.

Added: 


Modified: 
libcxx/docs/Cxx2aStatusIssuesStatus.csv

Removed: 




diff  --git a/libcxx/docs/Cxx2aStatusIssuesStatus.csv 
b/libcxx/docs/Cxx2aStatusIssuesStatus.csv
index 58ef50fd2fea..4c78b1655631 100644
--- a/libcxx/docs/Cxx2aStatusIssuesStatus.csv
+++ b/libcxx/docs/Cxx2aStatusIssuesStatus.csv
@@ -188,7 +188,7 @@
 "`3277 `__","Pre-increment on prvalues is not a 
requirement of ``weakly_incrementable``\ ","Belfast","",""
 "`3149 `__","``DefaultConstructible``\  should 
require default initialization","Belfast","",""
 "","","","",""
-"`1203 `__","More useful rvalue stream 
insertion","Prague","12.0",""
+"`1203 `__","More useful rvalue stream 
insertion","Prague","|Complete|","12.0"
 "`2859 `__","Definition of *reachable* in 
[ptr.launder] misses pointer arithmetic from pointer-interconvertible 
object","Prague","",""
 "`3018 `__","``shared_ptr``\  of function 
type","Prague","",""
 "`3050 `__","Conversion specification problem in 
``chrono::duration``\  constructor","Prague","",""



___
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] 8668eae - [clang-format] Add option for case sensitive regexes for sorted includes

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

Author: mydeveloperday
Date: 2020-12-05T16:33:21Z
New Revision: 8668eae2adf23209e3f8d19477725eb7e73ba93c

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

LOG: [clang-format] Add option for case sensitive regexes for sorted includes

I think the title says everything.

Reviewed By: MyDeveloperDay

Patch By:  HazardyKnusperkeks

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

Added: 


Modified: 
clang/docs/ClangFormatStyleOptions.rst
clang/include/clang/Tooling/Inclusions/IncludeStyle.h
clang/lib/Format/Format.cpp
clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
clang/lib/Tooling/Inclusions/IncludeStyle.cpp
clang/unittests/Format/FormatTest.cpp
clang/unittests/Format/SortIncludesTest.cpp

Removed: 




diff  --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index d6d437a0a05e..55d706fe 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -1719,6 +1719,9 @@ the configuration (without a prefix: ``Auto``).
   priority for order.``SortPriority`` is set to the value of ``Priority``
   as default if it is not assigned.
 
+  Each regular expression can be marked as case sensitive with the field
+  ``CaseSensitive``, per default it is not.
+
   To configure this in the .clang-format file, use:
 
   .. code-block:: yaml
@@ -1727,6 +1730,7 @@ the configuration (without a prefix: ``Auto``).
   - Regex:   '^"(llvm|llvm-c|clang|clang-c)/'
 Priority:2
 SortPriority:2
+CaseSensitive:   true
   - Regex:   '^(<|"(gtest|gmock|isl|json)/)'
 Priority:3
   - Regex:   '<[[:alnum:].]+>'

diff  --git a/clang/include/clang/Tooling/Inclusions/IncludeStyle.h 
b/clang/include/clang/Tooling/Inclusions/IncludeStyle.h
index 2648297724e1..89b0d4635251 100644
--- a/clang/include/clang/Tooling/Inclusions/IncludeStyle.h
+++ b/clang/include/clang/Tooling/Inclusions/IncludeStyle.h
@@ -60,8 +60,11 @@ struct IncludeStyle {
 int Priority;
 /// The custom priority to sort before grouping.
 int SortPriority;
+/// If the regular expression is case sensitive.
+bool RegexIsCaseSensitive;
 bool operator==(const IncludeCategory &Other) const {
-  return Regex == Other.Regex && Priority == Other.Priority;
+  return Regex == Other.Regex && Priority == Other.Priority &&
+ RegexIsCaseSensitive == Other.RegexIsCaseSensitive;
 }
   };
 
@@ -84,20 +87,25 @@ struct IncludeStyle {
   /// (https://llvm.org/docs/CodingStandards.html#include-style). However, you
   /// can also assign negative priorities if you have certain headers that
   /// always need to be first.
-  /// 
+  ///
   /// There is a third and optional field ``SortPriority`` which can used while
-  /// ``IncludeBloks = IBS_Regroup`` to define the priority in which 
``#includes``
-  /// should be ordered, and value of ``Priority`` defines the order of
+  /// ``IncludeBloks = IBS_Regroup`` to define the priority in which
+  /// ``#includes`` should be ordered, and value of ``Priority`` defines the
+  /// order of
   /// ``#include blocks`` and also enables to group ``#includes`` of 
diff erent
   /// priority for order.``SortPriority`` is set to the value of ``Priority``
   /// as default if it is not assigned.
   ///
+  /// Each regular expression can be marked as case sensitive with the field
+  /// ``CaseSensitive``, per default it is not.
+  ///
   /// To configure this in the .clang-format file, use:
   /// \code{.yaml}
   ///   IncludeCategories:
   /// - Regex:   '^"(llvm|llvm-c|clang|clang-c)/'
   ///   Priority:2
   ///   SortPriority:2
+  ///   CaseSensitive:   true
   /// - Regex:   '^(<|"(gtest|gmock|isl|json)/)'
   ///   Priority:3
   /// - Regex:   '<[[:alnum:].]+>'

diff  --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index f5ae35131ace..a3f740ff8692 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -916,9 +916,9 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind 
Language) {
   LLVMStyle.ForEachMacros.push_back("Q_FOREACH");
   LLVMStyle.ForEachMacros.push_back("BOOST_FOREACH");
   LLVMStyle.IncludeStyle.IncludeCategories = {
-  {"^\"(llvm|llvm-c|clang|clang-c)/", 2, 0},
-  {"^(<|\"(gtest|gmock|isl|json)/)", 3, 0},
-  {".*", 1, 0}};
+  {"^\"(llvm|llvm-c|clang|clang-c)/", 2, 0, false},
+  {"^(<|\"(gtest|gmock|isl|json)/)", 3, 0, false},
+  {".*", 1, 0, false}};
   LLVMStyle.IncludeStyle.IncludeIsMainRegex = "(Test)?$";
   LLVMStyle.IncludeStyle.IncludeBlocks = tooling::IncludeStyle::IBS_Preserve;
   LLVMStyle.IndentCaseLabels = false;
@@ -1016,10 +1016,10 @@ Fo

[llvm-branch-commits] [libcxx] e6c89a4 - [SystemZ][ZOS] Fix the usage of pthread_t within libc++

2020-12-05 Thread Zbigniew Sarbinowski via llvm-branch-commits

Author: Zbigniew Sarbinowski
Date: 2020-12-05T17:46:30Z
New Revision: e6c89a499d91b5d50ac556428dac995d07f0f6e5

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

LOG: [SystemZ][ZOS] Fix the usage of pthread_t within libc++

This is the the minimal change introduced in [[ https://reviews.llvm.org/D88599 
| D88599 ]]  to unblock the controversial change and discussion of proper 
separation between thread from thread id which will continue in D88599.

This patch will address the differences of definition of pthread_t on z/OS vs. 
Linux and other OS. Main trick to make the code work on z/OS relies on 
redefining libcpp_thread_id type and _LIBCPP_NULL_THREAD macro. This is 
necessary to separate initialization of libcxx_thread_id from the one of 
__libcxx_thread_t;

Reviewed By: #libc, ldionne

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

Added: 


Modified: 
libcxx/include/__config
libcxx/include/__threading_support

Removed: 




diff  --git a/libcxx/include/__config b/libcxx/include/__config
index 3f56a022177d..d2fdf6785c7e 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -1113,6 +1113,7 @@ _LIBCPP_FUNC_VIS extern "C" void 
__sanitizer_annotate_contiguous_container(
   defined(__APPLE__) || \
   defined(__CloudABI__) || \
   defined(__sun__) || \
+  defined(__MVS__) || \
   (defined(__MINGW32__) && __has_include())
 #define _LIBCPP_HAS_THREAD_API_PTHREAD
 #  elif defined(__Fuchsia__)

diff  --git a/libcxx/include/__threading_support 
b/libcxx/include/__threading_support
index 2d0ccf5cb244..473c9c3bbe49 100644
--- a/libcxx/include/__threading_support
+++ b/libcxx/include/__threading_support
@@ -31,7 +31,7 @@
 #if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
 # include 
 # include 
-# ifdef __APPLE__
+# if defined(__APPLE__) || defined(__MVS__)
 #  define _LIBCPP_NO_NATIVE_SEMAPHORES
 # endif
 # ifndef _LIBCPP_NO_NATIVE_SEMAPHORES
@@ -87,11 +87,14 @@ typedef pthread_once_t __libcpp_exec_once_flag;
 #define _LIBCPP_EXEC_ONCE_INITIALIZER PTHREAD_ONCE_INIT
 
 // Thread id
-typedef pthread_t __libcpp_thread_id;
+#if defined(__MVS__)
+  typedef unsigned long long __libcpp_thread_id;
+#else
+  typedef pthread_t __libcpp_thread_id;
+#endif
 
 // Thread
-#define _LIBCPP_NULL_THREAD 0U
-
+#define _LIBCPP_NULL_THREAD ((__libcpp_thread_t()))
 typedef pthread_t __libcpp_thread_t;
 
 // Thread Local Storage
@@ -486,7 +489,7 @@ int __libcpp_execute_once(__libcpp_exec_once_flag *flag,
 // Returns non-zero if the thread ids are equal, otherwise 0
 bool __libcpp_thread_id_equal(__libcpp_thread_id t1, __libcpp_thread_id t2)
 {
-  return pthread_equal(t1, t2) != 0;
+  return t1 == t2;
 }
 
 // Returns non-zero if t1 < t2, otherwise 0
@@ -508,12 +511,17 @@ int __libcpp_thread_create(__libcpp_thread_t *__t, void 
*(*__func)(void *),
 
 __libcpp_thread_id __libcpp_thread_get_current_id()
 {
-  return pthread_self();
+  const __libcpp_thread_t thread = pthread_self();
+  return __libcpp_thread_get_id(&thread);
 }
 
 __libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t *__t)
 {
+#if defined(__MVS__)
+  return __t->__;
+#else
   return *__t;
+#endif
 }
 
 int __libcpp_thread_join(__libcpp_thread_t *__t)
@@ -653,7 +661,7 @@ bool __libcpp_thread_id_less(__libcpp_thread_id t1, 
__libcpp_thread_id t2)
 
 // Thread
 bool __libcpp_thread_isnull(const __libcpp_thread_t *__t) {
-  return *__t == 0;
+  return __libcpp_thread_get_id(__t) == 0;
 }
 
 int __libcpp_thread_create(__libcpp_thread_t *__t, void *(*__func)(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] [openmp] a148216 - [OpenMP][OMPT] Fix OMPT return address guard for gomp interface

2020-12-05 Thread Joachim Protze via llvm-branch-commits

Author: Joachim Protze
Date: 2020-12-05T19:06:28+01:00
New Revision: a148216b31292e52c0229dae98f52d3b2c350400

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

LOG: [OpenMP][OMPT] Fix OMPT return address guard for gomp interface

D91692 missed various locations in kmp_gsupport, where the scope for
OMPT_STORE_RETURN_ADDRESS is too narrow, i.e. the scope ends before the OMPT
callback is called in some nested function.

This patch fixes the scoping issue, so that all OMPT tests pass, when the
tests are built with gcc.

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

Added: 


Modified: 
openmp/runtime/src/kmp_gsupport.cpp

Removed: 




diff  --git a/openmp/runtime/src/kmp_gsupport.cpp 
b/openmp/runtime/src/kmp_gsupport.cpp
index 7b4a941d275f..08ad5c6d1551 100644
--- a/openmp/runtime/src/kmp_gsupport.cpp
+++ b/openmp/runtime/src/kmp_gsupport.cpp
@@ -102,8 +102,8 @@ void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_BARRIER)(void) {
   if (ompt_enabled.enabled) {
 __ompt_get_task_info_internal(0, NULL, NULL, &ompt_frame, NULL, NULL);
 ompt_frame->enter_frame.ptr = OMPT_GET_FRAME_ADDRESS(0);
-OMPT_STORE_RETURN_ADDRESS(gtid);
   }
+  OMPT_STORE_RETURN_ADDRESS(gtid);
 #endif
   __kmpc_barrier(&loc, gtid);
 #if OMPT_SUPPORT && OMPT_OPTIONAL
@@ -250,20 +250,20 @@ void 
*KMP_EXPAND_NAME(KMP_API_NAME_GOMP_SINGLE_COPY_START)(void) {
   if (ompt_enabled.enabled) {
 __ompt_get_task_info_internal(0, NULL, NULL, &ompt_frame, NULL, NULL);
 ompt_frame->enter_frame.ptr = OMPT_GET_FRAME_ADDRESS(0);
-OMPT_STORE_RETURN_ADDRESS(gtid);
   }
+  OMPT_STORE_RETURN_ADDRESS(gtid);
 #endif
   __kmp_barrier(bs_plain_barrier, gtid, FALSE, 0, NULL, NULL);
 
   // Retrieve the value of the copyprivate data point, and wait for all
   // threads to do likewise, then return.
   retval = __kmp_team_from_gtid(gtid)->t.t_copypriv_data;
+  {
 #if OMPT_SUPPORT && OMPT_OPTIONAL
-  if (ompt_enabled.enabled) {
 OMPT_STORE_RETURN_ADDRESS(gtid);
-  }
 #endif
-  __kmp_barrier(bs_plain_barrier, gtid, FALSE, 0, NULL, NULL);
+__kmp_barrier(bs_plain_barrier, gtid, FALSE, 0, NULL, NULL);
+  }
 #if OMPT_SUPPORT && OMPT_OPTIONAL
   if (ompt_enabled.enabled) {
 ompt_frame->enter_frame = ompt_data_none;
@@ -286,16 +286,16 @@ void 
KMP_EXPAND_NAME(KMP_API_NAME_GOMP_SINGLE_COPY_END)(void *data) {
   if (ompt_enabled.enabled) {
 __ompt_get_task_info_internal(0, NULL, NULL, &ompt_frame, NULL, NULL);
 ompt_frame->enter_frame.ptr = OMPT_GET_FRAME_ADDRESS(0);
-OMPT_STORE_RETURN_ADDRESS(gtid);
   }
+  OMPT_STORE_RETURN_ADDRESS(gtid);
 #endif
   __kmp_barrier(bs_plain_barrier, gtid, FALSE, 0, NULL, NULL);
+  {
 #if OMPT_SUPPORT && OMPT_OPTIONAL
-  if (ompt_enabled.enabled) {
 OMPT_STORE_RETURN_ADDRESS(gtid);
-  }
 #endif
-  __kmp_barrier(bs_plain_barrier, gtid, FALSE, 0, NULL, NULL);
+__kmp_barrier(bs_plain_barrier, gtid, FALSE, 0, NULL, NULL);
+  }
 #if OMPT_SUPPORT && OMPT_OPTIONAL
   if (ompt_enabled.enabled) {
 ompt_frame->enter_frame = ompt_data_none;
@@ -482,8 +482,8 @@ void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_PARALLEL_START)(void 
(*task)(void *),
   if (ompt_enabled.enabled) {
 __ompt_get_task_info_internal(0, NULL, NULL, &parent_frame, NULL, NULL);
 parent_frame->enter_frame.ptr = OMPT_GET_FRAME_ADDRESS(0);
-OMPT_STORE_RETURN_ADDRESS(gtid);
   }
+  OMPT_STORE_RETURN_ADDRESS(gtid);
 #endif
 
   MKLOC(loc, "GOMP_parallel_start");
@@ -1231,10 +1231,10 @@ void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_TASK)(void 
(*func)(void *), void *data,
 #if OMPT_SUPPORT
   kmp_taskdata_t *current_task;
   if (ompt_enabled.enabled) {
-OMPT_STORE_RETURN_ADDRESS(gtid);
 current_task = __kmp_threads[gtid]->th.th_current_task;
 current_task->ompt_task_info.frame.enter_frame.ptr = 
OMPT_GET_FRAME_ADDRESS(0);
   }
+  OMPT_STORE_RETURN_ADDRESS(gtid);
 #endif
 
   if (if_cond) {
@@ -1262,8 +1262,8 @@ void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_TASK)(void 
(*func)(void *), void *data,
   thread->th.ompt_thread_info.wait_id = 0;
   thread->th.ompt_thread_info.state = ompt_state_work_parallel;
   taskdata->ompt_task_info.frame.exit_frame.ptr = 
OMPT_GET_FRAME_ADDRESS(0);
-  OMPT_STORE_RETURN_ADDRESS(gtid);
 }
+OMPT_STORE_RETURN_ADDRESS(gtid);
 #endif
 if (gomp_flags & KMP_GOMP_TASK_DEPENDS_FLAG) {
   KMP_ASSERT(depend);
@@ -1300,8 +1300,7 @@ void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_TASKWAIT)(void) {
   int gtid = __kmp_entry_gtid();
 
 #if OMPT_SUPPORT
-  if (ompt_enabled.enabled)
-OMPT_STORE_RETURN_ADDRESS(gtid);
+  OMPT_STORE_RETURN_ADDRESS(gtid);
 #endif
 
   KA_TRACE(20, ("GOMP_taskwait: T#%d\n", gtid));
@@ -1378,8 +1377,8 @@ void 
KMP_EXPAND_NAME(KMP_API_NAME_GOMP_PARALLEL_SECTIONS_START)(
   if (ompt_enabled.enabled) {
 __ompt_get_task_info_internal(0, 

[llvm-branch-commits] [llvm] 2a136a7 - [X86] Autodetect znver3

2020-12-05 Thread Benjamin Kramer via llvm-branch-commits

Author: Benjamin Kramer
Date: 2020-12-05T19:08:20+01:00
New Revision: 2a136a7a9c68e4818b28bea6051b78a8181ba78e

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

LOG: [X86] Autodetect znver3

Added: 


Modified: 
clang/test/CodeGen/target-builtin-noerror.c
compiler-rt/lib/builtins/cpu_model.c
llvm/include/llvm/Support/X86TargetParser.def
llvm/lib/Support/Host.cpp

Removed: 




diff  --git a/clang/test/CodeGen/target-builtin-noerror.c 
b/clang/test/CodeGen/target-builtin-noerror.c
index 50967c6657cd..808f3a03431b 100644
--- a/clang/test/CodeGen/target-builtin-noerror.c
+++ b/clang/test/CodeGen/target-builtin-noerror.c
@@ -128,4 +128,5 @@ void verifycpustrings() {
   (void)__builtin_cpu_is("westmere");
   (void)__builtin_cpu_is("znver1");
   (void)__builtin_cpu_is("znver2");
+  (void)__builtin_cpu_is("znver3");
 }

diff  --git a/compiler-rt/lib/builtins/cpu_model.c 
b/compiler-rt/lib/builtins/cpu_model.c
index 05ef8492384f..51bedd98c3d3 100644
--- a/compiler-rt/lib/builtins/cpu_model.c
+++ b/compiler-rt/lib/builtins/cpu_model.c
@@ -68,6 +68,7 @@ enum ProcessorTypes {
   INTEL_GOLDMONT,
   INTEL_GOLDMONT_PLUS,
   INTEL_TREMONT,
+  AMDFAM19H,
   CPU_TYPE_MAX
 };
 
@@ -97,6 +98,7 @@ enum ProcessorSubtypes {
   INTEL_COREI7_COOPERLAKE,
   INTEL_COREI7_SAPPHIRERAPIDS,
   INTEL_COREI7_ALDERLAKE,
+  AMDFAM19H_ZNVER3,
   CPU_SUBTYPE_MAX
 };
 
@@ -550,6 +552,14 @@ getAMDProcessorTypeAndSubtype(unsigned Family, unsigned 
Model,
   break; // 00h-0Fh: Zen1
 }
 break;
+  case 25:
+CPU = "znver3";
+*Type = AMDFAM19H;
+if (Model <= 0x0f) {
+  *Subtype = AMDFAM19H_ZNVER3;
+  break; // 00h-0Fh: Zen3
+}
+break;
   default:
 break; // Unknown AMD CPU.
   }

diff  --git a/llvm/include/llvm/Support/X86TargetParser.def 
b/llvm/include/llvm/Support/X86TargetParser.def
index c0fe76dfdd64..ec19ce4e7cdd 100644
--- a/llvm/include/llvm/Support/X86TargetParser.def
+++ b/llvm/include/llvm/Support/X86TargetParser.def
@@ -44,6 +44,7 @@ X86_CPU_TYPE(INTEL_KNM,   "knm")
 X86_CPU_TYPE(INTEL_GOLDMONT,  "goldmont")
 X86_CPU_TYPE(INTEL_GOLDMONT_PLUS, "goldmont-plus")
 X86_CPU_TYPE(INTEL_TREMONT,   "tremont")
+X86_CPU_TYPE(AMDFAM19H,   "amdfam19h")
 
 // Alternate names supported by __builtin_cpu_is and target multiversioning.
 X86_CPU_TYPE_ALIAS(INTEL_BONNELL,"atom")
@@ -86,6 +87,7 @@ X86_CPU_SUBTYPE(INTEL_COREI7_TIGERLAKE,  "tigerlake")
 X86_CPU_SUBTYPE(INTEL_COREI7_COOPERLAKE, "cooperlake")
 X86_CPU_SUBTYPE(INTEL_COREI7_SAPPHIRERAPIDS, "sapphirerapids")
 X86_CPU_SUBTYPE(INTEL_COREI7_ALDERLAKE,  "alderlake")
+X86_CPU_SUBTYPE(AMDFAM19H_ZNVER3,"znver3")
 #undef X86_CPU_SUBTYPE
 
 

diff  --git a/llvm/lib/Support/Host.cpp b/llvm/lib/Support/Host.cpp
index 4fb93928ff15..b179c8334a2b 100644
--- a/llvm/lib/Support/Host.cpp
+++ b/llvm/lib/Support/Host.cpp
@@ -964,6 +964,14 @@ getAMDProcessorTypeAndSubtype(unsigned Family, unsigned 
Model,
   break; // 00h-0Fh: Zen1
 }
 break;
+  case 25:
+CPU = "znver3";
+*Type = X86::AMDFAM19H;
+if (Model <= 0x0f) {
+  *Subtype = X86::AMDFAM19H_ZNVER3;
+  break; // 00h-0Fh: Zen3
+}
+break;
   default:
 break; // Unknown AMD CPU.
   }



___
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] c722096 - [debugserver] Remove bridgeos availability

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

Author: Jonas Devlieghere
Date: 2020-12-05T10:18:45-08:00
New Revision: c722096b399695e89f283f0847474ccb038515f2

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

LOG: [debugserver] Remove bridgeos availability

I didn't realize that the 'bridgeos' is not part of the public SDK.

Added: 


Modified: 
lldb/tools/debugserver/source/MacOSX/MachProcess.mm

Removed: 




diff  --git a/lldb/tools/debugserver/source/MacOSX/MachProcess.mm 
b/lldb/tools/debugserver/source/MacOSX/MachProcess.mm
index fad39784b151..232a0d25a38a 100644
--- a/lldb/tools/debugserver/source/MacOSX/MachProcess.mm
+++ b/lldb/tools/debugserver/source/MacOSX/MachProcess.mm
@@ -3273,8 +3273,7 @@ static bool FBSAddEventDataToOptions(NSMutableDictionary 
*options,
 bool slice_preference_set = false;
 
 if (cpu_subtype != 0) {
-  if (@available(macOS 10.16, ios 10.14, watchos 7.0, tvos 14.0,
- bridgeos 5.0, *)) {
+  if (@available(macOS 10.16, ios 10.14, watchos 7.0, tvos 14.0, *)) {
 err.SetError(posix_spawnattr_setarchpref_np(&attr, 1, &cpu_type,
 &cpu_subtype, &ocount));
 slice_preference_set = err.Success();



___
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] 68edf39 - [TargetMachine] Simplify shouldAssumeDSOLocal by processing ExternalSymbolSDNode early

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

Author: Fangrui Song
Date: 2020-12-05T11:40:18-08:00
New Revision: 68edf39ededf97a12602676f9cd537ed689151f0

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

LOG: [TargetMachine] Simplify shouldAssumeDSOLocal by processing 
ExternalSymbolSDNode early

The function accrues many `GV` nullness checks. Process `!GV`
(ExternalSymbolSDNode) early to simplify code.

Also improve a comment added in r327198 (intrinsics is a subset of
ExternalSymbolSDNode).

Intended to be NFC.

Added: 


Modified: 
llvm/lib/Target/TargetMachine.cpp

Removed: 




diff  --git a/llvm/lib/Target/TargetMachine.cpp 
b/llvm/lib/Target/TargetMachine.cpp
index e2fd4687d3c8..5067d942ec4c 100644
--- a/llvm/lib/Target/TargetMachine.cpp
+++ b/llvm/lib/Target/TargetMachine.cpp
@@ -93,21 +93,15 @@ static TLSModel::Model getSelectedTLSModel(const 
GlobalValue *GV) {
 
 bool TargetMachine::shouldAssumeDSOLocal(const Module &M,
  const GlobalValue *GV) const {
-  // If the IR producer requested that this GV be treated as dso local, obey.
-  if (GV && GV->isDSOLocal())
-return true;
-
-  // If we are not supossed to use a PLT, we cannot assume that intrinsics are
-  // local since the linker can convert some direct access to access via plt.
-  if (M.getRtLibUseGOT() && !GV)
-return false;
+  const Triple &TT = getTargetTriple();
+  Reloc::Model RM = getRelocationModel();
 
   // According to the llvm language reference, we should be able to
   // just return false in here if we have a GV, as we know it is
   // dso_preemptable.  At this point in time, the various IR producers
   // have not been transitioned to always produce a dso_local when it
   // is possible to do so.
-  // In the case of intrinsics, GV is null and there is nowhere to put
+  // In the case of ExternalSymbolSDNode, GV is null and there is nowhere to 
put
   // dso_local. Returning false for those will produce worse code in some
   // architectures. For example, on x86 the caller has to set ebx before 
calling
   // a plt.
@@ -115,12 +109,24 @@ bool TargetMachine::shouldAssumeDSOLocal(const Module &M,
   // generated code.
   // FIXME: Add a module level metadata for whether intrinsics should be 
assumed
   // local.
+  if (!GV) {
+if (TT.isOSBinFormatCOFF())
+  return true;
+if (TT.isOSBinFormatELF() && TT.isX86() && RM == Reloc::Static) {
+  // For -fno-plt, we cannot assume that intrinsics are local since the
+  // linker can convert some direct access to access via plt.
+  return !M.getRtLibUseGOT();
+}
 
-  Reloc::Model RM = getRelocationModel();
-  const Triple &TT = getTargetTriple();
+return false;
+  }
+
+  // If the IR producer requested that this GV be treated as dso local, obey.
+  if (GV->isDSOLocal())
+return true;
 
   // DLLImport explicitly marks the GV as external.
-  if (GV && GV->hasDLLImportStorageClass())
+  if (GV->hasDLLImportStorageClass())
 return false;
 
   // On MinGW, variables that haven't been declared with DLLImport may still
@@ -128,14 +134,14 @@ bool TargetMachine::shouldAssumeDSOLocal(const Module &M,
   // don't assume the variables to be DSO local unless we actually know
   // that for sure. This only has to be done for variables; for functions
   // the linker can insert thunks for calling functions from another DLL.
-  if (TT.isWindowsGNUEnvironment() && TT.isOSBinFormatCOFF() && GV &&
+  if (TT.isWindowsGNUEnvironment() && TT.isOSBinFormatCOFF() &&
   GV->isDeclarationForLinker() && isa(GV))
 return false;
 
   // On COFF, don't mark 'extern_weak' symbols as DSO local. If these symbols
   // remain unresolved in the link, they can be resolved to zero, which is
   // outside the current DSO.
-  if (TT.isOSBinFormatCOFF() && GV && GV->hasExternalWeakLinkage())
+  if (TT.isOSBinFormatCOFF() && GV->hasExternalWeakLinkage())
 return false;
 
   // Every other GV is local on COFF.
@@ -151,16 +157,16 @@ bool TargetMachine::shouldAssumeDSOLocal(const Module &M,
   // produce a 0 if it turns out the symbol is undefined. While this
   // is ABI and relocation depended, it seems worth it to handle it
   // here.
-  if (GV && isPositionIndependent() && GV->hasExternalWeakLinkage())
+  if (isPositionIndependent() && GV->hasExternalWeakLinkage())
 return false;
 
-  if (GV && !GV->hasDefaultVisibility())
+  if (!GV->hasDefaultVisibility())
 return true;
 
   if (TT.isOSBinFormatMachO()) {
 if (RM == Reloc::Static)
   return true;
-return GV && GV->isStrongDefinitionForLinker();
+return GV->isStrongDefinitionForLinker();
   }
 
   // Due to the AIX linkage model, any global with default visibility is
@@ -175,13 +181,13 @@ bool TargetMachine::shouldAssumeDSOLocal(const Module &M,
   RM == Reloc::Stati

[llvm-branch-commits] [llvm] ae5e013 - [BasicAA] Add more tests for non-equal index (NFC)

2020-12-05 Thread Nikita Popov via llvm-branch-commits

Author: Nikita Popov
Date: 2020-12-05T21:22:57+01:00
New Revision: ae5e013f6e3a1391fd44e292857e359b83806c2f

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

LOG: [BasicAA] Add more tests for non-equal index (NFC)

Added: 


Modified: 
llvm/test/Analysis/BasicAA/sequential-gep.ll

Removed: 




diff  --git a/llvm/test/Analysis/BasicAA/sequential-gep.ll 
b/llvm/test/Analysis/BasicAA/sequential-gep.ll
index ab97c6492d36..0b53958d6f68 100644
--- a/llvm/test/Analysis/BasicAA/sequential-gep.ll
+++ b/llvm/test/Analysis/BasicAA/sequential-gep.ll
@@ -51,4 +51,65 @@ define void @t5([8 x i32]* %p, i32 %addend, i32* %q) {
   ret void
 }
 
+; CHECK-LABEL: Function: add_non_zero_simple
+; CHECK: MayAlias: i32* %gep1, i32* %gep2
+; TODO: This could be NoAlias.
+define void @add_non_zero_simple(i32* %p, i32 %addend, i32* %q) {
+  %knownnonzero = load i32, i32* %q, !range !0
+  %add = add i32 %addend, %knownnonzero
+  %gep1 = getelementptr i32, i32* %p, i32 %addend
+  %gep2 = getelementptr i32, i32* %p, i32 %add
+  ret void
+}
+
+; CHECK-LABEL: Function: add_non_zero_
diff erent_scales
+; CHECK: MayAlias: i16* %gep2, i32* %gep1
+define void @add_non_zero_
diff erent_scales(i32* %p, i32 %addend, i32* %q) {
+  %knownnonzero = load i32, i32* %q, !range !0
+  %add = add i32 %addend, %knownnonzero
+  %p16 = bitcast i32* %p to i16*
+  %gep1 = getelementptr i32, i32* %p, i32 %addend
+  %gep2 = getelementptr i16, i16* %p16, i32 %add
+  ret void
+}
+
+; CHECK-LABEL: Function: add_non_zero_
diff erent_sizes
+; CHECK: MayAlias: i16* %gep1.16, i32* %gep2
+; CHECK: MayAlias: i16* %gep2.16, i32* %gep1
+; CHECK: MayAlias: i16* %gep1.16, i16* %gep2.16
+; CHECK: MayAlias: i32* %gep2, i64* %gep1.64
+; CHECK: MayAlias: i16* %gep2.16, i64* %gep1.64
+; CHECK: MayAlias: i32* %gep1, i64* %gep2.64
+; CHECK: MayAlias: i16* %gep1.16, i64* %gep2.64
+; CHECK: MayAlias: i64* %gep1.64, i64* %gep2.64
+; TODO: The first three could be NoAlias.
+define void @add_non_zero_
diff erent_sizes(i32* %p, i32 %addend, i32* %q) {
+  %knownnonzero = load i32, i32* %q, !range !0
+  %add = add i32 %addend, %knownnonzero
+  %gep1 = getelementptr i32, i32* %p, i32 %addend
+  %gep2 = getelementptr i32, i32* %p, i32 %add
+  %gep1.16 = bitcast i32* %gep1 to i16*
+  %gep2.16 = bitcast i32* %gep2 to i16*
+  %gep1.64 = bitcast i32* %gep1 to i64*
+  %gep2.64 = bitcast i32* %gep2 to i64*
+  ret void
+}
+
+
+; CHECK-LABEL: add_non_zero_with_offset
+; MayAlias: i32* %gep1, i32* %gep2
+; NoAlias: i16* %gep1.16, i16* %gep2.16
+define void @add_non_zero_with_offset(i32* %p, i32 %addend, i32* %q) {
+  %knownnonzero = load i32, i32* %q, !range !0
+  %add = add i32 %addend, %knownnonzero
+  %p.8 = bitcast i32* %p to i8*
+  %p.off.8 = getelementptr i8, i8* %p.8, i32 2
+  %p.off = bitcast i8* %p.off.8 to i32*
+  %gep1 = getelementptr i32, i32* %p.off, i32 %addend
+  %gep2 = getelementptr i32, i32* %p, i32 %add
+  %gep1.16 = bitcast i32* %gep1 to i16*
+  %gep2.16 = bitcast i32* %gep2 to i16*
+  ret void
+}
+
 !0 = !{ i32 1, i32 5 }



___
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] db13a13 - [TargetMachine] Move X86 specific shouldAssumeDSOLocal logic to X86Subtarget::classifyGlobalFunctionReference

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

Author: Fangrui Song
Date: 2020-12-05T12:32:50-08:00
New Revision: db13a138bdad3aae1f0f387c871c43729badbc69

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

LOG: [TargetMachine] Move X86 specific shouldAssumeDSOLocal logic to 
X86Subtarget::classifyGlobalFunctionReference

Added: 


Modified: 
llvm/lib/Target/TargetMachine.cpp
llvm/lib/Target/X86/X86Subtarget.cpp

Removed: 




diff  --git a/llvm/lib/Target/TargetMachine.cpp 
b/llvm/lib/Target/TargetMachine.cpp
index 5067d942ec4c..dd41bc25ff3f 100644
--- a/llvm/lib/Target/TargetMachine.cpp
+++ b/llvm/lib/Target/TargetMachine.cpp
@@ -109,17 +109,8 @@ bool TargetMachine::shouldAssumeDSOLocal(const Module &M,
   // generated code.
   // FIXME: Add a module level metadata for whether intrinsics should be 
assumed
   // local.
-  if (!GV) {
-if (TT.isOSBinFormatCOFF())
-  return true;
-if (TT.isOSBinFormatELF() && TT.isX86() && RM == Reloc::Static) {
-  // For -fno-plt, we cannot assume that intrinsics are local since the
-  // linker can convert some direct access to access via plt.
-  return !M.getRtLibUseGOT();
-}
-
-return false;
-  }
+  if (!GV)
+return TT.isOSBinFormatCOFF();
 
   // If the IR producer requested that this GV be treated as dso local, obey.
   if (GV->isDSOLocal())

diff  --git a/llvm/lib/Target/X86/X86Subtarget.cpp 
b/llvm/lib/Target/X86/X86Subtarget.cpp
index d50c552a65b6..8c9248569a13 100644
--- a/llvm/lib/Target/X86/X86Subtarget.cpp
+++ b/llvm/lib/Target/X86/X86Subtarget.cpp
@@ -202,6 +202,9 @@ X86Subtarget::classifyGlobalFunctionReference(const 
GlobalValue *GV,
  (!F && M.getRtLibUseGOT())) &&
 is64Bit())
return X86II::MO_GOTPCREL;
+// Reference ExternalSymbol directly in static relocation model.
+if (!GV && TM.getRelocationModel() == Reloc::Static)
+  return X86II::MO_NO_FLAG;
 return X86II::MO_PLT;
   }
 



___
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] 9737c12 - [llvmbuildectomy] removed vestigial LLVMBuild.txt files

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

Author: Chris Sears
Date: 2020-12-05T22:00:22+01:00
New Revision: 9737c128f14d60f73b1d198453801a05b37c6b28

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

LOG: [llvmbuildectomy] removed vestigial LLVMBuild.txt files

LLVMBuild has been removed from the build system. However, three LLVMBuild.txt
files remain in the tree. This patch simply removes them.

llvm/lib/ExecutionEngine/Orc/TargetProcess/LLVMBuild.txt
llvm/tools/llvm-jitlink/llvm-jitlink-executor/LLVMBuild.txt
llvm/tools/llvm-profgen/LLVMBuild.txt

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

Added: 


Modified: 


Removed: 
llvm/lib/ExecutionEngine/Orc/TargetProcess/LLVMBuild.txt
llvm/tools/llvm-jitlink/llvm-jitlink-executor/LLVMBuild.txt
llvm/tools/llvm-profgen/LLVMBuild.txt



diff  --git a/llvm/lib/ExecutionEngine/Orc/TargetProcess/LLVMBuild.txt 
b/llvm/lib/ExecutionEngine/Orc/TargetProcess/LLVMBuild.txt
deleted file mode 100644
index 781e6188a702..
--- a/llvm/lib/ExecutionEngine/Orc/TargetProcess/LLVMBuild.txt
+++ /dev/null
@@ -1,21 +0,0 @@
-;===- ./lib/ExecutionEngine/OrcTargetProcess/LLVMBuild.txt -*- Conf 
-*--===;
-;
-; Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-; See https://llvm.org/LICENSE.txt for license information.
-; SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-;
-;======;
-;
-; This is an LLVMBuild description file for the components in this 
subdirectory.
-;
-; For more information on the LLVMBuild system, please see:
-;
-;   http://llvm.org/docs/LLVMBuild.html
-;
-;======;
-
-[component_0]
-type = Library
-name = OrcTargetProcess
-parent = OrcJIT
-required_libraries = OrcShared Support

diff  --git a/llvm/tools/llvm-jitlink/llvm-jitlink-executor/LLVMBuild.txt 
b/llvm/tools/llvm-jitlink/llvm-jitlink-executor/LLVMBuild.txt
deleted file mode 100644
index 0d96143673dd..
--- a/llvm/tools/llvm-jitlink/llvm-jitlink-executor/LLVMBuild.txt
+++ /dev/null
@@ -1,21 +0,0 @@
-;===- ./tools/llvm-jitlink/llvm-jitlink-executor/LLVMBuild.txt -*- Conf 
-*--===;
-;
-; Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-; See https://llvm.org/LICENSE.txt for license information.
-; SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-;
-;======;
-;
-; This is an LLVMBuild description file for the components in this 
subdirectory.
-;
-; For more information on the LLVMBuild system, please see:
-;
-;   http://llvm.org/docs/LLVMBuild.html
-;
-;======;
-
-[component_0]
-type = Tool
-name = llvm-jitlink-executor
-parent = llvm-jitlink
-required_libraries = OrcTargetProcess Support

diff  --git a/llvm/tools/llvm-profgen/LLVMBuild.txt 
b/llvm/tools/llvm-profgen/LLVMBuild.txt
deleted file mode 100644
index 70b2c3109872..
--- a/llvm/tools/llvm-profgen/LLVMBuild.txt
+++ /dev/null
@@ -1,21 +0,0 @@
-;===- ./tools/llvm-profgen/LLVMBuild.txt --*- Conf -*--===;
-;
-; Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-; See https://llvm.org/LICENSE.txt for license information.
-; SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-;
-;======;
-;
-; This is an LLVMBuild description file for the components in this 
subdirectory.
-;
-; For more information on the LLVMBuild system, please see:
-;
-;   http://llvm.org/docs/LLVMBuild.html
-;
-;======;
-
-[component_0]
-type = Tool
-name = llvm-profgen
-parent = Tools
-required_libraries = DebugInfoDWARF MC MCDisassembler MCParser Object 
all-targets Demangle Support



___
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] 37f0c8d - [X86] Emit @PLT for x86-64 and keep unadorned symbols for x86-32

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

Author: Fangrui Song
Date: 2020-12-05T13:17:47-08:00
New Revision: 37f0c8df47d84ba311fc9a2c1884935ba8961e84

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

LOG: [X86] Emit @PLT for x86-64 and keep unadorned symbols for x86-32

This essentially reverts the x86-64 side effect of r327198.

For x86-32, @PLT (R_386_PLT32) is not suitable in -fno-pic mode so the
code forces MO_NO_FLAG (like a forced dso_local) 
(https://bugs.llvm.org//show_bug.cgi?id=36674#c6).

For x86-64, both `call/jmp foo` and `call/jmp foo@PLT` emit R_X86_64_PLT32
(https://sourceware.org/bugzilla/show_bug.cgi?id=22791) so there is no
difference using @PLT. Using @PLT is actually favorable because this drops
a difference with -fpie/-fpic code and makes it possible to avoid a canonical
PLT entry when taking the address of an undefined function symbol.

Added: 


Modified: 
llvm/lib/Target/X86/X86Subtarget.cpp
llvm/test/CodeGen/X86/cvt16.ll
llvm/test/CodeGen/X86/extract-fp.ll
llvm/test/CodeGen/X86/extractelement-fp.ll
llvm/test/CodeGen/X86/finite-libcalls.ll
llvm/test/CodeGen/X86/fmaxnum.ll
llvm/test/CodeGen/X86/fmf-flags.ll
llvm/test/CodeGen/X86/fminnum.ll
llvm/test/CodeGen/X86/fp128-extract.ll
llvm/test/CodeGen/X86/fp128-i128.ll
llvm/test/CodeGen/X86/fp128-libcalls.ll
llvm/test/CodeGen/X86/half.ll
llvm/test/CodeGen/X86/llround-conv.ll
llvm/test/CodeGen/X86/lround-conv-i32.ll
llvm/test/CodeGen/X86/lround-conv-i64.ll
llvm/test/CodeGen/X86/memcpy-inline.ll
llvm/test/CodeGen/X86/memcpy.ll
llvm/test/CodeGen/X86/memset-nonzero.ll
llvm/test/CodeGen/X86/negative-sin.ll
llvm/test/CodeGen/X86/pow.ll
llvm/test/CodeGen/X86/powi.ll
llvm/test/CodeGen/X86/pr38865.ll
llvm/test/CodeGen/X86/vector-half-conversions.ll

Removed: 




diff  --git a/llvm/lib/Target/X86/X86Subtarget.cpp 
b/llvm/lib/Target/X86/X86Subtarget.cpp
index 8c9248569a13..684854725817 100644
--- a/llvm/lib/Target/X86/X86Subtarget.cpp
+++ b/llvm/lib/Target/X86/X86Subtarget.cpp
@@ -203,7 +203,7 @@ X86Subtarget::classifyGlobalFunctionReference(const 
GlobalValue *GV,
 is64Bit())
return X86II::MO_GOTPCREL;
 // Reference ExternalSymbol directly in static relocation model.
-if (!GV && TM.getRelocationModel() == Reloc::Static)
+if (!is64Bit() && !GV && TM.getRelocationModel() == Reloc::Static)
   return X86II::MO_NO_FLAG;
 return X86II::MO_PLT;
   }

diff  --git a/llvm/test/CodeGen/X86/cvt16.ll b/llvm/test/CodeGen/X86/cvt16.ll
index 9b36c5a0cc34..64be9aad49be 100644
--- a/llvm/test/CodeGen/X86/cvt16.ll
+++ b/llvm/test/CodeGen/X86/cvt16.ll
@@ -60,7 +60,7 @@ define float @test2(i16* nocapture %src) {
 ; LIBCALL-LABEL: test2:
 ; LIBCALL:   # %bb.0:
 ; LIBCALL-NEXT:movzwl (%rdi), %edi
-; LIBCALL-NEXT:jmp __gnu_h2f_ieee # TAILCALL
+; LIBCALL-NEXT:jmp __gnu_h2f_ieee@PLT # TAILCALL
 ;
 ; F16C-LABEL: test2:
 ; F16C:   # %bb.0:
@@ -92,7 +92,7 @@ define float @test3(float %src) nounwind uwtable readnone {
 ; LIBCALL-NEXT:movzwl %ax, %edi
 ; LIBCALL-NEXT:popq %rax
 ; LIBCALL-NEXT:.cfi_def_cfa_offset 8
-; LIBCALL-NEXT:jmp __gnu_h2f_ieee # TAILCALL
+; LIBCALL-NEXT:jmp __gnu_h2f_ieee@PLT # TAILCALL
 ;
 ; F16C-LABEL: test3:
 ; F16C:   # %bb.0:
@@ -154,11 +154,11 @@ define double @test4(i16* nocapture %src) {
 define i16 @test5(double %src) {
 ; LIBCALL-LABEL: test5:
 ; LIBCALL:   # %bb.0:
-; LIBCALL-NEXT:jmp __truncdfhf2 # TAILCALL
+; LIBCALL-NEXT:jmp __truncdfhf2@PLT # TAILCALL
 ;
 ; F16C-LABEL: test5:
 ; F16C:   # %bb.0:
-; F16C-NEXT:jmp __truncdfhf2 # TAILCALL
+; F16C-NEXT:jmp __truncdfhf2@PLT # TAILCALL
 ;
 ; SOFTFLOAT-LABEL: test5:
 ; SOFTFLOAT:   # %bb.0:

diff  --git a/llvm/test/CodeGen/X86/extract-fp.ll 
b/llvm/test/CodeGen/X86/extract-fp.ll
index 6281f12979f1..317f3188c2df 100644
--- a/llvm/test/CodeGen/X86/extract-fp.ll
+++ b/llvm/test/CodeGen/X86/extract-fp.ll
@@ -65,7 +65,7 @@ define float @ext_frem_v4f32(<4 x float> %x) {
 ; CHECK:   # %bb.0:
 ; CHECK-NEXT:movhlps {{.*#+}} xmm0 = xmm0[1,1]
 ; CHECK-NEXT:movss {{.*#+}} xmm1 = mem[0],zero,zero,zero
-; CHECK-NEXT:jmp fmodf # TAILCALL
+; CHECK-NEXT:jmp fmodf@PLT # TAILCALL
   %bo = frem <4 x float> %x, 
   %ext = extractelement <4 x float> %bo, i32 2
   ret float %ext
@@ -77,7 +77,7 @@ define float @ext_frem_v4f32_constant_op0(<4 x float> %x) {
 ; CHECK-NEXT:movaps %xmm0, %xmm1
 ; CHECK-NEXT:shufps {{.*#+}} xmm1 = xmm1[1,1],xmm0[1,1]
 ; CHECK-NEXT:movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
-; CHECK-NEXT:jmp fmodf # TAILCALL
+; CHECK-NEXT:jmp fmodf@PLT # TAILCALL
   %bo = frem <4 x float> , %x
   %ext = extractelement <4 x float> %bo, i32 1
   ret float %ext

diff  --git a/llvm/test/CodeGen/

[llvm-branch-commits] [lldb] 13ee00d - [debugserver] Use dlsym for posix_spawnattr_setarchpref_np

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

Author: Jonas Devlieghere
Date: 2020-12-05T14:06:45-08:00
New Revision: 13ee00d0c95a4eede96ba9520146a01930af2a0a

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

LOG: [debugserver] Use dlsym for posix_spawnattr_setarchpref_np

The @available check did not work as I thought it did. Use good old
dlsym instead.

Added: 


Modified: 
lldb/tools/debugserver/source/MacOSX/MachProcess.mm

Removed: 




diff  --git a/lldb/tools/debugserver/source/MacOSX/MachProcess.mm 
b/lldb/tools/debugserver/source/MacOSX/MachProcess.mm
index 232a0d25a38a..386c5e42306a 100644
--- a/lldb/tools/debugserver/source/MacOSX/MachProcess.mm
+++ b/lldb/tools/debugserver/source/MacOSX/MachProcess.mm
@@ -3273,9 +3273,14 @@ static bool FBSAddEventDataToOptions(NSMutableDictionary 
*options,
 bool slice_preference_set = false;
 
 if (cpu_subtype != 0) {
-  if (@available(macOS 10.16, ios 10.14, watchos 7.0, tvos 14.0, *)) {
-err.SetError(posix_spawnattr_setarchpref_np(&attr, 1, &cpu_type,
-&cpu_subtype, &ocount));
+  typedef int (*posix_spawnattr_setarchpref_np_t)(
+  posix_spawnattr_t *, size_t, cpu_type_t *, cpu_subtype_t *, size_t 
*);
+  posix_spawnattr_setarchpref_np_t posix_spawnattr_setarchpref_np_fn =
+  (posix_spawnattr_setarchpref_np_t)dlsym(
+  RTLD_DEFAULT, "posix_spawnattr_setarchpref_np");
+  if (posix_spawnattr_setarchpref_np_fn) {
+err.SetError((*posix_spawnattr_setarchpref_np)(&attr, 1, &cpu_type,
+   &cpu_subtype, &ocount));
 slice_preference_set = err.Success();
 if (err.Fail() || DNBLogCheckLogBit(LOG_PROCESS))
   err.LogThreaded(



___
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] bfda694 - [BasicAA] Fix a bug with relational reasoning across iterations

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

Author: Philip Reames
Date: 2020-12-05T14:10:21-08:00
New Revision: bfda69416c6d0a76b40644b1b0cbc1cbca254a61

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

LOG: [BasicAA] Fix a bug with relational reasoning across iterations

Due to the recursion through phis basicaa does, the code needs to be extremely 
careful not to reason about equality between values which might represent 
distinct iterations. I'm generally skeptical of the correctness of the whole 
scheme, but this particular patch fixes one particular instance which is 
demonstrateable incorrect.

Interestingly, this appears to be the second attempted fix for the same issue. 
The former fix is incomplete and doesn't address the actual issue.

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

Added: 


Modified: 
llvm/include/llvm/Analysis/BasicAliasAnalysis.h
llvm/lib/Analysis/BasicAliasAnalysis.cpp
llvm/test/Analysis/BasicAA/phi-aa.ll

Removed: 




diff  --git a/llvm/include/llvm/Analysis/BasicAliasAnalysis.h 
b/llvm/include/llvm/Analysis/BasicAliasAnalysis.h
index d9a174951695..eedecd2a4381 100644
--- a/llvm/include/llvm/Analysis/BasicAliasAnalysis.h
+++ b/llvm/include/llvm/Analysis/BasicAliasAnalysis.h
@@ -202,6 +202,12 @@ class BasicAAResult : public AAResultBase {
   const DecomposedGEP &DecompGEP, const DecomposedGEP &DecompObject,
   LocationSize ObjectAccessSize);
 
+  AliasResult aliasSameBasePointerGEPs(const GEPOperator *GEP1,
+   LocationSize MaybeV1Size,
+   const GEPOperator *GEP2,
+   LocationSize MaybeV2Size,
+   const DataLayout &DL);
+
   /// A Heuristic for aliasGEP that searches for a constant offset
   /// between the variables.
   ///

diff  --git a/llvm/lib/Analysis/BasicAliasAnalysis.cpp 
b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
index 2fb353eabb6e..5e611a9e193c 100644
--- a/llvm/lib/Analysis/BasicAliasAnalysis.cpp
+++ b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
@@ -1032,11 +1032,11 @@ ModRefInfo BasicAAResult::getModRefInfo(const CallBase 
*Call1,
 
 /// Provide ad-hoc rules to disambiguate accesses through two GEP operators,
 /// both having the exact same pointer operand.
-static AliasResult aliasSameBasePointerGEPs(const GEPOperator *GEP1,
-LocationSize MaybeV1Size,
-const GEPOperator *GEP2,
-LocationSize MaybeV2Size,
-const DataLayout &DL) {
+AliasResult BasicAAResult::aliasSameBasePointerGEPs(const GEPOperator *GEP1,
+LocationSize MaybeV1Size,
+const GEPOperator *GEP2,
+LocationSize MaybeV2Size,
+const DataLayout &DL) {
   assert(GEP1->getPointerOperand()->stripPointerCastsAndInvariantGroups() ==
  GEP2->getPointerOperand()->stripPointerCastsAndInvariantGroups() 
&&
  GEP1->getPointerOperandType() == GEP2->getPointerOperandType() &&
@@ -1126,24 +1126,12 @@ static AliasResult aliasSameBasePointerGEPs(const 
GEPOperator *GEP1,
 if (C1 && C2)
   return NoAlias;
 {
+  // If we're not potentially reasoning about values from 
diff erent
+  // iterations, see if we can prove them inequal.
   Value *GEP1LastIdx = GEP1->getOperand(GEP1->getNumOperands() - 1);
   Value *GEP2LastIdx = GEP2->getOperand(GEP2->getNumOperands() - 1);
-  if (isa(GEP1LastIdx) || isa(GEP2LastIdx)) {
-// If one of the indices is a PHI node, be safe and only use
-// computeKnownBits so we don't make any assumptions about the
-// relationships between the two indices. This is important if we're
-// asking about values from 
diff erent loop iterations. See PR32314.
-// TODO: We may be able to change the check so we only do this when
-// we definitely looked through a PHINode.
-if (GEP1LastIdx != GEP2LastIdx &&
-GEP1LastIdx->getType() == GEP2LastIdx->getType()) {
-  KnownBits Known1 = computeKnownBits(GEP1LastIdx, DL);
-  KnownBits Known2 = computeKnownBits(GEP2LastIdx, DL);
-  if (Known1.Zero.intersects(Known2.One) ||
-  Known1.One.intersects(Known2.Zero))
-return NoAlias;
-}
-  } else if (isKnownNonEqual(GEP1LastIdx, GEP2LastIdx, DL))
+  if (VisitedPhiBBs.empty() &&
+  isKnownNonEqual(GEP1LastIdx, GEP2LastIdx, DL))
 return NoAlias;
 }
   }

diff  --git a/llvm/test/Analysis/BasicAA/phi-

[llvm-branch-commits] [llvm] 6b6c3aa - [test] Add explicit dso_local to function declarations in static relocation model tests

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

Author: Fangrui Song
Date: 2020-12-05T14:54:37-08:00
New Revision: 6b6c3aaeacfdc4a482de4af41719b0a4b50aeadf

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

LOG: [test] Add explicit dso_local to function declarations in static 
relocation model tests

They are currently implicit because TargetMachine::shouldAssumeDSOLocal implies
dso_local.

For such function declarations, clang -fno-pic emits the dso_local specifier.
Adding explicit dso_local makes these tests align with the clang behavior and
helps implementing an option to use GOT indirection when taking the address of a
function symbol in -fno-pic (to avoid a canonical PLT entry (SHN_UNDEF with
non-zero st_value)).

Added: 


Modified: 
llvm/test/CodeGen/AArch64/extern-weak.ll
llvm/test/CodeGen/AArch64/funcptr_cast.ll
llvm/test/CodeGen/AArch64/tagged-globals-static.ll
llvm/test/CodeGen/SystemZ/la-01.ll
llvm/test/CodeGen/X86/add.ll
llvm/test/CodeGen/X86/avx-vzeroupper.ll
llvm/test/CodeGen/X86/avx512-i1test.ll
llvm/test/CodeGen/X86/bmi.ll
llvm/test/CodeGen/X86/bool-zext.ll
llvm/test/CodeGen/X86/btq.ll
llvm/test/CodeGen/X86/callbr-asm-branch-folding.ll
llvm/test/CodeGen/X86/cmp.ll
llvm/test/CodeGen/X86/conditional-tailcall.ll
llvm/test/CodeGen/X86/copy-eflags.ll
llvm/test/CodeGen/X86/dagcombine-shifts.ll
llvm/test/CodeGen/X86/fold-rmw-ops.ll
llvm/test/CodeGen/X86/fp-strict-scalar-cmp.ll
llvm/test/CodeGen/X86/fp-une-cmp.ll
llvm/test/CodeGen/X86/fp128-i128.ll
llvm/test/CodeGen/X86/lvi-hardening-indirectbr.ll
llvm/test/CodeGen/X86/memcmp-minsize.ll
llvm/test/CodeGen/X86/memcmp-more-load-pairs.ll
llvm/test/CodeGen/X86/memcmp-optsize.ll
llvm/test/CodeGen/X86/memcmp-pgso.ll
llvm/test/CodeGen/X86/memcmp.ll
llvm/test/CodeGen/X86/mov-zero-to-xor.ll
llvm/test/CodeGen/X86/musttail-tailcc.ll
llvm/test/CodeGen/X86/neg_cmp.ll
llvm/test/CodeGen/X86/nomerge.ll
llvm/test/CodeGen/X86/peep-test-4.ll
llvm/test/CodeGen/X86/pr37063.ll
llvm/test/CodeGen/X86/pr38865.ll
llvm/test/CodeGen/X86/pr47024.ll
llvm/test/CodeGen/X86/rd-mod-wr-eflags.ll
llvm/test/CodeGen/X86/retpoline-external.ll
llvm/test/CodeGen/X86/shrink-compare-pgso.ll
llvm/test/CodeGen/X86/shrink-compare.ll
llvm/test/CodeGen/X86/shrinkwrap-callbr.ll
llvm/test/CodeGen/X86/sibcall-win64.ll
llvm/test/CodeGen/X86/sibcall.ll
llvm/test/CodeGen/X86/sqrt-partial.ll
llvm/test/CodeGen/X86/sse-fcopysign.ll
llvm/test/CodeGen/X86/statepoint-vreg-details.ll
llvm/test/CodeGen/X86/statepoint-vreg-unlimited-tied-opnds.ll
llvm/test/CodeGen/X86/tail-call-deref.ll
llvm/test/CodeGen/X86/tail-dup-asm-goto.ll
llvm/test/CodeGen/X86/tail-opts.ll
llvm/test/CodeGen/X86/tailcall-assume.ll
llvm/test/CodeGen/X86/tailcall-extract.ll
llvm/test/CodeGen/X86/tailcall-tailcc.ll
llvm/test/CodeGen/X86/win64_sibcall.ll
llvm/test/CodeGen/X86/xor-icmp.ll
llvm/test/DebugInfo/X86/live-debug-values-remove-range.ll

Removed: 




diff  --git a/llvm/test/CodeGen/AArch64/extern-weak.ll 
b/llvm/test/CodeGen/AArch64/extern-weak.ll
index 4ea8c2617e6e..0746701c67fc 100644
--- a/llvm/test/CodeGen/AArch64/extern-weak.ll
+++ b/llvm/test/CodeGen/AArch64/extern-weak.ll
@@ -3,7 +3,7 @@
 ; RUN: llc -mtriple=aarch64-none-linux-gnu -code-model=large -o - %s | 
FileCheck --check-prefix=CHECK-LARGE %s
 ; RUN: llc -mtriple=aarch64-none-none-eabi -code-model=tiny -o - %s | 
FileCheck --check-prefix=CHECK-TINY %s
 
-declare extern_weak i32 @var()
+declare extern_weak dso_local i32 @var()
 
 define i32()* @foo() {
 ; The usual ADRP/ADD pair can't be used for a weak reference because it must

diff  --git a/llvm/test/CodeGen/AArch64/funcptr_cast.ll 
b/llvm/test/CodeGen/AArch64/funcptr_cast.ll
index 19a20c8bcf4f..406eccf6324c 100644
--- a/llvm/test/CodeGen/AArch64/funcptr_cast.ll
+++ b/llvm/test/CodeGen/AArch64/funcptr_cast.ll
@@ -12,4 +12,4 @@ entry:
   ret i8 %0
 }
 
-declare void @foo(...)
+declare dso_local void @foo(...)

diff  --git a/llvm/test/CodeGen/AArch64/tagged-globals-static.ll 
b/llvm/test/CodeGen/AArch64/tagged-globals-static.ll
index ba8bc26ffee1..ed5597c0c3ca 100644
--- a/llvm/test/CodeGen/AArch64/tagged-globals-static.ll
+++ b/llvm/test/CodeGen/AArch64/tagged-globals-static.ll
@@ -8,7 +8,7 @@ target datalayout = 
"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
 target triple = "aarch64-unknown-linux-android"
 
 @global = external dso_local global i32
-declare void @func()
+declare dso_local void @func()
 
 define i32* @global_addr() #0 {
   ; Static relocation model has common codegen between SelectionDAGISel and

diff  --git a/llvm/test/CodeGen/SystemZ/la-01.ll 
b/llvm/test/CodeGen/SystemZ/la-01.ll
index 303d057ea0ff..bbe1c9d8

[llvm-branch-commits] [llvm] a084c03 - [TargetMachine] Don't imply dso_local on function declarations in Reloc::Static model for ELF/wasm

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

Author: Fangrui Song
Date: 2020-12-05T14:54:37-08:00
New Revision: a084c0388e2a59b9556f2de008232da3f1d6

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

LOG: [TargetMachine] Don't imply dso_local on function declarations in 
Reloc::Static model for ELF/wasm

clang/lib/CodeGen/CodeGenModule sets dso_local on applicable function 
declarations,
we don't need to duplicate the work in TargetMachine:shouldAssumeDSOLocal.
(Actually the long-term goal (started by r324535) is to drop 
TargetMachine::shouldAssumeDSOLocal.)

By not implying dso_local, we will respect dso_local/dso_preemptable specifiers
set by the frontend. This allows the proposed -fno-direct-access-external-data
option to work with -fno-pic and prevent a canonical PLT entry (SHN_UNDEF with 
non-zero st_value)
when taking the address of a function symbol.

This patch should be NFC in terms of the Clang emitted assembly because the case
we don't set dso_local is a case Clang sets dso_local. However, some tests don't
set dso_local on some function declarations and expose some differences. Most
tests have been fixed to be more robust in the previous commit.

Added: 


Modified: 
llvm/lib/Target/TargetMachine.cpp
llvm/lib/Target/X86/X86Subtarget.cpp
llvm/test/CodeGen/AArch64/tiny_model.ll
llvm/test/CodeGen/ARM/fast-isel-call.ll
llvm/test/CodeGen/RISCV/mir-target-flags.ll
llvm/test/CodeGen/X86/abi-isel.ll
llvm/test/CodeGen/X86/absolute-cmp.ll
llvm/test/CodeGen/X86/absolute-constant.ll
llvm/test/CodeGen/X86/code-model-elf.ll
llvm/test/CodeGen/X86/conditional-tailcall-pgso.ll
llvm/test/CodeGen/X86/csr-split.ll
llvm/test/CodeGen/X86/fp-stack-direct-ret.ll
llvm/test/CodeGen/X86/jump_sign.ll
llvm/test/CodeGen/X86/linux-preemption.ll
llvm/test/CodeGen/X86/no-plt.ll
llvm/test/CodeGen/X86/or-branch.ll
llvm/test/CodeGen/X86/retpoline.ll
llvm/test/CodeGen/X86/slow-incdec.ll
llvm/test/CodeGen/X86/tailcall.ll

Removed: 




diff  --git a/llvm/lib/Target/TargetMachine.cpp 
b/llvm/lib/Target/TargetMachine.cpp
index dd41bc25ff3f..9770446470e7 100644
--- a/llvm/lib/Target/TargetMachine.cpp
+++ b/llvm/lib/Target/TargetMachine.cpp
@@ -101,10 +101,9 @@ bool TargetMachine::shouldAssumeDSOLocal(const Module &M,
   // dso_preemptable.  At this point in time, the various IR producers
   // have not been transitioned to always produce a dso_local when it
   // is possible to do so.
-  // In the case of ExternalSymbolSDNode, GV is null and there is nowhere to 
put
-  // dso_local. Returning false for those will produce worse code in some
-  // architectures. For example, on x86 the caller has to set ebx before 
calling
-  // a plt.
+  // In the case of ExternalSymbolSDNode, GV is null and we should just return
+  // false. However, COFF currently relies on this to be true
+  //
   // As a result we still have some logic in here to improve the quality of the
   // generated code.
   // FIXME: Add a module level metadata for whether intrinsics should be 
assumed
@@ -191,12 +190,8 @@ bool TargetMachine::shouldAssumeDSOLocal(const Module &M,
 // drop the if block entirely and respect dso_local/dso_preemptable
 // specifiers set by the frontend.
 if (RM == Reloc::Static) {
-  // We currently respect dso_local/dso_preemptable specifiers for
-  // variables.
-  if (F)
-return true;
   // TODO Remove the special case for x86-32.
-  if (Arch == Triple::x86 && !GV->isThreadLocal())
+  if (Arch == Triple::x86 && !F && !GV->isThreadLocal())
 return true;
 }
   } else if (TT.isOSBinFormatELF()) {

diff  --git a/llvm/lib/Target/X86/X86Subtarget.cpp 
b/llvm/lib/Target/X86/X86Subtarget.cpp
index 684854725817..c95213c3539d 100644
--- a/llvm/lib/Target/X86/X86Subtarget.cpp
+++ b/llvm/lib/Target/X86/X86Subtarget.cpp
@@ -166,6 +166,10 @@ unsigned char X86Subtarget::classifyGlobalReference(const 
GlobalValue *GV,
 return X86II::MO_DARWIN_NONLAZY_PIC_BASE;
   }
 
+  // 32-bit ELF references GlobalAddress directly in static relocation model.
+  // We cannot use MO_GOT because EBX may not be set up.
+  if (TM.getRelocationModel() == Reloc::Static)
+return X86II::MO_NO_FLAG;
   return X86II::MO_GOT;
 }
 

diff  --git a/llvm/test/CodeGen/AArch64/tiny_model.ll 
b/llvm/test/CodeGen/AArch64/tiny_model.ll
index c66e09df3c29..8f56ed1e37f7 100644
--- a/llvm/test/CodeGen/AArch64/tiny_model.ll
+++ b/llvm/test/CodeGen/AArch64/tiny_model.ll
@@ -370,12 +370,12 @@ declare void @func(...)
 define i8* @externfuncaddr() {
 ; CHECK-LABEL: externfuncaddr:
 ; CHECK:   // %bb.0: // %entry
-; CHECK-NEXT:adr x0, func
+; CHECK-NEXT:ldr x0, :got:func
 ; CHECK-NEXT:ret
 ;
 ; CHECK-GLOBISEL-LABEL: externfuncaddr:
 ; CHECK-GLOBISEL:   // %bb.0

[llvm-branch-commits] [llvm] 930b339 - [TargetMachine] Clean up TargetMachine::shouldAssumeDSOLocal after x86-32 specific hack is moved to X86Subtarget

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

Author: Fangrui Song
Date: 2020-12-05T15:13:42-08:00
New Revision: 930b3398c7e4b3b15a9f262a2856d11fb2071eb7

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

LOG: [TargetMachine] Clean up TargetMachine::shouldAssumeDSOLocal after x86-32 
specific hack is moved to X86Subtarget

With my previous commit, X86Subtarget::classifyGlobalReference has learned to
use MO_NO_FLAG for 32-bit ELF -fno-pic code, the x86-32 special case in
TargetMachine::shouldAssumeDSOLocal can be removed. Since we no longer imply
dso_local for function declarations, we can drop the ppc64 special case as well.

This is NFC in terms of Clang emitted assembly.

Added: 


Modified: 
llvm/lib/Target/TargetMachine.cpp
llvm/test/CodeGen/X86/abi-isel.ll

Removed: 




diff  --git a/llvm/lib/Target/TargetMachine.cpp 
b/llvm/lib/Target/TargetMachine.cpp
index 9770446470e7..3b48fd3622dc 100644
--- a/llvm/lib/Target/TargetMachine.cpp
+++ b/llvm/lib/Target/TargetMachine.cpp
@@ -173,27 +173,6 @@ bool TargetMachine::shouldAssumeDSOLocal(const Module &M,
 // If the symbol is defined, it cannot be preempted.
 if (!GV->isDeclarationForLinker())
   return true;
-
-// A symbol marked nonlazybind should not be accessed with a plt. If the
-// symbol turns out to be external, the linker will convert a direct
-// access to an access via the plt, so don't assume it is local.
-const Function *F = dyn_cast(GV);
-if (F && F->hasFnAttribute(Attribute::NonLazyBind))
-  return false;
-Triple::ArchType Arch = TT.getArch();
-
-// PowerPC64 prefers TOC indirection to avoid copy relocations.
-if (TT.isPPC64())
-  return false;
-
-// dso_local is traditionally implied for Reloc::Static. Eventually we 
shall
-// drop the if block entirely and respect dso_local/dso_preemptable
-// specifiers set by the frontend.
-if (RM == Reloc::Static) {
-  // TODO Remove the special case for x86-32.
-  if (Arch == Triple::x86 && !F && !GV->isThreadLocal())
-return true;
-}
   } else if (TT.isOSBinFormatELF()) {
 // If dso_local allows AsmPrinter::getSymbolPreferLocal to use a local
 // alias, set the flag. We cannot set dso_local for other global values,

diff  --git a/llvm/test/CodeGen/X86/abi-isel.ll 
b/llvm/test/CodeGen/X86/abi-isel.ll
index 102120aa66bd..170e597d7498 100644
--- a/llvm/test/CodeGen/X86/abi-isel.ll
+++ b/llvm/test/CodeGen/X86/abi-isel.ll
@@ -1246,7 +1246,8 @@ define void @qux01() nounwind {
 ;
 ; LINUX-32-STATIC-LABEL: qux01:
 ; LINUX-32-STATIC:   # %bb.0: # %entry
-; LINUX-32-STATIC-NEXT:movl $dst+64, ptr
+; LINUX-32-STATIC-NEXT:leal dst+64, %eax
+; LINUX-32-STATIC-NEXT:movl %eax, ptr
 ; LINUX-32-STATIC-NEXT:retl
 ;
 ; LINUX-32-PIC-LABEL: qux01:
@@ -1334,7 +1335,8 @@ define void @qxx01() nounwind {
 ;
 ; LINUX-32-STATIC-LABEL: qxx01:
 ; LINUX-32-STATIC:   # %bb.0: # %entry
-; LINUX-32-STATIC-NEXT:movl $xdst+64, ptr
+; LINUX-32-STATIC-NEXT:leal xdst+64, %eax
+; LINUX-32-STATIC-NEXT:movl %eax, ptr
 ; LINUX-32-STATIC-NEXT:retl
 ;
 ; LINUX-32-PIC-LABEL: qxx01:
@@ -4519,7 +4521,8 @@ define void @moo01(i64 %i) nounwind {
 ;
 ; LINUX-32-STATIC-LABEL: moo01:
 ; LINUX-32-STATIC:   # %bb.0: # %entry
-; LINUX-32-STATIC-NEXT:movl $dst+262144, ptr
+; LINUX-32-STATIC-NEXT:leal dst+262144, %eax
+; LINUX-32-STATIC-NEXT:movl %eax, ptr
 ; LINUX-32-STATIC-NEXT:retl
 ;
 ; LINUX-32-PIC-LABEL: moo01:
@@ -7448,7 +7451,7 @@ define i8* @bat00() nounwind {
 ;
 ; LINUX-32-STATIC-LABEL: bat00:
 ; LINUX-32-STATIC:   # %bb.0: # %entry
-; LINUX-32-STATIC-NEXT:movl $src+64, %eax
+; LINUX-32-STATIC-NEXT:leal src+64, %eax
 ; LINUX-32-STATIC-NEXT:retl
 ;
 ; LINUX-32-PIC-LABEL: bat00:
@@ -7519,7 +7522,7 @@ define i8* @bxt00() nounwind {
 ;
 ; LINUX-32-STATIC-LABEL: bxt00:
 ; LINUX-32-STATIC:   # %bb.0: # %entry
-; LINUX-32-STATIC-NEXT:movl $xsrc+64, %eax
+; LINUX-32-STATIC-NEXT:leal xsrc+64, %eax
 ; LINUX-32-STATIC-NEXT:retl
 ;
 ; LINUX-32-PIC-LABEL: bxt00:
@@ -7590,7 +7593,7 @@ define i8* @bat01() nounwind {
 ;
 ; LINUX-32-STATIC-LABEL: bat01:
 ; LINUX-32-STATIC:   # %bb.0: # %entry
-; LINUX-32-STATIC-NEXT:movl $dst+64, %eax
+; LINUX-32-STATIC-NEXT:leal dst+64, %eax
 ; LINUX-32-STATIC-NEXT:retl
 ;
 ; LINUX-32-PIC-LABEL: bat01:
@@ -7661,7 +7664,7 @@ define i8* @bxt01() nounwind {
 ;
 ; LINUX-32-STATIC-LABEL: bxt01:
 ; LINUX-32-STATIC:   # %bb.0: # %entry
-; LINUX-32-STATIC-NEXT:movl $xdst+64, %eax
+; LINUX-32-STATIC-NEXT:leal xdst+64, %eax
 ; LINUX-32-STATIC-NEXT:retl
 ;
 ; LINUX-32-PIC-LABEL: bxt01:
@@ -8226,7 +8229,7 @@ define i8* @bam00() nounwind {
 ;
 ; LINUX-32-STATIC-LABEL: bam00:
 ; LINUX-32-STATIC:   # %bb.0: # %entry
-; LINUX-32-STATIC-NEXT:

[llvm-branch-commits] [llvm] c4e327a - Remove memory allocation with string

2020-12-05 Thread Aditya Kumar via llvm-branch-commits

Author: Aditya Kumar
Date: 2020-12-05T15:14:44-08:00
New Revision: c4e327a960d20e18f3a8116da51a5686c628d51b

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

LOG: Remove memory allocation with string

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

Added: 


Modified: 
llvm/lib/Option/OptTable.cpp

Removed: 




diff  --git a/llvm/lib/Option/OptTable.cpp b/llvm/lib/Option/OptTable.cpp
index 304c09fff9d2..9564b4433f0c 100644
--- a/llvm/lib/Option/OptTable.cpp
+++ b/llvm/lib/Option/OptTable.cpp
@@ -196,11 +196,13 @@ static unsigned matchOption(const OptTable::Info *I, 
StringRef Str,
 
 // Returns true if one of the Prefixes + In.Names matches Option
 static bool optionMatches(const OptTable::Info &In, StringRef Option) {
-  if (In.Prefixes)
+  if (In.Prefixes) {
+StringRef InName(In.Name);
 for (size_t I = 0; In.Prefixes[I]; I++)
-  if (Option.endswith(In.Name))
-if (Option == std::string(In.Prefixes[I]) + In.Name)
+  if (Option.endswith(InName))
+if (Option.slice(0, Option.size() - InName.size()) == In.Prefixes[I])
   return true;
+  }
   return 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] [llvm] a553ac9 - [CodeGen] llvm::erase_if (NFC)

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

Author: Kazu Hirata
Date: 2020-12-05T15:44:40-08:00
New Revision: a553ac979146df59f062018dbb66f345c8f8

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

LOG: [CodeGen] llvm::erase_if (NFC)

Added: 


Modified: 
llvm/lib/CodeGen/MachineBlockPlacement.cpp
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp

Removed: 




diff  --git a/llvm/lib/CodeGen/MachineBlockPlacement.cpp 
b/llvm/lib/CodeGen/MachineBlockPlacement.cpp
index 461a73741648..61e803fbfc40 100644
--- a/llvm/lib/CodeGen/MachineBlockPlacement.cpp
+++ b/llvm/lib/CodeGen/MachineBlockPlacement.cpp
@@ -1673,11 +1673,9 @@ MachineBasicBlock 
*MachineBlockPlacement::selectBestCandidateBlock(
   // worklist of already placed entries.
   // FIXME: If this shows up on profiles, it could be folded (at the cost of
   // some code complexity) into the loop below.
-  WorkList.erase(llvm::remove_if(WorkList,
- [&](MachineBasicBlock *BB) {
-   return BlockToChain.lookup(BB) == &Chain;
- }),
- WorkList.end());
+  llvm::erase_if(WorkList, [&](MachineBasicBlock *BB) {
+return BlockToChain.lookup(BB) == &Chain;
+  });
 
   if (WorkList.empty())
 return nullptr;

diff  --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp 
b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index 9d2174f4b85a..397a69654933 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -1141,7 +1141,7 @@ void SelectionDAGBuilder::dropDanglingDebugInfo(const 
DILocalVariable *Variable,
   if (isMatchingDbgValue(DDI))
 salvageUnresolvedDbgValue(DDI);
 
-DDIV.erase(remove_if(DDIV, isMatchingDbgValue), DDIV.end());
+erase_if(DDIV, isMatchingDbgValue);
   }
 }
 



___
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] 109e70d - [TargetMachine] Drop implied dso_local for an edge case (extern_weak + non-pic + hidden)

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

Author: Fangrui Song
Date: 2020-12-05T15:52:33-08:00
New Revision: 109e70d357284f612fbe69d213b002366dd67927

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

LOG: [TargetMachine] Drop implied dso_local for an edge case (extern_weak + 
non-pic + hidden)

This does not deserve special handling. The code should be added to Clang
instead if deemed useful. With this simplification, we can additionally delete
the PIC extern_weak special case.

Added: 


Modified: 
llvm/lib/Target/TargetMachine.cpp
llvm/test/CodeGen/ARM/hidden-vis-3.ll
llvm/test/CodeGen/X86/hidden-vis-3.ll

Removed: 




diff  --git a/llvm/lib/Target/TargetMachine.cpp 
b/llvm/lib/Target/TargetMachine.cpp
index 3b48fd3622dc..ad0e90125258 100644
--- a/llvm/lib/Target/TargetMachine.cpp
+++ b/llvm/lib/Target/TargetMachine.cpp
@@ -143,16 +143,6 @@ bool TargetMachine::shouldAssumeDSOLocal(const Module &M,
   if (TT.isOSBinFormatCOFF() || TT.isOSWindows())
 return true;
 
-  // Most PIC code sequences that assume that a symbol is local cannot
-  // produce a 0 if it turns out the symbol is undefined. While this
-  // is ABI and relocation depended, it seems worth it to handle it
-  // here.
-  if (isPositionIndependent() && GV->hasExternalWeakLinkage())
-return false;
-
-  if (!GV->hasDefaultVisibility())
-return true;
-
   if (TT.isOSBinFormatMachO()) {
 if (RM == Reloc::Static)
   return true;

diff  --git a/llvm/test/CodeGen/ARM/hidden-vis-3.ll 
b/llvm/test/CodeGen/ARM/hidden-vis-3.ll
index 0cf2f779704d..148502686a1a 100644
--- a/llvm/test/CodeGen/ARM/hidden-vis-3.ll
+++ b/llvm/test/CodeGen/ARM/hidden-vis-3.ll
@@ -7,8 +7,9 @@ define i32 @t() nounwind readonly {
 entry:
 ; CHECK: LCPI0_0:
 ; CHECK-NEXT: .long _x
+;; .long _y can be used if @y is dso_local.
 ; CHECK: LCPI0_1:
-; CHECK-NEXT: .long _y
+; CHECK-NEXT: .long L_y$non_lazy_ptr
 
%0 = load i32, i32* @x, align 4 ;  [#uses=1]
%1 = load i32, i32* @y, align 4 ;  [#uses=1]

diff  --git a/llvm/test/CodeGen/X86/hidden-vis-3.ll 
b/llvm/test/CodeGen/X86/hidden-vis-3.ll
index 3137b936f5be..baad2a080aa0 100644
--- a/llvm/test/CodeGen/X86/hidden-vis-3.ll
+++ b/llvm/test/CodeGen/X86/hidden-vis-3.ll
@@ -6,8 +6,10 @@
 
 define i32 @t() nounwind readonly {
 entry:
+;; movl _y, %eax can be used if @y is dso_local.
 ; X32: _t:
-; X32: movl _y, %eax
+; X32:  movl L_y$non_lazy_ptr, %eax
+; X32-NEXT: movl (%eax), %eax
 
 ; X64: _t:
 ; X64: movq _y@GOTPCREL(%rip), %rax



___
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] 8f07629 - Add recursive decomposition reasoning to isKnownNonEqual

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

Author: Philip Reames
Date: 2020-12-05T15:58:19-08:00
New Revision: 8f076291be41467560ebf73738561225d2b67206

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

LOG: Add recursive decomposition reasoning to isKnownNonEqual

The basic idea is that by looking through operand instructions which don't 
change the equality result that we can push the existing known bits comparison 
down past instructions which would obscure them.

We have analogous handling in InstSimplify for most - though weirdly not all - 
of these cases starting from an icmp root. It's a bit unfortunate to duplicate 
logic, but since my actual goal is to extend BasicAA, the icmp logic doesn't 
help. (And just makes it hard to test here.)  The BasicAA change will be posted 
separately for review.

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

Added: 


Modified: 
llvm/lib/Analysis/ValueTracking.cpp
llvm/test/Analysis/ValueTracking/known-non-equal.ll

Removed: 




diff  --git a/llvm/lib/Analysis/ValueTracking.cpp 
b/llvm/lib/Analysis/ValueTracking.cpp
index 32e0ca321dec..a1bb6e2eea78 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -350,13 +350,14 @@ bool llvm::isKnownNegative(const Value *V, const 
DataLayout &DL, unsigned Depth,
   return Known.isNegative();
 }
 
-static bool isKnownNonEqual(const Value *V1, const Value *V2, const Query &Q);
+static bool isKnownNonEqual(const Value *V1, const Value *V2, unsigned Depth,
+const Query &Q);
 
 bool llvm::isKnownNonEqual(const Value *V1, const Value *V2,
const DataLayout &DL, AssumptionCache *AC,
const Instruction *CxtI, const DominatorTree *DT,
bool UseInstrInfo) {
-  return ::isKnownNonEqual(V1, V2,
+  return ::isKnownNonEqual(V1, V2, 0,
Query(DL, AC, safeCxtI(V1, safeCxtI(V2, CxtI)), DT,
  UseInstrInfo, /*ORE=*/nullptr));
 }
@@ -2486,7 +2487,8 @@ bool isKnownNonZero(const Value* V, unsigned Depth, const 
Query& Q) {
 }
 
 /// Return true if V2 == V1 + X, where X is known non-zero.
-static bool isAddOfNonZero(const Value *V1, const Value *V2, const Query &Q) {
+static bool isAddOfNonZero(const Value *V1, const Value *V2, unsigned Depth,
+   const Query &Q) {
   const BinaryOperator *BO = dyn_cast(V1);
   if (!BO || BO->getOpcode() != Instruction::Add)
 return false;
@@ -2497,24 +2499,54 @@ static bool isAddOfNonZero(const Value *V1, const Value 
*V2, const Query &Q) {
 Op = BO->getOperand(0);
   else
 return false;
-  return isKnownNonZero(Op, 0, Q);
+  return isKnownNonZero(Op, Depth + 1, Q);
 }
 
 /// Return true if it is known that V1 != V2.
-static bool isKnownNonEqual(const Value *V1, const Value *V2, const Query &Q) {
+static bool isKnownNonEqual(const Value *V1, const Value *V2, unsigned Depth,
+const Query &Q) {
   if (V1 == V2)
 return false;
   if (V1->getType() != V2->getType())
 // We can't look through casts yet.
 return false;
-  if (isAddOfNonZero(V1, V2, Q) || isAddOfNonZero(V2, V1, Q))
+
+  if (Depth >= MaxAnalysisRecursionDepth)
+return false;
+
+  // See if we can recurse through (exactly one of) our operands.
+  auto *O1 = dyn_cast(V1);
+  auto *O2 = dyn_cast(V2);
+  if (O1 && O2 && O1->getOpcode() == O2->getOpcode()) {
+switch (O1->getOpcode()) {
+default: break;
+case Instruction::Add:
+case Instruction::Sub:
+  // Assume operand order has been canonicalized
+  if (O1->getOperand(0) == O2->getOperand(0))
+return isKnownNonEqual(O1->getOperand(1), O2->getOperand(1),
+   Depth + 1, Q);
+  if (O1->getOperand(1) == O2->getOperand(1))
+return isKnownNonEqual(O1->getOperand(0), O2->getOperand(0),
+   Depth + 1, Q);
+  break;
+case Instruction::SExt:
+case Instruction::ZExt:
+  if (O1->getOperand(0)->getType() == O2->getOperand(0)->getType())
+return isKnownNonEqual(O1->getOperand(0), O2->getOperand(0),
+   Depth + 1, Q);
+  break;
+};
+  }
+  
+  if (isAddOfNonZero(V1, V2, Depth, Q) || isAddOfNonZero(V2, V1, Depth, Q))
 return true;
 
   if (V1->getType()->isIntOrIntVectorTy()) {
 // Are any known bits in V1 contradictory to known bits in V2? If V1
 // has a known zero where V2 has a known one, they must not be equal.
-KnownBits Known1 = computeKnownBits(V1, 0, Q);
-KnownBits Known2 = computeKnownBits(V2, 0, Q);
+KnownBits Known1 = computeKnownBits(V1, Depth, Q);
+KnownBits Known2 = computeKnownBits(V2, Depth, Q);
 
 if (Known1.Zero.intersects(Known2.One) |

[llvm-branch-commits] [llvm] 5121400 - [ConstantHoisting] Remove unused declaration optimizeConstants (NFC)

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

Author: Kazu Hirata
Date: 2020-12-05T16:22:12-08:00
New Revision: 5121400e71bbe821488240335cbffb41fe852514

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

LOG: [ConstantHoisting] Remove unused declaration optimizeConstants (NFC)

The function was renamed to runImpl on Jul 2, 2016 in commit
071d8306b0d9d1345c1da84ae3e1c1b231ffd29d, but the old declaration has
remained since.

Added: 


Modified: 
llvm/include/llvm/Transforms/Scalar/ConstantHoisting.h

Removed: 




diff  --git a/llvm/include/llvm/Transforms/Scalar/ConstantHoisting.h 
b/llvm/include/llvm/Transforms/Scalar/ConstantHoisting.h
index 26d4a2476a86..11379e59467f 100644
--- a/llvm/include/llvm/Transforms/Scalar/ConstantHoisting.h
+++ b/llvm/include/llvm/Transforms/Scalar/ConstantHoisting.h
@@ -198,7 +198,6 @@ class ConstantHoistingPass : public 
PassInfoMixin {
   // constant GEP base.
   bool emitBaseConstants(GlobalVariable *BaseGV);
   void deleteDeadCastInst() const;
-  bool optimizeConstants(Function &Fn);
 };
 
 } // end namespace llvm



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


[llvm-branch-commits] [lldb] ee607ed - [debugserver] Call posix_spawnattr_setarchpref_np throught the fn ptr.

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

Author: Jonas Devlieghere
Date: 2020-12-05T17:38:42-08:00
New Revision: ee607ed5c36efd8e0536ddbeab1f2025b0e5f045

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

LOG: [debugserver] Call posix_spawnattr_setarchpref_np throught the fn ptr.

Fourth time is the charm? Of course all of these issues don't show up
when the function is available...

Added: 


Modified: 
lldb/tools/debugserver/source/MacOSX/MachProcess.mm

Removed: 




diff  --git a/lldb/tools/debugserver/source/MacOSX/MachProcess.mm 
b/lldb/tools/debugserver/source/MacOSX/MachProcess.mm
index 386c5e42306a..7176a47972bf 100644
--- a/lldb/tools/debugserver/source/MacOSX/MachProcess.mm
+++ b/lldb/tools/debugserver/source/MacOSX/MachProcess.mm
@@ -3279,8 +3279,8 @@ typedef int (*posix_spawnattr_setarchpref_np_t)(
   (posix_spawnattr_setarchpref_np_t)dlsym(
   RTLD_DEFAULT, "posix_spawnattr_setarchpref_np");
   if (posix_spawnattr_setarchpref_np_fn) {
-err.SetError((*posix_spawnattr_setarchpref_np)(&attr, 1, &cpu_type,
-   &cpu_subtype, &ocount));
+err.SetError((*posix_spawnattr_setarchpref_np_fn)(
+&attr, 1, &cpu_type, &cpu_subtype, &ocount));
 slice_preference_set = err.Success();
 if (err.Fail() || DNBLogCheckLogBit(LOG_PROCESS))
   err.LogThreaded(



___
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] 5582a79 - [TargetMachine] Set dso_local if asan is detected

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

Author: Fangrui Song
Date: 2020-12-05T17:51:10-08:00
New Revision: 5582a7987662a92eda5d883b88fc4586e755acf5

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

LOG: [TargetMachine] Set dso_local if asan is detected

AddressSanitizer instrumentation does not set dso_local on non-thread-local
global variables in -fno-pic and it seems to rely on implied dso_local to work.
Add a hack until we have fixed AddressSanitizer to call setDSOLocal() as
appropriate.

Thanks to Vitaly Buka for reporting the issue and suggesting the way to detect 
asan.

Added: 


Modified: 
llvm/lib/Target/TargetMachine.cpp

Removed: 




diff  --git a/llvm/lib/Target/TargetMachine.cpp 
b/llvm/lib/Target/TargetMachine.cpp
index ad0e90125258..f214a47ba702 100644
--- a/llvm/lib/Target/TargetMachine.cpp
+++ b/llvm/lib/Target/TargetMachine.cpp
@@ -163,6 +163,11 @@ bool TargetMachine::shouldAssumeDSOLocal(const Module &M,
 // If the symbol is defined, it cannot be preempted.
 if (!GV->isDeclarationForLinker())
   return true;
+// FIXME asan does not call setDSOLocal appropriately. Fix asan and delete
+// the hack.
+if (RM == Reloc::Static && !GV->isThreadLocal() &&
+M.getFunction("asan.module_ctor"))
+  return true;
   } else if (TT.isOSBinFormatELF()) {
 // If dso_local allows AsmPrinter::getSymbolPreferLocal to use a local
 // alias, set the flag. We cannot set dso_local for other global values,



___
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] b00f345 - [asan][test] Fix odr-vtable.cpp

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

Author: Fangrui Song
Date: 2020-12-05T19:30:41-08:00
New Revision: b00f345acd9496936f9c91eb5d0b0f305838bf13

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

LOG: [asan][test] Fix odr-vtable.cpp

Added: 


Modified: 
compiler-rt/test/asan/TestCases/Linux/odr-vtable.cpp

Removed: 




diff  --git a/compiler-rt/test/asan/TestCases/Linux/odr-vtable.cpp 
b/compiler-rt/test/asan/TestCases/Linux/odr-vtable.cpp
index 52483c3a5020..56f71b79288f 100644
--- a/compiler-rt/test/asan/TestCases/Linux/odr-vtable.cpp
+++ b/compiler-rt/test/asan/TestCases/Linux/odr-vtable.cpp
@@ -4,6 +4,7 @@
 /// Not using private alias or enabling ODR indicator can detect ODR issues.
 // RUN: %clangxx_asan -fno-rtti -DBUILD_SO1 -fPIC -shared -mllvm 
-asan-use-private-alias=0 %s -o %dynamiclib1
 // RUN: %clangxx_asan -fno-rtti -DBUILD_SO2 -fPIC -shared -mllvm 
-asan-use-private-alias=0 %s -o %dynamiclib2
+// RUN: %clangxx_asan -fno-rtti %s %ld_flags_rpath_exe1 %ld_flags_rpath_exe2 
-o %t
 // RUN: %env_asan_opts=fast_unwind_on_malloc=0:detect_odr_violation=2 not %run 
%t 2>&1 | FileCheck %s
 
 // RUN: %clangxx_asan -fno-rtti -DBUILD_SO1 -fPIC -shared -mllvm 
-asan-use-odr-indicator=1 %s -o %dynamiclib1
@@ -13,7 +14,6 @@
 /// By default we can detect ODR issues in vtables.
 // RUN: %clangxx_asan -fno-rtti -DBUILD_SO1 -fPIC -shared %s -o %dynamiclib1
 // RUN: %clangxx_asan -fno-rtti -DBUILD_SO2 -fPIC -shared %s -o %dynamiclib2
-// RUN: %clangxx_asan -fno-rtti %s %ld_flags_rpath_exe1 %ld_flags_rpath_exe2 
-o %t
 // RUN: %env_asan_opts=fast_unwind_on_malloc=0:detect_odr_violation=2 not %run 
%t 2>&1 | FileCheck %s
 
 struct XYZ {



___
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] 5fc8f90 - [RISCV] Replace a custom SDTypeProfile with SDTIntBinOp which should be sufficient here.

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

Author: Craig Topper
Date: 2020-12-05T20:18:22-08:00
New Revision: 5fc8f90f0a96a32b774cecc593af82959025906b

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

LOG: [RISCV] Replace a custom SDTypeProfile with SDTIntBinOp which should be 
sufficient here.

On the surface this would be slightly less optimal for the isel
table, but due to a tablegen issue with HW mode this ends up
generating a smaller isel table.

Added: 


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

Removed: 




diff  --git a/llvm/lib/Target/RISCV/RISCVInstrInfoB.td 
b/llvm/lib/Target/RISCV/RISCVInstrInfoB.td
index 8d9748d80ba3..2f663cad82b8 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfoB.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfoB.td
@@ -716,13 +716,10 @@ let Predicates = [HasStdExtZbs] in
 def : Pat<(and (srl GPR:$rs1, uimmlog2xlen:$shamt), (XLenVT 1)),
   (SBEXTI GPR:$rs1, uimmlog2xlen:$shamt)>;
 
-def SDT_RISCVGREVGORC  : SDTypeProfile<1, 2, [SDTCisVT<0, XLenVT>,
-  SDTCisSameAs<0, 1>,
-  SDTCisSameAs<1, 2>]>;
-def riscv_grevi: SDNode<"RISCVISD::GREVI", SDT_RISCVGREVGORC, []>;
-def riscv_greviw   : SDNode<"RISCVISD::GREVIW", SDT_RISCVGREVGORC, []>;
-def riscv_gorci: SDNode<"RISCVISD::GORCI", SDT_RISCVGREVGORC, []>;
-def riscv_gorciw   : SDNode<"RISCVISD::GORCIW", SDT_RISCVGREVGORC, []>;
+def riscv_grevi: SDNode<"RISCVISD::GREVI", SDTIntBinOp, []>;
+def riscv_greviw   : SDNode<"RISCVISD::GREVIW", SDTIntBinOp, []>;
+def riscv_gorci: SDNode<"RISCVISD::GORCI", SDTIntBinOp, []>;
+def riscv_gorciw   : SDNode<"RISCVISD::GORCIW", SDTIntBinOp, []>;
 
 let Predicates = [HasStdExtZbp] in {
 def : Pat<(riscv_grevi GPR:$rs1, timm:$shamt), (GREVI GPR:$rs1, timm:$shamt)>;



___
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] 5bc9c85 - [ORC] Fix missing forward of Allow filter in TPCDynamicLibrarySearchGenerator.

2020-12-05 Thread Lang Hames via llvm-branch-commits

Author: Lang Hames
Date: 2020-12-06T15:42:45+11:00
New Revision: 5bc9c858e34026462070dbe0f937d4f243682bef

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

LOG: [ORC] Fix missing forward of Allow filter in 
TPCDynamicLibrarySearchGenerator.

Added: 


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

Removed: 




diff  --git 
a/llvm/include/llvm/ExecutionEngine/Orc/TPCDynamicLibrarySearchGenerator.h 
b/llvm/include/llvm/ExecutionEngine/Orc/TPCDynamicLibrarySearchGenerator.h
index 07720f5c0f33..ed4f6080bb4e 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/TPCDynamicLibrarySearchGenerator.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/TPCDynamicLibrarySearchGenerator.h
@@ -47,7 +47,7 @@ class TPCDynamicLibrarySearchGenerator : public 
DefinitionGenerator {
   static Expected>
   GetForTargetProcess(TargetProcessControl &TPC,
   SymbolPredicate Allow = SymbolPredicate()) {
-return Load(TPC, nullptr);
+return Load(TPC, nullptr, std::move(Allow));
   }
 
   Error tryToGenerate(LookupState &LS, LookupKind K, JITDylib &JD,



___
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] 204d0d5 - [MemProf] Make __memprof_shadow_memory_dynamic_address dso_local in static relocation model

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

Author: Fangrui Song
Date: 2020-12-05T21:36:31-08:00
New Revision: 204d0d51b3cec91696f8b0b03f204cd0cf8d5ed4

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

LOG: [MemProf] Make __memprof_shadow_memory_dynamic_address dso_local in static 
relocation model

The x86-64 backend currently has a bug which uses a wrong register when for the 
GOTPCREL reference.
The program will crash without the dso_local specifier.

Added: 
llvm/test/Instrumentation/HeapProfiler/shadow.ll

Modified: 
llvm/lib/Transforms/Instrumentation/MemProfiler.cpp

Removed: 




diff  --git a/llvm/lib/Transforms/Instrumentation/MemProfiler.cpp 
b/llvm/lib/Transforms/Instrumentation/MemProfiler.cpp
index 32fd11a258fa..56006bbc94c7 100644
--- a/llvm/lib/Transforms/Instrumentation/MemProfiler.cpp
+++ b/llvm/lib/Transforms/Instrumentation/MemProfiler.cpp
@@ -576,6 +576,8 @@ bool 
MemProfiler::insertDynamicShadowAtFunctionEntry(Function &F) {
   IRBuilder<> IRB(&F.front().front());
   Value *GlobalDynamicAddress = F.getParent()->getOrInsertGlobal(
   MemProfShadowMemoryDynamicAddress, IntptrTy);
+  if (F.getParent()->getPICLevel() == PICLevel::NotPIC)
+dyn_cast(GlobalDynamicAddress)->setDSOLocal(true);
   DynamicShadowOffset = IRB.CreateLoad(IntptrTy, GlobalDynamicAddress);
   return true;
 }

diff  --git a/llvm/test/Instrumentation/HeapProfiler/shadow.ll 
b/llvm/test/Instrumentation/HeapProfiler/shadow.ll
new file mode 100644
index ..4472f3d33a0f
--- /dev/null
+++ b/llvm/test/Instrumentation/HeapProfiler/shadow.ll
@@ -0,0 +1,14 @@
+; RUN: opt < %s -passes='function(memprof),module(memprof-module)' -S | 
FileCheck --check-prefixes=STATIC %s
+
+; RUN: cp %s %t.pic.ll
+; RUN: echo -e '!llvm.module.flags = !{!0}\n!0 = !{i32 7, !"PIC Level", i32 
1}' >> %t.pic.ll
+; RUN: opt < %t.pic.ll -passes='function(memprof),module(memprof-module)' -S | 
FileCheck --check-prefixes=PIC %s
+
+; STATIC: @__memprof_shadow_memory_dynamic_address = external dso_local global 
i64
+; PIC: @__memprof_shadow_memory_dynamic_address = external global i64
+
+define i32 @test_load(i32* %a) {
+entry:
+  %tmp1 = load i32, i32* %a, align 4
+  ret i32 %tmp1
+}



___
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] a4cadc2 - [TargetMachine] Don't imply dso_local for memprof in static relocation model

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

Author: Fangrui Song
Date: 2020-12-05T21:39:03-08:00
New Revision: a4cadc2df92bb1b6c5d6c0d20ebadbc0fa74189b

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

LOG: [TargetMachine] Don't imply dso_local for memprof in static relocation 
model

The workaround is no longer needed with my previous commit to MemProfiler.cpp

Added: 


Modified: 
llvm/lib/Target/TargetMachine.cpp

Removed: 




diff  --git a/llvm/lib/Target/TargetMachine.cpp 
b/llvm/lib/Target/TargetMachine.cpp
index d9c894537b72..07a6e53c8f0f 100644
--- a/llvm/lib/Target/TargetMachine.cpp
+++ b/llvm/lib/Target/TargetMachine.cpp
@@ -166,8 +166,7 @@ bool TargetMachine::shouldAssumeDSOLocal(const Module &M,
 // FIXME Sanitizers do not call setDSOLocal appropriately. Fix sanitizers
 // and delete the hack.
 if (RM == Reloc::Static && !GV->isThreadLocal() &&
-(M.getFunction("asan.module_ctor") ||
- M.getFunction("memprof.module_ctor")))
+M.getFunction("asan.module_ctor"))
   return true;
   } else if (TT.isOSBinFormatELF()) {
 // If dso_local allows AsmPrinter::getSymbolPreferLocal to use a local



___
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] 687b83c - [X86FastISel] Fix MO_GOTPCREL GlobalValue reference in static relocation model

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

Author: Fangrui Song
Date: 2020-12-05T23:13:28-08:00
New Revision: 687b83ceabafe81970cd4639e7f0c89036402081

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

LOG: [X86FastISel] Fix MO_GOTPCREL GlobalValue reference in static relocation 
model

This fixes the bug referenced by 5582a7987662a92eda5d883b88fc4586e755acf5
which was exposed by 961f31d8ad14c66829991522d73e14b5a96ff6d4.

With this change, `movq src@GOTPCREL, %rcx` => `movq src@GOTPCREL(%rip), %rcx`

Added: 


Modified: 
llvm/lib/Target/X86/X86FastISel.cpp
llvm/test/CodeGen/X86/fast-isel-mem.ll

Removed: 




diff  --git a/llvm/lib/Target/X86/X86FastISel.cpp 
b/llvm/lib/Target/X86/X86FastISel.cpp
index a8db3d416c2e..caf158102230 100644
--- a/llvm/lib/Target/X86/X86FastISel.cpp
+++ b/llvm/lib/Target/X86/X86FastISel.cpp
@@ -784,7 +784,7 @@ bool X86FastISel::handleConstantAddresses(const Value *V, 
X86AddressMode &AM) {
   RC  = &X86::GR32RegClass;
 }
 
-if (Subtarget->isPICStyleRIPRel())
+if (Subtarget->isPICStyleRIPRel() || GVFlags == X86II::MO_GOTPCREL)
   StubAM.Base.Reg = X86::RIP;
 
 LoadReg = createResultReg(RC);

diff  --git a/llvm/test/CodeGen/X86/fast-isel-mem.ll 
b/llvm/test/CodeGen/X86/fast-isel-mem.ll
index 3f1d9cae9340..42f210199e64 100644
--- a/llvm/test/CodeGen/X86/fast-isel-mem.ll
+++ b/llvm/test/CodeGen/X86/fast-isel-mem.ll
@@ -1,7 +1,8 @@
 ; RUN: llc < %s -fast-isel -mtriple=i386-apple-darwin -mcpu=generic | 
FileCheck %s
 ; RUN: llc < %s -fast-isel -mtriple=i386-apple-darwin -mcpu=atom | FileCheck 
-check-prefix=ATOM %s
+; RUN: llc < %s -fast-isel -fast-isel-abort=3 -mtriple=x86_64 | FileCheck 
-check-prefix=ELF64 %s
 
-@src = external global i32
+@src = external dso_preemptable global i32
 
 ; rdar://6653118
 define i32 @loadgv() nounwind {
@@ -26,6 +27,14 @@ entry:
 ; ATOM: movl%eax, (%ecx)
 ; ATOM: ret
 
+;; dso_preemptable src is loaded via GOT indirection.
+; ELF64-LABEL: loadgv:
+; ELF64:movqsrc@GOTPCREL(%rip), %rcx
+; ELF64-NEXT:   movl(%rcx), %eax
+; ELF64-NEXT:   addl(%rcx), %eax
+; ELF64-NEXT:   movl%eax, (%rcx)
+; ELF64-NEXT:   retq
+
 }
 
 %stuff = type { i32 (...)** }



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