[llvm-branch-commits] [llvm] fd04cb4 - [Clang][Driver] After default -fintegrated-cc1, make llvm::report_fatal_error() generate preprocessed source + reproducer.sh again.

2020-02-12 Thread Hans Wennborg via llvm-branch-commits

Author: Alexandre Ganea
Date: 2020-02-12T10:22:21+01:00
New Revision: fd04cb43e1d83c6f18c932de94c1e341272ed160

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

LOG: [Clang][Driver] After default -fintegrated-cc1, make 
llvm::report_fatal_error() generate preprocessed source + reproducer.sh again.

Added a test for #pragma clang __debug llvm_fatal_error to test for the 
original issue.
Added llvm::sys::Process::Exit() and replaced ::exit() in places where it was 
appropriate. This new function would call the current CrashRecoveryContext if 
one is running on the same thread; or call ::exit() otherwise.

Fixes PR44705.

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

(cherry picked from commit faace365088a2a3a4cb1050a9facfc34a7a56577)

Added: 


Modified: 
clang/test/Driver/crash-report.c
clang/tools/driver/cc1_main.cpp
clang/tools/driver/cc1as_main.cpp
llvm/include/llvm/Support/CrashRecoveryContext.h
llvm/include/llvm/Support/Process.h
llvm/lib/Support/CrashRecoveryContext.cpp
llvm/lib/Support/ErrorHandling.cpp
llvm/lib/Support/Process.cpp

Removed: 




diff  --git a/clang/test/Driver/crash-report.c 
b/clang/test/Driver/crash-report.c
index 3a77a21c62b4..ceb16cb6e18a 100644
--- a/clang/test/Driver/crash-report.c
+++ b/clang/test/Driver/crash-report.c
@@ -21,12 +21,20 @@
 // RUN: cat %t/crash-report-*.c | FileCheck --check-prefix=CHECKSRC %s
 // RUN: cat %t/crash-report-*.sh | FileCheck --check-prefix=CHECKSH %s
 
+// RUN: env TMPDIR=%t TEMP=%t TMP=%t RC_DEBUG_OPTIONS=1  \
+// RUN:  CC_PRINT_HEADERS=1 CC_LOG_DIAGNOSTICS=1 \
+// RUN:  not %clang %s @%t.rsp -DFATAL 2>&1 | FileCheck %s
+// RUN: cat %t/crash-report-*.c | FileCheck --check-prefix=CHECKSRC %s
+// RUN: cat %t/crash-report-*.sh | FileCheck --check-prefix=CHECKSH %s
+
 // REQUIRES: crash-recovery
 
 #ifdef PARSER
 #pragma clang __debug parser_crash
 #elif CRASH
 #pragma clang __debug crash
+#elif FATAL
+#pragma clang __debug llvm_fatal_error
 #endif
 
 // CHECK: Preprocessed source(s) and associated run script(s) are located at:

diff  --git a/clang/tools/driver/cc1_main.cpp b/clang/tools/driver/cc1_main.cpp
index b551e9f4cf82..6d1a67f2a4fa 100644
--- a/clang/tools/driver/cc1_main.cpp
+++ b/clang/tools/driver/cc1_main.cpp
@@ -36,6 +36,7 @@
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/Process.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/TargetRegistry.h"
 #include "llvm/Support/TargetSelect.h"
@@ -69,7 +70,7 @@ static void LLVMErrorHandler(void *UserData, const 
std::string &Message,
   // We cannot recover from llvm errors.  When reporting a fatal error, exit
   // with status 70 to generate crash diagnostics.  For BSD systems this is
   // defined as an internal software error.  Otherwise, exit with status 1.
-  exit(GenCrashDiag ? 70 : 1);
+  llvm::sys::Process::Exit(GenCrashDiag ? 70 : 1);
 }
 
 #ifdef CLANG_HAVE_RLIMITS

diff  --git a/clang/tools/driver/cc1as_main.cpp 
b/clang/tools/driver/cc1as_main.cpp
index 53c8a9d642dc..e1041f91bfd5 100644
--- a/clang/tools/driver/cc1as_main.cpp
+++ b/clang/tools/driver/cc1as_main.cpp
@@ -46,6 +46,7 @@
 #include "llvm/Support/Host.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/Process.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/SourceMgr.h"
 #include "llvm/Support/TargetRegistry.h"
