[llvm-branch-commits] [clang] 72f1246 - Add a release note about deprecating the clang-cl /fallback flag

2021-02-05 Thread Hans Wennborg via llvm-branch-commits

Author: Hans Wennborg
Date: 2021-02-05T13:53:42+01:00
New Revision: 72f12467ded52160d52025e13a6217f00fe25f68

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

LOG: Add a release note about deprecating the clang-cl /fallback flag

As discussed in
https://lists.llvm.org/pipermail/cfe-dev/2021-January/067524.html

The flag has been removed on the main branch in D95876.

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index c17d84de320c..f4ca8a855142 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -109,6 +109,10 @@ Deprecated Compiler Flags
 The following options are deprecated and ignored. They will be removed in
 future versions of Clang.
 
+- The clang-cl ``/fallback`` flag, which made clang-cl invoke Microsoft Visual
+  C++ on files it couldn't compile itself, has been deprecated. It will be
+  removed in Clang 13.
+
 - ...
 
 Modified Compiler Flags



___
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] 81febec - [MemCpyOpt] Add test for incorrect optimization across lifetime (NFC)

2021-02-05 Thread Tom Stellard via llvm-branch-commits

Author: Nikita Popov
Date: 2021-02-05T20:40:28-08:00
New Revision: 81febec8a327ecbe83575ac280c2931718ab5e33

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

LOG: [MemCpyOpt] Add test for incorrect optimization across lifetime (NFC)

This only affects the MemorySSA-based implementation.

Added: 


Modified: 
llvm/test/Transforms/MemCpyOpt/lifetime.ll

Removed: 




diff  --git a/llvm/test/Transforms/MemCpyOpt/lifetime.ll 
b/llvm/test/Transforms/MemCpyOpt/lifetime.ll
index 1d2b699ee96d..5dc13ca10054 100644
--- a/llvm/test/Transforms/MemCpyOpt/lifetime.ll
+++ b/llvm/test/Transforms/MemCpyOpt/lifetime.ll
@@ -1,6 +1,6 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
-; RUN: opt < %s -O2 -S -enable-memcpyopt-memoryssa=0 | FileCheck %s
-; RUN: opt < %s -O2 -S -enable-memcpyopt-memoryssa=1 -verify-memoryssa | 
FileCheck %s
+; RUN: opt < %s -O2 -S -enable-memcpyopt-memoryssa=0 | FileCheck %s 
--check-prefixes=CHECK,NO_MSSA
+; RUN: opt < %s -O2 -S -enable-memcpyopt-memoryssa=1 -verify-memoryssa | 
FileCheck %s --check-prefixes=CHECK,MSSA
 
 ; performCallSlotOptzn in MemCpy should not exchange the calls to
 ; @llvm.lifetime.start and @llvm.memcpy.
@@ -9,8 +9,8 @@ declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* 
nocapture readonly, i
 declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture) #1
 declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture) #1
 