@@ -547,7 +548,7 @@ static void LLVMErrorHandler(void *UserData, const 
std::string &Message,
   Diags.Report(diag::err_fe_error_backend) << Message;
 
   // We cannot recover from llvm errors.
-  exit(1);
+  sys::Process::Exit(1);
 }
 
 int cc1as_main(ArrayRef Argv, const char *Argv0, void *MainAddr) 
{

diff  --git a/llvm/include/llvm/Support/CrashRecoveryContext.h 
b/llvm/include/llvm/Support/CrashRecoveryContext.h
index beeb855c7c58..61a1bd405a4d 100644
--- a/llvm/include/llvm/Support/CrashRecoveryContext.h
+++ b/llvm/include/llvm/Support/CrashRecoveryContext.h
@@ -97,6 +97,11 @@ class CrashRecoveryContext {
 return RunSafelyOnThread([&]() { Fn(UserData); }, RequestedStackSize);
   }
 
+  /// Explicitly trigger a crash recovery in the current process, and
+  /// return failure from RunSafely(). This function does not return.
+  LLVM_ATTRIBUTE_NORETURN
+  void HandleExit(int RetCode);
+
   /// In case of a crash, this is the crash identifier.
   int RetCode = 0;
 

diff  --git a/llvm/include/llvm/Support/Process.h 
b/llvm/include/llvm/Support/Process.h
index 67e37912519b..e934b7413c17 100644
--- a/llvm/include/llvm/Support/Process.h
+++ b/llvm/include/llvm/Support/Process.h
@@ -201,6 +201,12 @@ class Process {
   /// Get the result of a proces

[llvm-branch-commits] [llvm] 3c94b27 - [SystemZ] Bugfix in emitSelect()

2020-02-12 Thread Hans Wennborg via llvm-branch-commits

Author: Jonas Paulsson
Date: 2020-02-12T10:50:02+01:00
New Revision: 3c94b2780126be9cf0e828bbd62729cdc5f421da

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

LOG: [SystemZ]  Bugfix in emitSelect()

When more than one SelectPseudo instruction is handled a new MBB is
returned. This must not be done if that would result in leaving an undhandled
isel pseudo behind in the original MBB.

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

Review: Ulrich Weigand

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

(cherry picked from commit 0311e28e9cc01a244faa774b8cab337b45404fa9)

Added: 
llvm/test/CodeGen/SystemZ/multiselect-02.mir

Modified: 
llvm/lib/Target/SystemZ/SystemZISelLowering.cpp

Removed: 




diff  --git a/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp 
b/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
index c73905d3357a..ab00069497af 100644
--- a/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
+++ b/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
@@ -6859,8 +6859,6 @@ SystemZTargetLowering::emitSelect(MachineInstr &MI,
   for (MachineBasicBlock::iterator NextMIIt =
  std::next(MachineBasicBlock::iterator(MI));
NextMIIt != MBB->end(); ++NextMIIt) {
-if (NextMIIt->definesRegister(SystemZ::CC))
-  break;
 if (isSelectPseudo(*NextMIIt)) {
   assert(NextMIIt->getOperand(3).getImm() == CCValid &&
  "Bad CCValid operands since CC was not redefined.");
@@ -6871,6 +6869,9 @@ SystemZTargetLowering::emitSelect(MachineInstr &MI,
   }
   break;
 }
+if (NextMIIt->definesRegister(SystemZ::CC) ||
+NextMIIt->usesCustomInsertionHook())
+  break;
 bool User = false;
 for (auto SelMI : Selects)
   if (NextMIIt->readsVirtualRegister(SelMI->getOperand(0).getReg())) {

diff  --git a/llvm/test/CodeGen/SystemZ/multiselect-02.mir 
b/llvm/test/CodeGen/SystemZ/multiselect-02.mir
new file mode 100644
index ..fc8aa0ad538f
--- /dev/null
+++ b/llvm/test/CodeGen/SystemZ/multiselect-02.mir
@@ -0,0 +1,43 @@
+# RUN: llc -mtriple=s390x-linux-gnu -mcpu=z10 -run-pass=finalize-isel -o - %s \
+# RUN:   | FileCheck %s
+#
+# Test that an instruction (ZEXT128) that uses custom insertion gets treated
+# correctly also when it lies between two Select instructions that could
+# potentially be handled together.
+#
+# CHECK-LABEL: bb.0.entry:
+# CHECK-NOT: ZEXT128
+
+--- |
+  declare void @bar(i32)
+  define i32 @fun() { entry: ret i32 0 }
+---
+name:fun
+body: |
+  bb.0.entry:
+%1:addr64bit = IMPLICIT_DEF
+%0:gr32bit = LLC %1, 0, $noreg :: (load 1 from `i8* undef`)
+CHI killed %0, 0, implicit-def $cc
+%2:gr32bit = LHI 2
+%3:gr32bit = LHI 8
+%4:gr32bit = Select32 killed %3, killed %2, 14, 8, implicit $cc
+%5:gr32bit = LHI 128
+%7:gr64bit = IMPLICIT_DEF
+%6:gr64bit = INSERT_SUBREG %7, killed %5, %subreg.subreg_l32
+%8:gr128bit = ZEXT128 killed %6
+%10:addr64bit = IMPLICIT_DEF
+%9:gr128bit = DL %8, %10, 0, $noreg :: (load 4 from `i64* undef` + 4)
+%11:gr32bit = COPY %9.subreg_l32
+%12:gr64bit = LGHI 2
+%13:gr64bit = LGHI 8
+%14:gr64bit = Select64 killed %13, killed %12, 14, 8, implicit $cc
+CR %4, %11, implicit-def $cc
+%15:gr32bit = Select32 %11, %4, 14, 4, implicit $cc
+ADJCALLSTACKDOWN 0, 0
+$r2d = COPY %14
+CallBRASL @bar, $r2d, csr_systemz, implicit-def dead $r14d, implicit-def 
dead $cc, implicit $fpc
+ADJCALLSTACKUP 0, 0
+$r2l = COPY %15
+Return implicit $r2l
+
+...



___
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] d8a6dea - Fix MSVC build with C++ EH enabled

2020-02-12 Thread Hans Wennborg via llvm-branch-commits

Author: Reid Kleckner
Date: 2020-02-12T11:20:56+01:00
New Revision: d8a6deab7a84a559a1ff9f2196dae68870af80bf

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

LOG: Fix MSVC build with C++ EH enabled

Mark the CrashRecoveryContextImpl constructor noexcept, so that MSVC
won't emit an unwind helper to clean up the allocation from `new` if the
constructor throws an exception.

Otherwise, MSVC complains:
  llvm\lib\Support\CrashRecoveryContext.cpp(220): error C2712: \
  Cannot use __try in functions that require object unwinding

The other simple fix would be to wrap `new` in a static helper or
lambda.

Users have reported that Tensorflow builds LLVM with /EHsc.

(cherry picked from commit a349c09162a8260bdf691c4f7ab72a16c33975f6)

Added: 


Modified: 
llvm/lib/Support/CrashRecoveryContext.cpp

Removed: 




diff  --git a/llvm/lib/Support/CrashRecoveryContext.cpp 
b/llvm/lib/Support/CrashRecoveryContext.cpp
index f708da773f4c..356835609830 100644
--- a/llvm/lib/Support/CrashRecoveryContext.cpp
+++ b/llvm/lib/Support/CrashRecoveryContext.cpp
@@ -41,7 +41,7 @@ struct CrashRecoveryContextImpl {
   unsigned ValidJumpBuffer : 1;
 
 public:
-  CrashRecoveryContextImpl(CrashRecoveryContext *CRC)
+  CrashRecoveryContextImpl(CrashRecoveryContext *CRC) noexcept
   : CRC(CRC), Failed(false), SwitchedThread(false), ValidJumpBuffer(false) 
{
 Next = CurrentContext->get();
 CurrentContext->set(this);



___
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] b33830a - [OpenCL] Restrict addr space conversions in nested pointers

2020-02-12 Thread Hans Wennborg via llvm-branch-commits

Author: Anastasia Stulova
Date: 2020-02-12T13:45:17+01:00
New Revision: b33830aea54536f0f03334b2015b03af336ec90c

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

LOG: [OpenCL] Restrict addr space conversions in nested pointers

Address space conversion changes pointer representation.
This commit disallows such conversions when they are not
legal i.e. for the nested pointers even with compatible
address spaces. Because the address space conversion in
the nested levels can't be generated to modify the pointers
correctly. The behavior implemented is as follows:

- Any implicit conversions of nested pointers with different
  address spaces is rejected.
- Any conversion of address spaces in nested pointers in safe
  casts (e.g. const_cast or static_cast) is rejected.
- Conversion in low level C-style or reinterpret_cast is accepted
  but with a warning (this aligns with OpenCL C behavior).

Fixes PR39674

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

(cherry picked from commit 6064f426a18304e16b51cc79e74c9c2d55ef5a9c)

Added: 
clang/test/SemaOpenCLCXX/address-space-castoperators.cl

Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaCast.cpp
clang/lib/Sema/SemaOverload.cpp
clang/test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
clang/test/SemaOpenCL/address-spaces.cl
clang/test/SemaOpenCLCXX/address-space-deduction.cl
clang/test/SemaOpenCLCXX/address-space-references.cl

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index ecf959b9077a..2199dfbddc84 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6748,6 +6748,10 @@ def err_bad_cxx_cast_scalar_to_vector_
diff erent_size : Error<
 def err_bad_cxx_cast_vector_to_vector_
diff erent_size : Error<
   "%select{||reinterpret_cast||C-style cast|}0 from vector %1 "
   "to vector %2 of 
diff erent size">;
+def warn_bad_cxx_cast_nested_pointer_addr_space : Warning<
+  "%select{reinterpret_cast|C-style cast}0 from %1 to %2 "
+  "changes address space of nested pointers">,
+  InGroup;
 def err_bad_lvalue_to_rvalue_cast : Error<
   "cannot cast from lvalue of type %1 to rvalue reference type %2; types are "
   "not compatible">;

diff  --git a/clang/lib/Sema/SemaCast.cpp b/clang/lib/Sema/SemaCast.cpp
index a905ebc67305..7a8cbca1e3f1 100644
--- a/clang/lib/Sema/SemaCast.cpp
+++ b/clang/lib/Sema/SemaCast.cpp
@@ -2311,6 +2311,24 @@ static TryCastResult TryReinterpretCast(Sema &Self, 
ExprResult &SrcExpr,
 return SuccessResult;
   }
 
+  // Diagnose address space conversion in nested pointers.
+  QualType DestPtee = DestType->getPointeeType().isNull()
+  ? DestType->getPointeeType()
+  : DestType->getPointeeType()->getPointeeType();
+  QualType SrcPtee = SrcType->getPointeeType().isNull()
+ ? SrcType->getPointeeType()
+ : SrcType->getPointeeType()->getPointeeType();
+  while (!DestPtee.isNull() && !SrcPtee.isNull()) {
+if (DestPtee.getAddressSpace() != SrcPtee.getAddressSpace()) {
+  Self.Diag(OpRange.getBegin(),
+diag::warn_bad_cxx_cast_nested_pointer_addr_space)
+  << CStyle << SrcType << DestType << SrcExpr.get()->getSourceRange();
+  break;
+}
+DestPtee = DestPtee->getPointeeType();
+SrcPtee = SrcPtee->getPointeeType();
+  }
+
   // C++ 5.2.10p7: A pointer to an object can be explicitly converted to
   //   a pointer to an object of 
diff erent type.
   // Void pointers are not specified, but supported by every compiler out 
there.

diff  --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 9a9843827b3f..db1884acd349 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -3176,7 +3176,7 @@ static bool isNonTrivialObjCLifetimeConversion(Qualifiers 
FromQuals,
 /// FromType and \p ToType is permissible, given knowledge about whether every
 /// outer layer is const-qualified.
 static bool isQualificationConversionStep(QualType FromType, QualType ToType,
-  bool CStyle,
+  bool CStyle, bool IsTopLevel,
   bool &PreviousToQualsIncludeConst,
   bool &ObjCLifetimeConversion) {
   Qualifiers FromQuals = FromType.getQualifiers();
@@ -3213,11 +3213,15 @@ static bool isQualificationConversionStep(QualType 
FromType, QualType ToType,
   if (!CStyle && !ToQuals.compatiblyIncludes(FromQuals))
 return false;
 
-  // For a C-style cast, just require the address spaces to overlap.
-  /

[llvm-branch-commits] [llvm] c170172 - [DebugInfo] Re-instate LiveDebugVariables scope trimming

2020-02-12 Thread Hans Wennborg via llvm-branch-commits

Author: Jeremy Morse
Date: 2020-02-12T14:04:24+01:00
New Revision: c1701728b93b3aec39d3b93d0182648887edfdb1

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

LOG: [DebugInfo] Re-instate LiveDebugVariables scope trimming

This patch reverts part of r362750 / D62650, which stopped
LiveDebugVariables from trimming leading variable location ranges down
to only covering those instructions that are in scope. I've observed some
circumstances where the number of DBG_VALUEs in a function can be
amplified in an un-necessary way, to cover more instructions that are
out of scope, leading to very slow compile times. Trimming the range
of instructions that the variables cover solves the slow compile times.

The specific problem that r362750 tries to fix is addressed by the
assignment to RStart that I've added. Any variable location that begins
at the first instruction of a block will now be considered to begin at the
start of the block. While these sound the same, the have different
SlotIndexes, and the register allocator may shoehorn additional
instructions in between the two. The test added in the past
(wrong_debug_loc_after_regalloc.ll) still works with this modification.

live-debug-variables.ll has a range trimmed to not cover the prologue of
the function, while dbg-addr-dse.ll has a DBG_VALUE sink past one
instruction with no DebugLoc, which is expected behaviour.

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

(cherry picked from commit 41206b61e30c3d84188cb17b91c2c0c800982dd1)

Added: 


Modified: 
llvm/lib/CodeGen/LiveDebugVariables.cpp
llvm/test/DebugInfo/X86/dbg-addr-dse.ll
llvm/test/DebugInfo/X86/live-debug-variables.ll

Removed: 




diff  --git a/llvm/lib/CodeGen/LiveDebugVariables.cpp 
b/llvm/lib/CodeGen/LiveDebugVariables.cpp
index 2cc547a6b741..0bd0c27cb0e8 100644
--- a/llvm/lib/CodeGen/LiveDebugVariables.cpp
+++ b/llvm/lib/CodeGen/LiveDebugVariables.cpp
@@ -166,6 +166,10 @@ class UserValue {
   /// Map of slot indices where this value is live.
   LocMap locInts;
 
+  /// Set of interval start indexes that have been trimmed to the
+  /// lexical scope.
+  SmallSet trimmedDefs;
+
   /// Insert a DBG_VALUE into MBB at Idx for LocNo.
   void insertDebugValue(MachineBasicBlock *MBB, SlotIndex StartIdx,
 SlotIndex StopIdx, DbgValueLocation Loc, bool Spilled,
@@ -910,6 +914,11 @@ void UserValue::computeIntervals(MachineRegisterInfo &MRI,
 SlotIndex RStart = LIS.getInstructionIndex(*Range.first);
 SlotIndex REnd = LIS.getInstructionIndex(*Range.second);
 
+// Variable locations at the first instruction of a block should be
+// based on the block's SlotIndex, not the first instruction's index.
+if (Range.first == Range.first->getParent()->begin())
+  RStart = LIS.getSlotIndexes()->getIndexBefore(*Range.first);
+
 // At the start of each iteration I has been advanced so that
 // I.stop() >= PrevEnd. Check for overlap.
 if (PrevEnd && I.start() < PrevEnd) {
@@ -922,7 +931,8 @@ void UserValue::computeIntervals(MachineRegisterInfo &MRI,
   ++I;
 
   // If the interval also overlaps the start of the "next" (i.e.
-  // current) range create a new interval for the remainder
+  // current) range create a new interval for the remainder (which
+  // may be further trimmed).
   if (RStart < IStop)
 I.insert(RStart, IStop, Loc);
 }
@@ -932,6 +942,13 @@ void UserValue::computeIntervals(MachineRegisterInfo &MRI,
 if (!I.valid())
   return;
 
+if (I.start() < RStart) {
+  // Interval start overlaps range - trim to the scope range.
+  I.setStartUnchecked(RStart);
+  // Remember that this interval was trimmed.
+  trimmedDefs.insert(RStart);
+}
+
 // The end of a lexical scope range is the last instruction in the
 // range. To convert to an interval we need the index of the
 // instruction after it.
@@ -1345,6 +1362,12 @@ void UserValue::emitDebugValues(VirtRegMap *VRM, 
LiveIntervals &LIS,
 bool Spilled = SpillIt != SpillOffsets.end();
 unsigned SpillOffset = Spilled ? SpillIt->second : 0;
 
+// If the interval start was trimmed to the lexical scope insert the
+// DBG_VALUE at the previous index (otherwise it appears after the
+// first instruction in the range).
+if (trimmedDefs.count(Start))
+  Start = Start.getPrevIndex();
+
 LLVM_DEBUG(dbgs() << "\t[" << Start << ';' << Stop << "):" << Loc.locNo());
 MachineFunction::iterator MBB = LIS.getMBBFromIndex(Start)->getIterator();
 SlotIndex MBBEnd = LIS.getMBBEndIdx(&*MBB);

diff  --git a/llvm/test/DebugInfo/X86/dbg-addr-dse.ll 
b/llvm/test/DebugInfo/X86/dbg-addr-dse.ll
index a90d372cd98e..f6f653a1d982 100644
--- a/llvm/test/DebugInfo/X86/dbg-addr-dse.ll
+++

[llvm-branch-commits] [llvm] 04d7337 - Revert "[DebugInfo][DAG] Distinguish different kinds of location indirection"

2020-02-12 Thread Hans Wennborg via llvm-branch-commits

Author: Jeremy Morse
Date: 2020-02-12T14:06:19+01:00
New Revision: 04d7337d69fa38f00179811419207a9ef5eef83e

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

LOG: Revert "[DebugInfo][DAG] Distinguish different kinds of location 
indirection"

This reverts commit 3137fe4d23eeb8df08c03e9111465325eeafe08e.

I'm backing out D68945, which this patch is a follow up for. It'll be
re-landed when D68945 is fixed.

The changes to dbg-value-func-arg.ll occur because our handling of certain
kinds of location now mixes up indirection that happens at different points
in a DIExpression. While this is a regression, it's a return to the prior
behaviour while a better patch is sought.

(cherry picked from commit ece761427f63de96ee52bbd6be1c61b07967a917)

Added: 


Modified: 
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
llvm/test/CodeGen/X86/dbg-value-func-arg.ll

Removed: 
llvm/test/DebugInfo/X86/stack-arg-deref.ll



diff  --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp 
b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index 728d963a916f..b0d3eca8ab86 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -5622,6 +5622,7 @@ bool SelectionDAGBuilder::EmitFuncArgumentDbgValue(
   MachineFunction &MF = DAG.getMachineFunction();
   const TargetInstrInfo *TII = DAG.getSubtarget().getInstrInfo();
 
+  bool IsIndirect = false;
   Optional Op;
   // Some arguments' frame index is recorded during argument lowering.
   int FI = FuncInfo.getArgumentFrameIndex(Arg);
@@ -5643,6 +5644,7 @@ bool SelectionDAGBuilder::EmitFuncArgumentDbgValue(
 }
 if (Reg) {
   Op = MachineOperand::CreateReg(Reg, false);
+  IsIndirect = IsDbgDeclare;
 }
   }
 
@@ -5709,6 +5711,7 @@ bool SelectionDAGBuilder::EmitFuncArgumentDbgValue(
   }
 
   Op = MachineOperand::CreateReg(VMI->second, false);
+  IsIndirect = IsDbgDeclare;
 } else if (ArgRegsAndSizes.size() > 1) {
   // This was split due to the calling convention, and no virtual register
   // mapping exists for the value.
@@ -5722,26 +5725,9 @@ bool SelectionDAGBuilder::EmitFuncArgumentDbgValue(
 
   assert(Variable->isValidLocationForIntrinsic(DL) &&
  "Expected inlined-at fields to agree");
-
-  // If the argument arrives in a stack slot, then what the IR thought was a
-  // normal Value is actually in memory, and we must add a deref to load it.
-  if (Op->isFI()) {
-int FI = Op->getIndex();
-unsigned Size = DAG.getMachineFunction().getFrameInfo().getObjectSize(FI);
-if (Expr->isImplicit()) {
-  SmallVector Ops = {dwarf::DW_OP_deref_size, Size};
-  Expr = DIExpression::prependOpcodes(Expr, Ops);
-} else {
-  Expr = DIExpression::prepend(Expr, DIExpression::DerefBefore);
-}
-  }
-
-  // If this location was specified with a dbg.declare, then it and its
-  // expression calculate the address of the variable. Append a deref to
-  // force it to be a memory location.
-  if (IsDbgDeclare)
+  IsIndirect = (Op->isReg()) ? IsIndirect : true;
+  if (IsIndirect)
 Expr = DIExpression::append(Expr, {dwarf::DW_OP_deref});
-
   FuncInfo.ArgDbgValues.push_back(
   BuildMI(MF, DL, TII->get(TargetOpcode::DBG_VALUE), false,
   *Op, Variable, Expr));

diff  --git a/llvm/test/CodeGen/X86/dbg-value-func-arg.ll 
b/llvm/test/CodeGen/X86/dbg-value-func-arg.ll
index beaf84871d16..d589712690f5 100644
--- a/llvm/test/CodeGen/X86/dbg-value-func-arg.ll
+++ b/llvm/test/CodeGen/X86/dbg-value-func-arg.ll
@@ -34,8 +34,8 @@ define dso_local %struct.bar* @func1(%struct.bar* readnone 
returned %0, i32 %1,
 ; CHECK-DAG: DBG_VALUE %fixed-stack.0, $noreg, {{.*}}, 
!DIExpression(DW_OP_deref, DW_OP_LLVM_fragment, 32, 32),
 ; CHECK-DAG: DBG_VALUE %fixed-stack.3, $noreg, {{.*}}, 
!DIExpression(DW_OP_deref),
 ; CHECK-DAG: DBG_VALUE %fixed-stack.2, $noreg, {{.*}}, 
!DIExpression(DW_OP_deref),
-; CHECK-DAG: DBG_VALUE %fixed-stack.3, $noreg, {{.*}}, 
!DIExpression(DW_OP_deref_size, 4, DW_OP_plus_uconst, 144, DW_OP_stack_value),
-; CHECK-DAG: DBG_VALUE %fixed-stack.3, $noreg, {{.*}}, 
!DIExpression(DW_OP_deref_size, 4, DW_OP_plus_uconst, 144, DW_OP_stack_value, 
DW_OP_LLVM_fragment, 32, 32),
+; CHECK-DAG: DBG_VALUE %fixed-stack.3, $noreg, {{.*}}, 
!DIExpression(DW_OP_plus_uconst, 144, DW_OP_deref, DW_OP_stack_value),
+; CHECK-DAG: DBG_VALUE %fixed-stack.3, $noreg, {{.*}}, 
!DIExpression(DW_OP_plus_uconst, 144, DW_OP_deref, DW_OP_stack_value, 
DW_OP_LLVM_fragment, 32, 32),
 
   call void @llvm.dbg.value(metadata i32 %2, metadata !24, metadata 
!DIExpression(DW_OP_LLVM_fragment, 0, 32)), !dbg !26
   call void @llvm.dbg.value(metadata i32* %3, metadata !24, metadata 
!DIExpression(DW_OP_LLVM_fragment, 32, 32)), !db

[llvm-branch-commits] [clang-tools-extra] 7a136d2 - [clang-tidy] Added check to disable bugprone-infinite-loop on known false condition

2020-02-12 Thread Hans Wennborg via llvm-branch-commits

Author: Nathan James
Date: 2020-02-12T13:50:19+01:00
New Revision: 7a136d2768e26b30273f208fb3d64eae531c8455

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

LOG: [clang-tidy] Added check to disable bugprone-infinite-loop on known false 
condition

Summary: Addresses [[ https://bugs.llvm.org/show_bug.cgi?id=44816 | 
bugprone-infinite-loop false positive with CATCH2 ]] by disabling the check on 
loops where the condition is known to always eval as false, in other words not 
a loop.

Reviewers: aaron.ballman, alexfh, hokein, gribozavr2, JonasToth

Reviewed By: gribozavr2

Subscribers: xazax.hun, cfe-commits

Tags: #clang, #clang-tools-extra

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

(cherry picked from commit c69ec6476806147e46bf09b693acb24177982dc2)

Added: 


Modified: 
clang-tools-extra/clang-tidy/bugprone/InfiniteLoopCheck.cpp
clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/bugprone/InfiniteLoopCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/InfiniteLoopCheck.cpp
index c771ba81b250..5e5651fc256e 100644
--- a/clang-tools-extra/clang-tidy/bugprone/InfiniteLoopCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/InfiniteLoopCheck.cpp
@@ -152,6 +152,13 @@ static std::string getCondVarNames(const Stmt *Cond) {
   return Result;
 }
 
+static bool isKnownFalse(const Expr &Cond, const ASTContext &Ctx) {
+  bool Result = false;
+  if (Cond.EvaluateAsBooleanCondition(Result, Ctx))
+return !Result;
+  return false;
+}
+
 void InfiniteLoopCheck::registerMatchers(MatchFinder *Finder) {
   const auto LoopCondition = allOf(
   hasCondition(
@@ -170,6 +177,9 @@ void InfiniteLoopCheck::check(const 
MatchFinder::MatchResult &Result) {
   const auto *LoopStmt = Result.Nodes.getNodeAs("loop-stmt");
   const auto *Func = Result.Nodes.getNodeAs("func");
 
+  if (isKnownFalse(*Cond, *Result.Context))
+return;
+
   bool ShouldHaveConditionVariables = true;
   if (const auto *While = dyn_cast(LoopStmt)) {
 if (const VarDecl *LoopVarDecl = While->getConditionVariable()) {

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp
index d89bdadf0212..427b5f0272b9 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp
@@ -354,3 +354,12 @@ void lambda_capture() {
 (*p)++;
   } while (i < Limit);
 }
+
+void evaluatable(bool CondVar) {
+  for (; false && CondVar;) {
+  }
+  while (false && CondVar) {
+  }
+  do {
+  } while (false && CondVar);
+}



___
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] 4eb45a0 - Revert "[DebugInfo] Remove some users of DBG_VALUEs IsIndirect field"

2020-02-12 Thread Hans Wennborg via llvm-branch-commits

Author: Jeremy Morse
Date: 2020-02-12T14:06:29+01:00
New Revision: 4eb45a05a78f7c80bbec0453bc225deebec06209

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

LOG: Revert "[DebugInfo] Remove some users of DBG_VALUEs IsIndirect field"

This reverts commit ed29dbaafa49bb8c9039a35f768244c394411fea.

I'm backing out D68945, which as the discussion for D73526 shows, doesn't
seem to handle the -O0 path through the codegen backend correctly. I'll
reland the patch when a fix is worked out, apologies for all the churn.
The two parent commits are part of this revert too.

Conflicts:
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
llvm/test/DebugInfo/X86/dbg-addr-dse.ll

SelectionDAGBuilder conflict is due to a nearby change in e39e2b4a79c6
that's technically unrelated. dbg-addr-dse.ll conflicted because
41206b61e30c (legitimately) changes the order of two lines.

There are further modifications to dbg-value-func-arg.ll: it landed after
the patch being reverted, and I've converted indirection to be represented
by the isIndirect field rather than DW_OP_deref.

(cherry picked from commit 6531a78ac4b5b229bce272706593a0bc873877d7)

Added: 


Modified: 
llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp
llvm/lib/CodeGen/LiveDebugVariables.cpp
llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
llvm/lib/CodeGen/SelectionDAG/InstrEmitter.cpp
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
llvm/test/CodeGen/AArch64/GlobalISel/debug-cpp.ll
llvm/test/CodeGen/AArch64/GlobalISel/debug-insts.ll
llvm/test/CodeGen/ARM/debug-info-arg.ll
llvm/test/CodeGen/PowerPC/debuginfo-stackarg.ll
llvm/test/CodeGen/X86/dbg-value-func-arg.ll
llvm/test/DebugInfo/ARM/PR16736.ll
llvm/test/DebugInfo/ARM/float-stack-arg.ll
llvm/test/DebugInfo/COFF/pieces.ll
llvm/test/DebugInfo/X86/dbg-addr-dse.ll
llvm/test/DebugInfo/X86/dbg-addr.ll
llvm/test/DebugInfo/X86/live-debug-vars-dse.mir
llvm/test/DebugInfo/X86/op_deref.ll
llvm/test/DebugInfo/X86/parameters.ll
llvm/test/DebugInfo/X86/safestack-byval.ll
llvm/test/DebugInfo/X86/spill-indirect-nrvo.ll
llvm/test/DebugInfo/X86/spill-nontrivial-param.ll
llvm/test/DebugInfo/X86/vla.ll

Removed: 




diff  --git a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp 
b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
index 17eca2b0301c..96e794b15a44 100644
--- a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
@@ -1385,7 +1385,7 @@ bool IRTranslator::translateKnownIntrinsic(const CallInst 
&CI, Intrinsic::ID ID,
 if (!V) {
   // Currently the optimizer can produce this; insert an undef to
   // help debugging.  Probably the optimizer should not do this.
-  MIRBuilder.buildDirectDbgValue(0, DI.getVariable(), DI.getExpression());
+  MIRBuilder.buildIndirectDbgValue(0, DI.getVariable(), 
DI.getExpression());
 } else if (const auto *CI = dyn_cast(V)) {
   MIRBuilder.buildConstDbgValue(*CI, DI.getVariable(), DI.getExpression());
 } else {

diff  --git a/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp 
b/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp
index 67d9dacda61b..3f6622723bdc 100644
--- a/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp
@@ -107,13 +107,9 @@ MachineIRBuilder::buildIndirectDbgValue(Register Reg, 
const MDNode *Variable,
   assert(
   cast(Variable)->isValidLocationForIntrinsic(getDL()) &&
   "Expected inlined-at fields to agree");
-  // DBG_VALUE insts now carry IR-level indirection in their DIExpression
-  // rather than encoding it in the instruction itself.
-  const DIExpression *DIExpr = cast(Expr);
-  DIExpr = DIExpression::append(DIExpr, {dwarf::DW_OP_deref});
   return insertInstr(BuildMI(getMF(), getDL(),
  getTII().get(TargetOpcode::DBG_VALUE),
- /*IsIndirect*/ false, Reg, Variable, DIExpr));
+ /*IsIndirect*/ true, Reg, Variable, Expr));
 }
 
 MachineInstrBuilder MachineIRBuilder::buildFIDbgValue(int FI,
@@ -124,15 +120,11 @@ MachineInstrBuilder MachineIRBuilder::buildFIDbgValue(int 
FI,
   assert(
   cast(Variable)->isValidLocationForIntrinsic(getDL()) &&
   "Expected inlined-at fields to agree");
-  // DBG_VALUE insts now carry IR-level indirection in their DIExpression
-  // rather than encoding it in the instruction itself.
-  const DIExpression *DIExpr = cast(Expr);
-  DIExpr = DIExpression::append(DIExpr, {dwarf::DW_OP_deref});
   return buildInstr(TargetOpcode::DBG_VALUE)
   .addFrameIndex(FI)
-  .addReg(0)
+  .addImm(0)
   .addMetadata(Variable)
-  .addMetadata(DIExpr);
+

[llvm-branch-commits] [clang] 533d98b - [X86] Cast to __v4hi instead of __m64 in the implementation of _mm_extract_pi16 and _mm_insert_pi16.

2020-02-12 Thread Hans Wennborg via llvm-branch-commits

Author: Craig Topper
Date: 2020-02-12T14:49:56+01:00
New Revision: 533d98bdced6f75d0c7e4f42476b3bc873a113b6

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

LOG: [X86] Cast to __v4hi instead of __m64 in the implementation of 
_mm_extract_pi16 and _mm_insert_pi16.

__m64 is a vector of 1 long long. But the builtins these intrinsics
are calling expect a vector of 4 shorts.

Fixes PR44589

(cherry picked from commit 16b9410caa35da976fa5f3cf6dd3d6f3776d51ca)

Added: 


Modified: 
clang/lib/Headers/xmmintrin.h

Removed: 




diff  --git a/clang/lib/Headers/xmmintrin.h b/clang/lib/Headers/xmmintrin.h
index 0e61eab44aeb..9b8de63f04d5 100644
--- a/clang/lib/Headers/xmmintrin.h
+++ b/clang/lib/Headers/xmmintrin.h
@@ -2181,7 +2181,7 @@ void _mm_sfence(void);
 ///3: Bits [63:48] are copied to the destination.
 /// \returns A 16-bit integer containing the extracted 16 bits of packed data.
 #define _mm_extract_pi16(a, n) \
-  (int)__builtin_ia32_vec_ext_v4hi((__m64)a, (int)n)
+  (int)__builtin_ia32_vec_ext_v4hi((__v4hi)a, (int)n)
 
 /// Copies data from the 64-bit vector of [4 x i16] to the destination,
 ///and inserts the lower 16-bits of an integer operand at the 16-bit offset
@@ -2212,7 +2212,7 @@ void _mm_sfence(void);
 /// \returns A 64-bit integer vector containing the copied packed data from the
 ///operands.
 #define _mm_insert_pi16(a, d, n) \
-  (__m64)__builtin_ia32_vec_set_v4hi((__m64)a, (int)d, (int)n)
+  (__m64)__builtin_ia32_vec_set_v4hi((__v4hi)a, (int)d, (int)n)
 
 /// Compares each of the corresponding packed 16-bit integer values of
 ///the 64-bit integer vectors, and writes the greater value to the



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


[llvm-branch-commits] [llvm] 2804f35 - Fix an unused variable warning

2020-02-12 Thread Hans Wennborg via llvm-branch-commits

Author: Hans Wennborg
Date: 2020-02-12T14:54:32+01:00
New Revision: 2804f355820ed5358694d6952db665086024

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

LOG: Fix an unused variable warning

(cherry picked from commit ea9850b6c71d975935de15bd4128508b260165c5)

Added: 


Modified: 
llvm/lib/Target/ARM/ARMConstantIslandPass.cpp

Removed: 




diff  --git a/llvm/lib/Target/ARM/ARMConstantIslandPass.cpp 
b/llvm/lib/Target/ARM/ARMConstantIslandPass.cpp
index 634fb89b8e89..66ad120a111f 100644
--- a/llvm/lib/Target/ARM/ARMConstantIslandPass.cpp
+++ b/llvm/lib/Target/ARM/ARMConstantIslandPass.cpp
@@ -330,8 +330,8 @@ void ARMConstantIslands::verify() {
 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
 /// print block size and offset information - debugging
 LLVM_DUMP_METHOD void ARMConstantIslands::dumpBBs() {
-  BBInfoVector &BBInfo = BBUtils->getBBInfo();
   LLVM_DEBUG({
+BBInfoVector &BBInfo = BBUtils->getBBInfo();
 for (unsigned J = 0, E = BBInfo.size(); J !=E; ++J) {
   const BasicBlockInfo &BBI = BBInfo[J];
   dbgs() << format("%08x %bb.%u\t", BBI.Offset, J)



___
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] 9fbd4ab - [Concepts] Do not check constraints if not all template arguments have been deduced

2020-02-12 Thread Saar Raz via llvm-branch-commits

Author: Saar Raz
Date: 2020-02-12T16:03:13+02:00
New Revision: 9fbd4ab395f73209d09d821f6e5d49150c1e36ab

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

LOG: [Concepts] Do not check constraints if not all template arguments have 
been deduced

We previously checked the constraints of instantiated function templates even 
in cases where
PartialOverloading was true and not all template arguments have been deduced, 
which caused crashes
in clangd (bug 44714).

We now check if all arguments have been deduced before checking constraints in 
partial overloading
scenarios.

(cherry picked from commit 5fef14d932fe602bf998b8fb8a809ff85ca1e245)

Added: 
clang/test/CXX/temp/temp.deduct/p5.cpp

Modified: 
clang/lib/Sema/SemaTemplateDeduction.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaTemplateDeduction.cpp 
b/clang/lib/Sema/SemaTemplateDeduction.cpp
index 1a71f270679d..6b865a601f9d 100644
--- a/clang/lib/Sema/SemaTemplateDeduction.cpp
+++ b/clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -3439,13 +3439,16 @@ Sema::TemplateDeductionResult 
Sema::FinishTemplateArgumentDeduction(
   //   ([temp.constr.decl]), those constraints are checked for satisfaction
   //   ([temp.constr.constr]). If the constraints are not satisfied, type
   //   deduction fails.
-  if (CheckInstantiatedFunctionTemplateConstraints(Info.getLocation(),
-  Specialization, Builder, Info.AssociatedConstraintsSatisfaction))
-return TDK_MiscellaneousDeductionFailure;
+  if (!PartialOverloading ||
+  (Builder.size() == FunctionTemplate->getTemplateParameters()->size())) {
+if (CheckInstantiatedFunctionTemplateConstraints(Info.getLocation(),
+Specialization, Builder, Info.AssociatedConstraintsSatisfaction))
+  return TDK_MiscellaneousDeductionFailure;
 
-  if (!Info.AssociatedConstraintsSatisfaction.IsSatisfied) {
-Info.reset(TemplateArgumentList::CreateCopy(Context, Builder));
-return TDK_ConstraintsNotSatisfied;
+if (!Info.AssociatedConstraintsSatisfaction.IsSatisfied) {
+  Info.reset(TemplateArgumentList::CreateCopy(Context, Builder));
+  return TDK_ConstraintsNotSatisfied;
+}
   }
 
   if (OriginalCallArgs) {

diff  --git a/clang/test/CXX/temp/temp.deduct/p5.cpp 
b/clang/test/CXX/temp/temp.deduct/p5.cpp
new file mode 100644
index ..0c998b19f181
--- /dev/null
+++ b/clang/test/CXX/temp/temp.deduct/p5.cpp
@@ -0,0 +1,6 @@
+// RUN:  %clang_cc1 -std=c++2a -verify %s -code-completion-at=%s:6:16
+// expected-no-diagnostics
+
+template  concept C = true;
+void bar(C auto foo);
+int y = bar(
\ No newline at end of file



___
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] 6f69240 - [Concepts] Add missing TPA commit to requires expression parsing

2020-02-12 Thread Saar Raz via llvm-branch-commits

Author: Saar Raz
Date: 2020-02-12T16:27:14+02:00
New Revision: 6f692404a30d7f58b20d40f7a6ceaf826320b145

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

LOG: [Concepts] Add missing TPA commit to requires expression parsing

If an error had occurred when annotating a scope spec during the tentative parse
for a type-requirement, we would not revert nor commit the tentative parse, 
triggerring
an assertion failure.

Commit the TPA in this case and then do error recovery.

(cherry picked from commit 271e495399170d69627c1acd591c9298cb0b5b4b)

Added: 


Modified: 
clang/lib/Parse/ParseExprCXX.cpp

Removed: 




diff  --git a/clang/lib/Parse/ParseExprCXX.cpp 
b/clang/lib/Parse/ParseExprCXX.cpp
index 9f94e0dde3bd..17f81ec96c1f 100644
--- a/clang/lib/Parse/ParseExprCXX.cpp
+++ b/clang/lib/Parse/ParseExprCXX.cpp
@@ -3476,6 +3476,7 @@ ExprResult Parser::ParseRequiresExpression() {
   // We need to consume the typename to allow 'requires { typename a; 
}'
   SourceLocation TypenameKWLoc = ConsumeToken();
   if (TryAnnotateCXXScopeToken()) {
+TPA.Commit();
 SkipUntil(tok::semi, tok::r_brace, 
SkipUntilFlags::StopBeforeMatch);
 break;
   }



___
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] b3cf704 - [CodeGen] Fix the computation of the alignment of split stores.

2020-02-12 Thread Hans Wennborg via llvm-branch-commits

Author: Hans Wennborg
Date: 2020-02-12T15:29:31+01:00
New Revision: b3cf70427eb1e97d9b89ba6e9298c280c8a32c74

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

LOG: [CodeGen] Fix the computation of the alignment of split stores.

By Clement Courbet!

Backported from rG15488ff24b4a

Added: 
llvm/test/Transforms/CodeGenPrepare/PowerPC/split-store-alignment.ll
llvm/test/Transforms/CodeGenPrepare/X86/split-store-alignment.ll

Modified: 
llvm/lib/CodeGen/CodeGenPrepare.cpp

Removed: 




diff  --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp 
b/llvm/lib/CodeGen/CodeGenPrepare.cpp
index 003db39fe5f9..7d77664fbf69 100644
--- a/llvm/lib/CodeGen/CodeGenPrepare.cpp
+++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp
@@ -6857,12 +6857,20 @@ static bool splitMergedValStore(StoreInst &SI, const 
DataLayout &DL,
 Value *Addr = Builder.CreateBitCast(
 SI.getOperand(1),
 SplitStoreType->getPointerTo(SI.getPointerAddressSpace()));
-if ((IsLE && Upper) || (!IsLE && !Upper))
+const bool IsOffsetStore = (IsLE && Upper) || (!IsLE && !Upper);
+if (IsOffsetStore)
   Addr = Builder.CreateGEP(
   SplitStoreType, Addr,
   ConstantInt::get(Type::getInt32Ty(SI.getContext()), 1));
+MaybeAlign Alignment(SI.getAlignment());
+if (IsOffsetStore && Alignment) {
+  // When splitting the store in half, naturally one half will retain the
+  // alignment of the original wider store, regardless of whether it was
+  // over-aligned or not, while the other will require adjustment.
+  Alignment = commonAlignment(Alignment, HalfValBitSize / 8);
+}
 Builder.CreateAlignedStore(
-V, Addr, Upper ? SI.getAlignment() / 2 : SI.getAlignment());
+V, Addr, Alignment.hasValue() ? Alignment.getValue().value() : 0);
   };
 
   CreateSplitStore(LValue, false);

diff  --git 
a/llvm/test/Transforms/CodeGenPrepare/PowerPC/split-store-alignment.ll 
b/llvm/test/Transforms/CodeGenPrepare/PowerPC/split-store-alignment.ll
new file mode 100644
index ..5bc7d3a3b3b4
--- /dev/null
+++ b/llvm/test/Transforms/CodeGenPrepare/PowerPC/split-store-alignment.ll
@@ -0,0 +1,111 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -S -codegenprepare -mtriple=powerpc64-unknown-linux-gnu 
-data-layout="E-m:e-i64:64-n32:64" -force-split-store < %s  | FileCheck 
--check-prefixes=ALL,BE %s
+; RUN: opt -S -codegenprepare -mtriple=powerpc64le-unknown-linux-gnu 
-data-layout="e-m:e-i64:64-n32:64" -force-split-store < %s  | FileCheck 
--check-prefixes=ALL,LE %s
+
+define void @split_store_align1(float %x, i64* %p) {
+; BE-LABEL: @split_store_align1(
+; BE-NEXT:[[B:%.*]] = bitcast float [[X:%.*]] to i32
+; BE-NEXT:[[Z:%.*]] = zext i32 0 to i64
+; BE-NEXT:[[S:%.*]] = shl nuw nsw i64 [[Z]], 32
+; BE-NEXT:[[Z2:%.*]] = zext i32 [[B]] to i64
+; BE-NEXT:[[O:%.*]] = or i64 [[S]], [[Z2]]
+; BE-NEXT:[[TMP1:%.*]] = bitcast i64* [[P:%.*]] to i32*
+; BE-NEXT:[[TMP2:%.*]] = getelementptr i32, i32* [[TMP1]], i32 1
+; BE-NEXT:store i32 [[B]], i32* [[TMP2]], align 1
+; BE-NEXT:[[TMP3:%.*]] = bitcast i64* [[P]] to i32*
+; BE-NEXT:store i32 0, i32* [[TMP3]], align 1
+; BE-NEXT:ret void
+;
+; LE-LABEL: @split_store_align1(
+; LE-NEXT:[[B:%.*]] = bitcast float [[X:%.*]] to i32
+; LE-NEXT:[[Z:%.*]] = zext i32 0 to i64
+; LE-NEXT:[[S:%.*]] = shl nuw nsw i64 [[Z]], 32
+; LE-NEXT:[[Z2:%.*]] = zext i32 [[B]] to i64
+; LE-NEXT:[[O:%.*]] = or i64 [[S]], [[Z2]]
+; LE-NEXT:[[TMP1:%.*]] = bitcast i64* [[P:%.*]] to i32*
+; LE-NEXT:store i32 [[B]], i32* [[TMP1]], align 1
+; LE-NEXT:[[TMP2:%.*]] = bitcast i64* [[P]] to i32*
+; LE-NEXT:[[TMP3:%.*]] = getelementptr i32, i32* [[TMP2]], i32 1
+; LE-NEXT:store i32 0, i32* [[TMP3]], align 1
+; LE-NEXT:ret void
+;
+  %b = bitcast float %x to i32
+  %z = zext i32 0 to i64
+  %s = shl nuw nsw i64 %z, 32
+  %z2 = zext i32 %b to i64
+  %o = or i64 %s, %z2
+  store i64 %o, i64* %p, align 1
+  ret void
+}
+
+define void @split_store_align2(float %x, i64* %p) {
+; BE-LABEL: @split_store_align2(
+; BE-NEXT:[[B:%.*]] = bitcast float [[X:%.*]] to i32
+; BE-NEXT:[[Z:%.*]] = zext i32 0 to i64
+; BE-NEXT:[[S:%.*]] = shl nuw nsw i64 [[Z]], 32
+; BE-NEXT:[[Z2:%.*]] = zext i32 [[B]] to i64
+; BE-NEXT:[[O:%.*]] = or i64 [[S]], [[Z2]]
+; BE-NEXT:[[TMP1:%.*]] = bitcast i64* [[P:%.*]] to i32*
+; BE-NEXT:[[TMP2:%.*]] = getelementptr i32, i32* [[TMP1]], i32 1
+; BE-NEXT:store i32 [[B]], i32* [[TMP2]], align 2
+; BE-NEXT:[[TMP3:%.*]] = bitcast i64* [[P]] to i32*
+; BE-NEXT:store i32 0, i32* [[TMP3]], align 2
+; BE-NEXT:ret void
+;
+; LE-LABEL: @split_store_align2(
+; LE-NEXT:[[B:%.*]] = bitcast float [[X:%.*]