-define void @_ZN4CordC2EOS_(i8* nocapture dereferenceable(16) %arg1) {
-; CHECK-LABEL: @_ZN4CordC2EOS_(
+define void @call_slot(i8* nocapture dereferenceable(16) %arg1) {
+; CHECK-LABEL: @call_slot(
 ; CHECK-NEXT:  bb:
 ; CHECK-NEXT:[[TMP_SROA_3_0_ARG1_SROA_RAW_IDX:%.*]] = getelementptr 
inbounds i8, i8* [[ARG1:%.*]], i64 7
 ; CHECK-NEXT:store i8 0, i8* [[TMP_SROA_3_0_ARG1_SROA_RAW_IDX]], align 1
@@ -27,4 +27,39 @@ bb:
   ret void
 }
 
+; FIXME: Miscompile.
+define void @memcpy_memcpy_across_lifetime(i8* noalias %p1, i8* noalias %p2, 
i8* noalias %p3) {
+; NO_MSSA-LABEL: @memcpy_memcpy_across_lifetime(
+; NO_MSSA-NEXT:[[A:%.*]] = alloca [16 x i8], align 1
+; NO_MSSA-NEXT:[[A8:%.*]] = getelementptr inbounds [16 x i8], [16 x i8]* 
[[A]], i64 0, i64 0
+; NO_MSSA-NEXT:call void @llvm.lifetime.start.p0i8(i64 16, i8* nonnull 
[[A8]])
+; NO_MSSA-NEXT:call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull align 1 
dereferenceable(16) [[A8]], i8* nonnull align 1 dereferenceable(16) [[P1:%.*]], 
i64 16, i1 false)
+; NO_MSSA-NEXT:tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull align 
1 dereferenceable(16) [[P1]], i8* nonnull align 1 dereferenceable(16) 
[[P2:%.*]], i64 16, i1 false)
+; NO_MSSA-NEXT:call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull align 1 
dereferenceable(16) [[P2]], i8* nonnull align 1 dereferenceable(16) [[A8]], i64 
16, i1 false)
+; NO_MSSA-NEXT:call void @llvm.lifetime.end.p0i8(i64 16, i8* nonnull 
[[A8]])
+; NO_MSSA-NEXT:tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull align 
1 dereferenceable(16) [[P3:%.*]], i8* nonnull align 1 dereferenceable(16) 
[[P2]], i64 16, i1 false)
+; NO_MSSA-NEXT:ret void
+;
+; MSSA-LABEL: @memcpy_memcpy_across_lifetime(
+; MSSA-NEXT:[[A:%.*]] = alloca [16 x i8], align 1
+; MSSA-NEXT:[[A8:%.*]] = getelementptr inbounds [16 x i8], [16 x i8]* 
[[A]], i64 0, i64 0
+; MSSA-NEXT:call void @llvm.lifetime.start.p0i8(i64 16, i8* nonnull [[A8]])
+; MSSA-NEXT:call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull align 1 
dereferenceable(16) [[A8]], i8* nonnull align 1 dereferenceable(16) [[P1:%.*]], 
i64 16, i1 false)
+; MSSA-NEXT:tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull align 1 
dereferenceable(16) [[P1]], i8* nonnull align 1 dereferenceable(16) [[P2:%.*]], 
i64 16, i1 false)
+; MSSA-NEXT:call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull align 1 
dereferenceable(16) [[P2]], i8* nonnull align 1 dereferenceable(16) [[A8]], i64 
16, i1 false)
+; MSSA-NEXT:call void @llvm.lifetime.end.p0i8(i64 16, i8* nonnull [[A8]])
+; MSSA-NEXT:call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull align 1 
dereferenceable(16) [[P3:%.*]], i8* nonnull align 1 dereferenceable(16) [[A8]], 
i64 16, i1 false)
+; MSSA-NEXT:ret void
+;
+  %a = alloca [16 x i8]
+  %a8 = bitcast [16 x i8]* %a to i8*
+  call void @llvm.lifetime.start.p0i8(i64 16, i8* %a8)
+  call void @llvm.memcpy.p0i8.p0i8.i64(i8* %a8, i8* %p1, i64 16, i1 false)
+  call void @llvm.memcpy.p0i8.p0i8.i64(i8* %p1, i8* %p2, i64 16, i1 false)
+  call void @llvm.memcpy.p0i8.p0i8.i64(i8* %p2, i8* %a8, i64 16, i1 false)
+  call void @llvm.lifetime.end.p0i8(i64 16, i8* %a8)
+  call void @llvm.memcpy.p0i8.p0i8.i64(i8* %p3, i8* %p2, i64 16, i1 false)
+  ret void
+}
+
 attributes #1 = { argmemonly nounwind }



_

[llvm-branch-commits] [llvm] 12a772b - [MemorySSA] Don't treat lifetime.end as NoAlias

2021-02-05 Thread Tom Stellard via llvm-branch-commits

Author: Nikita Popov
Date: 2021-02-05T20:40:28-08:00
New Revision: 12a772b1a09a1b5c3f43d08c2804973506b8a859

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

LOG: [MemorySSA] Don't treat lifetime.end as NoAlias

MemorySSA currently treats lifetime.end intrinsics as not aliasing
anything. This breaks MemorySSA-based MemCpyOpt, because we'll happily
move a read of a pointer below a lifetime.end intrinsic, as no clobber
is reported.

I think the MemorySSA modelling here isn't correct: lifetime.end(p)
has approximately the same effect as doing a memcpy(p, undef), and
should be treated as a clobber.

This patch removes the special handling of lifetime.end, leaving
alias analysis to handle it appropriately.

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

Added: 


Modified: 
llvm/lib/Analysis/MemorySSA.cpp
llvm/test/Analysis/MemorySSA/lifetime-simple.ll
llvm/test/Transforms/MemCpyOpt/lifetime.ll

Removed: 




diff  --git a/llvm/lib/Analysis/MemorySSA.cpp b/llvm/lib/Analysis/MemorySSA.cpp
index 52dca7d378e1..4722b68e20e9 100644
--- a/llvm/lib/Analysis/MemorySSA.cpp
+++ b/llvm/lib/Analysis/MemorySSA.cpp
@@ -281,7 +281,6 @@ instructionClobbersQuery(const MemoryDef *MD, const 
MemoryLocation &UseLoc,
 // clobbers where they don't really exist at all. Please see D43269 for
 // context.
 switch (II->getIntrinsicID()) {
-case Intrinsic::lifetime_end:
 case Intrinsic::invariant_start:
 case Intrinsic::invariant_end:
 case Intrinsic::assume:
@@ -358,22 +357,6 @@ struct UpwardsMemoryQuery {
 
 } // end anonymous namespace
 
-static bool lifetimeEndsAt(MemoryDef *MD, const MemoryLocation &Loc,
-   BatchAAResults &AA) {
-  Instruction *Inst = MD->getMemoryInst();
-  if (IntrinsicInst *II = dyn_cast(Inst)) {
-switch (II->getIntrinsicID()) {
-case Intrinsic::lifetime_end: {
-  MemoryLocation ArgLoc = MemoryLocation::getAfter(II->getArgOperand(1));
-  return AA.alias(ArgLoc, Loc) == MustAlias;
-}
-default:
-  return false;
-}
-  }
-  return false;
-}
-
 template 
 static bool isUseTriviallyOptimizableToLiveOnEntry(AliasAnalysisType &AA,
const Instruction *I) {
@@ -1465,15 +1448,6 @@ void MemorySSA::OptimizeUses::optimizeUsesInBlock(
   }
 
   MemoryDef *MD = cast(VersionStack[UpperBound]);
-  // If the lifetime of the pointer ends at this instruction, it's live on
-  // entry.
-  if (!UseMLOC.IsCall && lifetimeEndsAt(MD, UseMLOC.getLoc(), *AA)) {
-// Reset UpperBound to liveOnEntryDef's place in the stack
-UpperBound = 0;
-FoundClobberResult = true;
-LocInfo.AR = MustAlias;
-break;
-  }
   ClobberAlias CA = instructionClobbersQuery(MD, MU, UseMLOC, *AA);
   if (CA.IsClobber) {
 FoundClobberResult = true;

diff  --git a/llvm/test/Analysis/MemorySSA/lifetime-simple.ll 
b/llvm/test/Analysis/MemorySSA/lifetime-simple.ll
index 33327c5539f6..2d0481c18415 100644
--- a/llvm/test/Analysis/MemorySSA/lifetime-simple.ll
+++ b/llvm/test/Analysis/MemorySSA/lifetime-simple.ll
@@ -1,8 +1,7 @@
 ; RUN: opt -basic-aa -print-memoryssa -verify-memoryssa -enable-new-pm=0 
-analyze < %s 2>&1 | FileCheck %s
 ; RUN: opt -aa-pipeline=basic-aa -passes='print,verify' 
-disable-output < %s 2>&1 | FileCheck %s
-; This test checks a number of things:
-; First, the lifetime markers should not clobber any uses of Q or P.
-; Second, the loads of P are MemoryUse(LiveOnEntry) due to the placement of 
the markers vs the loads.
+; This test checks that lifetime markers are considered clobbers of %P,
+; and due to lack of noalias information, of %Q as well.
 
 define i8 @test(i8* %P, i8* %Q) {
 entry:
@@ -18,10 +17,10 @@ entry:
 ; CHECK:  3 = MemoryDef(2)
 ; CHECK-NEXT:   call void @llvm.lifetime.end.p0i8(i64 32, i8* %P)
   call void @llvm.lifetime.end.p0i8(i64 32, i8* %P)
-; CHECK:  MemoryUse(liveOnEntry)
+; CHECK:  MemoryUse(3)
 ; CHECK-NEXT:   %1 = load i8, i8* %P
   %1 = load i8, i8* %P
-; CHECK:  MemoryUse(2)
+; CHECK:  MemoryUse(3)
 ; CHECK-NEXT:   %2 = load i8, i8* %Q
   %2 = load i8, i8* %Q
   ret i8 %1

diff  --git a/llvm/test/Transforms/MemCpyOpt/lifetime.ll 
b/llvm/test/Transforms/MemCpyOpt/lifetime.ll
index 5dc13ca10054..c7e7666307ab 100644
--- a/llvm/test/Transforms/MemCpyOpt/lifetime.ll
+++ b/llvm/test/Transforms/MemCpyOpt/lifetime.ll
@@ -1,6 +1,6 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
-; RUN: opt < %s -O2 -S -enable-memcpyopt-memoryssa=0 | FileCheck %s 
--check-prefixes=CHECK,NO_MSSA
-; RUN: opt < %s -O2 -S -enable-memcpyopt-memoryssa=1 -verify-memoryssa | 
FileCheck %s --check-prefixes=CHECK,MSSA
+; RUN: opt < %s -O2 -S -enable-memcpyopt-memoryssa=0 | F

[llvm-branch-commits] [openmp] 716eef9 - [OpenMP][libomptarget] Fixed an issue that device sync is skipped if the kernel doesn't have any argument

2021-02-05 Thread Tom Stellard via llvm-branch-commits

Author: Shilei Tian
Date: 2021-02-05T20:47:20-08:00
New Revision: 716eef9ad5b367e5cbcc22c8ac53395f9bdbe7a5

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

LOG: [OpenMP][libomptarget] Fixed an issue that device sync is skipped if the 
kernel doesn't have any argument

Currently if there is not kernel argument, device synchronization will
be skipped. This can lead to two issues:
1. If there is any device error, it will not be captured;
2. The target region might end before the kernel is done, which is not spec
   conformant.

The test added in this patch only runs on NVPTX platform, although it will not
be executed by Phab at all. It also requires `not` which is not available on 
most
systems.

Reviewed By: jdoerfert

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

(cherry picked from commit b68a6b09e60a24733b923a0fc282746a855852da)

Added: 
openmp/libomptarget/test/offloading/assert.cpp

Modified: 
openmp/libomptarget/src/omptarget.cpp

Removed: 




diff  --git a/openmp/libomptarget/src/omptarget.cpp 
b/openmp/libomptarget/src/omptarget.cpp
index 90966d25fb26..e4b7b18bc70b 100644
--- a/openmp/libomptarget/src/omptarget.cpp
+++ b/openmp/libomptarget/src/omptarget.cpp
@@ -451,6 +451,17 @@ struct DeallocTgtPtrInfo {
   : HstPtrBegin(HstPtr), DataSize(Size), ForceDelete(ForceDelete),
 HasCloseModifier(HasCloseModifier) {}
 };
+
+/// Synchronize device
+static int syncDevice(DeviceTy &Device, __tgt_async_info *AsyncInfo) {
+  assert(AsyncInfo && AsyncInfo->Queue && "Invalid AsyncInfo");
+  if (Device.synchronize(AsyncInfo) != OFFLOAD_SUCCESS) {
+REPORT("Failed to synchronize device.\n");
+return OFFLOAD_FAIL;
+  }
+
+  return OFFLOAD_SUCCESS;
+}
 } // namespace
 
 /// Internal function to undo the mapping and retrieve the data from the 
device.
@@ -631,11 +642,9 @@ int targetDataEnd(ident_t *loc, DeviceTy &Device, int32_t 
ArgNum,
   // AsyncInfo->Queue will not be nullptr, so again, we don't need to
   // synchronize.
   if (AsyncInfo && AsyncInfo->Queue) {
-Ret = Device.synchronize(AsyncInfo);
-if (Ret != OFFLOAD_SUCCESS) {
-  REPORT("Failed to synchronize device.\n");
+Ret = syncDevice(Device, AsyncInfo);
+if (Ret != OFFLOAD_SUCCESS)
   return OFFLOAD_FAIL;
-}
   }
 
   // Deallocate target pointer
@@ -1307,6 +1316,11 @@ int target(ident_t *loc, int64_t DeviceId, void 
*HostPtr, int32_t ArgNum,
   REPORT("Failed to process data after launching the kernel.\n");
   return OFFLOAD_FAIL;
 }
+  } else if (AsyncInfo.Queue) {
+// If ArgNum is zero, but AsyncInfo.Queue is valid, then the kernel doesn't
+// hava any argument, and the device supports async operations, so we need 
a
+// sync at this point.
+return syncDevice(Device, &AsyncInfo);
   }
 
   return OFFLOAD_SUCCESS;

diff  --git a/openmp/libomptarget/test/offloading/assert.cpp 
b/openmp/libomptarget/test/offloading/assert.cpp
new file mode 100644
index ..00112dd92cc6
--- /dev/null
+++ b/openmp/libomptarget/test/offloading/assert.cpp
@@ -0,0 +1,8 @@
+// RUN: %libomptarget-compilexx-nvptx64-nvidia-cuda && 
%libomptarget-run-fail-nvptx64-nvidia-cuda
+
+int main(int argc, char *argv[]) {
+#pragma omp target
+  { __builtin_trap(); }
+
+  return 0;
+}



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