[PATCH] D72184: [BPF] support atomic instructions

2020-12-02 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song updated this revision to Diff 309167.
yonghong-song added a comment.

fix clang-format warnings.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72184/new/

https://reviews.llvm.org/D72184

Files:
  llvm/lib/Target/BPF/BPFInstrFormats.td
  llvm/lib/Target/BPF/BPFInstrInfo.td
  llvm/lib/Target/BPF/BPFMIChecking.cpp
  llvm/lib/Target/BPF/Disassembler/BPFDisassembler.cpp
  llvm/lib/Target/BPF/MCTargetDesc/BPFMCCodeEmitter.cpp
  llvm/test/CodeGen/BPF/atomics.ll
  llvm/test/CodeGen/BPF/atomics_2.ll
  llvm/test/CodeGen/BPF/xadd.ll

Index: llvm/test/CodeGen/BPF/xadd.ll
===
--- llvm/test/CodeGen/BPF/xadd.ll
+++ llvm/test/CodeGen/BPF/xadd.ll
@@ -1,7 +1,5 @@
 ; RUN: not --crash llc -march=bpfel < %s 2>&1 | FileCheck %s
 ; RUN: not --crash llc -march=bpfeb < %s 2>&1 | FileCheck %s
-; RUN: not --crash llc -march=bpfel -mattr=+alu32 < %s 2>&1 | FileCheck %s
-; RUN: not --crash llc -march=bpfeb -mattr=+alu32 < %s 2>&1 | FileCheck %s
 
 ; This file is generated with the source command and source
 ; $ clang -target bpf -O2 -g -S -emit-llvm t.c
Index: llvm/test/CodeGen/BPF/atomics_2.ll
===
--- /dev/null
+++ llvm/test/CodeGen/BPF/atomics_2.ll
@@ -0,0 +1,254 @@
+; RUN: llc < %s -march=bpfel -mcpu=v3 -verify-machineinstrs -show-mc-encoding | FileCheck %s
+;
+; Source:
+;   int test_load_add_32(int *p, int v) {
+; return __sync_fetch_and_add(p, v);
+;   }
+;   int test_load_add_64(long *p, long v) {
+; return __sync_fetch_and_add(p, v);
+;   }
+;   int test_load_sub_32(int *p, int v) {
+; return __sync_fetch_and_sub(p, v);
+;   }
+;   int test_load_sub_64(long *p, long v) {
+; return __sync_fetch_and_sub(p, v);
+;   }
+;   // from https://gcc.gnu.org/onlinedocs/gcc-4.1.1/gcc/Atomic-Builtins.html
+;   // __sync_lock_test_and_set() actually does atomic xchg and returns
+;   // old contents.
+;   int test_xchg_32(int *p, int v) {
+; return __sync_lock_test_and_set(p, v);
+;   }
+;   int test_xchg_64(long *p, long v) {
+; return __sync_lock_test_and_set(p, v);
+;   }
+;   int test_cas_32(int *p, int old, int new) {
+; return __sync_val_compare_and_swap(p, old, new);
+;   }
+;   long test_cas_64(long *p, long old, long new) {
+; return __sync_val_compare_and_swap(p, old, new);
+;   }
+;   int test_load_and_32(int *p, int v) {
+; return __sync_fetch_and_and(p, v);
+;   }
+;   int test_load_and_64(long *p, long v) {
+; return __sync_fetch_and_and(p, v);
+;   }
+;   int test_load_or_32(int *p, int v) {
+; return __sync_fetch_and_or(p, v);
+;   }
+;   int test_load_or_64(long *p, long v) {
+; return __sync_fetch_and_or(p, v);
+;   }
+;   int test_load_xor_32(int *p, int v) {
+; return __sync_fetch_and_xor(p, v);
+;   }
+;   int test_load_xor_64(long *p, long v) {
+; return __sync_fetch_and_xor(p, v);
+;   }
+;   int test_atomic_xor_32(int *p, int v) {
+; __sync_fetch_and_xor(p, v);
+; return 0;
+;   }
+;   int test_atomic_xor_64(long *p, long v) {
+; __sync_fetch_and_xor(p, v);
+; return 0;
+;   }
+;   int test_atomic_and_64(long *p, long v) {
+; __sync_fetch_and_and(p, v);
+; return 0;
+;   }
+;   int test_atomic_or_64(long *p, long v) {
+; __sync_fetch_and_or(p, v);
+; return 0;
+;   }
+
+; CHECK-LABEL: test_load_add_32
+; CHECK: w0 = w2
+; CHECK: w0 = atomic_fetch_add((u32 *)(r1 + 0), w0)
+; CHECK: encoding: [0xc3,0x01,0x00,0x00,0x01,0x00,0x00,0x00]
+define dso_local i32 @test_load_add_32(i32* nocapture %p, i32 %v) local_unnamed_addr {
+entry:
+  %0 = atomicrmw add i32* %p, i32 %v seq_cst
+  ret i32 %0
+}
+
+; CHECK-LABEL: test_load_add_64
+; CHECK: r0 = r2
+; CHECK: r0 = atomic_fetch_add((u64 *)(r1 + 0), r0)
+; CHECK: encoding: [0xdb,0x01,0x00,0x00,0x01,0x00,0x00,0x00]
+define dso_local i32 @test_load_add_64(i64* nocapture %p, i64 %v) local_unnamed_addr {
+entry:
+  %0 = atomicrmw add i64* %p, i64 %v seq_cst
+  %conv = trunc i64 %0 to i32
+  ret i32 %conv
+}
+
+; CHECK-LABEL: test_load_sub_32
+; CHECK: w0 = w2
+; CHECK: w0 = -w0
+; CHECK: w0 = atomic_fetch_add((u32 *)(r1 + 0), w0)
+; CHECK: encoding: [0xc3,0x01,0x00,0x00,0x01,0x00,0x00,0x00]
+define dso_local i32 @test_load_sub_32(i32* nocapture %p, i32 %v) local_unnamed_addr {
+entry:
+  %0 = atomicrmw sub i32* %p, i32 %v seq_cst
+  ret i32 %0
+}
+
+; CHECK-LABEL: test_load_sub_64
+; CHECK: r0 = r2
+; CHECK: r0 = -r0
+; CHECK: r0 = atomic_fetch_add((u64 *)(r1 + 0), r0)
+; CHECK: encoding: [0xdb,0x01,0x00,0x00,0x01,0x00,0x00,0x00]
+define dso_local i32 @test_load_sub_64(i64* nocapture %p, i64 %v) local_unnamed_addr {
+entry:
+  %0 = atomicrmw sub i64* %p, i64 %v seq_cst
+  %conv = trunc i64 %0 to i32
+  ret i32 %conv
+}
+
+; CHECK-LABEL: test_xchg_32
+; CHECK: w0 = w2
+; CHECK: w0 = xchg32_32(r1 + 0, w0)
+; CHECK: encoding: [0xc3,0x01,0x00,0x00,0xe1,0x00,0x00,0x00]
+define dso_local i32 @test_xchg_32(i32* noca

[clang] a36f8fb - [NFC] Add proper triple for arc.ll test

2020-12-02 Thread via cfe-commits

Author: Yuanfang Chen
Date: 2020-12-02T23:31:06-08:00
New Revision: a36f8fb021d0a1719400eda446131290be21c3ed

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

LOG: [NFC] Add proper triple for arc.ll test

Added: 


Modified: 
clang/test/CodeGenObjC/arc.ll

Removed: 




diff  --git a/clang/test/CodeGenObjC/arc.ll b/clang/test/CodeGenObjC/arc.ll
index f23c656c3498..7b903d05cd17 100644
--- a/clang/test/CodeGenObjC/arc.ll
+++ b/clang/test/CodeGenObjC/arc.ll
@@ -1,4 +1,4 @@
-; RUN: %clang_cc1 -Os -emit-llvm -fobjc-arc -o - %s | FileCheck %s
+; RUN: %clang_cc1 -triple x86_64-apple-darwin10 -Os -emit-llvm -fobjc-arc -o - 
%s | FileCheck %s
 
 target triple = "x86_64-apple-darwin10"
 



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


[PATCH] D92278: [Clang] Don't adjust align for IBM extended double type

2020-12-02 Thread Qiu Chaofan via Phabricator via cfe-commits
qiucf added inline comments.



Comment at: clang/test/CodeGen/ppc64le-varargs-f128.c:8
 
+// RUN: %clang -target powerpc64le-unknown-linux-gnu -S -emit-llvm \
+// RUN:   -fopenmp-targets=ppc64le -mfloat128 -mabi=ieeelongdouble -mcpu=pwr9 \

hubert.reinterpretcast wrote:
> MaskRay wrote:
> > qiucf wrote:
> > > MaskRay wrote:
> > > > Generally `%clang` is only used in test/Driver and `%clang_cc1` should 
> > > > be used for tests.
> > > > 
> > > > `%clang_cc1` has a lit substitution rule to find the builtin include 
> > > > directory where stdarg.h can be found.
> > > Thanks! I moved it in rG222da77a
> > rG222da77a82d17cbc6b989779e2ba2bb4904bb672 looks more wrong to me: 
> > test/Driver tests how the clang driver passes CC1 options to the frontend. 
> > The CodeGen should be tested in this directory.
> > 
> > You probably should split %clang to several %clang_cc1 commands and keep 
> > the test here.
> I don't think moving the test such that a "driver test" checks code gen 
> output is the direction @MaskRay was pointing to. Changing the `RUN` line to 
> invoke `-cc1` (using `%clang_cc1`) and leaving the test as a code gen test is 
> what I would have expected.
Ah, thanks for pointing it out. I simplified the splitted commands from `clang 
-v`. https://reviews.llvm.org/D92544 is created for easier view, if that looks 
fine, I'll commit it :-)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92278/new/

https://reviews.llvm.org/D92278

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


[PATCH] D91147: AArch64: classify Triple::aarch64_32 as AArch64

2020-12-02 Thread Gerolf Hoflehner via Phabricator via cfe-commits
Gerolf accepted this revision.
Gerolf added a comment.
This revision is now accepted and ready to land.

LGTM.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91147/new/

https://reviews.llvm.org/D91147

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


[PATCH] D92278: [Clang] Don't adjust align for IBM extended double type

2020-12-02 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/test/CodeGen/ppc64le-varargs-f128.c:8
 
+// RUN: %clang -target powerpc64le-unknown-linux-gnu -S -emit-llvm \
+// RUN:   -fopenmp-targets=ppc64le -mfloat128 -mabi=ieeelongdouble -mcpu=pwr9 \

MaskRay wrote:
> qiucf wrote:
> > MaskRay wrote:
> > > Generally `%clang` is only used in test/Driver and `%clang_cc1` should be 
> > > used for tests.
> > > 
> > > `%clang_cc1` has a lit substitution rule to find the builtin include 
> > > directory where stdarg.h can be found.
> > Thanks! I moved it in rG222da77a
> rG222da77a82d17cbc6b989779e2ba2bb4904bb672 looks more wrong to me: 
> test/Driver tests how the clang driver passes CC1 options to the frontend. 
> The CodeGen should be tested in this directory.
> 
> You probably should split %clang to several %clang_cc1 commands and keep the 
> test here.
I don't think moving the test such that a "driver test" checks code gen output 
is the direction @MaskRay was pointing to. Changing the `RUN` line to invoke 
`-cc1` (using `%clang_cc1`) and leaving the test as a code gen test is what I 
would have expected.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92278/new/

https://reviews.llvm.org/D92278

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


[PATCH] D92278: [Clang] Don't adjust align for IBM extended double type

2020-12-02 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/test/CodeGen/ppc64le-varargs-f128.c:8
 
+// RUN: %clang -target powerpc64le-unknown-linux-gnu -S -emit-llvm \
+// RUN:   -fopenmp-targets=ppc64le -mfloat128 -mabi=ieeelongdouble -mcpu=pwr9 \

qiucf wrote:
> MaskRay wrote:
> > Generally `%clang` is only used in test/Driver and `%clang_cc1` should be 
> > used for tests.
> > 
> > `%clang_cc1` has a lit substitution rule to find the builtin include 
> > directory where stdarg.h can be found.
> Thanks! I moved it in rG222da77a
rG222da77a82d17cbc6b989779e2ba2bb4904bb672 looks more wrong to me: test/Driver 
tests how the clang driver passes CC1 options to the frontend. The CodeGen 
should be tested in this directory.

You probably should split %clang to several %clang_cc1 commands and keep the 
test here.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92278/new/

https://reviews.llvm.org/D92278

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


[PATCH] D92278: [Clang] Don't adjust align for IBM extended double type

2020-12-02 Thread Qiu Chaofan via Phabricator via cfe-commits
qiucf added inline comments.



Comment at: clang/test/CodeGen/ppc64le-varargs-f128.c:8
 
+// RUN: %clang -target powerpc64le-unknown-linux-gnu -S -emit-llvm \
+// RUN:   -fopenmp-targets=ppc64le -mfloat128 -mabi=ieeelongdouble -mcpu=pwr9 \

MaskRay wrote:
> Generally `%clang` is only used in test/Driver and `%clang_cc1` should be 
> used for tests.
> 
> `%clang_cc1` has a lit substitution rule to find the builtin include 
> directory where stdarg.h can be found.
Thanks! I moved it in rG222da77a


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92278/new/

https://reviews.llvm.org/D92278

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


[clang] 222da77 - [NFC] [Clang] Move ppc64le f128 vaargs OpenMP test

2020-12-02 Thread Qiu Chaofan via cfe-commits

Author: Qiu Chaofan
Date: 2020-12-03T10:50:42+08:00
New Revision: 222da77a82d17cbc6b989779e2ba2bb4904bb672

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

LOG: [NFC] [Clang] Move ppc64le f128 vaargs OpenMP test

This case for long-double semantics mismatch on OpenMP references
%clang, which should be located in Driver directory.

Added: 
clang/test/Driver/ppc-openmp-f128.c

Modified: 
clang/test/CodeGen/ppc64le-varargs-f128.c

Removed: 




diff  --git a/clang/test/CodeGen/ppc64le-varargs-f128.c 
b/clang/test/CodeGen/ppc64le-varargs-f128.c
index 5e9930ec716f..0b085859c5ac 100644
--- a/clang/test/CodeGen/ppc64le-varargs-f128.c
+++ b/clang/test/CodeGen/ppc64le-varargs-f128.c
@@ -5,46 +5,11 @@
 // RUN:   -target-cpu pwr9 -target-feature +float128 \
 // RUN:   -o - %s | FileCheck %s -check-prefix=IBM
 
-// RUN: %clang -target powerpc64le-unknown-linux-gnu -S -emit-llvm \
-// RUN:   -fopenmp-targets=ppc64le -mfloat128 -mabi=ieeelongdouble -mcpu=pwr9 \
-// RUN:   -Xopenmp-target=ppc64le -mcpu=pwr9 -Xopenmp-target=ppc64le \
-// RUN:   -mfloat128 -fopenmp=libomp -o - %s | FileCheck %s -check-prefix=OMP
-
 #include 
 
 void foo_ld(long double);
 void foo_fq(__float128);
 
-// Verify cases when OpenMP target's and host's long-double semantics 
diff er.
-
-// OMP-LABEL: define internal void @.omp_outlined.
-// OMP: %[[CUR:[0-9a-zA-Z_.]+]] = load i8*, i8**
-// OMP: %[[V2:[0-9a-zA-Z_.]+]] = bitcast i8* %[[CUR]] to ppc_fp128*
-// OMP: %[[V3:[0-9a-zA-Z_.]+]] = load ppc_fp128, ppc_fp128* %[[V2]], align 8
-// OMP: call void @foo_ld(ppc_fp128 %[[V3]])
-
-// OMP-LABEL: define dso_local void @omp
-// OMP: %[[AP1:[0-9a-zA-Z_.]+]] = bitcast i8** %[[AP:[0-9a-zA-Z_.]+]] to i8*
-// OMP: call void @llvm.va_start(i8* %[[AP1]])
-// OMP: %[[CUR:[0-9a-zA-Z_.]+]] = load i8*, i8** %[[AP]], align 8
-// OMP: %[[V0:[0-9a-zA-Z_.]+]] = ptrtoint i8* %[[CUR]] to i64
-// OMP: %[[V1:[0-9a-zA-Z_.]+]] = add i64 %[[V0]], 15
-// OMP: %[[V2:[0-9a-zA-Z_.]+]] = and i64 %[[V1]], -16
-// OMP: %[[ALIGN:[0-9a-zA-Z_.]+]] = inttoptr i64 %[[V2]] to i8*
-// OMP: %[[V3:[0-9a-zA-Z_.]+]] = bitcast i8* %[[ALIGN]] to fp128*
-// OMP: %[[V4:[0-9a-zA-Z_.]+]] = load fp128, fp128* %[[V3]], align 16
-// OMP: call void @foo_ld(fp128 %[[V4]])
-void omp(int n, ...) {
-  va_list ap;
-  va_start(ap, n);
-  foo_ld(va_arg(ap, long double));
-  #pragma omp target parallel
-  for (int i = 1; i < n; ++i) {
-foo_ld(va_arg(ap, long double));
-  }
-  va_end(ap);
-}
-
 // IEEE-LABEL: define void @f128
 // IEEE: %[[AP1:[0-9a-zA-Z_.]+]] = bitcast i8** %[[AP:[0-9a-zA-Z_.]+]] to i8*
 // IEEE: call void @llvm.va_start(i8* %[[AP1]])

diff  --git a/clang/test/Driver/ppc-openmp-f128.c 
b/clang/test/Driver/ppc-openmp-f128.c
new file mode 100644
index ..bff6fe35e526
--- /dev/null
+++ b/clang/test/Driver/ppc-openmp-f128.c
@@ -0,0 +1,39 @@
+// RUN: %clang -target powerpc64le-unknown-linux-gnu -S -emit-llvm \
+// RUN:   -fopenmp-targets=ppc64le -mfloat128 -mabi=ieeelongdouble -mcpu=pwr9 \
+// RUN:   -Xopenmp-target=ppc64le -mcpu=pwr9 -Xopenmp-target=ppc64le \
+// RUN:   -mfloat128 -fopenmp=libomp -o - %s | FileCheck %s -check-prefix=OMP
+
+#include 
+
+void foo_ld(long double);
+void foo_fq(__float128);
+
+// Verify cases when OpenMP target's and host's long-double semantics 
diff er.
+
+// OMP-LABEL: define internal void @.omp_outlined.
+// OMP: %[[CUR:[0-9a-zA-Z_.]+]] = load i8*, i8**
+// OMP: %[[V2:[0-9a-zA-Z_.]+]] = bitcast i8* %[[CUR]] to ppc_fp128*
+// OMP: %[[V3:[0-9a-zA-Z_.]+]] = load ppc_fp128, ppc_fp128* %[[V2]], align 8
+// OMP: call void @foo_ld(ppc_fp128 %[[V3]])
+
+// OMP-LABEL: define dso_local void @omp
+// OMP: %[[AP1:[0-9a-zA-Z_.]+]] = bitcast i8** %[[AP:[0-9a-zA-Z_.]+]] to i8*
+// OMP: call void @llvm.va_start(i8* %[[AP1]])
+// OMP: %[[CUR:[0-9a-zA-Z_.]+]] = load i8*, i8** %[[AP]], align 8
+// OMP: %[[V0:[0-9a-zA-Z_.]+]] = ptrtoint i8* %[[CUR]] to i64
+// OMP: %[[V1:[0-9a-zA-Z_.]+]] = add i64 %[[V0]], 15
+// OMP: %[[V2:[0-9a-zA-Z_.]+]] = and i64 %[[V1]], -16
+// OMP: %[[ALIGN:[0-9a-zA-Z_.]+]] = inttoptr i64 %[[V2]] to i8*
+// OMP: %[[V3:[0-9a-zA-Z_.]+]] = bitcast i8* %[[ALIGN]] to fp128*
+// OMP: %[[V4:[0-9a-zA-Z_.]+]] = load fp128, fp128* %[[V3]], align 16
+// OMP: call void @foo_ld(fp128 %[[V4]])
+void omp(int n, ...) {
+  va_list ap;
+  va_start(ap, n);
+  foo_ld(va_arg(ap, long double));
+  #pragma omp target parallel
+  for (int i = 1; i < n; ++i) {
+foo_ld(va_arg(ap, long double));
+  }
+  va_end(ap);
+}



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


[PATCH] D92480: [llvm] Unify interface of (ThreadSafe)?RefCountedBase

2020-12-02 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

I've added test cases which demonstrate what these copies/moves are about.
The move constructor probably would never get used. I can't see of a reason to 
move the contents of a ref counted pointer. In which case there could be an 
argument to delete it.
The copy constructor OTOH is very likely to be used (which i think is the 
reason its currently defined in RefCountedBase).
Adding the CopyAssignment and MoveAssignment operators are there to make sure 
the compiler wont define them implicitly, copying the ref count.




Comment at: llvm/include/llvm/ADT/IntrusiveRefCntPtr.h:75-76
   RefCountedBase() = default;
+  // Copy and move constructors/assignments are no-ops as the RefCount isn't
+  // dictated by the class directly.
   RefCountedBase(const RefCountedBase &) {}

njames93 wrote:
> dexonsmith wrote:
> > dblaikie wrote:
> > > I can't quite understand this comment - perhaps you could try rephrasing 
> > > it?
> > I'm not quite following why you needed to add these special members; it 
> > seems like just the destructor would be enough for the assertion; but if 
> > you do need them, can/should they be `= default`?
> They can't be defaulted as we don't want to copy the RefCount.
I understand it in my head, just can't think of the best way to write it down.



Comment at: llvm/include/llvm/ADT/IntrusiveRefCntPtr.h:75-80
+  // Copy and move constructors/assignments are no-ops as the RefCount isn't
+  // dictated by the class directly.
   RefCountedBase(const RefCountedBase &) {}
+  RefCountedBase(RefCountedBase &&) {}
+  RefCountedBase &operator=(const RefCountedBase &) { return *this; }
+  RefCountedBase &operator=(RefCountedBase &&) { return *this; }

dexonsmith wrote:
> dblaikie wrote:
> > I can't quite understand this comment - perhaps you could try rephrasing it?
> I'm not quite following why you needed to add these special members; it seems 
> like just the destructor would be enough for the assertion; but if you do 
> need them, can/should they be `= default`?
They can't be defaulted as we don't want to copy the RefCount.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92480/new/

https://reviews.llvm.org/D92480

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


[PATCH] D92529: ASTImporter: Migrate to the FileEntryRef overload of SourceManager::createFileID, NFC

2020-12-02 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92529/new/

https://reviews.llvm.org/D92529

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


[PATCH] D92101: [Clang][Sema] Attempt to fix CTAD faulty copy of non-local typedefs

2020-12-02 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

Looks good with a minor cleanup. Thanks!




Comment at: clang/lib/Sema/SemaTemplate.cpp:2081-2085
 TypeLocBuilder InnerTLB;
 QualType Transformed =
 TransformType(InnerTLB, OrigDecl->getTypeSourceInfo()->getTypeLoc());
 TypeSourceInfo *TSI =
 TransformType(InnerTLB.getTypeSourceInfo(Context, Transformed));

We only need to transform the underlying type of the typedef if we're cloning 
the typedef.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92101/new/

https://reviews.llvm.org/D92101

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


[PATCH] D92480: [llvm] Unify interface of (ThreadSafe)?RefCountedBase

2020-12-02 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 309120.
njames93 added a comment.

Added test cases demonstrating copy and move behaviour.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92480/new/

https://reviews.llvm.org/D92480

Files:
  clang/lib/ASTMatchers/ASTMatchersInternal.cpp
  llvm/include/llvm/ADT/IntrusiveRefCntPtr.h
  llvm/unittests/ADT/IntrusiveRefCntPtrTest.cpp

Index: llvm/unittests/ADT/IntrusiveRefCntPtrTest.cpp
===
--- llvm/unittests/ADT/IntrusiveRefCntPtrTest.cpp
+++ llvm/unittests/ADT/IntrusiveRefCntPtrTest.cpp
@@ -63,4 +63,54 @@
   EXPECT_TRUE(Retained);
 }
 
+namespace {
+class DestructionCounter : public RefCountedBase {
+public:
+  DestructionCounter() {}
+  DestructionCounter(const DestructionCounter &) = default;
+  DestructionCounter(DestructionCounter &&) = default;
+  DestructionCounter &operator=(const DestructionCounter &) = default;
+  DestructionCounter &operator=(DestructionCounter &&) = default;
+
+  ~DestructionCounter() { ++Count; }
+
+  static unsigned getCount() { return Count; }
+  static void resetCount() { Count = 0; }
+
+private:
+  static unsigned Count;
+};
+unsigned DestructionCounter::Count = 0U;
+} // namespace
+
+TEST(IntrusiveRefCntPtr, CopyMove) {
+  {
+
+IntrusiveRefCntPtr FirstRef = new DestructionCounter();
+{
+  IntrusiveRefCntPtr SecondRef = FirstRef;
+  // FirstRef and SecondRef both hold the same object, which has a ref count
+  // of 2.
+
+  IntrusiveRefCntPtr Copy =
+  new DestructionCounter(*FirstRef);
+  // Copy holds an object which is a copy of the object stored in FirstRef,
+  // but its ref count is only 1.
+
+  IntrusiveRefCntPtr Move =
+  new DestructionCounter(std::move(*FirstRef));
+  // This follows the same logic as Copy above so its ref count is 1 as
+  // well.
+}
+// Copy and Move should destroy their underlying object in the destructor as
+// the ref count should drop to 0. SecondRef destructor should drop its ref
+// count to 1, therefore keeping the underlying object alive.
+EXPECT_EQ(DestructionCounter::getCount(), 2U);
+DestructionCounter::resetCount();
+  }
+  // Now that FirstRef destructor has ran, the ref count should drop to 0 and
+  // destroy the underlying object
+  EXPECT_EQ(DestructionCounter::getCount(), 1U);
+}
+
 } // end namespace llvm
Index: llvm/include/llvm/ADT/IntrusiveRefCntPtr.h
===
--- llvm/include/llvm/ADT/IntrusiveRefCntPtr.h
+++ llvm/include/llvm/ADT/IntrusiveRefCntPtr.h
@@ -70,10 +70,27 @@
 template  class RefCountedBase {
   mutable unsigned RefCount = 0;
 
-public:
+protected:
   RefCountedBase() = default;
+  // Copy and move constructors/assignments are no-ops as the RefCount isn't
+  // dictated by the class directly.
   RefCountedBase(const RefCountedBase &) {}
+  RefCountedBase(RefCountedBase &&) {}
+  RefCountedBase &operator=(const RefCountedBase &) { return *this; }
+  RefCountedBase &operator=(RefCountedBase &&) { return *this; }
+
+#ifndef NDEBUG
+  ~RefCountedBase() {
+assert(RefCount == 0 &&
+   "Destruction occured when there are still references to this.");
+  }
+#else
+  // Default the destructor in release builds, A trivial destructor may enable
+  // better codegen.
+  ~RefCountedBase() = default;
+#endif
 
+public:
   void Retain() const { ++RefCount; }
 
   void Release() const {
@@ -85,10 +102,29 @@
 
 /// A thread-safe version of \c RefCountedBase.
 template  class ThreadSafeRefCountedBase {
-  mutable std::atomic RefCount;
+  mutable std::atomic RefCount{0};
 
 protected:
-  ThreadSafeRefCountedBase() : RefCount(0) {}
+  ThreadSafeRefCountedBase() = default;
+  ThreadSafeRefCountedBase(const ThreadSafeRefCountedBase &) {}
+  ThreadSafeRefCountedBase(ThreadSafeRefCountedBase &&) {}
+  ThreadSafeRefCountedBase &operator=(const ThreadSafeRefCountedBase &) {
+return *this;
+  }
+  ThreadSafeRefCountedBase &operator=(ThreadSafeRefCountedBase &&) {
+return *this;
+  }
+
+#ifndef NDEBUG
+  ~ThreadSafeRefCountedBase() {
+assert(RefCount == 0 &&
+   "Destruction occured when there are still references to this.");
+  }
+#else
+  // Default the destructor in release builds, A trivial destructor may enable
+  // better codegen.
+  ~ThreadSafeRefCountedBase() = default;
+#endif
 
 public:
   void Retain() const { RefCount.fetch_add(1, std::memory_order_relaxed); }
Index: clang/lib/ASTMatchers/ASTMatchersInternal.cpp
===
--- clang/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ clang/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -187,9 +187,20 @@
   IntrusiveRefCntPtr InnerMatcher;
 };
 
+// Use a custom deleter for the TrueMatcherInstance ManagedStatic. This prevents
+// an assert firing when the refcount is nonzero while running its destructor.
+struct DynMa

[PATCH] D90733: Frontend: Sink named pipe logic from CompilerInstance down to FileManager

2020-12-02 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

In D90733#2429976 , @dexonsmith wrote:

> Hmm, I had to revert this in b34632201987eed369bb7ef4646f341b901c95b8 
>  due to 
> a bot failure; I'll need to look into it.

Posted a new version here: https://reviews.llvm.org/D92531


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D90733/new/

https://reviews.llvm.org/D90733

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


[PATCH] D92531: Reapply "Frontend: Sink named pipe logic from CompilerInstance down to FileManager"

2020-12-02 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

Note that the original commit was reviewed here: 
https://reviews.llvm.org/D90733.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92531/new/

https://reviews.llvm.org/D92531

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


[PATCH] D92531: Reapply "Frontend: Sink named pipe logic from CompilerInstance down to FileManager"

2020-12-02 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith created this revision.
dexonsmith added reviewers: arphaman, Bigcheese, jansvoboda11.
Herald added subscribers: ributzka, JDevlieghere.
Herald added a project: clang.
dexonsmith requested review of this revision.

This reverts commit b34632201987eed369bb7ef4646f341b901c95b8 
,
reapplying 3b18a594c7717a328c33b9c1eba675e9f4bd367c 
 with an 
additional
change to SourceManager.

SourceManager checks if the file entry's size matches the eventually
loaded buffer. This doesn't make sense for named pipes so I've disabled
that check. Since we can't trust `ContentsEntry->getSize()`, we also need
shift the check for files that are too large until after the buffer is
loaded... and load the buffer immediately in `createFileID` so that no
client gets a bad value from `ContentCache::getSize`.

My main goal with this commit is to remove a use of
`SourceManager::overrideFileContents`, whose existance blocks sinking
the content cache down to `FileManager`.

The original commit message follows:

Frontend: Sink named pipe logic from CompilerInstance down to FileManager

Remove compilicated logic from CompilerInstance::InitializeSourceManager
to deal with named pipes, updating FileManager::getBufferForFile to
handle it in a more straightforward way. The existing test at
clang/test/Misc/dev-fd-fs.c covers the new behaviour (just like it did
the old behaviour).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92531

Files:
  clang/lib/Basic/FileManager.cpp
  clang/lib/Basic/SourceManager.cpp
  clang/lib/Frontend/CompilerInstance.cpp

Index: clang/lib/Frontend/CompilerInstance.cpp
===
--- clang/lib/Frontend/CompilerInstance.cpp
+++ clang/lib/Frontend/CompilerInstance.cpp
@@ -858,30 +858,8 @@
 }
 FileEntryRef File = *FileOrErr;
 
-// The natural SourceManager infrastructure can't currently handle named
-// pipes, but we would at least like to accept them for the main
-// file. Detect them here, read them with the volatile flag so FileMgr will
-// pick up the correct size, and simply override their contents as we do for
-// STDIN.
-if (File.getFileEntry().isNamedPipe()) {
-  auto MB =
-  FileMgr.getBufferForFile(&File.getFileEntry(), /*isVolatile=*/true);
-  if (MB) {
-// Create a new virtual file that will have the correct size.
-const FileEntry *FE =
-FileMgr.getVirtualFile(InputFile, (*MB)->getBufferSize(), 0);
-SourceMgr.overrideFileContents(FE, std::move(*MB));
-SourceMgr.setMainFileID(
-SourceMgr.createFileID(FE, SourceLocation(), Kind));
-  } else {
-Diags.Report(diag::err_cannot_open_file) << InputFile
- << MB.getError().message();
-return false;
-  }
-} else {
-  SourceMgr.setMainFileID(
-  SourceMgr.createFileID(File, SourceLocation(), Kind));
-}
+SourceMgr.setMainFileID(
+SourceMgr.createFileID(File, SourceLocation(), Kind));
   } else {
 llvm::ErrorOr> SBOrErr =
 llvm::MemoryBuffer::getSTDIN();
Index: clang/lib/Basic/SourceManager.cpp
===
--- clang/lib/Basic/SourceManager.cpp
+++ clang/lib/Basic/SourceManager.cpp
@@ -120,8 +120,10 @@
   // Clang (including elsewhere in this file!) use 'unsigned' to represent file
   // offsets, line numbers, string literal lengths, and so on, and fail
   // miserably on large source files.
-  if ((uint64_t)ContentsEntry->getSize() >=
-  std::numeric_limits::max()) {
+  auto diagnoseFileTooLarge = [&](uint64_t Size) {
+if (Size < std::numeric_limits::max())
+  return false;
+
 if (Diag.isDiagnosticInFlight())
   Diag.SetDelayedDiagnostic(diag::err_file_too_large,
 ContentsEntry->getName());
@@ -129,8 +131,14 @@
   Diag.Report(Loc, diag::err_file_too_large)
 << ContentsEntry->getName();
 
+return true;
+  };
+
+  // Check ContentsEntry's size, unless it's a named pipe (in which case we
+  // need to load the buffer first).
+  if (!ContentsEntry->isNamedPipe() &&
+  diagnoseFileTooLarge(ContentsEntry->getSize()))
 return None;
-  }
 
   auto BufferOrError = FM.getBufferForFile(ContentsEntry, IsFileVolatile);
 
@@ -153,9 +161,14 @@
 
   Buffer = std::move(*BufferOrError);
 
-  // Check that the file's size is the same as in the file entry (which may
-  // have come from a stat cache).
-  if (Buffer->getBufferSize() != (size_t)ContentsEntry->getSize()) {
+  // If this is a named pipe, check the buffer to see if it's too big.
+  // Otherwise, check that the file's size is the same as in the file entry
+  // (which may have come from a stat cache).
+  if (ContentsEntry->isNamedPipe()) {
+// Check the buffer si

[clang] c4fb772 - PR48339: Improve diagnostics for invalid dependent unqualified function calls.

2020-12-02 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-12-02T17:54:55-08:00
New Revision: c4fb7720ceb30f25c38d994fb375e4d1978de144

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

LOG: PR48339: Improve diagnostics for invalid dependent unqualified function 
calls.

Fix bogus diagnostics that would get confused and think a "no viable
fuctions" case was an "undeclared identifiers" case, resulting in an
incorrect diagnostic preceding the correct one. Use overload resolution
to determine which function we should select when we can find call
candidates from a dependent base class. Make the diagnostics for a call
that could call a function from a dependent base class more specific,
and use a different diagnostic message for the case where the call
target is instead declared later in the same class. Plus some minor
diagnostic wording improvements.

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaOverload.cpp
clang/test/CXX/drs/dr2xx.cpp
clang/test/CXX/expr/expr.prim/expr.prim.general/p3-0x.cpp
clang/test/SemaTemplate/cxx1z-using-declaration.cpp
clang/test/SemaTemplate/dependent-names.cpp
clang/test/SemaTemplate/dependent-typos-recovery.cpp
clang/test/SemaTemplate/ms-lookup-template-base-classes.cpp
clang/test/SemaTemplate/recovery-crash.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 3067c077ddb2..44195cc9db45 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -5204,11 +5204,17 @@ def ext_undeclared_unqual_id_with_dependent_base : 
ExtWarn<
   "use of undeclared identifier %0; "
   "unqualified lookup into dependent bases of class template %1 is a Microsoft 
extension">,
   InGroup;
-def ext_found_via_dependent_bases_lookup : ExtWarn<"use of identifier %0 "
+def err_found_in_dependent_base : Error<
+  "explicit qualification required to use member %0 from dependent base 
class">;
+def ext_found_in_dependent_base : ExtWarn<"use of member %0 "
   "found via unqualified lookup into dependent bases of class templates is a "
   "Microsoft extension">, InGroup;
-def note_dependent_var_use : Note<"must qualify identifier to find this "
-"declaration in dependent base class">;
+def err_found_later_in_class : Error<"member %0 used before its declaration">;
+def ext_found_later_in_class : ExtWarn<
+  "use of member %0 before its declaration is a Microsoft extension">,
+  InGroup;
+def note_dependent_member_use : Note<
+  "must qualify identifier to find this declaration in dependent base class">;
 def err_not_found_by_two_phase_lookup : Error<"call to function %0 that is 
neither "
 "visible in the template definition nor found by argument-dependent 
lookup">;
 def note_not_found_by_two_phase_lookup : Note<"%0 should be declared prior to 
the "

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 775dd1793dea..8b4a18ab11d6 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -3676,6 +3676,9 @@ class Sema final {
ArrayRef Args,
OverloadCandidateSet &CandidateSet,
bool PartialOverloading = false);
+  void AddOverloadedCallCandidates(
+  LookupResult &R, TemplateArgumentListInfo *ExplicitTemplateArgs,
+  ArrayRef Args, OverloadCandidateSet &CandidateSet);
 
   // An enum used to represent the 
diff erent possible results of building a
   // range-based for loop.
@@ -4958,6 +4961,8 @@ class Sema final {
   DeclarationNameInfo &NameInfo,
   const TemplateArgumentListInfo *&TemplateArgs);
 
+  bool DiagnoseDependentMemberLookup(LookupResult &R);
+
   bool
   DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R,
   CorrectionCandidateCallback &CCC,

diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 7da854f4fb9e..6da530c245fe 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -255,7 +255,7 @@ static ParsedType recoverFromTypeInKnownDependentBase(Sema 
&S,
   // We found some types in dependent base classes.  Recover as if the user
   // wrote 'typename MyClass::II' instead of 'II'.  We'll fully resolve the
   // lookup during template instantiation.
-  S.Diag(NameLoc, diag::ext_found_via_dependent_bases_lookup) << &II;
+  S.Diag(NameLoc, diag::ext_found_in_dependent_base) << &II;
 
   ASTContext &Context = S.Context;
   auto *NNS = NestedNameSpecifier::Create(Context, 

[PATCH] D90733: Frontend: Sink named pipe logic from CompilerInstance down to FileManager

2020-12-02 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

Hmm, I had to revert this in b34632201987eed369bb7ef4646f341b901c95b8 
 due to a 
bot failure; I'll need to look into it.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D90733/new/

https://reviews.llvm.org/D90733

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


[clang] b346322 - Revert "Frontend: Sink named pipe logic from CompilerInstance down to FileManager"

2020-12-02 Thread Duncan P. N. Exon Smith via cfe-commits

Author: Duncan P. N. Exon Smith
Date: 2020-12-02T17:36:20-08:00
New Revision: b34632201987eed369bb7ef4646f341b901c95b8

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

LOG: Revert "Frontend: Sink named pipe logic from CompilerInstance down to 
FileManager"

This reverts commit 3b18a594c7717a328c33b9c1eba675e9f4bd367c, since
apparently this doesn't work everywhere. E.g.,
clang-x86_64-debian-fast/3889
(http://lab.llvm.org:8011/#/builders/109/builds/3889) gives me:
```
+ : 'RUN: at line 8'
+ /b/1/clang-x86_64-debian-fast/llvm.obj/bin/clang -x c /dev/fd/0 -E
+ cat /b/1/clang-x86_64-debian-fast/llvm.src/clang/test/Misc/dev-fd-fs.c
fatal error: file '/dev/fd/0' modified since it was first processed
1 error generated.
```

Added: 


Modified: 
clang/lib/Basic/FileManager.cpp
clang/lib/Frontend/CompilerInstance.cpp

Removed: 




diff  --git a/clang/lib/Basic/FileManager.cpp b/clang/lib/Basic/FileManager.cpp
index f3afe6dd5f48..c0d3685001ee 100644
--- a/clang/lib/Basic/FileManager.cpp
+++ b/clang/lib/Basic/FileManager.cpp
@@ -489,7 +489,7 @@ FileManager::getBufferForFile(const FileEntry *Entry, bool 
isVolatile,
   uint64_t FileSize = Entry->getSize();
   // If there's a high enough chance that the file have changed since we
   // got its size, force a stat before opening it.
-  if (isVolatile || Entry->isNamedPipe())
+  if (isVolatile)
 FileSize = -1;
 
   StringRef Filename = Entry->getName();

diff  --git a/clang/lib/Frontend/CompilerInstance.cpp 
b/clang/lib/Frontend/CompilerInstance.cpp
index e3018b218b76..5c82878d8e21 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -858,8 +858,30 @@ bool CompilerInstance::InitializeSourceManager(const 
FrontendInputFile &Input,
 }
 FileEntryRef File = *FileOrErr;
 
-SourceMgr.setMainFileID(
-SourceMgr.createFileID(File, SourceLocation(), Kind));
+// The natural SourceManager infrastructure can't currently handle named
+// pipes, but we would at least like to accept them for the main
+// file. Detect them here, read them with the volatile flag so FileMgr will
+// pick up the correct size, and simply override their contents as we do 
for
+// STDIN.
+if (File.getFileEntry().isNamedPipe()) {
+  auto MB =
+  FileMgr.getBufferForFile(&File.getFileEntry(), /*isVolatile=*/true);
+  if (MB) {
+// Create a new virtual file that will have the correct size.
+const FileEntry *FE =
+FileMgr.getVirtualFile(InputFile, (*MB)->getBufferSize(), 0);
+SourceMgr.overrideFileContents(FE, std::move(*MB));
+SourceMgr.setMainFileID(
+SourceMgr.createFileID(FE, SourceLocation(), Kind));
+  } else {
+Diags.Report(diag::err_cannot_open_file) << InputFile
+ << MB.getError().message();
+return false;
+  }
+} else {
+  SourceMgr.setMainFileID(
+  SourceMgr.createFileID(File, SourceLocation(), Kind));
+}
   } else {
 llvm::ErrorOr> SBOrErr =
 llvm::MemoryBuffer::getSTDIN();



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


[PATCH] D92529: ASTImporter: Migrate to the FileEntryRef overload of SourceManager::createFileID, NFC

2020-12-02 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith created this revision.
dexonsmith added reviewers: shafik, arphaman, jansvoboda11.
Herald added subscribers: teemperor, ributzka, martong.
Herald added a reviewer: a.sidorin.
Herald added a project: clang.
dexonsmith requested review of this revision.

Migrate `ASTImporter::Import` over to using the `FileEntryRef` overload
of `SourceManager::createFileID`. No functionality change here.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92529

Files:
  clang/lib/AST/ASTImporter.cpp


Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -8719,7 +8719,7 @@
 // FIXME: We definitely want to re-use the existing MemoryBuffer, 
rather
 // than mmap the files several times.
 auto Entry =
-ToFileManager.getFile(Cache->OrigEntry->getName());
+ToFileManager.getOptionalFileRef(Cache->OrigEntry->getName());
 // FIXME: The filename may be a virtual name that does probably not
 // point to a valid file and we get no Entry here. In this case try 
with
 // the memory buffer below.


Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -8719,7 +8719,7 @@
 // FIXME: We definitely want to re-use the existing MemoryBuffer, rather
 // than mmap the files several times.
 auto Entry =
-ToFileManager.getFile(Cache->OrigEntry->getName());
+ToFileManager.getOptionalFileRef(Cache->OrigEntry->getName());
 // FIXME: The filename may be a virtual name that does probably not
 // point to a valid file and we get no Entry here. In this case try with
 // the memory buffer below.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91315: [RISCV] Handle zfh in the arch string.

2020-12-02 Thread Hsiangkai Wang via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG432d05174ed0: [RISCV] Handle zfh in the arch string. 
(authored by HsiangKai).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91315/new/

https://reviews.llvm.org/D91315

Files:
  clang/lib/Basic/Targets/RISCV.cpp
  clang/lib/Basic/Targets/RISCV.h
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/test/Driver/riscv-arch.c
  clang/test/Preprocessor/riscv-target-features.c


Index: clang/test/Preprocessor/riscv-target-features.c
===
--- clang/test/Preprocessor/riscv-target-features.c
+++ clang/test/Preprocessor/riscv-target-features.c
@@ -78,3 +78,9 @@
 // CHECK-DOUBLE: __riscv_float_abi_double 1
 // CHECK-DOUBLE-NOT: __riscv_float_abi_soft
 // CHECK-DOUBLE-NOT: __riscv_float_abi_single
+
+// RUN: %clang -target riscv32-unknown-linux-gnu 
-menable-experimental-extensions -march=rv32izfh0p1 -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-ZFH-EXT %s
+// RUN: %clang -target riscv64-unknown-linux-gnu 
-menable-experimental-extensions -march=rv64izfh0p1 -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-ZFH-EXT %s
+// CHECK-ZFH-EXT: __riscv_zfh 1
Index: clang/test/Driver/riscv-arch.c
===
--- clang/test/Driver/riscv-arch.c
+++ clang/test/Driver/riscv-arch.c
@@ -383,3 +383,12 @@
 // RUN: %clang -target riscv32-unknown-elf -march=rv32iv0p9 
-menable-experimental-extensions -### %s -c 2>&1 | \
 // RUN:   FileCheck -check-prefix=RV32-EXPERIMENTAL-V-GOODVERS %s
 // RV32-EXPERIMENTAL-V-GOODVERS: "-target-feature" "+experimental-v"
+
+// RUN: %clang -target riscv32-unknown-elf -march=rv32izfh -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck 
-check-prefix=RV32-EXPERIMENTAL-ZFH-NOFLAG %s
+// RV32-EXPERIMENTAL-ZFH-NOFLAG: error: invalid arch name 'rv32izfh'
+// RV32-EXPERIMENTAL-ZFH-NOFLAG: requires '-menable-experimental-extensions'
+
+// RUN: %clang -target riscv32-unknown-elf -march=rv32izfh0p1 
-menable-experimental-extensions -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-EXPERIMENTAL-ZFH %s
+// RV32-EXPERIMENTAL-ZFH: "-target-feature" "+experimental-zfh"
Index: clang/lib/Driver/ToolChains/Arch/RISCV.cpp
===
--- clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ clang/lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -64,6 +64,8 @@
 return RISCVExtensionVersion{"0", "92"};
   if (Ext == "v")
 return RISCVExtensionVersion{"0", "9"};
+  if (Ext == "zfh")
+return RISCVExtensionVersion{"0", "1"};
   return None;
 }
 
Index: clang/lib/Basic/Targets/RISCV.h
===
--- clang/lib/Basic/Targets/RISCV.h
+++ clang/lib/Basic/Targets/RISCV.h
@@ -31,11 +31,12 @@
   bool HasD;
   bool HasC;
   bool HasB;
+  bool HasZfh;
 
 public:
   RISCVTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
-  : TargetInfo(Triple), HasM(false), HasA(false), HasF(false),
-HasD(false), HasC(false), HasB(false) {
+  : TargetInfo(Triple), HasM(false), HasA(false), HasF(false), HasD(false),
+HasC(false), HasB(false), HasZfh(false) {
 LongDoubleWidth = 128;
 LongDoubleAlign = 128;
 LongDoubleFormat = &llvm::APFloat::IEEEquad();
Index: clang/lib/Basic/Targets/RISCV.cpp
===
--- clang/lib/Basic/Targets/RISCV.cpp
+++ clang/lib/Basic/Targets/RISCV.cpp
@@ -135,6 +135,9 @@
 
   if (HasB)
 Builder.defineMacro("__riscv_bitmanip");
+
+  if (HasZfh)
+Builder.defineMacro("__riscv_zfh");
 }
 
 /// Return true if has this feature, need to sync with handleTargetFeatures.
@@ -150,6 +153,7 @@
   .Case("d", HasD)
   .Case("c", HasC)
   .Case("experimental-b", HasB)
+  .Case("experimental-zfh", HasZfh)
   .Default(false);
 }
 
@@ -169,6 +173,8 @@
   HasC = true;
 else if (Feature == "+experimental-b")
   HasB = true;
+else if (Feature == "+experimental-zfh")
+  HasZfh = true;
   }
 
   return true;


Index: clang/test/Preprocessor/riscv-target-features.c
===
--- clang/test/Preprocessor/riscv-target-features.c
+++ clang/test/Preprocessor/riscv-target-features.c
@@ -78,3 +78,9 @@
 // CHECK-DOUBLE: __riscv_float_abi_double 1
 // CHECK-DOUBLE-NOT: __riscv_float_abi_soft
 // CHECK-DOUBLE-NOT: __riscv_float_abi_single
+
+// RUN: %clang -target riscv32-unknown-linux-gnu -menable-experimental-extensions -march=rv32izfh0p1 -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-ZFH-EXT %s
+// RUN: %clang -target riscv64-unknown-linux-gnu -menable-experimental-extensions -march=rv64izfh0p1 -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-ZFH-EXT %s
+// 

[clang] 432d051 - [RISCV] Handle zfh in the arch string.

2020-12-02 Thread Hsiangkai Wang via cfe-commits

Author: Hsiangkai Wang
Date: 2020-12-03T09:16:44+08:00
New Revision: 432d05174ed00a217c0ad37e2e823154624c1311

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

LOG: [RISCV] Handle zfh in the arch string.

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

Added: 


Modified: 
clang/lib/Basic/Targets/RISCV.cpp
clang/lib/Basic/Targets/RISCV.h
clang/lib/Driver/ToolChains/Arch/RISCV.cpp
clang/test/Driver/riscv-arch.c
clang/test/Preprocessor/riscv-target-features.c

Removed: 




diff  --git a/clang/lib/Basic/Targets/RISCV.cpp 
b/clang/lib/Basic/Targets/RISCV.cpp
index 37e688d14b4a..2b076c9c16f2 100644
--- a/clang/lib/Basic/Targets/RISCV.cpp
+++ b/clang/lib/Basic/Targets/RISCV.cpp
@@ -135,6 +135,9 @@ void RISCVTargetInfo::getTargetDefines(const LangOptions 
&Opts,
 
   if (HasB)
 Builder.defineMacro("__riscv_bitmanip");
+
+  if (HasZfh)
+Builder.defineMacro("__riscv_zfh");
 }
 
 /// Return true if has this feature, need to sync with handleTargetFeatures.
@@ -150,6 +153,7 @@ bool RISCVTargetInfo::hasFeature(StringRef Feature) const {
   .Case("d", HasD)
   .Case("c", HasC)
   .Case("experimental-b", HasB)
+  .Case("experimental-zfh", HasZfh)
   .Default(false);
 }
 
@@ -169,6 +173,8 @@ bool 
RISCVTargetInfo::handleTargetFeatures(std::vector &Features,
   HasC = true;
 else if (Feature == "+experimental-b")
   HasB = true;
+else if (Feature == "+experimental-zfh")
+  HasZfh = true;
   }
 
   return true;

diff  --git a/clang/lib/Basic/Targets/RISCV.h b/clang/lib/Basic/Targets/RISCV.h
index a4e6777a11e2..20a7b1c73175 100644
--- a/clang/lib/Basic/Targets/RISCV.h
+++ b/clang/lib/Basic/Targets/RISCV.h
@@ -31,11 +31,12 @@ class RISCVTargetInfo : public TargetInfo {
   bool HasD;
   bool HasC;
   bool HasB;
+  bool HasZfh;
 
 public:
   RISCVTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
-  : TargetInfo(Triple), HasM(false), HasA(false), HasF(false),
-HasD(false), HasC(false), HasB(false) {
+  : TargetInfo(Triple), HasM(false), HasA(false), HasF(false), HasD(false),
+HasC(false), HasB(false), HasZfh(false) {
 LongDoubleWidth = 128;
 LongDoubleAlign = 128;
 LongDoubleFormat = &llvm::APFloat::IEEEquad();

diff  --git a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp 
b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
index 7ca05a1f3a39..aa1a5d8c803f 100644
--- a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -64,6 +64,8 @@ isExperimentalExtension(StringRef Ext) {
 return RISCVExtensionVersion{"0", "92"};
   if (Ext == "v")
 return RISCVExtensionVersion{"0", "9"};
+  if (Ext == "zfh")
+return RISCVExtensionVersion{"0", "1"};
   return None;
 }
 

diff  --git a/clang/test/Driver/riscv-arch.c b/clang/test/Driver/riscv-arch.c
index 8b630b1846c9..533f1cff42af 100644
--- a/clang/test/Driver/riscv-arch.c
+++ b/clang/test/Driver/riscv-arch.c
@@ -383,3 +383,12 @@
 // RUN: %clang -target riscv32-unknown-elf -march=rv32iv0p9 
-menable-experimental-extensions -### %s -c 2>&1 | \
 // RUN:   FileCheck -check-prefix=RV32-EXPERIMENTAL-V-GOODVERS %s
 // RV32-EXPERIMENTAL-V-GOODVERS: "-target-feature" "+experimental-v"
+
+// RUN: %clang -target riscv32-unknown-elf -march=rv32izfh -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck 
-check-prefix=RV32-EXPERIMENTAL-ZFH-NOFLAG %s
+// RV32-EXPERIMENTAL-ZFH-NOFLAG: error: invalid arch name 'rv32izfh'
+// RV32-EXPERIMENTAL-ZFH-NOFLAG: requires '-menable-experimental-extensions'
+
+// RUN: %clang -target riscv32-unknown-elf -march=rv32izfh0p1 
-menable-experimental-extensions -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-EXPERIMENTAL-ZFH %s
+// RV32-EXPERIMENTAL-ZFH: "-target-feature" "+experimental-zfh"

diff  --git a/clang/test/Preprocessor/riscv-target-features.c 
b/clang/test/Preprocessor/riscv-target-features.c
index d8c18f76e53b..c0ffd83bc7e2 100644
--- a/clang/test/Preprocessor/riscv-target-features.c
+++ b/clang/test/Preprocessor/riscv-target-features.c
@@ -78,3 +78,9 @@
 // CHECK-DOUBLE: __riscv_float_abi_double 1
 // CHECK-DOUBLE-NOT: __riscv_float_abi_soft
 // CHECK-DOUBLE-NOT: __riscv_float_abi_single
+
+// RUN: %clang -target riscv32-unknown-linux-gnu 
-menable-experimental-extensions -march=rv32izfh0p1 -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-ZFH-EXT %s
+// RUN: %clang -target riscv64-unknown-linux-gnu 
-menable-experimental-extensions -march=rv64izfh0p1 -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-ZFH-EXT %s
+// CHECK-ZFH-EXT: __riscv_zfh 1



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


[PATCH] D90733: Frontend: Sink named pipe logic from CompilerInstance down to FileManager

2020-12-02 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3b18a594c771: Frontend: Sink named pipe logic from 
CompilerInstance down to FileManager (authored by dexonsmith).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D90733/new/

https://reviews.llvm.org/D90733

Files:
  clang/lib/Basic/FileManager.cpp
  clang/lib/Frontend/CompilerInstance.cpp


Index: clang/lib/Frontend/CompilerInstance.cpp
===
--- clang/lib/Frontend/CompilerInstance.cpp
+++ clang/lib/Frontend/CompilerInstance.cpp
@@ -858,30 +858,8 @@
 }
 FileEntryRef File = *FileOrErr;
 
-// The natural SourceManager infrastructure can't currently handle named
-// pipes, but we would at least like to accept them for the main
-// file. Detect them here, read them with the volatile flag so FileMgr will
-// pick up the correct size, and simply override their contents as we do 
for
-// STDIN.
-if (File.getFileEntry().isNamedPipe()) {
-  auto MB =
-  FileMgr.getBufferForFile(&File.getFileEntry(), /*isVolatile=*/true);
-  if (MB) {
-// Create a new virtual file that will have the correct size.
-const FileEntry *FE =
-FileMgr.getVirtualFile(InputFile, (*MB)->getBufferSize(), 0);
-SourceMgr.overrideFileContents(FE, std::move(*MB));
-SourceMgr.setMainFileID(
-SourceMgr.createFileID(FE, SourceLocation(), Kind));
-  } else {
-Diags.Report(diag::err_cannot_open_file) << InputFile
- << MB.getError().message();
-return false;
-  }
-} else {
-  SourceMgr.setMainFileID(
-  SourceMgr.createFileID(File, SourceLocation(), Kind));
-}
+SourceMgr.setMainFileID(
+SourceMgr.createFileID(File, SourceLocation(), Kind));
   } else {
 llvm::ErrorOr> SBOrErr =
 llvm::MemoryBuffer::getSTDIN();
Index: clang/lib/Basic/FileManager.cpp
===
--- clang/lib/Basic/FileManager.cpp
+++ clang/lib/Basic/FileManager.cpp
@@ -489,7 +489,7 @@
   uint64_t FileSize = Entry->getSize();
   // If there's a high enough chance that the file have changed since we
   // got its size, force a stat before opening it.
-  if (isVolatile)
+  if (isVolatile || Entry->isNamedPipe())
 FileSize = -1;
 
   StringRef Filename = Entry->getName();


Index: clang/lib/Frontend/CompilerInstance.cpp
===
--- clang/lib/Frontend/CompilerInstance.cpp
+++ clang/lib/Frontend/CompilerInstance.cpp
@@ -858,30 +858,8 @@
 }
 FileEntryRef File = *FileOrErr;
 
-// The natural SourceManager infrastructure can't currently handle named
-// pipes, but we would at least like to accept them for the main
-// file. Detect them here, read them with the volatile flag so FileMgr will
-// pick up the correct size, and simply override their contents as we do for
-// STDIN.
-if (File.getFileEntry().isNamedPipe()) {
-  auto MB =
-  FileMgr.getBufferForFile(&File.getFileEntry(), /*isVolatile=*/true);
-  if (MB) {
-// Create a new virtual file that will have the correct size.
-const FileEntry *FE =
-FileMgr.getVirtualFile(InputFile, (*MB)->getBufferSize(), 0);
-SourceMgr.overrideFileContents(FE, std::move(*MB));
-SourceMgr.setMainFileID(
-SourceMgr.createFileID(FE, SourceLocation(), Kind));
-  } else {
-Diags.Report(diag::err_cannot_open_file) << InputFile
- << MB.getError().message();
-return false;
-  }
-} else {
-  SourceMgr.setMainFileID(
-  SourceMgr.createFileID(File, SourceLocation(), Kind));
-}
+SourceMgr.setMainFileID(
+SourceMgr.createFileID(File, SourceLocation(), Kind));
   } else {
 llvm::ErrorOr> SBOrErr =
 llvm::MemoryBuffer::getSTDIN();
Index: clang/lib/Basic/FileManager.cpp
===
--- clang/lib/Basic/FileManager.cpp
+++ clang/lib/Basic/FileManager.cpp
@@ -489,7 +489,7 @@
   uint64_t FileSize = Entry->getSize();
   // If there's a high enough chance that the file have changed since we
   // got its size, force a stat before opening it.
-  if (isVolatile)
+  if (isVolatile || Entry->isNamedPipe())
 FileSize = -1;
 
   StringRef Filename = Entry->getName();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 3b18a59 - Frontend: Sink named pipe logic from CompilerInstance down to FileManager

2020-12-02 Thread Duncan P. N. Exon Smith via cfe-commits

Author: Duncan P. N. Exon Smith
Date: 2020-12-02T17:14:27-08:00
New Revision: 3b18a594c7717a328c33b9c1eba675e9f4bd367c

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

LOG: Frontend: Sink named pipe logic from CompilerInstance down to FileManager

Remove compilicated logic from CompilerInstance::InitializeSourceManager
to deal with named pipes, updating FileManager::getBufferForFile to
handle it in a more straightforward way. The existing test at
clang/test/Misc/dev-fd-fs.c covers the new behaviour (just like it did
the old behaviour).

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

Added: 


Modified: 
clang/lib/Basic/FileManager.cpp
clang/lib/Frontend/CompilerInstance.cpp

Removed: 




diff  --git a/clang/lib/Basic/FileManager.cpp b/clang/lib/Basic/FileManager.cpp
index c0d3685001ee..f3afe6dd5f48 100644
--- a/clang/lib/Basic/FileManager.cpp
+++ b/clang/lib/Basic/FileManager.cpp
@@ -489,7 +489,7 @@ FileManager::getBufferForFile(const FileEntry *Entry, bool 
isVolatile,
   uint64_t FileSize = Entry->getSize();
   // If there's a high enough chance that the file have changed since we
   // got its size, force a stat before opening it.
-  if (isVolatile)
+  if (isVolatile || Entry->isNamedPipe())
 FileSize = -1;
 
   StringRef Filename = Entry->getName();

diff  --git a/clang/lib/Frontend/CompilerInstance.cpp 
b/clang/lib/Frontend/CompilerInstance.cpp
index 5c82878d8e21..e3018b218b76 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -858,30 +858,8 @@ bool CompilerInstance::InitializeSourceManager(const 
FrontendInputFile &Input,
 }
 FileEntryRef File = *FileOrErr;
 
-// The natural SourceManager infrastructure can't currently handle named
-// pipes, but we would at least like to accept them for the main
-// file. Detect them here, read them with the volatile flag so FileMgr will
-// pick up the correct size, and simply override their contents as we do 
for
-// STDIN.
-if (File.getFileEntry().isNamedPipe()) {
-  auto MB =
-  FileMgr.getBufferForFile(&File.getFileEntry(), /*isVolatile=*/true);
-  if (MB) {
-// Create a new virtual file that will have the correct size.
-const FileEntry *FE =
-FileMgr.getVirtualFile(InputFile, (*MB)->getBufferSize(), 0);
-SourceMgr.overrideFileContents(FE, std::move(*MB));
-SourceMgr.setMainFileID(
-SourceMgr.createFileID(FE, SourceLocation(), Kind));
-  } else {
-Diags.Report(diag::err_cannot_open_file) << InputFile
- << MB.getError().message();
-return false;
-  }
-} else {
-  SourceMgr.setMainFileID(
-  SourceMgr.createFileID(File, SourceLocation(), Kind));
-}
+SourceMgr.setMainFileID(
+SourceMgr.createFileID(File, SourceLocation(), Kind));
   } else {
 llvm::ErrorOr> SBOrErr =
 llvm::MemoryBuffer::getSTDIN();



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


[PATCH] D92209: [ASTImporter] Support CXXDeductionGuideDecl with local typedef

2020-12-02 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added inline comments.



Comment at: clang/lib/AST/ASTImporter.cpp:2522
+  // Add to the lookupTable because we could not do that in MapImported.
+  Importer.AddToLookupTable(ToTypedef);
+

I am not super excited about this solution, I feel like several bugs we have 
had can be attributed to these exception control flow cases that we have in the 
ASTImporter. I don't have any immediate better solution.




Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92209/new/

https://reviews.llvm.org/D92209

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


[PATCH] D88220: [C++20] P1825R0: More implicit moves

2020-12-02 Thread David Stone via Phabricator via cfe-commits
davidstone added inline comments.



Comment at: clang/test/CXX/class/class.init/class.copy.elision/p3.cpp:22
+  return c;
+}
+#else

Quuxplusone wrote:
> Quuxplusone wrote:
> > @rsmith @david_stone (or anyone), what is the status in C++20 of the 
> > following test case?
> > 
> > C&& test(C&& c) {
> > return c;
> > }
> > 
> > I know we talked about this in person at CppCon 2018, and concluded that 
> > our //intention// was for this to be legal, but that it wasn't actually 
> > legal as-worded, because the returned thingie here is not an object but 
> > rather a reference, and therefore none of 
> > [P1825's](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1825r0.html)
> >  wording actually covers it. Is that still the case? Is there an open issue 
> > about this? Is there any appetite for Clang to just go ahead and //make// 
> > this legal?  (The current patch does //not// make this legal.)
> > 
> > Relevant reading: 
> > https://quuxplusone.github.io/blog/2018/09/25/perfect-backwarding/
> Apparently @davidstone has been active more recently than @david_stone... :)
Going through the wording in http://eel.is/c++draft/class.copy.elision#3

"An implicitly movable entity is a variable of automatic storage duration that 
is either a non-volatile object or an rvalue reference to a non-volatile object 
type."

So we are fine with a reference as the source. However, it then goes on to say

"...overload resolution to select the constructor for the copy or the 
return_­value overload to call is first performed as if the expression or 
operand were an rvalue."

There is technically no constructor to call here, which I think means this 
section does not apply.

I don't believe an issue has been raised for this yet, so I'll email CWG about 
it.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88220/new/

https://reviews.llvm.org/D88220

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


[PATCH] D92480: [llvm] Unify interface of (ThreadSafe)?RefCountedBase

2020-12-02 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added inline comments.



Comment at: llvm/include/llvm/ADT/IntrusiveRefCntPtr.h:75-80
+  // Copy and move constructors/assignments are no-ops as the RefCount isn't
+  // dictated by the class directly.
   RefCountedBase(const RefCountedBase &) {}
+  RefCountedBase(RefCountedBase &&) {}
+  RefCountedBase &operator=(const RefCountedBase &) { return *this; }
+  RefCountedBase &operator=(RefCountedBase &&) { return *this; }

dblaikie wrote:
> I can't quite understand this comment - perhaps you could try rephrasing it?
I'm not quite following why you needed to add these special members; it seems 
like just the destructor would be enough for the assertion; but if you do need 
them, can/should they be `= default`?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92480/new/

https://reviews.llvm.org/D92480

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


[PATCH] D92480: [llvm] Unify interface of (ThreadSafe)?RefCountedBase

2020-12-02 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added inline comments.



Comment at: llvm/include/llvm/ADT/IntrusiveRefCntPtr.h:75-76
   RefCountedBase() = default;
+  // Copy and move constructors/assignments are no-ops as the RefCount isn't
+  // dictated by the class directly.
   RefCountedBase(const RefCountedBase &) {}

I can't quite understand this comment - perhaps you could try rephrasing it?



Comment at: llvm/include/llvm/ADT/IntrusiveRefCntPtr.h:79-80
+  RefCountedBase(RefCountedBase &&) {}
+  RefCountedBase &operator=(const RefCountedBase &) { return *this; }
+  RefCountedBase &operator=(RefCountedBase &&) { return *this; }
+

What does it mean to copy a ref counted object with a builtin ref count?

I would /guess/ maybe copies (or moves) of ref counted objects like this should 
only be valid when the ref count is 1 or maybe only 0? (since all the other 
users who might have an active reference certainly aren't getting a reference 
to the newly copied object implicitly)

Do you know which users which relied on any of the copy behavior? Maybe leave 
it as = default for now?

I guess it makes sense that the copy would have a zero ref count - same as if 
it were newly default constructed. But if no one's been using this 
effectively/at all already - maybe avoid creating this new behavior/changing 
the semantics here? What if we only allowed copies of objects with a zero ref 
count - is that sufficient for existing uses?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92480/new/

https://reviews.llvm.org/D92480

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


[PATCH] D92439: [CLANG] Fix missing error for use of 128-bit integer inside SPIR64 device code.

2020-12-02 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 added a comment.

In D92439#2429511 , @jdoerfert wrote:

> Still unsure if we should also error out for NVPTX but that is a different 
> story. Looks OK from my side, assuming you address the earlier comment.

With this change if NVPTX need diagnostic for  use of 128-bit integer, adding 
"bool hasInt128Type() const override { return false; }" in NVPTX.h is all 
needed.

> Maybe someone else should accept though.

Do you have suggestion whom I may contact for acceptance?  We have customer 
needs for this...   Thank you in advance. :-)


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92439/new/

https://reviews.llvm.org/D92439

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


[PATCH] D90887: ARCMigrate: Stop abusing PreprocessorOptions for passing back file remappings, NFC

2020-12-02 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdcc4f7f3c4b4: ARCMigrate: Stop abusing PreprocessorOptions 
for passing back file remappings… (authored by dexonsmith).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D90887/new/

https://reviews.llvm.org/D90887

Files:
  clang/include/clang/ARCMigrate/FileRemapper.h
  clang/lib/ARCMigrate/ARCMT.cpp
  clang/lib/ARCMigrate/FileRemapper.cpp
  clang/tools/arcmt-test/arcmt-test.cpp


Index: clang/tools/arcmt-test/arcmt-test.cpp
===
--- clang/tools/arcmt-test/arcmt-test.cpp
+++ clang/tools/arcmt-test/arcmt-test.cpp
@@ -139,11 +139,10 @@
 }
 
 static void printResult(FileRemapper &remapper, raw_ostream &OS) {
-  PreprocessorOptions PPOpts;
-  remapper.applyMappings(PPOpts);
-  // The changed files will be in memory buffers, print them.
-  for (const auto &RB : PPOpts.RemappedFileBuffers)
-OS << RB.second->getBuffer();
+  remapper.forEachMapping([](StringRef, StringRef) {},
+  [&](StringRef, const llvm::MemoryBufferRef &Buffer) {
+OS << Buffer.getBuffer();
+  });
 }
 
 static bool performTransformations(StringRef resourcesPath,
Index: clang/lib/ARCMigrate/FileRemapper.cpp
===
--- clang/lib/ARCMigrate/FileRemapper.cpp
+++ clang/lib/ARCMigrate/FileRemapper.cpp
@@ -190,6 +190,21 @@
   return false;
 }
 
+void FileRemapper::forEachMapping(
+llvm::function_ref CaptureFile,
+llvm::function_ref
+CaptureBuffer) const {
+  for (auto &Mapping : FromToMappings) {
+if (const FileEntry *FE = Mapping.second.dyn_cast()) {
+  CaptureFile(Mapping.first->getName(), FE->getName());
+  continue;
+}
+CaptureBuffer(
+Mapping.first->getName(),
+Mapping.second.get()->getMemBufferRef());
+  }
+}
+
 void FileRemapper::applyMappings(PreprocessorOptions &PPOpts) const {
   for (MappingsTy::const_iterator
  I = FromToMappings.begin(), E = FromToMappings.end(); I != E; ++I) {
Index: clang/lib/ARCMigrate/ARCMT.cpp
===
--- clang/lib/ARCMigrate/ARCMT.cpp
+++ clang/lib/ARCMigrate/ARCMT.cpp
@@ -416,9 +416,11 @@
   if (err)
 return true;
 
-  PreprocessorOptions PPOpts;
-  remapper.applyMappings(PPOpts);
-  remap = PPOpts.RemappedFiles;
+  remapper.forEachMapping(
+  [&](StringRef From, StringRef To) {
+remap.push_back(std::make_pair(From.str(), To.str()));
+  },
+  [](StringRef, const llvm::MemoryBufferRef &) {});
 
   return false;
 }
Index: clang/include/clang/ARCMigrate/FileRemapper.h
===
--- clang/include/clang/ARCMigrate/FileRemapper.h
+++ clang/include/clang/ARCMigrate/FileRemapper.h
@@ -12,11 +12,13 @@
 #include "clang/Basic/LLVM.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/PointerUnion.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include 
 
 namespace llvm {
   class MemoryBuffer;
+  class MemoryBufferRef;
 }
 
 namespace clang {
@@ -55,6 +57,12 @@
 
   void applyMappings(PreprocessorOptions &PPOpts) const;
 
+  /// Iterate through all the mappings.
+  void forEachMapping(
+  llvm::function_ref CaptureFile,
+  llvm::function_ref
+  CaptureBuffer) const;
+
   void clear(StringRef outputDir = StringRef());
 
 private:


Index: clang/tools/arcmt-test/arcmt-test.cpp
===
--- clang/tools/arcmt-test/arcmt-test.cpp
+++ clang/tools/arcmt-test/arcmt-test.cpp
@@ -139,11 +139,10 @@
 }
 
 static void printResult(FileRemapper &remapper, raw_ostream &OS) {
-  PreprocessorOptions PPOpts;
-  remapper.applyMappings(PPOpts);
-  // The changed files will be in memory buffers, print them.
-  for (const auto &RB : PPOpts.RemappedFileBuffers)
-OS << RB.second->getBuffer();
+  remapper.forEachMapping([](StringRef, StringRef) {},
+  [&](StringRef, const llvm::MemoryBufferRef &Buffer) {
+OS << Buffer.getBuffer();
+  });
 }
 
 static bool performTransformations(StringRef resourcesPath,
Index: clang/lib/ARCMigrate/FileRemapper.cpp
===
--- clang/lib/ARCMigrate/FileRemapper.cpp
+++ clang/lib/ARCMigrate/FileRemapper.cpp
@@ -190,6 +190,21 @@
   return false;
 }
 
+void FileRemapper::forEachMapping(
+llvm::function_ref CaptureFile,
+llvm::function_ref
+CaptureBuffer) const {
+  for (auto &Mapping : FromToMappings) {
+if (const FileEntry *FE = Mapping.second.dyn_cast()) {
+  CaptureFile(Mapping.first->getName(), FE->getName());
+  continue;
+}
+CaptureBuffer(
+Mapping.first->getName(),
+M

[clang] dcc4f7f - ARCMigrate: Stop abusing PreprocessorOptions for passing back file remappings, NFC

2020-12-02 Thread Duncan P. N. Exon Smith via cfe-commits

Author: Duncan P. N. Exon Smith
Date: 2020-12-02T16:28:33-08:00
New Revision: dcc4f7f3c4b4442710ae73d6f73cded665426678

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

LOG: ARCMigrate: Stop abusing PreprocessorOptions for passing back file 
remappings, NFC

As part of reducing use of PreprocessorOptions::RemappedFileBuffers,
stop abusing it to pass information around remapped files in
`ARCMigrate`.  This simplifies an eventual follow-up to switch to using
an `InMemoryFileSystem` for this.

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

Added: 


Modified: 
clang/include/clang/ARCMigrate/FileRemapper.h
clang/lib/ARCMigrate/ARCMT.cpp
clang/lib/ARCMigrate/FileRemapper.cpp
clang/tools/arcmt-test/arcmt-test.cpp

Removed: 




diff  --git a/clang/include/clang/ARCMigrate/FileRemapper.h 
b/clang/include/clang/ARCMigrate/FileRemapper.h
index 76b65b2f6884..4da68a678be2 100644
--- a/clang/include/clang/ARCMigrate/FileRemapper.h
+++ b/clang/include/clang/ARCMigrate/FileRemapper.h
@@ -12,11 +12,13 @@
 #include "clang/Basic/LLVM.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/PointerUnion.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include 
 
 namespace llvm {
   class MemoryBuffer;
+  class MemoryBufferRef;
 }
 
 namespace clang {
@@ -55,6 +57,12 @@ class FileRemapper {
 
   void applyMappings(PreprocessorOptions &PPOpts) const;
 
+  /// Iterate through all the mappings.
+  void forEachMapping(
+  llvm::function_ref CaptureFile,
+  llvm::function_ref
+  CaptureBuffer) const;
+
   void clear(StringRef outputDir = StringRef());
 
 private:

diff  --git a/clang/lib/ARCMigrate/ARCMT.cpp b/clang/lib/ARCMigrate/ARCMT.cpp
index e18def8a0b19..36fbe90e1e3a 100644
--- a/clang/lib/ARCMigrate/ARCMT.cpp
+++ b/clang/lib/ARCMigrate/ARCMT.cpp
@@ -416,9 +416,11 @@ bool 
arcmt::getFileRemappings(std::vector > &
   if (err)
 return true;
 
-  PreprocessorOptions PPOpts;
-  remapper.applyMappings(PPOpts);
-  remap = PPOpts.RemappedFiles;
+  remapper.forEachMapping(
+  [&](StringRef From, StringRef To) {
+remap.push_back(std::make_pair(From.str(), To.str()));
+  },
+  [](StringRef, const llvm::MemoryBufferRef &) {});
 
   return false;
 }

diff  --git a/clang/lib/ARCMigrate/FileRemapper.cpp 
b/clang/lib/ARCMigrate/FileRemapper.cpp
index 0222583c015b..f536af1795ed 100644
--- a/clang/lib/ARCMigrate/FileRemapper.cpp
+++ b/clang/lib/ARCMigrate/FileRemapper.cpp
@@ -190,6 +190,21 @@ bool FileRemapper::overwriteOriginal(DiagnosticsEngine 
&Diag,
   return false;
 }
 
+void FileRemapper::forEachMapping(
+llvm::function_ref CaptureFile,
+llvm::function_ref
+CaptureBuffer) const {
+  for (auto &Mapping : FromToMappings) {
+if (const FileEntry *FE = Mapping.second.dyn_cast()) {
+  CaptureFile(Mapping.first->getName(), FE->getName());
+  continue;
+}
+CaptureBuffer(
+Mapping.first->getName(),
+Mapping.second.get()->getMemBufferRef());
+  }
+}
+
 void FileRemapper::applyMappings(PreprocessorOptions &PPOpts) const {
   for (MappingsTy::const_iterator
  I = FromToMappings.begin(), E = FromToMappings.end(); I != E; ++I) {

diff  --git a/clang/tools/arcmt-test/arcmt-test.cpp 
b/clang/tools/arcmt-test/arcmt-test.cpp
index c4ba12d4f7cf..940e622b8a68 100644
--- a/clang/tools/arcmt-test/arcmt-test.cpp
+++ b/clang/tools/arcmt-test/arcmt-test.cpp
@@ -139,11 +139,10 @@ static bool checkForMigration(StringRef resourcesPath,
 }
 
 static void printResult(FileRemapper &remapper, raw_ostream &OS) {
-  PreprocessorOptions PPOpts;
-  remapper.applyMappings(PPOpts);
-  // The changed files will be in memory buffers, print them.
-  for (const auto &RB : PPOpts.RemappedFileBuffers)
-OS << RB.second->getBuffer();
+  remapper.forEachMapping([](StringRef, StringRef) {},
+  [&](StringRef, const llvm::MemoryBufferRef &Buffer) {
+OS << Buffer.getBuffer();
+  });
 }
 
 static bool performTransformations(StringRef resourcesPath,



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


[PATCH] D92480: [llvm] Unify interface of (ThreadSafe)?RefCountedBase

2020-12-02 Thread Nathan James via Phabricator via cfe-commits
njames93 added reviewers: chandlerc, dblaikie.
njames93 added inline comments.



Comment at: clang/lib/ASTMatchers/ASTMatchersInternal.cpp:190-196
+// Use a custom deleter for the TrueMatcherInstance ManagedStatic. This 
prevents
+// an assert firing when the refcount is nonzero while running its destructor.
+struct DynMatcherInterfaceDeleter {
+  static void call(void *Ptr) {
+static_cast(Ptr)->Release();
+  }
+};

Is this a case that happens in other places, ManagedStatics holding RefCounted 
objects, if so this could be extracted and reused in other places.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92480/new/

https://reviews.llvm.org/D92480

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


[PATCH] D92480: [llvm] Unify interface of (ThreadSafe)?RefCountedBase

2020-12-02 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir removed a reviewer: benlangmuir.
benlangmuir added a comment.

Removing myself as reviewer since I no longer work in this area.  Someone who 
is more involved with llvm Support/ADT should review this.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92480/new/

https://reviews.llvm.org/D92480

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


[clang] 3a781b9 - Fix assertion in tryEmitAsConstant

2020-12-02 Thread Yaxun Liu via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2020-12-02T19:10:01-05:00
New Revision: 3a781b912fc7b492a21fe52cc8ce6c9e5854a9ab

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

LOG: Fix assertion in tryEmitAsConstant

due to cd95338ee3022bffd658e52cd3eb9419b4c218ca

Need to check if result is LValue before getLValueBase.

Added: 


Modified: 
clang/lib/CodeGen/CGExpr.cpp
clang/test/CodeGenCUDA/lambda-reference-var.cu

Removed: 




diff  --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 92d0cba7a733..11914b6cd9fb 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -1529,7 +1529,7 @@ CodeGenFunction::tryEmitAsConstant(DeclRefExpr *refExpr) {
   // global variable as compile time constant, since the host variable is not
   // accessible on device. The DRE of the captured reference variable has to be
   // loaded from captures.
-  if (CGM.getLangOpts().CUDAIsDevice &&
+  if (CGM.getLangOpts().CUDAIsDevice && result.Val.isLValue() &&
   refExpr->refersToEnclosingVariableOrCapture()) {
 auto *MD = dyn_cast_or_null(CurCodeDecl);
 if (MD && MD->getParent()->isLambda() &&

diff  --git a/clang/test/CodeGenCUDA/lambda-reference-var.cu 
b/clang/test/CodeGenCUDA/lambda-reference-var.cu
index 6d7b343b3193..44b012956507 100644
--- a/clang/test/CodeGenCUDA/lambda-reference-var.cu
+++ b/clang/test/CodeGenCUDA/lambda-reference-var.cu
@@ -27,6 +27,15 @@ __device__ void dev_capture_dev_ref_by_copy(int *out) {
   [=](){ *out = ref;}();
 }
 
+// DEV-LABEL: @_ZZ28dev_capture_dev_rval_by_copyPiENKUlvE_clEv(
+// DEV: store i32 3
+__device__ void dev_capture_dev_rval_by_copy(int *out) {
+  constexpr int a = 1;
+  constexpr int b = 2;
+  constexpr int c = a + b;
+  [=](){ *out = c;}();
+}
+
 // DEV-LABEL: @_ZZ26dev_capture_dev_ref_by_refPiENKUlvE_clEv(
 // DEV: %[[VAL:.*]] = load i32, i32* addrspacecast (i32 addrspace(1)* 
@global_device_var to i32*)
 // DEV: %[[VAL2:.*]] = add nsw i32 %[[VAL]], 1



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


[PATCH] D92480: [llvm] Unify interface of (ThreadSafe)?RefCountedBase

2020-12-02 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 309093.
njames93 added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Fix assertion due to a pointer stored in a ManagedStatic.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92480/new/

https://reviews.llvm.org/D92480

Files:
  clang/lib/ASTMatchers/ASTMatchersInternal.cpp
  llvm/include/llvm/ADT/IntrusiveRefCntPtr.h


Index: llvm/include/llvm/ADT/IntrusiveRefCntPtr.h
===
--- llvm/include/llvm/ADT/IntrusiveRefCntPtr.h
+++ llvm/include/llvm/ADT/IntrusiveRefCntPtr.h
@@ -70,10 +70,27 @@
 template  class RefCountedBase {
   mutable unsigned RefCount = 0;
 
-public:
+protected:
   RefCountedBase() = default;
+  // Copy and move constructors/assignments are no-ops as the RefCount isn't
+  // dictated by the class directly.
   RefCountedBase(const RefCountedBase &) {}
+  RefCountedBase(RefCountedBase &&) {}
+  RefCountedBase &operator=(const RefCountedBase &) { return *this; }
+  RefCountedBase &operator=(RefCountedBase &&) { return *this; }
+
+#ifndef NDEBUG
+  ~RefCountedBase() {
+assert(RefCount == 0 &&
+   "Destruction occured when there are still references to this.");
+  }
+#else
+  // Default the destructor in release builds, A trivial destructor may enable
+  // better codegen.
+  ~RefCountedBase() = default;
+#endif
 
+public:
   void Retain() const { ++RefCount; }
 
   void Release() const {
@@ -85,10 +102,29 @@
 
 /// A thread-safe version of \c RefCountedBase.
 template  class ThreadSafeRefCountedBase {
-  mutable std::atomic RefCount;
+  mutable std::atomic RefCount{0};
 
 protected:
-  ThreadSafeRefCountedBase() : RefCount(0) {}
+  ThreadSafeRefCountedBase() = default;
+  ThreadSafeRefCountedBase(const ThreadSafeRefCountedBase &) {}
+  ThreadSafeRefCountedBase(ThreadSafeRefCountedBase &&) {}
+  ThreadSafeRefCountedBase &operator=(const ThreadSafeRefCountedBase &) {
+return *this;
+  }
+  ThreadSafeRefCountedBase &operator=(ThreadSafeRefCountedBase &&) {
+return *this;
+  }
+
+#ifndef NDEBUG
+  ~ThreadSafeRefCountedBase() {
+assert(RefCount == 0 &&
+   "Destruction occured when there are still references to this.");
+  }
+#else
+  // Default the destructor in release builds, A trivial destructor may enable
+  // better codegen.
+  ~ThreadSafeRefCountedBase() = default;
+#endif
 
 public:
   void Retain() const { RefCount.fetch_add(1, std::memory_order_relaxed); }
Index: clang/lib/ASTMatchers/ASTMatchersInternal.cpp
===
--- clang/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ clang/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -187,9 +187,20 @@
   IntrusiveRefCntPtr InnerMatcher;
 };
 
+// Use a custom deleter for the TrueMatcherInstance ManagedStatic. This 
prevents
+// an assert firing when the refcount is nonzero while running its destructor.
+struct DynMatcherInterfaceDeleter {
+  static void call(void *Ptr) {
+static_cast(Ptr)->Release();
+  }
+};
+
 } // namespace
 
-static llvm::ManagedStatic TrueMatcherInstance;
+static llvm::ManagedStatic,
+   DynMatcherInterfaceDeleter>
+TrueMatcherInstance;
 
 bool ASTMatchFinder::isTraversalIgnoringImplicitNodes() const {
   return getASTContext().getParentMapContext().getTraversalKind() ==


Index: llvm/include/llvm/ADT/IntrusiveRefCntPtr.h
===
--- llvm/include/llvm/ADT/IntrusiveRefCntPtr.h
+++ llvm/include/llvm/ADT/IntrusiveRefCntPtr.h
@@ -70,10 +70,27 @@
 template  class RefCountedBase {
   mutable unsigned RefCount = 0;
 
-public:
+protected:
   RefCountedBase() = default;
+  // Copy and move constructors/assignments are no-ops as the RefCount isn't
+  // dictated by the class directly.
   RefCountedBase(const RefCountedBase &) {}
+  RefCountedBase(RefCountedBase &&) {}
+  RefCountedBase &operator=(const RefCountedBase &) { return *this; }
+  RefCountedBase &operator=(RefCountedBase &&) { return *this; }
+
+#ifndef NDEBUG
+  ~RefCountedBase() {
+assert(RefCount == 0 &&
+   "Destruction occured when there are still references to this.");
+  }
+#else
+  // Default the destructor in release builds, A trivial destructor may enable
+  // better codegen.
+  ~RefCountedBase() = default;
+#endif
 
+public:
   void Retain() const { ++RefCount; }
 
   void Release() const {
@@ -85,10 +102,29 @@
 
 /// A thread-safe version of \c RefCountedBase.
 template  class ThreadSafeRefCountedBase {
-  mutable std::atomic RefCount;
+  mutable std::atomic RefCount{0};
 
 protected:
-  ThreadSafeRefCountedBase() : RefCount(0) {}
+  ThreadSafeRefCountedBase() = default;
+  ThreadSafeRefCountedBase(const ThreadSafeRefCountedBase &) {}
+  ThreadSafeRefCountedBase(ThreadSafeRefCountedBase &&) {}
+  ThreadSafeRefCountedBase &operator=(const ThreadSafeRefCountedBase &) {
+return *this;
+  }
+  Threa

[PATCH] D92516: ADT: Migrate users of AlignedCharArrayUnion to std::aligned_union_t, NFC

2020-12-02 Thread David Blaikie via Phabricator via cfe-commits
dblaikie accepted this revision.
dblaikie added a comment.
This revision is now accepted and ready to land.

Looks good to me!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92516/new/

https://reviews.llvm.org/D92516

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


[PATCH] D92516: ADT: Migrate users of AlignedCharArrayUnion to std::aligned_union_t, NFC

2020-12-02 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith created this revision.
dexonsmith added reviewers: rnk, dblaikie.
Herald added subscribers: ributzka, jfb, hiraditya.
Herald added projects: clang, LLVM.
dexonsmith requested review of this revision.

Prepare to delete `AlignedCharArrayUnion` by migrating its users over to
`std::aligned_union_t`.

I will delete `AlignedCharArrayUnion` and its tests in a follow-up
commit so that it's easier to revert in isolation in case some
downstream wants to keep using it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92516

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

Index: llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
===
--- llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
+++ llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
@@ -26,7 +26,6 @@
 #include "llvm/IR/PatternMatch.h"
 #include "llvm/IR/Type.h"
 #include "llvm/IR/Value.h"
-#include "llvm/Support/AlignOf.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/KnownBits.h"
 #include "llvm/Transforms/InstCombine/InstCombiner.h"
@@ -120,7 +119,7 @@
 // is overkill of this end.
 short IntVal = 0;
 
-AlignedCharArrayUnion FpValBuf;
+std::aligned_union_t<1, APFloat> FpValBuf;
   };
 
   /// FAddend is used to represent floating-point addend. An addend is
Index: llvm/include/llvm/Support/YAMLTraits.h
===
--- llvm/include/llvm/Support/YAMLTraits.h
+++ llvm/include/llvm/Support/YAMLTraits.h
@@ -15,7 +15,6 @@
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/Twine.h"
-#include "llvm/Support/AlignOf.h"
 #include "llvm/Support/Allocator.h"
 #include "llvm/Support/Endian.h"
 #include "llvm/Support/Regex.h"
@@ -1311,7 +1310,7 @@
   TNorm* operator->() { return BufPtr; }
 
 private:
-  using Storage = AlignedCharArrayUnion;
+  using Storage = std::aligned_union_t<1, TNorm>;
 
   Storage   Buffer;
   IO   &io;
@@ -1348,7 +1347,7 @@
   TNorm* operator->() { return BufPtr; }
 
 private:
-  using Storage = AlignedCharArrayUnion;
+  using Storage = std::aligned_union_t<1, TNorm>;
 
   Storage   Buffer;
   IO   &io;
Index: llvm/include/llvm/Support/TrailingObjects.h
===
--- llvm/include/llvm/Support/TrailingObjects.h
+++ llvm/include/llvm/Support/TrailingObjects.h
@@ -46,7 +46,6 @@
 #ifndef LLVM_SUPPORT_TRAILINGOBJECTS_H
 #define LLVM_SUPPORT_TRAILINGOBJECTS_H
 
-#include "llvm/Support/AlignOf.h"
 #include "llvm/Support/Alignment.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/MathExtras.h"
Index: llvm/include/llvm/Support/JSON.h
===
--- llvm/include/llvm/Support/JSON.h
+++ llvm/include/llvm/Support/JSON.h
@@ -479,8 +479,8 @@
   };
   // All members mutable, see moveFrom().
   mutable ValueType Type;
-  mutable llvm::AlignedCharArrayUnion
+  mutable std::aligned_union_t<1, bool, double, int64_t, llvm::StringRef,
+   std::string, json::Array, json::Object>
   Union;
   friend bool operator==(const Value &, const Value &);
 };
Index: llvm/include/llvm/Support/ErrorOr.h
===
--- llvm/include/llvm/Support/ErrorOr.h
+++ llvm/include/llvm/Support/ErrorOr.h
@@ -15,7 +15,6 @@
 #ifndef LLVM_SUPPORT_ERROROR_H
 #define LLVM_SUPPORT_ERROROR_H
 
-#include "llvm/Support/AlignOf.h"
 #include 
 #include 
 #include 
@@ -253,8 +252,8 @@
   }
 
   union {
-AlignedCharArrayUnion TStorage;
-AlignedCharArrayUnion ErrorStorage;
+std::aligned_union_t<1, storage_type> TStorage;
+std::aligned_union_t<1, std::error_code> ErrorStorage;
   };
   bool HasError : 1;
 };
Index: llvm/include/llvm/Support/Error.h
===
--- llvm/include/llvm/Support/Error.h
+++ llvm/include/llvm/Support/Error.h
@@ -19,7 +19,6 @@
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/Twine.h"
 #include "llvm/Config/abi-breaking.h"
-#include "llvm/Support/AlignOf.h"
 #include "llvm/Support/Compile

[PATCH] D92512: ADT: Change AlignedCharArrayUnion to an alias of std::aligned_union_t, NFC

2020-12-02 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added inline comments.



Comment at: clang/include/clang/AST/APValue.h:405
 assert(isInt() && "Invalid accessor");
-return *(APSInt*)(char*)Data.buffer;
+return *(APSInt *)(char *)&Data;
   }

shafik wrote:
> I notice that in `ASTTypeTraits.h` we use `reinterpret_cast` while here we 
> revert to C-style casts.
Yes, this old code probably predates C++11. It'd be nice to fix it, but that 
seems out of scope for this patch.



Comment at: clang/include/clang/AST/APValue.h:511
 assert(isArray() && "Invalid accessor");
-return ((const Arr*)(const void *)Data.buffer)->NumElts;
+return ((const Arr *)(const void *)&Data)->NumElts;
   }

shafik wrote:
> What is it `char *` in some cases and `void*` in others?
> What is it `char *` in some cases and `void*` in others?

Agreed it's inconsistent! I'd have to guess the original authors here had a 
different ideas about which type was more fundamental.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92512/new/

https://reviews.llvm.org/D92512

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


[PATCH] D92512: ADT: Change AlignedCharArrayUnion to an alias of std::aligned_union_t, NFC

2020-12-02 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added inline comments.



Comment at: clang/include/clang/AST/APValue.h:405
 assert(isInt() && "Invalid accessor");
-return *(APSInt*)(char*)Data.buffer;
+return *(APSInt *)(char *)&Data;
   }

I notice that in `ASTTypeTraits.h` we use `reinterpret_cast` while here we 
revert to C-style casts.



Comment at: clang/include/clang/AST/APValue.h:511
 assert(isArray() && "Invalid accessor");
-return ((const Arr*)(const void *)Data.buffer)->NumElts;
+return ((const Arr *)(const void *)&Data)->NumElts;
   }

What is it `char *` in some cases and `void*` in others?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92512/new/

https://reviews.llvm.org/D92512

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


[PATCH] D92512: ADT: Change AlignedCharArrayUnion to an alias of std::aligned_union_t, NFC

2020-12-02 Thread David Blaikie via Phabricator via cfe-commits
dblaikie accepted this revision.
dblaikie added a comment.

Yeah, looks good to me - I'd probably go with your suggestion of committing the 
cleanup pre-emptively, then the alias change. But dealer's choice.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92512/new/

https://reviews.llvm.org/D92512

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


[PATCH] D92512: ADT: Change AlignedCharArrayUnion to an alias of std::aligned_union_t, NFC

2020-12-02 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

Sorry, racing updates. I agree, landing them together is better, since there is 
risk that some corner case platform won't have this support.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92512/new/

https://reviews.llvm.org/D92512

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


[PATCH] D92512: ADT: Change AlignedCharArrayUnion to an alias of std::aligned_union_t, NFC

2020-12-02 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith updated this revision to Diff 309071.
dexonsmith added a comment.

Fix some build errors on the clang side of the patch.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92512/new/

https://reviews.llvm.org/D92512

Files:
  clang/include/clang/AST/APValue.h
  clang/include/clang/AST/ASTTypeTraits.h
  clang/include/clang/AST/ParentMapContext.h
  clang/lib/AST/APValue.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/Frontend/PrecompiledPreamble.cpp
  llvm/include/llvm/ADT/DenseMap.h
  llvm/include/llvm/ADT/IntervalMap.h
  llvm/include/llvm/CodeGen/DIE.h
  llvm/include/llvm/Support/AlignOf.h
  llvm/include/llvm/Support/Error.h
  llvm/include/llvm/Support/ErrorOr.h
  llvm/include/llvm/Support/JSON.h
  llvm/lib/Support/JSON.cpp
  llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp

Index: llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
===
--- llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
+++ llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
@@ -82,11 +82,11 @@
   private:
 bool insaneIntVal(int V) { return V > 4 || V < -4; }
 
-APFloat *getFpValPtr()
-  { return reinterpret_cast(&FpValBuf.buffer[0]); }
+APFloat *getFpValPtr() { return reinterpret_cast(&FpValBuf); }
 
-const APFloat *getFpValPtr() const
-  { return reinterpret_cast(&FpValBuf.buffer[0]); }
+const APFloat *getFpValPtr() const {
+  return reinterpret_cast(&FpValBuf);
+}
 
 const APFloat &getFpVal() const {
   assert(IsFp && BufHasFpVal && "Incorret state");
Index: llvm/lib/Support/JSON.cpp
===
--- llvm/lib/Support/JSON.cpp
+++ llvm/lib/Support/JSON.cpp
@@ -109,7 +109,7 @@
   case T_Boolean:
   case T_Double:
   case T_Integer:
-memcpy(Union.buffer, M.Union.buffer, sizeof(Union.buffer));
+memcpy(&Union, &M.Union, sizeof(Union));
 break;
   case T_StringRef:
 create(M.as());
@@ -133,7 +133,7 @@
   case T_Boolean:
   case T_Double:
   case T_Integer:
-memcpy(Union.buffer, M.Union.buffer, sizeof(Union.buffer));
+memcpy(&Union, &M.Union, sizeof(Union));
 break;
   case T_StringRef:
 create(M.as());
Index: llvm/include/llvm/Support/JSON.h
===
--- llvm/include/llvm/Support/JSON.h
+++ llvm/include/llvm/Support/JSON.h
@@ -456,12 +456,12 @@
   friend class Object;
 
   template  void create(U &&... V) {
-new (reinterpret_cast(Union.buffer)) T(std::forward(V)...);
+new (reinterpret_cast(&Union)) T(std::forward(V)...);
   }
   template  T &as() const {
 // Using this two-step static_cast via void * instead of reinterpret_cast
 // silences a -Wstrict-aliasing false positive from GCC6 and earlier.
-void *Storage = static_cast(Union.buffer);
+void *Storage = static_cast(&Union);
 return *static_cast(Storage);
   }
 
Index: llvm/include/llvm/Support/ErrorOr.h
===
--- llvm/include/llvm/Support/ErrorOr.h
+++ llvm/include/llvm/Support/ErrorOr.h
@@ -235,17 +235,17 @@
 
   storage_type *getStorage() {
 assert(!HasError && "Cannot get value when an error exists!");
-return reinterpret_cast(TStorage.buffer);
+return reinterpret_cast(&TStorage);
   }
 
   const storage_type *getStorage() const {
 assert(!HasError && "Cannot get value when an error exists!");
-return reinterpret_cast(TStorage.buffer);
+return reinterpret_cast(&TStorage);
   }
 
   std::error_code *getErrorStorage() {
 assert(HasError && "Cannot get error when a value exists!");
-return reinterpret_cast(ErrorStorage.buffer);
+return reinterpret_cast(&ErrorStorage);
   }
 
   const std::error_code *getErrorStorage() const {
Index: llvm/include/llvm/Support/Error.h
===
--- llvm/include/llvm/Support/Error.h
+++ llvm/include/llvm/Support/Error.h
@@ -629,22 +629,22 @@
 
   storage_type *getStorage() {
 assert(!HasError && "Cannot get value when an error exists!");
-return reinterpret_cast(TStorage.buffer);
+return reinterpret_cast(&TStorage);
   }
 
   const storage_type *getStorage() const {
 assert(!HasError && "Cannot get value when an error exists!");
-return reinterpret_cast(TStorage.buffer);
+return reinterpret_cast(&TStorage);
   }
 
   error_type *getErrorStorage() {
 assert(HasError && "Cannot get error when a value exists!");
-return reinterpret_cast(ErrorStorage.buffer);
+return reinterpret_cast(&ErrorStorage);
   }
 
   const error_type *getErrorStorage() const {
 assert(HasError && "Cannot get error when a value exists!");
-return reinterpret_cast(ErrorStorage.buffer);
+return reinterpret_cast(&ErrorStorage);
   }
 
   // Used by ExpectedAsOutParameter to reset the checked flag.
Index: llvm/include/llvm/Support/AlignOf.h
===

[PATCH] D92512: ADT: Change AlignedCharArrayUnion to an alias of std::aligned_union_t, NFC

2020-12-02 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

Looks good to me.




Comment at: llvm/include/llvm/Support/ErrorOr.h:256-257
   union {
 AlignedCharArrayUnion TStorage;
 AlignedCharArrayUnion ErrorStorage;
   };

This union of unions of one type seems silly. I think there can be as single 
`Storage` field. Anyway, fixing this is not in scope for this patch.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92512/new/

https://reviews.llvm.org/D92512

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


[PATCH] D92439: [CLANG] Fix missing error for use of 128-bit integer inside SPIR64 device code.

2020-12-02 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 added inline comments.



Comment at: clang/lib/Sema/Sema.cpp:241
+  (Context.getAuxTargetInfo() &&
+   Context.getAuxTargetInfo()->hasInt128Type())) {
 // If either of the 128-bit integer types are unavailable to name lookup,

jdoerfert wrote:
> jyu2 wrote:
> > jyu2 wrote:
> > > jdoerfert wrote:
> > > > jyu2 wrote:
> > > > > jdoerfert wrote:
> > > > > > I don't understand why this (and the changes below) are necessary. 
> > > > > > Host and device compilation are separate. This should not be any 
> > > > > > different to CUDA, HIP, or OpenMP offload which seem not to require 
> > > > > > this.
> > > > > As far as I can know, in real compile, the auxtarget should be also 
> > > > > set for example SYCL.  May be that is only for our compiler.  I am 
> > > > > not sure what do you mean by it should same with CUDA, HIP...?  Do 
> > > > > you mean, CUDA(or HIP...) target should also not support 128-bit 
> > > > > integer?  If so, I don't see any error emit for CUDA when I try with 
> > > > > nvptx64-nvidia-cuda.
> > > > > 
> > > > > Thanks.
> > > > > 
> > > > I'm not saying auxtarget is not set. I'm trying to understand why this 
> > > > is necessary. Why would you initialize `__int128_t` if your target 
> > > > doesn't support it? What happens if you only include the SPIR.h change?
> > > Without this change you will see error:
> > > 
> > > j3.c:2:15: error: unknown type name '__uint128_t'
> > > typedef const __uint128_t  megeType;
> > > 
> > > bash-4.4$ cat j3.c
> > > 
> > > typedef const __uint128_t  megeType;
> > > 
> > > Without change in SemaOverload.c:
> > > you will see error:
> > > x.cpp:3:14: error: use of overloaded operator '==' is ambiguous (with 
> > > operand types 'struct X' and '__int128')
> > >   bool a = x == __int128(0);
> > >~ ^  ~~~
> > > 
> > > bash-4.4$ cat x.cpp
> > > namespace PR12964 {
> > >   struct X { operator  __int128() const; } x;
> > >   bool a = x == __int128(0);
> > > }
> > > 
> > > 
> > > 
> > Just one more point, the errors only need to be emitted for 128-bit integer 
> > used inside device code.  The test case above 128-bit integer is not used 
> > in device code, so we don't want to emit error for it.
> > 
> > Thanks.
> > Jennifer
> I see. You want the types to be there so the diagnostic says the types are 
> not available. OK, fine by me.
Thank you so much for your time for review this!!!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92439/new/

https://reviews.llvm.org/D92439

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


[PATCH] D88220: [C++20] P1825R0: More implicit moves

2020-12-02 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added a subscriber: davidstone.
Quuxplusone added inline comments.



Comment at: clang/test/CXX/class/class.init/class.copy.elision/p3.cpp:22
+  return c;
+}
+#else

Quuxplusone wrote:
> @rsmith @david_stone (or anyone), what is the status in C++20 of the 
> following test case?
> 
> C&& test(C&& c) {
> return c;
> }
> 
> I know we talked about this in person at CppCon 2018, and concluded that our 
> //intention// was for this to be legal, but that it wasn't actually legal 
> as-worded, because the returned thingie here is not an object but rather a 
> reference, and therefore none of 
> [P1825's](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1825r0.html)
>  wording actually covers it. Is that still the case? Is there an open issue 
> about this? Is there any appetite for Clang to just go ahead and //make// 
> this legal?  (The current patch does //not// make this legal.)
> 
> Relevant reading: 
> https://quuxplusone.github.io/blog/2018/09/25/perfect-backwarding/
Apparently @davidstone has been active more recently than @david_stone... :)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88220/new/

https://reviews.llvm.org/D88220

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


[PATCH] D92439: [CLANG] Fix missing error for use of 128-bit integer inside SPIR64 device code.

2020-12-02 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 updated this revision to Diff 309067.
jyu2 retitled this revision from "Fix missing error for use of 128-bit integer 
inside SPIR64 device code." to "[CLANG] Fix missing error for use of 128-bit 
integer inside SPIR64 device code.".
jyu2 added a comment.

Fix problem with @jdoerfert pointed where using bool hasInt128Type() const 
override { return false; } instead.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92439/new/

https://reviews.llvm.org/D92439

Files:
  clang/lib/Basic/Targets/SPIR.h
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/CodeGen/ext-int-cc.c
  clang/test/SemaSYCL/int128.cpp

Index: clang/test/SemaSYCL/int128.cpp
===
--- /dev/null
+++ clang/test/SemaSYCL/int128.cpp
@@ -0,0 +1,118 @@
+// RUN: %clang_cc1 -triple spir64 -aux-triple x86_64-unknown-linux-gnu \
+// RUN:-fsycl -fsycl-is-device -verify -fsyntax-only %s
+
+typedef __uint128_t BIGTY;
+
+template 
+class Z {
+public:
+  // expected-note@+1 {{'field' defined here}}
+  T field;
+  // expected-note@+1 2{{'field1' defined here}}
+  __int128 field1;
+  using BIGTYPE = __int128;
+  // expected-note@+1 {{'bigfield' defined here}}
+  BIGTYPE bigfield;
+};
+
+void host_ok(void) {
+  __int128 A;
+  int B = sizeof(__int128);
+  Z<__int128> C;
+  C.field1 = A;
+}
+
+void usage() {
+  // expected-note@+1 3{{'A' defined here}}
+  __int128 A;
+  Z<__int128> C;
+  // expected-error@+2 {{'A' requires 128 bit size '__int128' type support, but device 'spir64' does not support it}}
+  // expected-error@+1 {{'field1' requires 128 bit size '__int128' type support, but device 'spir64' does not support it}}
+  C.field1 = A;
+  // expected-error@+1 {{'bigfield' requires 128 bit size 'Z::BIGTYPE' (aka '__int128') type support, but device 'spir64' does not support it}}
+  C.bigfield += 1.0;
+
+  // expected-error@+1 {{'A' requires 128 bit size '__int128' type support, but device 'spir64' does not support it}}
+  auto foo1 = [=]() {
+__int128 AA;
+// expected-note@+2 {{'BB' defined here}}
+// expected-error@+1 {{'A' requires 128 bit size '__int128' type support, but device 'spir64' does not support it}}
+auto BB = A;
+// expected-error@+1 {{'BB' requires 128 bit size '__int128' type support, but device 'spir64' does not support it}}
+BB += 1;
+  };
+
+  // expected-note@+1 {{called by 'usage'}}
+  foo1();
+}
+
+template 
+void foo2(){};
+
+// expected-note@+3 {{'P' defined here}}
+// expected-error@+2 {{'P' requires 128 bit size '__int128' type support, but device 'spir64' does not support it}}
+// expected-note@+1 2{{'foo' defined here}}
+__int128 foo(__int128 P) { return P; }
+
+void foobar() {
+  // expected-note@+1 {{'operator __int128' defined here}}
+  struct X { operator  __int128() const; } x;
+  bool a = false;
+  // expected-error@+1 {{'operator __int128' requires 128 bit size '__int128' type support, but device 'spir64' does not support it}}
+  a = x == __int128(0);
+}
+
+template 
+__attribute__((sycl_kernel)) void kernel(Func kernelFunc) {
+  // expected-note@+1 6{{called by 'kernel}}
+  kernelFunc();
+}
+
+int main() {
+  // expected-note@+1 {{'CapturedToDevice' defined here}}
+  __int128 CapturedToDevice = 1;
+  host_ok();
+  kernel([=]() {
+decltype(CapturedToDevice) D;
+// expected-error@+1 {{'CapturedToDevice' requires 128 bit size '__int128' type support, but device 'spir64' does not support it}}
+auto C = CapturedToDevice;
+Z<__int128> S;
+// expected-error@+1 {{'field1' requires 128 bit size '__int128' type support, but device 'spir64' does not support it}}
+S.field1 += 1;
+// expected-error@+1 {{'field' requires 128 bit size '__int128' type support, but device 'spir64' does not support it}}
+S.field = 1;
+  });
+
+  kernel([=]() {
+// expected-note@+1 2{{called by 'operator()'}}
+usage();
+// expected-note@+1 {{'' defined here}}
+BIGTY ;
+// expected-error@+3 {{'' requires 128 bit size 'BIGTY' (aka 'unsigned __int128') type support, but device 'spir64' does not support it}}
+// expected-error@+2 2{{'foo' requires 128 bit size '__int128' type support, but device 'spir64' does not support it}}
+// expected-note@+1 1{{called by 'operator()'}}
+auto A = foo();
+// expected-note@+1 {{called by 'operator()'}}
+foobar();
+  });
+
+  kernel([=]() {
+Z<__int128> S;
+foo2<__int128>();
+auto A = sizeof(CapturedToDevice);
+  });
+
+  return 0;
+}
+
+// no error expected
+BIGTY zoo(BIGTY h) {
+  h = 1;
+  return h;
+}
+
+namespace PR12964 {
+  struct X { operator  __int128() const; } x;
+  bool a = x == __int128(0);
+}
+
Index: clang/test/CodeGen/ext-int-cc.c
===
--- clang/test/CodeGen/ext-int-cc.c
+++ clang/test/CodeGen/ext-int-cc.c
@@ -43,7 +43,7 @@
 // SPARC: define void @ParamPassing(i129* byval(i129) align 8 %{{.+}}, i128* by

[PATCH] D92512: ADT: Change AlignedCharArrayUnion to an alias of std::aligned_union_t, NFC

2020-12-02 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

Optionally, I could commit everything but the change to `AlignedCharArrayUnion` 
separately, just updating all the users to stop looking inside. If we think 
there's a chance of a revert that might be better...


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92512/new/

https://reviews.llvm.org/D92512

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


[PATCH] D92512: ADT: Change AlignedCharArrayUnion to an alias of std::aligned_union_t, NFC

2020-12-02 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith created this revision.
dexonsmith added a reviewer: rnk.
Herald added subscribers: ributzka, martong, hiraditya.
Herald added a reviewer: shafik.
Herald added projects: clang, LLVM.
dexonsmith requested review of this revision.

Update all the users of `AlignedCharArrayUnion` to stop peeking inside
(to look at `buffer`), and then finish gutting it. It's now an alias of
`std::aligned_union_t`, with a minor difference in template parameters
(`std::aligned_union_t` takes a minimum size and 0+ types, whereas this
just takes 1+ types... maybe a bit simpler to use correctly?).

A potential follow up would be to remove `AlignedCharArrayUnion`
entirely, inlining this alias into its users, but it's not clear to me
if that's better.

If https://reviews.llvm.org/D92500 lands without any issue, I think this should 
be safe as well.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92512

Files:
  clang/include/clang/AST/APValue.h
  clang/include/clang/AST/ASTTypeTraits.h
  clang/include/clang/AST/ParentMapContext.h
  clang/lib/AST/APValue.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/Frontend/PrecompiledPreamble.cpp
  llvm/include/llvm/ADT/DenseMap.h
  llvm/include/llvm/ADT/IntervalMap.h
  llvm/include/llvm/CodeGen/DIE.h
  llvm/include/llvm/Support/AlignOf.h
  llvm/include/llvm/Support/Error.h
  llvm/include/llvm/Support/ErrorOr.h
  llvm/include/llvm/Support/JSON.h
  llvm/lib/Support/JSON.cpp
  llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp

Index: llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
===
--- llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
+++ llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
@@ -82,11 +82,11 @@
   private:
 bool insaneIntVal(int V) { return V > 4 || V < -4; }
 
-APFloat *getFpValPtr()
-  { return reinterpret_cast(&FpValBuf.buffer[0]); }
+APFloat *getFpValPtr() { return reinterpret_cast(&FpValBuf); }
 
-const APFloat *getFpValPtr() const
-  { return reinterpret_cast(&FpValBuf.buffer[0]); }
+const APFloat *getFpValPtr() const {
+  return reinterpret_cast(&FpValBuf);
+}
 
 const APFloat &getFpVal() const {
   assert(IsFp && BufHasFpVal && "Incorret state");
Index: llvm/lib/Support/JSON.cpp
===
--- llvm/lib/Support/JSON.cpp
+++ llvm/lib/Support/JSON.cpp
@@ -109,7 +109,7 @@
   case T_Boolean:
   case T_Double:
   case T_Integer:
-memcpy(Union.buffer, M.Union.buffer, sizeof(Union.buffer));
+memcpy(&Union, &M.Union, sizeof(Union));
 break;
   case T_StringRef:
 create(M.as());
@@ -133,7 +133,7 @@
   case T_Boolean:
   case T_Double:
   case T_Integer:
-memcpy(Union.buffer, M.Union.buffer, sizeof(Union.buffer));
+memcpy(&Union, &M.Union, sizeof(Union));
 break;
   case T_StringRef:
 create(M.as());
Index: llvm/include/llvm/Support/JSON.h
===
--- llvm/include/llvm/Support/JSON.h
+++ llvm/include/llvm/Support/JSON.h
@@ -456,12 +456,12 @@
   friend class Object;
 
   template  void create(U &&... V) {
-new (reinterpret_cast(Union.buffer)) T(std::forward(V)...);
+new (reinterpret_cast(&Union)) T(std::forward(V)...);
   }
   template  T &as() const {
 // Using this two-step static_cast via void * instead of reinterpret_cast
 // silences a -Wstrict-aliasing false positive from GCC6 and earlier.
-void *Storage = static_cast(Union.buffer);
+void *Storage = static_cast(&Union);
 return *static_cast(Storage);
   }
 
Index: llvm/include/llvm/Support/ErrorOr.h
===
--- llvm/include/llvm/Support/ErrorOr.h
+++ llvm/include/llvm/Support/ErrorOr.h
@@ -235,17 +235,17 @@
 
   storage_type *getStorage() {
 assert(!HasError && "Cannot get value when an error exists!");
-return reinterpret_cast(TStorage.buffer);
+return reinterpret_cast(&TStorage);
   }
 
   const storage_type *getStorage() const {
 assert(!HasError && "Cannot get value when an error exists!");
-return reinterpret_cast(TStorage.buffer);
+return reinterpret_cast(&TStorage);
   }
 
   std::error_code *getErrorStorage() {
 assert(HasError && "Cannot get error when a value exists!");
-return reinterpret_cast(ErrorStorage.buffer);
+return reinterpret_cast(&ErrorStorage);
   }
 
   const std::error_code *getErrorStorage() const {
Index: llvm/include/llvm/Support/Error.h
===
--- llvm/include/llvm/Support/Error.h
+++ llvm/include/llvm/Support/Error.h
@@ -629,22 +629,22 @@
 
   storage_type *getStorage() {
 assert(!HasError && "Cannot get value when an error exists!");
-return reinterpret_cast(TStorage.buffer);
+return reinterpret_cast(&TStorage);
   }
 
   const storage_type *getStorage() const {
 assert(!HasError && "Cannot get value when a

[PATCH] D92439: Fix missing error for use of 128-bit integer inside SPIR64 device code.

2020-12-02 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

Still unsure if we should also error out for NVPTX but that is a different 
story. Looks OK from my side, assuming you address the earlier comment.

Maybe someone else should accept though.




Comment at: clang/lib/Sema/Sema.cpp:241
+  (Context.getAuxTargetInfo() &&
+   Context.getAuxTargetInfo()->hasInt128Type())) {
 // If either of the 128-bit integer types are unavailable to name lookup,

jyu2 wrote:
> jyu2 wrote:
> > jdoerfert wrote:
> > > jyu2 wrote:
> > > > jdoerfert wrote:
> > > > > I don't understand why this (and the changes below) are necessary. 
> > > > > Host and device compilation are separate. This should not be any 
> > > > > different to CUDA, HIP, or OpenMP offload which seem not to require 
> > > > > this.
> > > > As far as I can know, in real compile, the auxtarget should be also set 
> > > > for example SYCL.  May be that is only for our compiler.  I am not sure 
> > > > what do you mean by it should same with CUDA, HIP...?  Do you mean, 
> > > > CUDA(or HIP...) target should also not support 128-bit integer?  If so, 
> > > > I don't see any error emit for CUDA when I try with nvptx64-nvidia-cuda.
> > > > 
> > > > Thanks.
> > > > 
> > > I'm not saying auxtarget is not set. I'm trying to understand why this is 
> > > necessary. Why would you initialize `__int128_t` if your target doesn't 
> > > support it? What happens if you only include the SPIR.h change?
> > Without this change you will see error:
> > 
> > j3.c:2:15: error: unknown type name '__uint128_t'
> > typedef const __uint128_t  megeType;
> > 
> > bash-4.4$ cat j3.c
> > 
> > typedef const __uint128_t  megeType;
> > 
> > Without change in SemaOverload.c:
> > you will see error:
> > x.cpp:3:14: error: use of overloaded operator '==' is ambiguous (with 
> > operand types 'struct X' and '__int128')
> >   bool a = x == __int128(0);
> >~ ^  ~~~
> > 
> > bash-4.4$ cat x.cpp
> > namespace PR12964 {
> >   struct X { operator  __int128() const; } x;
> >   bool a = x == __int128(0);
> > }
> > 
> > 
> > 
> Just one more point, the errors only need to be emitted for 128-bit integer 
> used inside device code.  The test case above 128-bit integer is not used in 
> device code, so we don't want to emit error for it.
> 
> Thanks.
> Jennifer
I see. You want the types to be there so the diagnostic says the types are not 
available. OK, fine by me.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92439/new/

https://reviews.llvm.org/D92439

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


[PATCH] D91373: [OpenMP5.0] Support more kinds of lvalues in map clauses

2020-12-02 Thread Jacob Weightman via Phabricator via cfe-commits
jacobdweightman updated this revision to Diff 309056.
jacobdweightman added a comment.

I separated the handling of `ConditionalOperator`s and 
`BinaryConditionalOperator`s in order to eliminate handling of 
`OpaqueValueExpression`s in general, and asserted that the OVE's `SourceExpr` 
is not null. I also made some minor changes to improve readability.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91373/new/

https://reviews.llvm.org/D91373

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/target_map_messages.cpp
  clang/test/OpenMP/target_parallel_for_map_messages.cpp
  clang/test/OpenMP/target_parallel_for_simd_map_messages.cpp
  clang/test/OpenMP/target_parallel_map_messages.cpp
  clang/test/OpenMP/target_simd_map_messages.cpp
  clang/test/OpenMP/target_teams_distribute_map_messages.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_map_messages.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_simd_map_messages.cpp
  clang/test/OpenMP/target_teams_distribute_simd_map_messages.cpp
  clang/test/OpenMP/target_teams_map_messages.cpp
  clang/test/OpenMP/target_update_codegen.cpp
  clang/test/OpenMP/target_update_from_messages.cpp
  clang/test/OpenMP/target_update_to_messages.cpp

Index: clang/test/OpenMP/target_update_to_messages.cpp
===
--- clang/test/OpenMP/target_update_to_messages.cpp
+++ clang/test/OpenMP/target_update_to_messages.cpp
@@ -1,12 +1,12 @@
-// RUN: %clang_cc1 -verify=expected,le50 -fopenmp -ferror-limit 100 %s -Wno-openmp-mapping -Wuninitialized
-// RUN: %clang_cc1 -verify=expected,le45 -fopenmp -fopenmp-version=40 -ferror-limit 100 %s -Wno-openmp-mapping -Wuninitialized
-// RUN: %clang_cc1 -verify=expected,le45 -fopenmp -fopenmp-version=45 -ferror-limit 100 %s -Wno-openmp-mapping -Wuninitialized
-// RUN: %clang_cc1 -verify=expected,le50 -fopenmp -fopenmp-version=50 -ferror-limit 100 %s -Wno-openmp-mapping -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,le50 -fopenmp -ferror-limit 200 %s -Wno-openmp-mapping -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,le45 -fopenmp -fopenmp-version=40 -ferror-limit 200 %s -Wno-openmp-mapping -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,le45 -fopenmp -fopenmp-version=45 -ferror-limit 200 %s -Wno-openmp-mapping -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,le50 -fopenmp -fopenmp-version=50 -ferror-limit 200 %s -Wno-openmp-mapping -Wuninitialized
 
-// RUN: %clang_cc1 -verify=expected,le50 -fopenmp-simd -ferror-limit 100 %s -Wno-openmp-mapping -Wuninitialized
-// RUN: %clang_cc1 -verify=expected,le45 -fopenmp-simd -fopenmp-version=40 -ferror-limit 100 %s -Wno-openmp-mapping -Wuninitialized
-// RUN: %clang_cc1 -verify=expected,le45 -fopenmp-simd -fopenmp-version=45 -ferror-limit 100 %s -Wno-openmp-mapping -Wuninitialized
-// RUN: %clang_cc1 -verify=expected,le50 -fopenmp-simd -fopenmp-version=50 -ferror-limit 100 %s -Wno-openmp-mapping -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,le50 -fopenmp-simd -ferror-limit 200 %s -Wno-openmp-mapping -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,le45 -fopenmp-simd -fopenmp-version=40 -ferror-limit 200 %s -Wno-openmp-mapping -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,le45 -fopenmp-simd -fopenmp-version=45 -ferror-limit 200 %s -Wno-openmp-mapping -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,le50 -fopenmp-simd -fopenmp-version=50 -ferror-limit 200 %s -Wno-openmp-mapping -Wuninitialized
 
 void foo() {
 }
@@ -15,6 +15,14 @@
   return argc;
 }
 
+int &id(int &x) {
+  return x;
+}
+
+int *id2(int *x) {
+  return x;
+}
+
 struct S1; // expected-note 2 {{declared here}}
 extern S1 a;
 class S2 {
@@ -83,6 +91,12 @@
 double marr[10][5][10];
 #pragma omp target update to(marr [0:1][2:4][1:2]) // le45-error {{array section does not specify contiguous storage}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
 {}
+
+#pragma omp target update to(id)   // le45-error {{expected expression containing only member accesses and/or array sections based on named variables}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} le50-error {{expected addressable lvalue in 'to' clause}} le50-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+#pragma omp target update to(id(this->a))  // le45-error {{expected expression containing only member accesses and/or array sections based on named variables}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+#pragma omp target update to(id(id(this->a)))  // le45-error {{expected expression containing only member accesses and/or array sections based on named variables}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target 

[PATCH] D92101: [Clang][Sema] Attempt to fix CTAD faulty copy of non-local typedefs

2020-12-02 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.

In D92101#2428104 , @martong wrote:

> In D92101#2423685 , @shafik wrote:
>
>> Should we add a test for the `regular function template` case as well?
>
> I think this issue is specific for a `CXXDeductionGuideDecl` which is a 
> `FunctionDecl`. I am not sure if I can follow what kind of test do you 
> suggest, could you please be more specific?

Apologies, I think I meant this for another PR


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92101/new/

https://reviews.llvm.org/D92101

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


[PATCH] D92078: [asan] Default to -asan-use-private-alias=1

2020-12-02 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 309058.
MaskRay edited the summary of this revision.
MaskRay added a comment.
Herald added subscribers: cfe-commits, sunfish, aheejin, dschuff.
Herald added a project: clang.

Fix two clang/test/CodeGen tests


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92078/new/

https://reviews.llvm.org/D92078

Files:
  clang/test/CodeGen/asan-globals-odr.cpp
  clang/test/CodeGen/asan-static-odr.cpp
  compiler-rt/test/asan/TestCases/Linux/odr-violation.cpp
  compiler-rt/test/asan/TestCases/Linux/odr-vtable.cpp
  compiler-rt/test/asan/TestCases/Linux/odr_c_test.c
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
  llvm/test/Instrumentation/AddressSanitizer/global_metadata.ll
  llvm/test/Instrumentation/AddressSanitizer/global_metadata_darwin.ll
  llvm/test/Instrumentation/AddressSanitizer/local_alias.ll
  llvm/test/Instrumentation/AddressSanitizer/odr-check-ignore.ll

Index: llvm/test/Instrumentation/AddressSanitizer/odr-check-ignore.ll
===
--- llvm/test/Instrumentation/AddressSanitizer/odr-check-ignore.ll
+++ llvm/test/Instrumentation/AddressSanitizer/odr-check-ignore.ll
@@ -1,5 +1,5 @@
-; RUN: opt < %s -asan -asan-module -enable-new-pm=0 -S | FileCheck %s 
-; RUN: opt < %s -passes='asan-pipeline' -S | FileCheck %s 
+; RUN: opt < %s -asan -asan-module -asan-use-private-alias=0 -enable-new-pm=0 -S | FileCheck %s
+; RUN: opt < %s -passes='asan-pipeline' -asan-use-private-alias=0 -S | FileCheck %s
 
 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
Index: llvm/test/Instrumentation/AddressSanitizer/local_alias.ll
===
--- llvm/test/Instrumentation/AddressSanitizer/local_alias.ll
+++ llvm/test/Instrumentation/AddressSanitizer/local_alias.ll
@@ -1,11 +1,11 @@
-; RUN: opt < %s -asan -asan-module -enable-new-pm=0 -S | FileCheck %s --check-prefixes=CHECK-NOALIAS,CHECK-NOINDICATOR
-; RUN: opt < %s -passes='asan-pipeline' -S | FileCheck %s --check-prefixes=CHECK-NOALIAS,CHECK-NOINDICATOR
+; RUN: opt < %s -asan -asan-module -enable-new-pm=0 -S | FileCheck %s --check-prefixes=CHECK-ALIAS,CHECK-NOINDICATOR
+; RUN: opt < %s -passes='asan-pipeline' -S | FileCheck %s --check-prefixes=CHECK-ALIAS,CHECK-NOINDICATOR
 ; RUN: opt < %s -asan -asan-module -enable-new-pm=0 -asan-use-private-alias=1 -S | FileCheck %s --check-prefixes=CHECK-ALIAS,CHECK-NOINDICATOR
-; RUN: opt < %s -passes='asan-pipeline' -asan-use-private-alias=1 -S | FileCheck %s --check-prefixes=CHECK-ALIAS,CHECK-NOINDICATOR
-; RUN: opt < %s -asan -asan-module -enable-new-pm=0 -asan-use-odr-indicator=1 -S | FileCheck %s --check-prefixes=CHECK-INDICATOR,CHECK-NOALIAS
-; RUN: opt < %s -passes='asan-pipeline' -asan-use-odr-indicator=1 -S | FileCheck %s --check-prefixes=CHECK-INDICATOR,CHECK-NOALIAS
+; RUN: opt < %s -passes='asan-pipeline' -asan-use-private-alias=0 -S | FileCheck %s --check-prefixes=CHECK-NOALIAS,CHECK-NOINDICATOR
+; RUN: opt < %s -asan -asan-module -enable-new-pm=0 -asan-use-odr-indicator=1 -S | FileCheck %s --check-prefixes=CHECK-INDICATOR,CHECK-ALIAS
+; RUN: opt < %s -passes='asan-pipeline' -asan-use-odr-indicator=1 -S | FileCheck %s --check-prefixes=CHECK-INDICATOR,CHECK-ALIAS
 ; RUN: opt < %s -asan -asan-module -enable-new-pm=0 -asan-use-private-alias=1 -asan-use-odr-indicator=1 -S | FileCheck %s --check-prefixes=CHECK-ALIAS,CHECK-INDICATOR
-; RUN: opt < %s -passes='asan-pipeline' -asan-use-private-alias=1 -asan-use-odr-indicator=1 -S | FileCheck %s --check-prefixes=CHECK-ALIAS,CHECK-INDICATOR
+; RUN: opt < %s -passes='asan-pipeline' -asan-use-private-alias=0 -asan-use-odr-indicator=1 -S | FileCheck %s --check-prefixes=CHECK-NOALIAS,CHECK-INDICATOR
 
 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
Index: llvm/test/Instrumentation/AddressSanitizer/global_metadata_darwin.ll
===
--- llvm/test/Instrumentation/AddressSanitizer/global_metadata_darwin.ll
+++ llvm/test/Instrumentation/AddressSanitizer/global_metadata_darwin.ll
@@ -2,8 +2,8 @@
 ; allowing dead stripping to be performed, and that the appropriate runtime
 ; routines are invoked.
 
-; RUN: opt < %s -asan -asan-module -enable-new-pm=0 -asan-globals-live-support=1 -S | FileCheck %s
-; RUN: opt < %s -passes='asan-pipeline' -asan-globals-live-support=1 -S | FileCheck %s
+; RUN: opt < %s -asan -asan-module -enable-new-pm=0 -asan-use-private-alias=0 -asan-globals-live-support=1 -S | FileCheck %s
+; RUN: opt < %s -passes='asan-pipeline' -asan-use-private-alias=0 -asan-globals-live-support=1 -S | FileCheck %s
 
 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-apple-macosx10.11.0"
Index: llvm/test/Instrumentation/AddressSanitizer/global_metadata.ll
=

[PATCH] D91980: [OpenMP] Add initial support for `omp [begin/end] assumes`

2020-12-02 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticParseKinds.td:1296-1297
+: Error<"'#pragma omp end assumes' with no matching '#pragma omp begin 
assumes'">;
+def err_expected_assumption_clause
+: Error<"'%0' directive requires at least one clause">;
+def warn_omp_unknown_assumption_clause_missing_id

There is `err_omp_no_clause_for_directive` defined in Sema. See 
`Sema::ActOnOpenMPTargetDataDirective` how to use it, better to reduce the 
number of diagnostics if possible



Comment at: clang/lib/Sema/SemaLambda.cpp:999-1002
+  // OpenMP lambdas might get assumumption attributes.
+  if (LangOpts.OpenMP)
+ActOnFinishedFunctionDefinitionInOpenMPAssumeScope(Method);
+

Are there any other function-like constructs that also should have markings? 
Coroutines maybe? 



Comment at: clang/lib/Sema/SemaOpenMP.cpp:3203
+  auto *AA = AssumptionAttr::Create(Context, llvm::join(Assumptions, ","), 
Loc);
+  // Disable assumes in OpenMP simd mode.
+  if (DKind == llvm::omp::Directive::OMPD_begin_assumes) {

How this comment relates to the code?



Comment at: clang/lib/Sema/SemaOpenMP.cpp:3207
+  } else {
+assert(DKind == llvm::omp::Directive::OMPD_assumes && "");
+OMPAssumeGlobal.push_back(AA);

Add a message in for the assertion



Comment at: clang/lib/Sema/SemaOpenMP.cpp:3217
+while (Ctx->getParent())
+  Ctx = Ctx->getParent();
+DeclContexts.push_back(Ctx);

Maybe, better to use `getLexicalParent`? `getParent` returns semantic parent, 
while `getLexicalParent` - the lexical parent. Do you need to mark the 
declarations in the lexical context or in the semantic context?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91980/new/

https://reviews.llvm.org/D91980

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


[PATCH] D91373: [OpenMP5.0] Support more kinds of lvalues in map clauses

2020-12-02 Thread Jacob Weightman via Phabricator via cfe-commits
jacobdweightman added inline comments.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:16869
+// Allow results of method calls to be mapped.
+if (isa(ME->getMemberDecl())) {
+  RelevantExpr = ME;

ABataev wrote:
> I don't think it should always return `true`. What about `map(s.foo)` where 
> `foo` is a member function?
Hmm... I had previously added a test covering this on line 416 of 
target_map_messages.cpp which seemed to be passing, but not for the reason I 
thought. This program illustrates the difference:
```
struct Foo {
int x;
int &id() {
return x;
}
};

int x;
int &id() {
return x;
}

int main(void) {
Foo f;
#pragma omp target map(tofrom: id, f.id)
{}
}
```

The free function is parsed in `bool Parser::ParseOpenMPVarList` to this:
```
DeclRefExpr 0xfee3f8 'int &(void)' lvalue Function 0xfedc10 'id' 'int &(void)'
```

Whereas the method is parsed to this:
```
MemberExpr 0xfee438 '' .id 0xfeda00
`-DeclRefExpr 0xfee418 'struct Foo' lvalue Var 0xfede98 'f' 'struct Foo'
```

Note that the former is an lvalue, whereas the latter is not. Therefore, the 
latter emits the error "early" inside of `void checkMappableExpressionList` due 
to the `!RE->isLValue()` check near SemaOpenMP.cpp:17668 rather than in the 
`Visit*` methods. I guess the current error message is misleading given that 
`id` is still an lvalue, though. Perhaps it would be good to add a new message 
specifically for free functions since they are lvalues, but that issue already 
exists in Clang today and feels out of scope for this change. If you disagree, 
I wouldn't mind adding it.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:16939
+// forward to the source expression.
+return Visit(OVE->getSourceExpr()->IgnoreParenImpCasts());
+  }

ABataev wrote:
> Same, too general check, plus in some cases `OVE->getSourceExpr()` may return 
> `nullptr`.
I'm not exactly sure in what sense this check is too general, but perhaps it 
would be better to handle this together with the Elvis operator. For instance, 
I could have a `VisitBinaryConditionalOperator` which would "unwrap" the 
`OpaqueValueExpression` (OVA) directly rather than calling through to this 
method, since this is the only context in which we expect to handle OVAs. Let 
me know if this doesn't fully address your concern, though.

However, this usage of `getSourceExpr` appears to be consistent with other uses 
of OVAs that I see in Clang (I see a few similar examples in the static 
analyzer), but you make a good point. The Elvis operator's OVA should always 
have a source expression which refers to the condition without the implicit 
cast to bool. I'll add an assert that it isn't `nullptr` for now, but let me 
know if you have any other ideas.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:17072
   bool VisitUnaryOperator(UnaryOperator *UO) {
-if (SemaRef.getLangOpts().OpenMP < 50 || !UO->isLValue() ||
-UO->getOpcode() != UO_Deref) {
+if (SemaRef.getLangOpts().OpenMP < 50 ||
+(Components.empty() &&

ABataev wrote:
> What is this for?
This is a bit of a hack and definitely unclear to the reader. The 
`Components.empty()` check was added because an rvalue or a unary operator 
other than the de-referencing operator should be allowed in a sub-expression of 
the map clause list item, so long as the complete expression is an lvalue. As a 
minimal example, consider something like `map(*(&x))`. More usefully, one may 
cast pointer types so that a variable is mapped as a different type like 
`map(*((int *) &x))`. Without this check, the new casting tests which do this 
would fail.

A few ideas to make this more readable would be to use a temporary variable 
before the `if` statement like `bool isFullExpression = Components.empty();` or 
add a comment explaining the above. Do you have any other ideas for how to 
improve this?



Comment at: clang/lib/Sema/SemaOpenMP.cpp:17115-17124
+  bool VisitCallExpr(CallExpr *CE) {
+if (SemaRef.getLangOpts().OpenMP < 50 ||
+(Components.empty() && !CE->isLValue())) {
+  emitErrorMsg();
+  return false;
+}
+assert(!RelevantExpr && "RelevantExpr is expected to be nullptr");

ABataev wrote:
> ```
> int a;
> int &foo() {return a;}
> 
> ...
> #pragma omp target map(foo())
>  foo() = 0;
> ...
> 
> ```
> How is this supposed to work?
From my understanding of the spec, `foo` should be implicitly declared for both 
the host and the target. However, the user would be responsible for explicitly 
declaring `a` for the target if it isn't referenced in the `target` region. 
This test program seems to behave as I expect, with the result that `a = 2`:
```
#include 

int a;
#pragma omp declare target to(a)

int &foo() { return a; }

int main(void) {
a = 1;

#pragma omp target map(foo())
foo() = 2;

#pragma omp target update from(foo())

  

[PATCH] D78058: option to write files to memory instead of disk

2020-12-02 Thread Marc Rasi via Phabricator via cfe-commits
marcrasi added a comment.

Ping on this. Could anyone take a look?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D78058/new/

https://reviews.llvm.org/D78058

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


[PATCH] D92427: [OPENMP51] Add present modifier in defaultmap clause

2020-12-02 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen added inline comments.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:3490
+OMPC_MAP_MODIFIER_present);
+ImplicitMapModifierLoc[ClauseKind].push_back(SourceLocation());
+  }

ABataev wrote:
> Why need to add an empty `SourceLocation`?
I'm doing this since there is no actual location for present modifier. Maybe I 
should just pass llvm::None to ActOnOpenMPMapClause.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92427/new/

https://reviews.llvm.org/D92427

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


[PATCH] D90497: Module: Use FileEntryRef and DirectoryEntryRef in Umbrella, Header, and DirectoryName, NFC

2020-12-02 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG32c501dd88b6: Module: Use FileEntryRef and DirectoryEntryRef 
in Umbrella, Header, and… (authored by dexonsmith).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D90497?vs=302022&id=309054#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D90497/new/

https://reviews.llvm.org/D90497

Files:
  clang/include/clang/Basic/DirectoryEntry.h
  clang/include/clang/Basic/Module.h
  clang/include/clang/Lex/ModuleMap.h
  clang/lib/Basic/Module.cpp
  clang/lib/Frontend/FrontendActions.cpp
  clang/lib/Lex/ModuleMap.cpp
  clang/lib/Serialization/ASTReader.cpp

Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -1915,7 +1915,8 @@
 // FIXME: This is not always the right filename-as-written, but we're not
 // going to use this information to rebuild the module, so it doesn't make
 // a lot of difference.
-Module::Header H = {std::string(key.Filename), *FileMgr.getFile(Filename)};
+Module::Header H = {std::string(key.Filename),
+*FileMgr.getOptionalFileRef(Filename)};
 ModMap.addHeader(Mod, H, HeaderRole, /*Imported*/true);
 HFI.isModuleHeader |= !(HeaderRole & ModuleMap::TextualHeader);
   }
@@ -5564,7 +5565,7 @@
 case SUBMODULE_UMBRELLA_HEADER: {
   std::string Filename = std::string(Blob);
   ResolveImportedPath(F, Filename);
-  if (auto Umbrella = PP.getFileManager().getFile(Filename)) {
+  if (auto Umbrella = PP.getFileManager().getOptionalFileRef(Filename)) {
 if (!CurrentModule->getUmbrellaHeader())
   ModMap.setUmbrellaHeader(CurrentModule, *Umbrella, Blob);
 else if (CurrentModule->getUmbrellaHeader().Entry != *Umbrella) {
@@ -5597,7 +5598,8 @@
 case SUBMODULE_UMBRELLA_DIR: {
   std::string Dirname = std::string(Blob);
   ResolveImportedPath(F, Dirname);
-  if (auto Umbrella = PP.getFileManager().getDirectory(Dirname)) {
+  if (auto Umbrella =
+  PP.getFileManager().getOptionalDirectoryRef(Dirname)) {
 if (!CurrentModule->getUmbrellaDir())
   ModMap.setUmbrellaDir(CurrentModule, *Umbrella, Blob);
 else if (CurrentModule->getUmbrellaDir().Entry != *Umbrella) {
Index: clang/lib/Lex/ModuleMap.cpp
===
--- clang/lib/Lex/ModuleMap.cpp
+++ clang/lib/Lex/ModuleMap.cpp
@@ -300,7 +300,7 @@
   // supplied by Clang. Find that builtin header.
   SmallString<128> Path;
   llvm::sys::path::append(Path, BuiltinIncludeDir->getName(), Header.FileName);
-  auto File = SourceMgr.getFileManager().getFile(Path);
+  auto File = SourceMgr.getFileManager().getOptionalFileRef(Path);
   if (!File)
 return false;
 
@@ -1012,7 +1012,7 @@
   // Look for an umbrella header.
   SmallString<128> UmbrellaName = StringRef(FrameworkDir->getName());
   llvm::sys::path::append(UmbrellaName, "Headers", ModuleName + ".h");
-  auto UmbrellaHeader = FileMgr.getFile(UmbrellaName);
+  auto UmbrellaHeader = FileMgr.getOptionalFileRef(UmbrellaName);
 
   // FIXME: If there's no umbrella header, we could probably scan the
   // framework to load *everything*. But, it's not clear that this is a good
@@ -1121,21 +1121,21 @@
   return Result;
 }
 
-void ModuleMap::setUmbrellaHeader(Module *Mod, const FileEntry *UmbrellaHeader,
+void ModuleMap::setUmbrellaHeader(Module *Mod, FileEntryRef UmbrellaHeader,
   Twine NameAsWritten) {
   Headers[UmbrellaHeader].push_back(KnownHeader(Mod, NormalHeader));
-  Mod->Umbrella = UmbrellaHeader;
+  Mod->Umbrella = &UmbrellaHeader.getMapEntry();
   Mod->UmbrellaAsWritten = NameAsWritten.str();
-  UmbrellaDirs[UmbrellaHeader->getDir()] = Mod;
+  UmbrellaDirs[UmbrellaHeader.getDir()] = Mod;
 
   // Notify callbacks that we just added a new header.
   for (const auto &Cb : Callbacks)
 Cb->moduleMapAddUmbrellaHeader(&SourceMgr.getFileManager(), UmbrellaHeader);
 }
 
-void ModuleMap::setUmbrellaDir(Module *Mod, const DirectoryEntry *UmbrellaDir,
+void ModuleMap::setUmbrellaDir(Module *Mod, DirectoryEntryRef UmbrellaDir,
Twine NameAsWritten) {
-  Mod->Umbrella = UmbrellaDir;
+  Mod->Umbrella = &UmbrellaDir.getMapEntry();
   Mod->UmbrellaAsWritten = NameAsWritten.str();
   UmbrellaDirs[UmbrellaDir] = Mod;
 }
@@ -2416,15 +2416,15 @@
   }
 
   // Look for this file.
-  const DirectoryEntry *Dir = nullptr;
+  Optional Dir;
   if (llvm::sys::path::is_absolute(DirName)) {
-if (auto D = SourceMgr.getFileManager().getDirectory(DirName))
+if (auto D = SourceMgr.getFileManager().getOptionalDirectoryRef(DirName))
   Dir = *D;
   } else {
 SmallString<128> PathName;
 PathName = Directory->getName();
 llvm::sys::path::appen

[clang] 32c501d - Module: Use FileEntryRef and DirectoryEntryRef in Umbrella, Header, and DirectoryName, NFC

2020-12-02 Thread Duncan P. N. Exon Smith via cfe-commits

Author: Duncan P. N. Exon Smith
Date: 2020-12-02T14:07:23-08:00
New Revision: 32c501dd88b62787d3a5ffda7aabcf4650dbe3cd

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

LOG: Module: Use FileEntryRef and DirectoryEntryRef in Umbrella, Header, and 
DirectoryName, NFC

Push `FileEntryRef` and `DirectoryEntryRef` further, using it them
`Module::Umbrella`, `Module::Header::Entry`, and
`Module::DirectoryName::Entry`.

- Add `DirectoryEntryRef::operator const DirectoryEntry *` and
  `OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr`, to get the
  same "degrades to `DirectoryEntry*` behaviour `FileEntryRef` enjoys
  (this avoids a bunch of churn in various clang tools).
- Fix the `DirectoryEntryRef` constructor from `MapEntry` to take it by
  `const&`.

Note that we cannot get rid of the `...AsWritten` names leveraging the
new classes, since these need to be as written in the `ModuleMap` file
and the module directory path is preprended for the lookup in the
`FileManager`.

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

Added: 


Modified: 
clang/include/clang/Basic/DirectoryEntry.h
clang/include/clang/Basic/Module.h
clang/include/clang/Lex/ModuleMap.h
clang/lib/Basic/Module.cpp
clang/lib/Frontend/FrontendActions.cpp
clang/lib/Lex/ModuleMap.cpp
clang/lib/Serialization/ASTReader.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DirectoryEntry.h 
b/clang/include/clang/Basic/DirectoryEntry.h
index a6ec5f89aa28..4e229962bdcc 100644
--- a/clang/include/clang/Basic/DirectoryEntry.h
+++ b/clang/include/clang/Basic/DirectoryEntry.h
@@ -51,7 +51,26 @@ class DirectoryEntryRef {
   const MapEntry &getMapEntry() const { return *ME; }
 
   DirectoryEntryRef() = delete;
-  DirectoryEntryRef(MapEntry &ME) : ME(&ME) {}
+  DirectoryEntryRef(const MapEntry &ME) : ME(&ME) {}
+
+  /// Allow DirectoryEntryRef to degrade into 'const DirectoryEntry*' to
+  /// facilitate incremental adoption.
+  ///
+  /// The goal is to avoid code churn due to dances like the following:
+  /// \code
+  /// // Old code.
+  /// lvalue = rvalue;
+  ///
+  /// // Temporary code from an incremental patch.
+  /// lvalue = &rvalue.getDirectoryEntry();
+  ///
+  /// // Final code.
+  /// lvalue = rvalue;
+  /// \endcode
+  ///
+  /// FIXME: Once DirectoryEntryRef is "everywhere" and DirectoryEntry::getName
+  /// has been deleted, delete this implicit conversion.
+  operator const DirectoryEntry *() const { return &getDirEntry(); }
 
 private:
   friend class FileMgr::MapEntryOptionalStorage;
@@ -147,4 +166,76 @@ static_assert(
 } // end namespace optional_detail
 } // end namespace llvm
 
+namespace clang {
+
+/// Wrapper around Optional that degrades to 'const
+/// DirectoryEntry*', facilitating incremental patches to propagate
+/// DirectoryEntryRef.
+///
+/// This class can be used as return value or field where it's convenient for
+/// an Optional to degrade to a 'const DirectoryEntry*'. The
+/// purpose is to avoid code churn due to dances like the following:
+/// \code
+/// // Old code.
+/// lvalue = rvalue;
+///
+/// // Temporary code from an incremental patch.
+/// Optional MaybeF = rvalue;
+/// lvalue = MaybeF ? &MaybeF.getDirectoryEntry() : nullptr;
+///
+/// // Final code.
+/// lvalue = rvalue;
+/// \endcode
+///
+/// FIXME: Once DirectoryEntryRef is "everywhere" and DirectoryEntry::LastRef
+/// and DirectoryEntry::getName have been deleted, delete this class and
+/// replace instances with Optional.
+class OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr
+: public Optional {
+public:
+  OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr() = default;
+  OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr(
+  OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr &&) = default;
+  OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr(
+  const OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr &) = default;
+  OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr &
+  operator=(OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr &&) = default;
+  OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr &
+  operator=(const OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr &) = 
default;
+
+  OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr(llvm::NoneType) {}
+  OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr(DirectoryEntryRef Ref)
+  : Optional(Ref) {}
+  
OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr(Optional
 MaybeRef)
+  : Optional(MaybeRef) {}
+
+  OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr 
&operator=(llvm::NoneType) {
+Optional::operator=(None);
+return *this;
+  }
+  OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr 
&operator=(DirectoryEntryRef Ref) {
+Optional::operator=(Ref);
+return *this;
+  }
+ 

[PATCH] D87216: [NewPM] Support --print-before/after in NPM

2020-12-02 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks updated this revision to Diff 309052.
aeubanks added a comment.

add comments to new methods


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D87216/new/

https://reviews.llvm.org/D87216

Files:
  llvm/include/llvm/IR/IRPrintingPasses.h
  llvm/include/llvm/IR/PassInstrumentation.h
  llvm/include/llvm/IR/PrintPasses.h
  llvm/include/llvm/Passes/StandardInstrumentations.h
  llvm/lib/Analysis/CallGraphSCCPass.cpp
  llvm/lib/Analysis/LoopInfo.cpp
  llvm/lib/Analysis/LoopPass.cpp
  llvm/lib/CodeGen/MachineFunctionPrinterPass.cpp
  llvm/lib/IR/CMakeLists.txt
  llvm/lib/IR/IRPrintingPasses.cpp
  llvm/lib/IR/LegacyPassManager.cpp
  llvm/lib/IR/PassInstrumentation.cpp
  llvm/lib/IR/PrintPasses.cpp
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Passes/StandardInstrumentations.cpp
  llvm/test/CodeGen/Generic/print-after.ll
  llvm/test/Other/loop-pass-printer.ll
  llvm/test/Other/print-before-after.ll
  llvm/utils/gn/secondary/llvm/lib/IR/BUILD.gn

Index: llvm/utils/gn/secondary/llvm/lib/IR/BUILD.gn
===
--- llvm/utils/gn/secondary/llvm/lib/IR/BUILD.gn
+++ llvm/utils/gn/secondary/llvm/lib/IR/BUILD.gn
@@ -59,6 +59,7 @@
 "PassManager.cpp",
 "PassRegistry.cpp",
 "PassTimingInfo.cpp",
+"PrintPasses.cpp",
 "ProfileSummary.cpp",
 "SafepointIRVerifier.cpp",
 "Statepoint.cpp",
Index: llvm/test/Other/print-before-after.ll
===
--- /dev/null
+++ llvm/test/Other/print-before-after.ll
@@ -0,0 +1,33 @@
+; RUN: not --crash opt < %s -disable-output -passes='no-op-module' -print-before=bleh 2>&1 | FileCheck %s --check-prefix=NONE --allow-empty
+; RUN: not --crash opt < %s -disable-output -passes='no-op-module' -print-after=bleh 2>&1 | FileCheck %s --check-prefix=NONE --allow-empty
+; RUN: opt < %s -disable-output -passes='no-op-module' -print-before=no-op-function 2>&1 | FileCheck %s --check-prefix=NONE --allow-empty
+; RUN: opt < %s -disable-output -passes='no-op-module' -print-after=no-op-function 2>&1 | FileCheck %s --check-prefix=NONE --allow-empty
+; RUN: opt < %s -disable-output -passes='no-op-module,no-op-function' -print-before=no-op-module 2>&1 | FileCheck %s --check-prefix=ONCE
+; RUN: opt < %s -disable-output -passes='no-op-module,no-op-function' -print-after=no-op-module 2>&1 | FileCheck %s --check-prefix=ONCE
+; RUN: opt < %s -disable-output -passes='no-op-function' -print-before=no-op-function 2>&1 | FileCheck %s --check-prefix=ONCE
+; RUN: opt < %s -disable-output -passes='no-op-function' -print-after=no-op-function 2>&1 | FileCheck %s --check-prefix=ONCE
+; RUN: opt < %s -disable-output -passes='no-op-module,no-op-function' -print-before=no-op-function --print-module-scope 2>&1 | FileCheck %s --check-prefix=TWICE
+; RUN: opt < %s -disable-output -passes='no-op-module,no-op-function' -print-after=no-op-function --print-module-scope 2>&1 | FileCheck %s --check-prefix=TWICE
+
+; NONE-NOT: @foo
+; NONE-NOT: @bar
+
+; ONCE: @foo
+; ONCE: @bar
+; ONCE-NOT: @foo
+; ONCE-NOT: @bar
+
+; TWICE: @foo
+; TWICE: @bar
+; TWICE: @foo
+; TWICE: @bar
+; TWICE-NOT: @foo
+; TWICE-NOT: @bar
+
+define void @foo() {
+  ret void
+}
+
+define void @bar() {
+  ret void
+}
Index: llvm/test/Other/loop-pass-printer.ll
===
--- llvm/test/Other/loop-pass-printer.ll
+++ llvm/test/Other/loop-pass-printer.ll
@@ -1,23 +1,23 @@
 ; This test checks -print-after/before on loop passes
 ; Besides of the loop itself it should be dumping loop pre-header and exits.
 ;
-; RUN: opt -enable-new-pm=0 < %s 2>&1 -disable-output \
+; RUN: opt < %s 2>&1 -disable-output \
 ; RUN: 	   -loop-deletion -print-before=loop-deletion \
 ; RUN:	   | FileCheck %s -check-prefix=DEL
 ; RUN: opt < %s 2>&1 -disable-output \
-; RUN: 	   -passes='loop(loop-deletion)' -print-before-all \
+; RUN: 	   -passes='loop(loop-deletion)' -print-before=loop-deletion \
 ; RUN:	   | FileCheck %s -check-prefix=DEL
 ; RUN: opt -enable-new-pm=0 < %s 2>&1 -disable-output \
 ; RUN: 	   -loop-unroll -print-after=loop-unroll -filter-print-funcs=bar \
 ; RUN:	   | FileCheck %s -check-prefix=BAR -check-prefix=BAR-OLD
 ; RUN: opt < %s 2>&1 -disable-output \
-; RUN: 	   -passes='require,loop(loop-unroll-full)' -print-after-all -filter-print-funcs=bar \
+; RUN: 	   -passes='require,loop(loop-unroll-full)' -print-after=loop-unroll-full -filter-print-funcs=bar \
 ; RUN:	   | FileCheck %s -check-prefix=BAR
 ; RUN: opt -enable-new-pm=0 < %s 2>&1 -disable-output \
 ; RUN: 	   -loop-unroll -print-after=loop-unroll -filter-print-funcs=foo -print-module-scope \
 ; RUN:	   | FileCheck %s -check-prefix=FOO-MODULE -check-prefix=FOO-MODULE-OLD
 ; RUN: opt < %s 2>&1 -disable-output \
-; RUN: 	   -passes='require,loop(loop-unroll-full)' -print-after-all -filter-print-funcs=foo -print-module-scope \
+; RUN: 	   -passes='require,loop(loop-unroll-full)' -print-

[PATCH] D87216: [NewPM] Support --print-before/after in NPM

2020-12-02 Thread Jamie Schmeiser via Phabricator via cfe-commits
jamieschmeiser added a comment.

I previously saw unrelated changes showing up in the differences here but this 
no longer seems to be the case so that comment can be ignored.




Comment at: llvm/include/llvm/IR/PassInstrumentation.h:126
 
+  void addClassToPassName(StringRef ClassName, StringRef PassName);
+  StringRef getPassNameForClassName(StringRef ClassName);

Comments describing these functions?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D87216/new/

https://reviews.llvm.org/D87216

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


[PATCH] D92427: [OPENMP51] Add present modifier in defaultmap clause

2020-12-02 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:3310
+  case OMPC_DEFAULTMAP_MODIFIER_present:
+// If implicit-behavior is present, each variable referenced in the
+// construct in the category specified by variable-category is treated as 
if

Add a reference to the OpenMP standard, section and related text.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:3490
+OMPC_MAP_MODIFIER_present);
+ImplicitMapModifierLoc[ClauseKind].push_back(SourceLocation());
+  }

Why need to add an empty `SourceLocation`?



Comment at: clang/lib/Sema/SemaOpenMP.cpp:18592
 if (!isDefaultmapKind || !isDefaultmapModifier) {
-  std::string ModifierValue = "'alloc', 'from', 'to', 'tofrom', "
-  "'firstprivate', 'none', 'default'";
   std::string KindValue = "'scalar', 'aggregate', 'pointer'";
+  if (LangOpts.OpenMP == 50) {

You can make it `StringRef`



Comment at: clang/lib/Sema/SemaOpenMP.cpp:18594
+  if (LangOpts.OpenMP == 50) {
+std::string ModifierValue = "'alloc', 'from', 'to', 'tofrom', "
+"'firstprivate', 'none', 'default'";

Same, `StringRef`



Comment at: clang/lib/Sema/SemaOpenMP.cpp:18609
   } else {
-Diag(MLoc, diag::err_omp_unexpected_clause_value)
-<< ModifierValue << getOpenMPClauseName(OMPC_defaultmap);
-Diag(KindLoc, diag::err_omp_unexpected_clause_value)
-<< KindValue << getOpenMPClauseName(OMPC_defaultmap);
+std::string ModifierValue =
+"'alloc', 'from', 'to', 'tofrom', "

`StringRef`



Comment at: clang/test/OpenMP/target_defaultmap_codegen.cpp:1557
+#endif
+///==///
+// RUN: %clang_cc1 -DCK27 -verify -fopenmp -fopenmp-version=51 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple 
powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck 
-allow-deprecated-dag-overlap  %s --check-prefix CK27 --check-prefix CK27-64

Add in a separate test file



Comment at: clang/test/OpenMP/target_defaultmap_messages.cpp:5
 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=50 %s 
-verify=expected,omp5 -Wuninitialized -DOMP5
-// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=50 %s 
-verify=expected,omp5 -Wuninitialized -DOMP5
+// run: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=50 %s 
-verify=expected,omp5 -wuninitialized -domp5
 

Why this line is changed?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92427/new/

https://reviews.llvm.org/D92427

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


[PATCH] D91756: [CSSPGO] Pseudo probes for function calls.

2020-12-02 Thread Hongtao Yu via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG24d4291ca704: [CSSPGO] Pseudo probes for function calls. 
(authored by hoy).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91756/new/

https://reviews.llvm.org/D91756

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  llvm/include/llvm/CodeGen/CommandFlags.h
  llvm/include/llvm/CodeGen/Passes.h
  llvm/include/llvm/IR/DebugInfoMetadata.h
  llvm/include/llvm/IR/PseudoProbe.h
  llvm/include/llvm/InitializePasses.h
  llvm/include/llvm/Passes/PassBuilder.h
  llvm/include/llvm/Target/TargetOptions.h
  llvm/include/llvm/Transforms/IPO/SampleProfileProbe.h
  llvm/lib/CodeGen/CMakeLists.txt
  llvm/lib/CodeGen/CommandFlags.cpp
  llvm/lib/CodeGen/PseudoProbeInserter.cpp
  llvm/lib/CodeGen/SelectionDAG/InstrEmitter.cpp
  llvm/lib/CodeGen/TargetPassConfig.cpp
  llvm/lib/Target/X86/X86TargetMachine.cpp
  llvm/lib/Transforms/IPO/SampleProfileProbe.cpp
  llvm/test/Transforms/SampleProfile/pseudo-probe-emit.ll

Index: llvm/test/Transforms/SampleProfile/pseudo-probe-emit.ll
===
--- llvm/test/Transforms/SampleProfile/pseudo-probe-emit.ll
+++ llvm/test/Transforms/SampleProfile/pseudo-probe-emit.ll
@@ -1,7 +1,7 @@
 ; REQUIRES: x86-registered-target
 ; RUN: opt < %s -passes=pseudo-probe -function-sections -S -o %t
 ; RUN: FileCheck %s < %t --check-prefix=CHECK-IL
-; RUN: llc %t -stop-after=instruction-select -o - | FileCheck %s --check-prefix=CHECK-MIR
+; RUN: llc %t -pseudo-probe-for-profiling -stop-after=pseudo-probe-inserter -o - | FileCheck %s --check-prefix=CHECK-MIR
 ;
 ;; Check the generation of pseudoprobe intrinsic call.
 
@@ -29,9 +29,35 @@
   ret void, !dbg !12
 }
 
+declare void @bar(i32 %x) 
+
+define internal void @foo2(void (i32)* %f) !dbg !4 {
+entry:
+; CHECK-IL: call void @llvm.pseudoprobe(i64 [[#GUID2:]], i64 1, i32 0)
+; CHECK-MIR: PSEUDO_PROBE [[#GUID2:]], 1, 0, 0
+; Check pseudo_probe metadata attached to the indirect call instruction.
+; CHECK-IL: call void %f(i32 1), !dbg ![[#PROBE0:]]
+; CHECK-MIR: PSEUDO_PROBE [[#GUID2]], 2, 1, 0
+  call void %f(i32 1), !dbg !13
+; Check pseudo_probe metadata attached to the direct call instruction.
+; CHECK-IL: call void @bar(i32 1), !dbg ![[#PROBE1:]]
+; CHECK-MIR: PSEUDO_PROBE	[[#GUID2]], 3, 2, 0
+  call void @bar(i32 1)
+  ret void
+}
+
 ; CHECK-IL: ![[#FOO:]] = distinct !DISubprogram(name: "foo"
 ; CHECK-IL: ![[#FAKELINE]] = !DILocation(line: 0, scope: ![[#FOO]])
 ; CHECK-IL: ![[#REALLINE]] = !DILocation(line: 2, scope: ![[#FOO]])
+; CHECK-IL: ![[#PROBE0]] = !DILocation(line: 2, column: 20, scope: ![[#SCOPE0:]])
+;; A discriminator of 67108887 which is 0x417 in hexdecimal, stands for a direct call probe
+;; with an index of 2.
+; CHECK-IL: ![[#SCOPE0]] = !DILexicalBlockFile(scope: ![[#]], file: ![[#]], discriminator: 67108887)
+; CHECK-IL: ![[#PROBE1]] = !DILocation(line: 0, scope: ![[#SCOPE1:]])
+;; A discriminator of 134217759 which is 0x81f in hexdecimal, stands for a direct call probe
+;; with an index of 3.
+; CHECK-IL: ![[#SCOPE1]] = !DILexicalBlockFile(scope: ![[#]], file: ![[#]], discriminator: 134217759)
+
 
 !llvm.dbg.cu = !{!0}
 !llvm.module.flags = !{!9, !10}
@@ -40,10 +66,12 @@
 !1 = !DIFile(filename: "test.c", directory: "")
 !2 = !{}
 !3 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 1, type: !5, unit: !0, retainedNodes: !2)
+!4 = distinct !DISubprogram(name: "foo2", scope: !1, file: !1, line: 2, type: !5, unit: !0, retainedNodes: !2)
 !5 = !DISubroutineType(types: !6)
 !6 = !{!7}
 !7 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
 !9 = !{i32 2, !"Dwarf Version", i32 4}
 !10 = !{i32 2, !"Debug Info Version", i32 3}
 !11 = !{!"clang version 3.9.0"}
-!12 = !DILocation(line: 2, scope: !3)
\ No newline at end of file
+!12 = !DILocation(line: 2, scope: !3)
+!13 = !DILocation(line: 2, column: 20, scope: !4)
Index: llvm/lib/Transforms/IPO/SampleProfileProbe.cpp
===
--- llvm/lib/Transforms/IPO/SampleProfileProbe.cpp
+++ llvm/lib/Transforms/IPO/SampleProfileProbe.cpp
@@ -37,8 +37,10 @@
 
 SampleProfileProber::SampleProfileProber(Function &Func) : F(&Func) {
   BlockProbeIds.clear();
+  CallProbeIds.clear();
   LastProbeId = (uint32_t)PseudoProbeReservedId::Last;
   computeProbeIdForBlocks();
+  computeProbeIdForCallsites();
 }
 
 void SampleProfileProber::computeProbeIdForBlocks() {
@@ -47,11 +49,28 @@
   }
 }
 
+void SampleProfileProber::computeProbeIdForCallsites() {
+  for (auto &BB : *F) {
+for (auto &I : BB) {
+  if (!isa(I))
+continue;
+  if (isa(&I))
+continue;
+  CallProbeIds[&I] = ++LastProbeId;
+}
+  }
+}
+
 uint32_t SampleProfileProber::getBlockId(const BasicBlock *BB) const {
   auto I = BlockProbeIds.find(const_cast(BB));
   return I == BlockPr

[clang] 24d4291 - [CSSPGO] Pseudo probes for function calls.

2020-12-02 Thread Hongtao Yu via cfe-commits

Author: Hongtao Yu
Date: 2020-12-02T13:45:20-08:00
New Revision: 24d4291ca704fa5ee2419b4163aa324eca693fd6

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

LOG: [CSSPGO] Pseudo probes for function calls.

An indirect call site needs to be probed for its potential call targets. With 
CSSPGO a direct call also needs a probe so that a calling context can be 
represented by a stack of callsite probes. Unlike pseudo probes for basic 
blocks that are in form of standalone intrinsic call instructions, pseudo 
probes for callsites have to be attached to the call instruction, thus a 
separate instruction would not work.

One possible way of attaching a probe to a call instruction is to use a special 
metadata that carries information about the probe. The special metadata will 
have to make its way through the optimization pipeline down to object emission. 
This requires additional efforts to maintain the metadata in various places. 
Given that the `!dbg` metadata is a first-class metadata and has all essential 
support in place , leveraging the `!dbg` metadata as a channel to encode pseudo 
probe information is probably the easiest solution.

With the requirement of not inflating `!dbg` metadata that is allocated for 
almost every instruction, we found that the 32-bit DWARF discriminator field 
which mainly serves AutoFDO can be reused for pseudo probes. DWARF 
discriminators distinguish identical source locations between instructions and 
with pseudo probes such support is not required. In this change we are using 
the discriminator field to encode the ID and type of a callsite probe and the 
encoded value will be unpacked and consumed right before object emission. When 
a callsite is inlined, the callsite discriminator field will go with the 
inlined instructions. The `!dbg` metadata of an inlined instruction is in form 
of a scope stack. The top of the stack is the instruction's original `!dbg` 
metadata and the bottom of the stack is for the original callsite of the 
top-level inliner. Except for the top of the stack, all other elements of the 
stack actually refer to the nested inlined callsites whose discriminator field 
(which actually represents a calliste probe) can be used together to represent 
the inline context of an inlined PseudoProbeInst or CallInst.

To avoid collision with the baseline AutoFDO in various places that handles 
dwarf discriminators where a check against  the `-pseudo-probe-for-profiling` 
switch is not available, a special encoding scheme is used to tell apart a 
pseudo probe discriminator from a regular discriminator. For the regular 
discriminator, if all lowest 3 bits are non-zero, it means the discriminator is 
basically empty and all higher 29 bits can be reversed for pseudo probe use.

Callsite pseudo probes are inserted in `SampleProfileProbePass` and a 
target-independent MIR pass `PseudoProbeInserter` is added to unpack the probe 
ID/type from `!dbg`.

Note that with this work the switch -debug-info-for-profiling will not work 
with -pseudo-probe-for-profiling anymore. They cannot be used at the same time.

Reviewed By: wmi

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

Added: 
llvm/include/llvm/IR/PseudoProbe.h
llvm/lib/CodeGen/PseudoProbeInserter.cpp

Modified: 
clang/lib/CodeGen/BackendUtil.cpp
llvm/include/llvm/CodeGen/CommandFlags.h
llvm/include/llvm/CodeGen/Passes.h
llvm/include/llvm/IR/DebugInfoMetadata.h
llvm/include/llvm/InitializePasses.h
llvm/include/llvm/Passes/PassBuilder.h
llvm/include/llvm/Target/TargetOptions.h
llvm/include/llvm/Transforms/IPO/SampleProfileProbe.h
llvm/lib/CodeGen/CMakeLists.txt
llvm/lib/CodeGen/CommandFlags.cpp
llvm/lib/CodeGen/SelectionDAG/InstrEmitter.cpp
llvm/lib/CodeGen/TargetPassConfig.cpp
llvm/lib/Target/X86/X86TargetMachine.cpp
llvm/lib/Transforms/IPO/SampleProfileProbe.cpp
llvm/test/Transforms/SampleProfile/pseudo-probe-emit.ll

Removed: 




diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index b62a66a51d26..724e2ec16fc3 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -555,6 +555,7 @@ static bool initTargetOptions(DiagnosticsEngine &Diags,
   Options.ForceDwarfFrameSection = CodeGenOpts.ForceDwarfFrameSection;
   Options.EmitCallSiteInfo = CodeGenOpts.EmitCallSiteInfo;
   Options.EnableAIXExtendedAltivecABI = 
CodeGenOpts.EnableAIXExtendedAltivecABI;
+  Options.PseudoProbeForProfiling = CodeGenOpts.PseudoProbeForProfiling;
   Options.ValueTrackingVariableLocations =
   CodeGenOpts.ValueTrackingVariableLocations;
   Options.XRayOmitFunctionIndex = CodeGenOpts.XRayOmitFunctionIndex;

diff  --git a/llvm/include/llvm/CodeGen/CommandFlags.h 
b/llvm/include/ll

[PATCH] D80450: [CUDA][HIP] Fix HD function resolution

2020-12-02 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
yaxunl marked an inline comment as done.
Closed by commit rGacb6f80d96b7: [CUDA][HIP] Fix overloading resolution 
(authored by yaxunl).

Changed prior to commit:
  https://reviews.llvm.org/D80450?vs=308515&id=309044#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80450/new/

https://reviews.llvm.org/D80450

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/include/clang/Sema/Overload.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/Driver/hip-options.hip
  clang/test/SemaCUDA/deferred-oeverload.cu
  clang/test/SemaCUDA/function-overload.cu

Index: clang/test/SemaCUDA/function-overload.cu
===
--- clang/test/SemaCUDA/function-overload.cu
+++ clang/test/SemaCUDA/function-overload.cu
@@ -1,8 +1,16 @@
 // REQUIRES: x86-registered-target
 // REQUIRES: nvptx-registered-target
 
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only -verify=host,expected %s
-// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fsyntax-only -fcuda-is-device -verify=dev,expected %s
+// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-linux-gnu -fsyntax-only \
+// RUN:   -verify=host,hostdefer,devdefer,expected %s
+// RUN: %clang_cc1 -std=c++14 -triple nvptx64-nvidia-cuda -fsyntax-only \
+// RUN:   -fcuda-is-device -verify=dev,devnodeferonly,hostdefer,devdefer,expected %s
+// RUN: %clang_cc1 -fgpu-exclude-wrong-side-overloads -fgpu-defer-diag -DDEFER=1 \
+// RUN:-std=c++14 -triple x86_64-unknown-linux-gnu -fsyntax-only \
+// RUN:-verify=host,hostdefer,expected %s
+// RUN: %clang_cc1 -fgpu-exclude-wrong-side-overloads -fgpu-defer-diag -DDEFER=1 \
+// RUN:-std=c++14 -triple nvptx64-nvidia-cuda -fsyntax-only -fcuda-is-device \
+// RUN:-verify=dev,devdeferonly,devdefer,expected %s
 
 #include "Inputs/cuda.h"
 
@@ -76,37 +84,37 @@
 // Helper functions to verify calling restrictions.
 __device__ DeviceReturnTy d() { return DeviceReturnTy(); }
 // host-note@-1 1+ {{'d' declared here}}
-// expected-note@-2 1+ {{candidate function not viable: call to __device__ function from __host__ function}}
+// hostdefer-note@-2 1+ {{candidate function not viable: call to __device__ function from __host__ function}}
 // expected-note@-3 0+ {{candidate function not viable: call to __device__ function from __host__ __device__ function}}
 
 __host__ HostReturnTy h() { return HostReturnTy(); }
 // dev-note@-1 1+ {{'h' declared here}}
-// expected-note@-2 1+ {{candidate function not viable: call to __host__ function from __device__ function}}
+// devdefer-note@-2 1+ {{candidate function not viable: call to __host__ function from __device__ function}}
 // expected-note@-3 0+ {{candidate function not viable: call to __host__ function from __host__ __device__ function}}
-// expected-note@-4 1+ {{candidate function not viable: call to __host__ function from __global__ function}}
+// devdefer-note@-4 1+ {{candidate function not viable: call to __host__ function from __global__ function}}
 
 __global__ void g() {}
 // dev-note@-1 1+ {{'g' declared here}}
-// expected-note@-2 1+ {{candidate function not viable: call to __global__ function from __device__ function}}
+// devdefer-note@-2 1+ {{candidate function not viable: call to __global__ function from __device__ function}}
 // expected-note@-3 0+ {{candidate function not viable: call to __global__ function from __host__ __device__ function}}
-// expected-note@-4 1+ {{candidate function not viable: call to __global__ function from __global__ function}}
+// devdefer-note@-4 1+ {{candidate function not viable: call to __global__ function from __global__ function}}
 
 extern "C" __device__ DeviceReturnTy cd() { return DeviceReturnTy(); }
 // host-note@-1 1+ {{'cd' declared here}}
-// expected-note@-2 1+ {{candidate function not viable: call to __device__ function from __host__ function}}
+// hostdefer-note@-2 1+ {{candidate function not viable: call to __device__ function from __host__ function}}
 // expected-note@-3 0+ {{candidate function not viable: call to __device__ function from __host__ __device__ function}}
 
 extern "C" __host__ HostReturnTy ch() { return HostReturnTy(); }
 // dev-note@-1 1+ {{'ch' declared here}}
-// expected-note@-2 1+ {{candidate function not viable: call to __host__ function from __device__ function}}
+// devdefer-note@-2 1+ {{candidate function not viable: call to __host__ function from __device__ function}}
 // expected-note@-3 0+ {{candidate function not viable: call to __host__ function from __host__ __device__ function}}
-// expected-note@-4 1+ {{candidate function not viable: call to __host__ function from __global__ function}}
+// devdefer-note@-4 1+ {{candidate function not viable: call to __host__ function from __global__ function}}
 
 __host

[clang] acb6f80 - [CUDA][HIP] Fix overloading resolution

2020-12-02 Thread Yaxun Liu via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2020-12-02T16:33:33-05:00
New Revision: acb6f80d96b74af3ec515bb9811d213abb406c31

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

LOG: [CUDA][HIP] Fix overloading resolution

This patch implements correct hostness based overloading resolution
in isBetterOverloadCandidate.

Based on hostness, if one candidate is emittable whereas the other
candidate is not emittable, the emittable candidate is better.

If both candidates are emittable, or neither is emittable based on hostness, 
then
other rules should be used to determine which is better. This is because
hostness based overloading resolution is mostly for determining
viability of a function. If two functions are both viable, other factors
should take precedence in preference.

If other rules cannot determine which is better, CUDA preference will be
used again to determine which is better.

However, correct hostness based overloading resolution
requires overloading resolution diagnostics to be deferred,
which is not on by default. The rationale is that deferring
overloading resolution diagnostics may hide overloading reslolutions
issues in header files.

An option -fgpu-exclude-wrong-side-overloads is added, which is off by
default.

When -fgpu-exclude-wrong-side-overloads is off, keep the original behavior,
that is, exclude wrong side overloads only if there are same side overloads.
This may result in incorrect overloading resolution when there are no
same side candates, but is sufficient for most CUDA/HIP applications.

When -fgpu-exclude-wrong-side-overloads is on, enable deferring
overloading resolution diagnostics and enable correct hostness
based overloading resolution, i.e., always exclude wrong side overloads.

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

Added: 


Modified: 
clang/include/clang/Basic/LangOptions.def
clang/include/clang/Driver/Options.td
clang/include/clang/Sema/Overload.h
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Sema/SemaOverload.cpp
clang/test/Driver/hip-options.hip
clang/test/SemaCUDA/deferred-oeverload.cu
clang/test/SemaCUDA/function-overload.cu

Removed: 




diff  --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index f41febf30c53..071cc314b7d1 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -243,6 +243,7 @@ LANGOPT(GPURelocatableDeviceCode, 1, 0, "generate 
relocatable device code")
 LANGOPT(GPUAllowDeviceInit, 1, 0, "allowing device side global init functions 
for HIP")
 LANGOPT(GPUMaxThreadsPerBlock, 32, 256, "default max threads per block for 
kernel launch bounds for HIP")
 LANGOPT(GPUDeferDiag, 1, 0, "defer host/device related diagnostic messages for 
CUDA/HIP")
+LANGOPT(GPUExcludeWrongSideOverloads, 1, 0, "always exclude wrong side 
overloads in overloading resolution for CUDA/HIP")
 
 LANGOPT(SYCL  , 1, 0, "SYCL")
 LANGOPT(SYCLIsDevice  , 1, 0, "Generate code for SYCL device")

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 6e37a3154bdf..b58f5cbc63d0 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -721,6 +721,9 @@ defm gpu_allow_device_init : 
OptInFFlag<"gpu-allow-device-init",
 defm gpu_defer_diag : OptInFFlag<"gpu-defer-diag",
   "Defer", "Don't defer", " host/device related diagnostic messages"
   " for CUDA/HIP">;
+defm gpu_exclude_wrong_side_overloads : 
OptInFFlag<"gpu-exclude-wrong-side-overloads",
+  "Always exclude wrong side overloads", "Exclude wrong side overloads only if 
there are same side overloads",
+  " in overloading resolution for CUDA/HIP", [HelpHidden]>;
 def gpu_max_threads_per_block_EQ : Joined<["--"], 
"gpu-max-threads-per-block=">,
   Flags<[CC1Option]>,
   HelpText<"Default max threads per block for kernel launch bounds for HIP">;

diff  --git a/clang/include/clang/Sema/Overload.h 
b/clang/include/clang/Sema/Overload.h
index 4f5e497bc202..5be6a618711c 100644
--- a/clang/include/clang/Sema/Overload.h
+++ b/clang/include/clang/Sema/Overload.h
@@ -1051,6 +1051,9 @@ class Sema;
 
 void destroyCandidates();
 
+/// Whether diagnostics should be deferred.
+bool shouldDeferDiags(Sema &S, ArrayRef Args, SourceLocation 
OpLoc);
+
   public:
 OverloadCandidateSet(SourceLocation Loc, CandidateSetKind CSK,
  OperatorRewriteInfo RewriteInfo = {})

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index caa77123f7eb..a513c0025a62 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -5610,6 +5610,12 @@ void Clang::

[clang] 0849047 - Add a less ambiguous macro for Android version.

2020-12-02 Thread Dan Albert via cfe-commits

Author: Dan Albert
Date: 2020-12-02T13:26:28-08:00
New Revision: 0849047860a343d8bcf1f828a82d585e89079943

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

LOG: Add a less ambiguous macro for Android version.

Android has a handful of API levels relevant to developers described
here: https://developer.android.com/studio/build#module-level.
`__ANDROID_API__` is too vague and confuses a lot of people. Introduce
a new macro name that is explicit about which one it represents. Keep
the old name around because code has been using it for a decade.

Added: 


Modified: 
clang/lib/Basic/Targets/OSTargets.h
clang/test/Preprocessor/init.c

Removed: 




diff  --git a/clang/lib/Basic/Targets/OSTargets.h 
b/clang/lib/Basic/Targets/OSTargets.h
index 60e47bcacbf4..0d5d6f553093 100644
--- a/clang/lib/Basic/Targets/OSTargets.h
+++ b/clang/lib/Basic/Targets/OSTargets.h
@@ -383,8 +383,12 @@ class LLVM_LIBRARY_VISIBILITY LinuxTargetInfo : public 
OSTargetInfo {
   Triple.getEnvironmentVersion(Maj, Min, Rev);
   this->PlatformName = "android";
   this->PlatformMinVersion = VersionTuple(Maj, Min, Rev);
-  if (Maj)
-Builder.defineMacro("__ANDROID_API__", Twine(Maj));
+  if (Maj) {
+Builder.defineMacro("__ANDROID_MIN_SDK_VERSION__", Twine(Maj));
+// This historical but ambiguous name for the minSdkVersion macro. Keep
+// defined for compatibility.
+Builder.defineMacro("__ANDROID_API__", "__ANDROID_MIN_SDK_VERSION__");
+  }
 } else {
 Builder.defineMacro("__gnu_linux__");
 }

diff  --git a/clang/test/Preprocessor/init.c b/clang/test/Preprocessor/init.c
index 079ec6e021f8..e599d9afb42e 100644
--- a/clang/test/Preprocessor/init.c
+++ b/clang/test/Preprocessor/init.c
@@ -1397,6 +1397,7 @@
 //
 // RUN: %clang_cc1 -triple arm-linux-androideabi -E -dM < /dev/null | 
FileCheck -match-full-lines -check-prefix ANDROID %s
 // ANDROID-NOT:#define __ANDROID_API__
+// ANDROID-NOT:#define __ANDROID_MIN_SDK_VERSION__
 // ANDROID:#define __ANDROID__ 1
 // ANDROID-NOT:#define __gnu_linux__
 //
@@ -1407,7 +1408,8 @@
 // X86_64-ANDROID-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 16UL
 //
 // RUN: %clang_cc1 -triple arm-linux-androideabi20 -E -dM < /dev/null | 
FileCheck -match-full-lines -check-prefix ANDROID20 %s
-// ANDROID20:#define __ANDROID_API__ 20
+// ANDROID20:#define __ANDROID_API__ __ANDROID_MIN_SDK_VERSION__
+// ANDROID20:#define __ANDROID_MIN_SDK_VERSION__ 20
 // ANDROID20:#define __ANDROID__ 1
 // ANDROID-NOT:#define __gnu_linux__
 //



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


[PATCH] D92001: [ubsan] Fix crash on __builtin_assume_aligned

2020-12-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/CodeGen/CodeGenFunction.cpp:2524
   // defined.
-  if (Ty->getPointeeType().isVolatileQualified())
+  if (!Ty->getPointeeType().isNull() && 
Ty->getPointeeType().isVolatileQualified())
 return;

lebedev.ri wrote:
> vsk wrote:
> > Is the pointee type associated with a PointerType QualType ever supposed to 
> > be null? I wonder why this happens, and whether it can cause problems in 
> > other places.
> Basically, we can't just use `getPointeeType()` here, but i'm not sure what 
> should be used instead.
I'm not super familiar with `__builtin_assume_aligned` but from the GCC docs, 
it looks like the code from the test case is valid code (so we don't need to 
add semantic checking that would ensure we don't reach this code path). 
However, it seems a bit odd to me that we'd get an array type here as opposed 
to a decayed type which would actually be a pointer.

I think the issue is further up the call chain, perhaps. `EmitBuiltinExpr()` 
gets the argument expression and passes it to `emitAlignmentAssumption()` which 
pulls the type directly out of the expression. It seems like there's an lvalue 
to rvalue conversion step missing to adjust the type.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92001/new/

https://reviews.llvm.org/D92001

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


[PATCH] D90173: [PowerPC] Exploit splat instruction xxsplti32dx in Power10

2020-12-02 Thread Albion Fung via Phabricator via cfe-commits
Conanap added a comment.

Replied to a comment




Comment at: llvm/lib/Target/PowerPC/PPCISelLowering.cpp:9213
+
+  if (bot) {
+SplatNode = DAG.getNode(

NeHuang wrote:
> I do not quite understand the `if` and `else` logic here, current logic seems 
> we can overwrite `SplatNode` after we execute `SplatNode = 
> DAG.getTargetConstant(0, dl, MVT::v2i64);` 
> Is that as expected? 
Thanks for bringing this up. `SplatNode` is reused in `if (Lo)` and `if (Hi)`; 
it just saves a variable and a ternary statement (`if (Hi)` will also have to 
check if `Lo` created a `SDNode` before deciding between `SplatNode` or the 
`SDNode` created by `Lo`), but can understandably be confusing. I could 
separate them in to different variables and if statements to make it easier to 
understand if that's preferred. 


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D90173/new/

https://reviews.llvm.org/D90173

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


[PATCH] D90173: [PowerPC] Exploit splat instruction xxsplti32dx in Power10

2020-12-02 Thread Albion Fung via Phabricator via cfe-commits
Conanap updated this revision to Diff 309039.
Conanap marked 6 inline comments as done.
Conanap added a comment.

Addressed some formatting comments


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D90173/new/

https://reviews.llvm.org/D90173

Files:
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/lib/Target/PowerPC/PPCInstrPrefix.td
  llvm/test/CodeGen/PowerPC/p10-splatImm-CPload-pcrel.ll
  llvm/test/CodeGen/PowerPC/p10-splatImm32.ll

Index: llvm/test/CodeGen/PowerPC/p10-splatImm32.ll
===
--- llvm/test/CodeGen/PowerPC/p10-splatImm32.ll
+++ llvm/test/CodeGen/PowerPC/p10-splatImm32.ll
@@ -118,3 +118,25 @@
   %vecins1 = shufflevector <4 x i32> , <4 x i32> %a, <4 x i32> 
   ret <4 x i32> %vecins1
 }
+
+define dso_local <2 x double> @test_xxsplti32dx_8() {
+; CHECK-LABEL: test_xxsplti32dx_8
+; CHECK-LE: xxlxor vs34, vs34, vs34
+; CHECK-LE: xxsplti32dx vs34, 1, 1082660167
+; CHECK-BE: xxlxor vs34, vs34, vs34
+; CHECK-BE: xxsplti32dx vs34, 0, 1082660167
+; CHECK: blr
+entry:
+  ret <2 x double> 
+}
+
+define dso_local <8 x i16> @test_xxsplti32dx_9() {
+; CHECK-LABEL: test_xxsplti32dx_9
+; CHECK-LE: xxlxor vs34, vs34, vs34
+; CHECK-LE: xxsplti32dx vs34, 1, 23855277
+; CHECK-BE: xxlxor vs34, vs34, vs34
+; CHECK-BE: xxsplti32dx vs34, 0, 19070977
+; CHECK: blr
+entry:
+  ret <8 x i16> 
+}
Index: llvm/test/CodeGen/PowerPC/p10-splatImm-CPload-pcrel.ll
===
--- llvm/test/CodeGen/PowerPC/p10-splatImm-CPload-pcrel.ll
+++ llvm/test/CodeGen/PowerPC/p10-splatImm-CPload-pcrel.ll
@@ -1,114 +1,216 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu -O2 \
-; RUN: -ppc-asm-full-reg-names -mcpu=pwr10 < %s | FileCheck %s
+; RUN: -ppc-asm-full-reg-names -mcpu=pwr10 < %s | FileCheck %s --check-prefixes=CHECK-LE
 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu -O2 \
 ; RUN: -ppc-asm-full-reg-names -mcpu=pwr10 < %s | FileCheck %s \
-; RUN: --check-prefix=CHECK-NOPCREL
+; RUN: --check-prefixes=CHECK-NOPCREL-BE
 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu -O2 \
 ; RUN: -mattr=-pcrelative-memops -ppc-asm-full-reg-names -mcpu=pwr10 < %s | \
-; RUN: FileCheck %s --check-prefix=CHECK-NOPCREL
+; RUN: FileCheck %s --check-prefixes=CHECK-NOPCREL-LE
 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu -O2 \
 ; RUN: -mattr=-prefix-instrs -ppc-asm-full-reg-names -mcpu=pwr10 < %s | \
-; RUN: FileCheck %s --check-prefix=CHECK-NOPCREL
+; RUN: FileCheck %s --check-prefixes=CHECK-NOPREFIX
 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu -O2 \
 ; RUN: -ppc-asm-full-reg-names -target-abi=elfv2 -mcpu=pwr10 < %s | \
-; RUN: FileCheck %s
+; RUN: FileCheck %s --check-prefixes=CHECK-BE
 
 define dso_local <2 x double> @testDoubleToDoubleFail() local_unnamed_addr {
-; CHECK-LABEL: testDoubleToDoubleFail:
-; CHECK:   # %bb.0: # %entry
-; CHECK-NEXT:plxv vs34, .LCPI0_0@PCREL(0), 1
-; CHECK-NEXT:blr
-;
-; CHECK-NOPCREL-LABEL: testDoubleToDoubleFail:
-; CHECK-NOPCREL:   # %bb.0: # %entry
-; CHECK-NOPCREL-NEXT:addis r3, r2, .LCPI0_0@toc@ha
-; CHECK-NOPCREL-NEXT:addi r3, r3, .LCPI0_0@toc@l
-; CHECK-NOPCREL-NEXT:lxvx vs34, 0, r3
-; CHECK-NOPCREL-NEXT:blr
-
+; CHECK-LE-LABEL: testDoubleToDoubleFail:
+; CHECK-LE:   # %bb.0: # %entry
+; CHECK-LE-NEXT:xxlxor vs34, vs34, vs34
+; CHECK-LE-NEXT:xxsplti32dx vs34, 1, 1081435463
+; CHECK-LE-NEXT:blr
+;
+; CHECK-NOPCREL-BE-LABEL: testDoubleToDoubleFail:
+; CHECK-NOPCREL-BE:   # %bb.0: # %entry
+; CHECK-NOPCREL-BE-NEXT:xxlxor vs34, vs34, vs34
+; CHECK-NOPCREL-BE-NEXT:xxsplti32dx vs34, 0, 1081435463
+; CHECK-NOPCREL-BE-NEXT:blr
+;
+; CHECK-NOPCREL-LE-LABEL: testDoubleToDoubleFail:
+; CHECK-NOPCREL-LE:   # %bb.0: # %entry
+; CHECK-NOPCREL-LE-NEXT:xxlxor vs34, vs34, vs34
+; CHECK-NOPCREL-LE-NEXT:xxsplti32dx vs34, 1, 1081435463
+; CHECK-NOPCREL-LE-NEXT:blr
+;
+; CHECK-NOPREFIX-LABEL: testDoubleToDoubleFail:
+; CHECK-NOPREFIX:   # %bb.0: # %entry
+; CHECK-NOPREFIX-NEXT:addis r3, r2, .LCPI0_0@toc@ha
+; CHECK-NOPREFIX-NEXT:addi r3, r3, .LCPI0_0@toc@l
+; CHECK-NOPREFIX-NEXT:lxvx vs34, 0, r3
+; CHECK-NOPREFIX-NEXT:blr
+;
+; CHECK-BE-LABEL: testDoubleToDoubleFail:
+; CHECK-BE:   # %bb.0: # %entry
+; CHECK-BE-NEXT:xxlxor vs34, vs34, vs34
+; CHECK-BE-NEXT:xxsplti32dx vs34, 0, 1081435463
+; CHECK-BE-NEXT:blr
 entry:
   ret <2 x double> 
 }
 
 define dso_local <2 x double> @testFloatDenormToDouble() local_unnamed_addr {
-; CHECK-LABEL: testFloatDenormToDouble:
-; CHECK:   # %bb.0: # %entry
-; CHECK-NEXT:plxv vs34, .LCPI1_0@PCREL(0), 1
-; CHECK-NEXT:blr
-;
-; CHECK-NOPCREL-LABEL: testFloatDenormToDouble:
-; CHECK-NOPCREL:   # %bb.0

[PATCH] D92439: Fix missing error for use of 128-bit integer inside SPIR64 device code.

2020-12-02 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 added inline comments.



Comment at: clang/lib/Sema/Sema.cpp:241
+  (Context.getAuxTargetInfo() &&
+   Context.getAuxTargetInfo()->hasInt128Type())) {
 // If either of the 128-bit integer types are unavailable to name lookup,

jyu2 wrote:
> jdoerfert wrote:
> > jyu2 wrote:
> > > jdoerfert wrote:
> > > > I don't understand why this (and the changes below) are necessary. Host 
> > > > and device compilation are separate. This should not be any different 
> > > > to CUDA, HIP, or OpenMP offload which seem not to require this.
> > > As far as I can know, in real compile, the auxtarget should be also set 
> > > for example SYCL.  May be that is only for our compiler.  I am not sure 
> > > what do you mean by it should same with CUDA, HIP...?  Do you mean, 
> > > CUDA(or HIP...) target should also not support 128-bit integer?  If so, I 
> > > don't see any error emit for CUDA when I try with nvptx64-nvidia-cuda.
> > > 
> > > Thanks.
> > > 
> > I'm not saying auxtarget is not set. I'm trying to understand why this is 
> > necessary. Why would you initialize `__int128_t` if your target doesn't 
> > support it? What happens if you only include the SPIR.h change?
> Without this change you will see error:
> 
> j3.c:2:15: error: unknown type name '__uint128_t'
> typedef const __uint128_t  megeType;
> 
> bash-4.4$ cat j3.c
> 
> typedef const __uint128_t  megeType;
> 
> Without change in SemaOverload.c:
> you will see error:
> x.cpp:3:14: error: use of overloaded operator '==' is ambiguous (with operand 
> types 'struct X' and '__int128')
>   bool a = x == __int128(0);
>~ ^  ~~~
> 
> bash-4.4$ cat x.cpp
> namespace PR12964 {
>   struct X { operator  __int128() const; } x;
>   bool a = x == __int128(0);
> }
> 
> 
> 
Just one more point, the errors only need to be emitted for 128-bit integer 
used inside device code.  The test case above 128-bit integer is not used in 
device code, so we don't want to emit error for it.

Thanks.
Jennifer


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92439/new/

https://reviews.llvm.org/D92439

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


[clang] 2ac5880 - Update MS ABI mangling for union constants based on new information from

2020-12-02 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-12-02T12:17:52-08:00
New Revision: 2ac58801873ab99dd5de48ad7557b76f1803100b

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

LOG: Update MS ABI mangling for union constants based on new information from
Jon Caves.

Added: 


Modified: 
clang/lib/AST/MicrosoftMangle.cpp
clang/test/CodeGenCXX/mangle-class-nttp.cpp

Removed: 




diff  --git a/clang/lib/AST/MicrosoftMangle.cpp 
b/clang/lib/AST/MicrosoftMangle.cpp
index b093b2514c19..1fba1392d0ed 100644
--- a/clang/lib/AST/MicrosoftMangle.cpp
+++ b/clang/lib/AST/MicrosoftMangle.cpp
@@ -1681,14 +1681,13 @@ void 
MicrosoftCXXNameMangler::mangleTemplateArgValue(QualType T,
   }
 
   case APValue::Union:
-Out << '2';
+Out << '7';
 mangleType(T, SourceRange(), QMM_Escape);
-// FIXME: MSVC doesn't mangle the active member, only the type, leading to
-// collisions if more than one member has the same type.
-// FIXME: MSVC doesn't yet support unions with no active member, but
-// there's an obvious mangling for that, so we use it.
-if (const FieldDecl *FD = V.getUnionField())
-  mangleTemplateArgValue(FD->getType(), V.getUnionValue());
+if (const FieldDecl *FD = V.getUnionField()) {
+  mangleUnqualifiedName(FD);
+  mangleTemplateArgValue(FD->getType(), V.getUnionValue(),
+ /*WithType*/false);
+}
 Out << '@';
 return;
 

diff  --git a/clang/test/CodeGenCXX/mangle-class-nttp.cpp 
b/clang/test/CodeGenCXX/mangle-class-nttp.cpp
index 9bb83fcf3246..579afd0a01be 100644
--- a/clang/test/CodeGenCXX/mangle-class-nttp.cpp
+++ b/clang/test/CodeGenCXX/mangle-class-nttp.cpp
@@ -120,16 +120,16 @@ template void f() {}
 // CHECK: define weak_odr void @_Z1fIXL1vv(
 // FIXME: MSVC rejects this; check this is the mangling MSVC uses when they
 // start accepting.
-// MSABI: define {{.*}} @"??$f@$2TE@YAXXZ"
+// MSABI: define {{.*}} @"??$f@$7TE@YAXXZ"
 template void f();
 // CHECK: define weak_odr void @_Z1fIXtl1vv(
-// MSABI: define {{.*}} @"??$f@$2TE@@H0AYAXXZ"
+// MSABI: define {{.*}} @"??$f@$7TE@@n@0AYAXXZ"
 template void f();
 // CHECK: define weak_odr void @_Z1fIXtl1Edi1nLi42vv(
-// MSABI: define {{.*}} @"??$f@$2TE@@H0CKYAXXZ"
+// MSABI: define {{.*}} @"??$f@$7TE@@n@0CKYAXXZ"
 template void f();
 // CHECK: define weak_odr void @_Z1fIXtl1Edi1fLfvv(
-// MSABI: define {{.*}} @"??$f@$2TE@@MAAYAXXZ"
+// MSABI: define {{.*}} @"??$f@$7TE@@0AAYAXXZ"
 template void f();
 
 // immintrin.h vector types.
@@ -210,24 +210,22 @@ template void f() {}
 template void f() {}
 template void f() {}
 // CHECK: define weak_odr void @_Z1fIXL2H1EEEvv
-// MSABI: define {{.*}} @"??$f@$2TH1@YAXXZ"
+// MSABI: define {{.*}} @"??$f@$7TH1@YAXXZ"
 template void f();
 // CHECK: define weak_odr void @_Z1fIXL2H2EEEvv
-// MSABI: define {{.*}} @"??$f@$2TH2@YAXXZ"
+// MSABI: define {{.*}} @"??$f@$7TH2@YAXXZ"
 template void f();
 // CHECK: define weak_odr void @_Z1fIXtl2H3EEEvv
-// MSABI: define {{.*}} @"??$f@$2TH3@@H0AYAXXZ"
+// MSABI: define {{.*}} @"??$f@$7TH3@@a@0AYAXXZ"
 template void f();
 // CHECK: define weak_odr void @_Z1fIXtl2H3di1aLi1vv
-// MSABI: define {{.*}} @"??$f@$2TH3@@H00@@@YAXXZ"
+// MSABI: define {{.*}} @"??$f@$7TH3@@a@00@@@YAXXZ"
 template void f();
-// FIXME: Leads to mangling collision under MS ABI; same mangling as the {.a = 
0} case.
-#ifndef _WIN32
 // CHECK: define weak_odr void @_Z1fIXtl2H3di1bLi0vv
+// MSABI: define {{.*}} @"??$f@$7TH3@@b@0AYAXXZ"
 template void f();
-#endif
 // CHECK: define weak_odr void @_Z1fIXtl2H4EEEvv
-// MSABI: define {{.*}} @"??$f@$2UH4@@2TH2@@YAXXZ"
+// MSABI: define {{.*}} @"??$f@$2UH4@@7TH2@@YAXXZ"
 template void f();
 
 // Floating-point.



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


[PATCH] D92495: [clang] Add a new nullability annotation for swift async: _Nullable_result

2020-12-02 Thread Doug Gregor via Phabricator via cfe-commits
doug.gregor accepted this revision.
doug.gregor added a comment.
This revision is now accepted and ready to land.

This looks great to me, thank you!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92495/new/

https://reviews.llvm.org/D92495

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


[PATCH] D92444: [CMake][Fuchsia] Install llvm-elfabi

2020-12-02 Thread Roland McGrath via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG70764c02e474: [CMake][Fuchsia] Install llvm-elfabi (authored 
by mcgrathr).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92444/new/

https://reviews.llvm.org/D92444

Files:
  clang/cmake/caches/Fuchsia-stage2.cmake


Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -245,6 +245,7 @@
   llvm-dlltool
   llvm-dwarfdump
   llvm-dwp
+  llvm-elfabi
   llvm-gsymutil
   llvm-lib
   llvm-mt


Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -245,6 +245,7 @@
   llvm-dlltool
   llvm-dwarfdump
   llvm-dwp
+  llvm-elfabi
   llvm-gsymutil
   llvm-lib
   llvm-mt
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 70764c0 - [CMake][Fuchsia] Install llvm-elfabi

2020-12-02 Thread Roland McGrath via cfe-commits

Author: Roland McGrath
Date: 2020-12-02T11:59:14-08:00
New Revision: 70764c02e474504e2ebfb5b230a3b2ccdbedc5c2

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

LOG: [CMake][Fuchsia] Install llvm-elfabi

The canonical Fuchsia toolchain configuration installs llvm-elfabi.

Reviewed By: haowei

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

Added: 


Modified: 
clang/cmake/caches/Fuchsia-stage2.cmake

Removed: 




diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 74c393fa7a8b..16bc96be1138 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -245,6 +245,7 @@ set(LLVM_TOOLCHAIN_TOOLS
   llvm-dlltool
   llvm-dwarfdump
   llvm-dwp
+  llvm-elfabi
   llvm-gsymutil
   llvm-lib
   llvm-mt



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


[PATCH] D92257: [clang-format] Add option to control the space at the front of a line comment

2020-12-02 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added inline comments.



Comment at: clang/docs/ClangFormatStyleOptions.rst:2710
 
+**SpacesInLineComments** (``SpacesInLineComment``)
+  How many spaces are allowed at the start of a line comment. To disable the

MyDeveloperDay wrote:
> Is this change generated? with clang/doc/tools/dump_style.py or did you hand 
> craft it?
> 
> ClangFormatStyleOptions.rst is always autogenerated from running 
> dump_style.py, any text you want in the rst needs to be present in Format.h
Yes it is generated, after you told me what I have to do on D91507 I have (and 
will in the future) always run that script, I've not touched the file directly.

But I also have not really looked at it, because it is generated. If it is a 
bit odd I can retake a look on other options with nested entries.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92257/new/

https://reviews.llvm.org/D92257

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


[PATCH] D92445: [PowerPC] Add powerpcle target.

2020-12-02 Thread Brandon Bergren via Phabricator via cfe-commits
Bdragon28 added a comment.

In D92445#2428563 , @sfertile wrote:

>> On FreeBSD, the main use of this will be on the new powerpc64le arch, where 
>> we need to build a 32-bit LE bootloader for use with pseries. (it is easier 
>> to retarget LLVM than make a cross-endian bootloader, as it would involve 
>> rewriting filesystem code etc.)
>
> Excuse my ignorance, but what are there technical limitations preventing 
> writing n 64-bit LE boot loader and avoid having a 32-bit LE target 
> all-together?

LoPAPR client binding requirements, section B.10.
"OF Client Programs for an LoPAPR platform shall execute in 32-bit mode with an 
OF cell size of 1."

FreeBSD loader on pseries is an OF client, and as such, while it is free to be 
either BE or LE (OF is required to adapt itself), it MUST be a 32-bit image.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92445/new/

https://reviews.llvm.org/D92445

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


[PATCH] D92354: [clang] add a new `swift_attr` attribute

2020-12-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Basic/Attr.td:2153
+def SwiftAttr : InheritableAttr {
+  let Spellings = [Clang<"swift_attr">];
+  let Args = [StringArgument<"Attribute">];

The other swift attributes use a GNU spelling and don't expose any C++ 
spelling. Should this follow suit (or should the other attributes be updated)?



Comment at: clang/include/clang/Basic/AttrDocs.td:3635
+  let Content = [{
+The ``swift_attr`` provides a Swift-specific annotation for the declaration
+to which the attribute appertains to. This kind of annotation is ignored by

What declarations does this attribute appertain to?



Comment at: clang/include/clang/Basic/AttrDocs.td:3637
+to which the attribute appertains to. This kind of annotation is ignored by
+clang as it doesn't have any semantic meaning in languages supported by clang.
+The Swift compiler can interpret these annotations according to its own rules

clang -> Clang


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92354/new/

https://reviews.llvm.org/D92354

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


[PATCH] D92355: [clang] add a `swift_async_name` attribute

2020-12-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman requested changes to this revision.
aaron.ballman added a comment.
This revision now requires changes to proceed.

There's no information in either the attribute definition in Attr.td or in the 
documentation as to what subject this attribute applies to.




Comment at: clang/lib/Sema/SemaDeclAttr.cpp:5950
+Diag(Loc, diag::warn_attr_swift_name_decl_missing_params)
+<< AL << (isa(D) ? 1 : 0);
+return false;

Do you actually need the ?: operator here, or is the conversion from bool 
sufficient?



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:6019
+static void handleSwiftName(Sema &S, Decl *D, const ParsedAttr &AL,
+bool IsAsync = false) {
   StringRef Name;

Please do not add an additional parameter to the handle functions -- we have a 
stretch goal of automating more of the switch behavior in SemaDeclAttr.cpp 
someday and we can only do that if the handle* functions have the same 
signatures.



Comment at: clang/test/SemaObjC/attr-swift_name.m:184
+
+// expected-warning@+1 {{too many parameters in '__swift_async_name__' 
attribute (expected 1; got 2)}}
+- (void)doSomethingY:(int)x withCallback:(CallbackTy)callback 
SWIFT_ASYNC_NAME("doSomething(x:y:)");

This diagnostic is too confusing for me -- a lot of people get 
parameter/argument confused and so this reads a bit like the *attribute* has 
too many arguments to it when the real issue is that the signature specified by 
the attribute argument has too many parameters.

How about: `too many parameters in the signature specified by the 
'swift_async_name' attribute` or something along those lines?

Also, missing tests for the number of arguments passed to the attribute. :-)



Comment at: clang/test/SemaObjC/attr-swift_name.m:197
+void asyncNoParams(void) SWIFT_ASYNC_NAME("asyncNoParams()");
+
+// expected-warning@+1 {{'__swift_async_name__' attribute cannot be applied to 
this declaration}}

It's not clear whether we should have additional tests around other subjects - 
like, can I apply this attribute to a virtual class function in C++? If you can 
apply it to a C++ class method, does the implicit `this` parameter count when 
checking for the right parameter count?

Should also have a test that the attribute applies to a vanilla function (the 
only test currently fails because the function has no args, but we should show 
an explicitly accepted case as well).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92355/new/

https://reviews.llvm.org/D92355

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


[PATCH] D91756: [CSSPGO] Pseudo probes for function calls.

2020-12-02 Thread Wei Mi via Phabricator via cfe-commits
wmi accepted this revision.
wmi added a comment.
This revision is now accepted and ready to land.

In D91756#2427795 , @hoy wrote:

> In D91756#2427759 , @wmi wrote:
>
>> Another question. Sorry for not bringing it up earlier. When a call with 
>> probe metadata attached is inlined, the probe will be gone or it will be 
>> kept somehow? I think you want to keep the probe especially for inline 
>> instance to reconstruct the context but I didn't figure it out how you did 
>> that from the description.
>
> No problem. Sorry for not clarifying it in the description. When a callee is 
> inlined, the probe metadata will go with the inlined instructions. The `!dbg` 
> metadata of an inlined instruction is in form of a scope stack. The top of 
> the stack is the instruction's original `!dbg` metadata and the bottom of the 
> stack is the for the original callsite of the top-level inliner. Except for 
> the top of the stack, all other elements of the stack actually refer to the 
> nested inlined callsites whose discriminator fields (which actually 
> represents a calliste probe) can be used to represent the inline context of 
> an inlined `PseudoProbeInst` or a `CallInst`. I'll update the description.

I see. Thanks for the explanation.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91756/new/

https://reviews.llvm.org/D91756

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


[PATCH] D91789: [clang-tidy] find/fix unneeded trailing semicolons in macros

2020-12-02 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

Hi @trixirt , thanks for the follow up.  I think the lint feedback about 
qualifying `auto` with pointers where applicable would be nice to have. Please 
make those suggested changes.

Should https://reviews.llvm.org/D90180 be abandoned in favor of this patch?

Would you mind editing the description/commit message of this patch to describe 
to kernel developers how they're expected to run this clang tidy check such 
that the fixits are applied?




Comment at: clang-tools-extra/clang-tidy/linuxkernel/ExtraSemiCheck.h:20
+
+enum ExtraSemiFixerKind { ESFK_None, ESFK_Switch, ESFK_TrailingMacro };
+class ExtraSemiCheck : public ClangTidyCheck {

Can this enum be declared within the class scope of `ExtraSemiCheck` rather 
than outside of it?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91789/new/

https://reviews.llvm.org/D91789

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


[PATCH] D92436: [Time-report] Add a flag -ftime-report={per-pass,per-pass-run} to control the pass timing aggregation

2020-12-02 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 309020.
ychen added a comment.

- rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92436/new/

https://reviews.llvm.org/D92436

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/include/clang/Frontend/FrontendOptions.h
  clang/include/clang/Frontend/Utils.h
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CMakeLists.txt
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Frontend/FrontendTiming.cpp
  clang/test/Driver/time-report.c
  clang/test/Misc/time-passes.c
  llvm/include/llvm/IR/PassTimingInfo.h
  llvm/include/llvm/Pass.h
  llvm/lib/IR/PassTimingInfo.cpp
  llvm/test/Other/time-passes.ll

Index: llvm/test/Other/time-passes.ll
===
--- llvm/test/Other/time-passes.ll
+++ llvm/test/Other/time-passes.ll
@@ -1,9 +1,15 @@
 ; RUN: opt -enable-new-pm=0 < %s -disable-output -instcombine -instcombine -licm -time-passes 2>&1 | FileCheck %s --check-prefix=TIME --check-prefix=TIME-LEGACY
 ; RUN: opt -enable-new-pm=0 < %s -disable-output -instcombine -instcombine -licm -licm -time-passes 2>&1 | FileCheck %s --check-prefix=TIME --check-prefix=TIME-LEGACY --check-prefix=TIME-DOUBLE-LICM-LEGACY
-; RUN: opt < %s -disable-output -passes='instcombine,instcombine,loop(licm)' -time-passes 2>&1 | FileCheck %s --check-prefix=TIME --check-prefix=TIME-NEW
-; RUN: opt < %s -disable-output -passes='instcombine,loop(licm),instcombine,loop(licm)' -time-passes 2>&1 | FileCheck %s --check-prefix=TIME --check-prefix=TIME-NEW -check-prefix=TIME-DOUBLE-LICM-NEW
 ; RUN: opt < %s -disable-output -passes='default' -time-passes 2>&1 | FileCheck %s --check-prefix=TIME
 ;
+; For new pass manager, check that -time-passes-per-run emit one report for each pass run.
+; RUN: opt < %s -disable-output -passes='instcombine,instcombine,loop(licm)' -time-passes-per-run 2>&1 | FileCheck %s --check-prefix=TIME --check-prefix=TIME-NEW
+; RUN: opt < %s -disable-output -passes='instcombine,loop(licm),instcombine,loop(licm)' -time-passes-per-run 2>&1 | FileCheck %s --check-prefix=TIME --check-prefix=TIME-NEW -check-prefix=TIME-DOUBLE-LICM-NEW
+;
+; For new pass manager, check that -time-passes emit one report for each pass.
+; RUN: opt < %s -disable-output -passes='instcombine,instcombine,loop(licm)' -time-passes 2>&1 | FileCheck %s --check-prefixes=TIME,TIME-NEW-PER-PASS
+; RUN: opt < %s -disable-output -passes='instcombine,loop(licm),instcombine,loop(licm)' -time-passes 2>&1 | FileCheck %s --check-prefixes=TIME,TIME-NEW-PER-PASS
+;
 ; The following 4 test runs verify -info-output-file interaction (default goes to stderr, '-' goes to stdout).
 ; RUN: opt -enable-new-pm=0 < %s -disable-output -O2 -time-passes -info-output-file='-' 2>/dev/null | FileCheck %s --check-prefix=TIME
 ; RUN: opt < %s -disable-output -passes='default' -time-passes -info-output-file='-' 2>/dev/null | FileCheck %s --check-prefix=TIME
@@ -46,6 +52,15 @@
 ; TIME-NEW-DAG:  VerifierPass
 ; TIME-NEW-DAG:  DominatorTreeAnalysis
 ; TIME-NEW-DAG:  TargetLibraryAnalysis
+; TIME-NEW-PER-PASS-DAG:   InstCombinePass
+; TIME-NEW-PER-PASS-DAG:   LICMPass
+; TIME-NEW-PER-PASS-DAG:   LCSSAPass
+; TIME-NEW-PER-PASS-DAG:   LoopSimplifyPass
+; TIME-NEW-PER-PASS-DAG:   ScalarEvolutionAnalysis
+; TIME-NEW-PER-PASS-DAG:   LoopAnalysis
+; TIME-NEW-PER-PASS-DAG:   VerifierPass
+; TIME-NEW-PER-PASS-DAG:   DominatorTreeAnalysis
+; TIME-NEW-PER-PASS-DAG:   TargetLibraryAnalysis
 ; TIME: Total{{$}}
 
 define i32 @foo() {
Index: llvm/lib/IR/PassTimingInfo.cpp
===
--- llvm/lib/IR/PassTimingInfo.cpp
+++ llvm/lib/IR/PassTimingInfo.cpp
@@ -35,11 +35,17 @@
 namespace llvm {
 
 bool TimePassesIsEnabled = false;
+bool TimePassesPerRun = false;
 
 static cl::opt EnableTiming(
 "time-passes", cl::location(TimePassesIsEnabled), cl::Hidden,
 cl::desc("Time each pass, printing elapsed time for each on exit"));
 
+static cl::opt EnableTimingPerRun(
+"time-passes-per-run", cl::location(TimePassesPerRun), cl::Hidden,
+cl::desc("Time each pass run, printing elapsed time for each run on exit"),
+cl::callback([](const bool &) { TimePassesIsEnabled = true; }));
+
 namespace {
 namespace legacy {
 
@@ -165,6 +171,13 @@
 /// Returns the timer for the specified pass invocation of \p PassID.
 /// Each time it creates a new timer.
 Timer &TimePassesHandler::getPassTimer(StringRef PassID) {
+  if (!PerRun) {
+TimerVector &Timers = TimingData[PassID];
+if (Timers.size() == 0)
+  Timers.emplace_back(new Timer(PassID, PassID, TG));
+return *Timers.front();
+  }
+
   // Take a vector of Timers created for this \p PassID and append
   // one more timer to it.
   TimerVector &Timers = TimingData[PassID

[PATCH] D91455: [XCOFF][AIX] Generate LSDA data and compact unwind section on AIX

2020-12-02 Thread Jason Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa65d8c5d720d: [XCOFF][AIX] Generate LSDA data and compact 
unwind section on AIX (authored by jasonliu).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D91455?vs=308752&id=309007#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91455/new/

https://reviews.llvm.org/D91455

Files:
  clang/lib/CodeGen/CGCleanup.h
  clang/lib/CodeGen/CGException.cpp
  clang/test/CodeGenCXX/personality.cpp
  llvm/include/llvm/Analysis/EHPersonalities.h
  llvm/include/llvm/CodeGen/AsmPrinter.h
  llvm/include/llvm/MC/MCTargetOptions.h
  llvm/lib/Analysis/EHPersonalities.cpp
  llvm/lib/CodeGen/AsmPrinter/AIXException.cpp
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp
  llvm/lib/CodeGen/AsmPrinter/CMakeLists.txt
  llvm/lib/CodeGen/AsmPrinter/DwarfException.h
  llvm/lib/CodeGen/AsmPrinter/EHStreamer.cpp
  llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
  llvm/lib/CodeGen/TargetPassConfig.cpp
  llvm/lib/MC/MCAsmInfoXCOFF.cpp
  llvm/lib/MC/MCObjectFileInfo.cpp
  llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
  llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
  llvm/test/CodeGen/PowerPC/aix-exception.ll

Index: llvm/test/CodeGen/PowerPC/aix-exception.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/aix-exception.ll
@@ -0,0 +1,152 @@
+; RUN: llc -verify-machineinstrs -mtriple powerpc-ibm-aix-xcoff -mcpu=pwr4 \
+; RUN: -mattr=-altivec < %s | \
+; RUN:   FileCheck --check-prefixes=ASM,ASM32 %s
+
+; RUN: llc -verify-machineinstrs -mtriple powerpc64-ibm-aix-xcoff -mcpu=pwr4 \
+; RUN: -mattr=-altivec < %s | \
+; RUN:   FileCheck --check-prefixes=ASM,ASM64 %s
+
+@_ZTIi = external constant i8*
+
+define void @_Z9throwFuncv() {
+entry:
+  %exception = call i8* @__cxa_allocate_exception(i32 4) #2
+  %0 = bitcast i8* %exception to i32*
+  store i32 1, i32* %0, align 16
+  call void @__cxa_throw(i8* %exception, i8* bitcast (i8** @_ZTIi to i8*), i8* null) #3
+  unreachable
+}
+
+; ASM:._Z9throwFuncv:
+; ASM:  bl .__cxa_allocate_exception[PR]
+; ASM:  nop
+; ASM32:lwz 4, L..C0(2)
+; ASM64:ld 4, L..C0(2)
+; ASM:  bl .__cxa_throw[PR]
+; ASM:  nop
+
+define i32 @_Z9catchFuncv() personality i8* bitcast (i32 (...)* @__xlcxx_personality_v1 to i8*) {
+entry:
+  %retval = alloca i32, align 4
+  %exn.slot = alloca i8*, align 4
+  %ehselector.slot = alloca i32, align 4
+  %0 = alloca i32, align 4
+  invoke void @_Z9throwFuncv()
+  to label %invoke.cont unwind label %lpad
+
+invoke.cont:  ; preds = %entry
+  br label %try.cont
+
+lpad: ; preds = %entry
+  %1 = landingpad { i8*, i32 }
+  catch i8* bitcast (i8** @_ZTIi to i8*)
+  %2 = extractvalue { i8*, i32 } %1, 0
+  store i8* %2, i8** %exn.slot, align 4
+  %3 = extractvalue { i8*, i32 } %1, 1
+  store i32 %3, i32* %ehselector.slot, align 4
+  br label %catch.dispatch
+
+catch.dispatch:   ; preds = %lpad
+  %sel = load i32, i32* %ehselector.slot, align 4
+  %4 = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIi to i8*)) #2
+  %matches = icmp eq i32 %sel, %4
+  br i1 %matches, label %catch, label %eh.resume
+
+catch:; preds = %catch.dispatch
+  %exn = load i8*, i8** %exn.slot, align 4
+  %5 = call i8* @__cxa_begin_catch(i8* %exn) #2
+  %6 = bitcast i8* %5 to i32*
+  %7 = load i32, i32* %6, align 4
+  store i32 %7, i32* %0, align 4
+  store i32 2, i32* %retval, align 4
+  call void @__cxa_end_catch() #2
+  br label %return
+
+try.cont: ; preds = %invoke.cont
+  store i32 1, i32* %retval, align 4
+  br label %return
+
+return:   ; preds = %try.cont, %catch
+  %8 = load i32, i32* %retval, align 4
+  ret i32 %8
+
+eh.resume:; preds = %catch.dispatch
+  %exn1 = load i8*, i8** %exn.slot, align 4
+  %sel2 = load i32, i32* %ehselector.slot, align 4
+  %lpad.val = insertvalue { i8*, i32 } undef, i8* %exn1, 0
+  %lpad.val3 = insertvalue { i8*, i32 } %lpad.val, i32 %sel2, 1
+  resume { i8*, i32 } %lpad.val3
+}
+
+; ASM:  ._Z9catchFuncv:
+; ASM:  L..func_begin0:
+; ASM:  # %bb.0:# %entry
+; ASM:  	mflr 0
+; ASM:  L..tmp0:
+; ASM:  	bl ._Z9throwFuncv
+; ASM:  	nop
+; ASM:  L..tmp1:
+; ASM:  # %bb.1:# %invoke.cont
+; ASM:  	li 3, 1
+; ASM:  L..BB1_2:   # %return
+; ASM:  	mtlr 0
+; ASM:  	blr
+; ASM:  L..BB1_3:   # %lpad
+; ASM:  L..tmp2:
+; ASM:  	bl .__cxa_begin_catch[PR]
+; ASM:  	nop
+; ASM:  	bl .__cxa_end_catch[PR]
+; ASM:  	nop
+; ASM:  	b L..BB1_2
+; ASM:  L..func_end0:
+
+; ASM:  

[clang] a65d8c5 - [XCOFF][AIX] Generate LSDA data and compact unwind section on AIX

2020-12-02 Thread via cfe-commits

Author: jasonliu
Date: 2020-12-02T18:42:44Z
New Revision: a65d8c5d720db8c646adb0ad9dac54da5d5fa230

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

LOG: [XCOFF][AIX] Generate LSDA data and compact unwind section on AIX

Summary:
AIX uses the existing EH infrastructure in clang and llvm.
The major differences would be
1. AIX do not have CFI instructions.
2. AIX uses a new personality routine, named __xlcxx_personality_v1.
   It doesn't use the GCC personality rountine, because the
   interoperability is not there yet on AIX.
3. AIX do not use eh_frame sections. Instead, it would use a eh_info
section (compat unwind section) to store the information about
personality routine and LSDA data address.

Reviewed By: daltenty, hubert.reinterpretcast

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

Added: 
llvm/lib/CodeGen/AsmPrinter/AIXException.cpp
llvm/test/CodeGen/PowerPC/aix-exception.ll

Modified: 
clang/lib/CodeGen/CGCleanup.h
clang/lib/CodeGen/CGException.cpp
clang/test/CodeGenCXX/personality.cpp
llvm/include/llvm/Analysis/EHPersonalities.h
llvm/include/llvm/CodeGen/AsmPrinter.h
llvm/include/llvm/MC/MCTargetOptions.h
llvm/lib/Analysis/EHPersonalities.cpp
llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
llvm/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp
llvm/lib/CodeGen/AsmPrinter/CMakeLists.txt
llvm/lib/CodeGen/AsmPrinter/DwarfException.h
llvm/lib/CodeGen/AsmPrinter/EHStreamer.cpp
llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
llvm/lib/CodeGen/TargetPassConfig.cpp
llvm/lib/MC/MCAsmInfoXCOFF.cpp
llvm/lib/MC/MCObjectFileInfo.cpp
llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
llvm/lib/Transforms/InstCombine/InstructionCombining.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGCleanup.h b/clang/lib/CodeGen/CGCleanup.h
index ef4f6b9ec133..1b54c0018d27 100644
--- a/clang/lib/CodeGen/CGCleanup.h
+++ b/clang/lib/CodeGen/CGCleanup.h
@@ -612,6 +612,7 @@ struct EHPersonality {
   static const EHPersonality MSVC_C_specific_handler;
   static const EHPersonality MSVC_CxxFrameHandler3;
   static const EHPersonality GNU_Wasm_CPlusPlus;
+  static const EHPersonality XL_CPlusPlus;
 
   /// Does this personality use landingpads or the family of pad instructions
   /// designed to form funclets?

diff  --git a/clang/lib/CodeGen/CGException.cpp 
b/clang/lib/CodeGen/CGException.cpp
index bdf70252b5ad..85604cf5e611 100644
--- a/clang/lib/CodeGen/CGException.cpp
+++ b/clang/lib/CodeGen/CGException.cpp
@@ -113,6 +113,8 @@ const EHPersonality
 EHPersonality::MSVC_CxxFrameHandler3 = { "__CxxFrameHandler3", nullptr };
 const EHPersonality
 EHPersonality::GNU_Wasm_CPlusPlus = { "__gxx_wasm_personality_v0", nullptr };
+const EHPersonality EHPersonality::XL_CPlusPlus = {"__xlcxx_personality_v1",
+   nullptr};
 
 static const EHPersonality &getCPersonality(const TargetInfo &Target,
 const LangOptions &L) {
@@ -161,6 +163,8 @@ static const EHPersonality &getCXXPersonality(const 
TargetInfo &Target,
   const llvm::Triple &T = Target.getTriple();
   if (T.isWindowsMSVCEnvironment())
 return EHPersonality::MSVC_CxxFrameHandler3;
+  if (T.isOSAIX())
+return EHPersonality::XL_CPlusPlus;
   if (L.SjLjExceptions)
 return EHPersonality::GNU_CPlusPlus_SJLJ;
   if (L.DWARFExceptions)

diff  --git a/clang/test/CodeGenCXX/personality.cpp 
b/clang/test/CodeGenCXX/personality.cpp
index ce4bad370d91..1bdc7736c4da 100644
--- a/clang/test/CodeGenCXX/personality.cpp
+++ b/clang/test/CodeGenCXX/personality.cpp
@@ -12,6 +12,9 @@
 // RUN: %clang_cc1 -triple i686-unknown-windows-gnu -fexceptions 
-fseh-exceptions -fcxx-exceptions -S -emit-llvm %s -o - | FileCheck %s 
-check-prefix CHECK-GNU-SEH
 // RUN: %clang_cc1 -triple i686-unknown-windows-gnu -fexceptions 
-fsjlj-exceptions -fcxx-exceptions -S -emit-llvm %s -o - | FileCheck %s 
-check-prefix CHECK-GNU-SJLJ
 
+// RUN: %clang_cc1 -triple powerpc-unknown-aix-xcoff -fexceptions 
-fcxx-exceptions -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-AIX
+// RUN: %clang_cc1 -triple powerpc64-unknown-aix-xcoff -fexceptions 
-fcxx-exceptions -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-AIX
+
 extern void g();
 
 // CHECK-GNU: personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
@@ -21,6 +24,8 @@ extern void g();
 
 // CHECK-WIN: personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
 
+// CHECK-AIX: personality i8* bitcast (i32 (...)* @__xlcxx_personality_v1 to 
i8*)
+
 void f() {
   try {
 g();

diff  --git a/llvm/include/llvm/Analysis/EHPersonalities.h 
b/llvm/include/llvm/Analysis/EHPersonalities.h
index 1905e0543fee..eaada6627494 100644
--- a/llvm/include/llvm/Analys

[PATCH] D80450: [CUDA][HIP] Fix HD function resolution

2020-12-02 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

In D80450#2428631 , @yaxunl wrote:

>> Also,  naming. `-ffix-overload-resolution` is rather non-specific. I didn't 
>> mean to use it literally. The problem is that I can't think of a good 
>> descriptive name for what we do here. `-fgpu-fix-wrong-side-overloads` ? 
>> Something else?
>
> How about `-fgpu-exclude-wrong-side-overloads`? Since what this patch does is 
> always excluding wrong side overloads whereas previously only excluding wrong 
> side overloads if there are same side overloads.

SGTM. Maybe, also make it hidden. I don't think it's useful for the end users.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80450/new/

https://reviews.llvm.org/D80450

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


[PATCH] D92278: [Clang] Don't adjust align for IBM extended double type

2020-12-02 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/test/CodeGen/ppc64le-varargs-f128.c:8
 
+// RUN: %clang -target powerpc64le-unknown-linux-gnu -S -emit-llvm \
+// RUN:   -fopenmp-targets=ppc64le -mfloat128 -mabi=ieeelongdouble -mcpu=pwr9 \

Generally `%clang` is only used in test/Driver and `%clang_cc1` should be used 
for tests.

`%clang_cc1` has a lit substitution rule to find the builtin include directory 
where stdarg.h can be found.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92278/new/

https://reviews.llvm.org/D92278

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


[PATCH] D92495: [clang] Add a new nullability annotation for swift async: _Nullable_result

2020-12-02 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington created this revision.
erik.pilkington added reviewers: arphaman, doug.gregor, aaron.ballman.
Herald added subscribers: dexonsmith, ributzka, jfb, jkorous.
erik.pilkington requested review of this revision.

You can read more about the clang attributes for swift async here:
https://github.com/DougGregor/swift-evolution/blob/concurrency-objc/proposals/-concurrency-objc.md

rdar://70106409

Thanks for taking a look!


https://reviews.llvm.org/D92495

Files:
  clang/include/clang-c/Index.h
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/Specifiers.h
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Sema/Sema.h
  clang/lib/APINotes/APINotesYAMLCompiler.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/Basic/Diagnostic.cpp
  clang/lib/Basic/IdentifierTable.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseTentative.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprObjC.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/Index/nullability.c
  clang/test/SemaObjC/nullability.m
  clang/test/SemaObjC/nullable-result.m
  clang/tools/c-index-test/c-index-test.c
  clang/tools/libclang/CXType.cpp

Index: clang/tools/libclang/CXType.cpp
===
--- clang/tools/libclang/CXType.cpp
+++ clang/tools/libclang/CXType.cpp
@@ -1315,6 +1315,8 @@
 return CXTypeNullability_NonNull;
   case NullabilityKind::Nullable:
 return CXTypeNullability_Nullable;
+  case NullabilityKind::NullableResult:
+return CXTypeNullability_NullableResult;
   case NullabilityKind::Unspecified:
 return CXTypeNullability_Unspecified;
 }
Index: clang/tools/c-index-test/c-index-test.c
===
--- clang/tools/c-index-test/c-index-test.c
+++ clang/tools/c-index-test/c-index-test.c
@@ -1539,10 +1539,20 @@
 
   const char *nullability = 0;
   switch (N) {
-case CXTypeNullability_NonNull: nullability = "nonnull"; break;
-case CXTypeNullability_Nullable: nullability = "nullable"; break;
-case CXTypeNullability_Unspecified: nullability = "unspecified"; break;
-case CXTypeNullability_Invalid: break;
+  case CXTypeNullability_NonNull:
+nullability = "nonnull";
+break;
+  case CXTypeNullability_Nullable:
+nullability = "nullable";
+break;
+  case CXTypeNullability_NullableResult:
+nullability = "nullable_result";
+break;
+  case CXTypeNullability_Unspecified:
+nullability = "unspecified";
+break;
+  case CXTypeNullability_Invalid:
+break;
   }
 
   if (nullability) {
Index: clang/test/SemaObjC/nullable-result.m
===
--- /dev/null
+++ clang/test/SemaObjC/nullable-result.m
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -fblocks -Wnullable-to-nonnull-conversion %s
+// RUN: %clang_cc1 -xobjective-c++ -verify -fsyntax-only -fblocks -Wnullable-to-nonnull-conversion %s
+
+@class X;
+@class NSError;
+
+@interface SomeClass
+-(void)async_get:(void (^)(X *_Nullable_result rptr, NSError *err))completionHandler;
+@end
+
+void call(SomeClass *sc) {
+  [sc async_get:^(X *_Nullable_result rptr, NSError *err) {}];
+  [sc async_get:^(X *_Nullable rptr, NSError *err) {}];
+}
+
+void test_conversion() {
+  X *_Nullable_result nr;
+  X *_Nonnull l = nr; // expected-warning{{implicit conversion from nullable pointer 'X * _Nullable_result' to non-nullable pointer type 'X * _Nonnull'}}
+
+  (void)^(X * _Nullable_result p) {
+X *_Nonnull l = p; // expected-warning{{implicit conversion from nullable pointer 'X * _Nullable_result' to non-nullable pointer type 'X * _Nonnull'}}
+  };
+}
+
+void test_dup() {
+  id _Nullable_result _Nullable_result a; // expected-warning {{duplicate nullability specifier _Nullable_result}}
+  id _Nullable _Nullable_result b; // expected-error{{nullability specifier _Nullable_result conflicts with existing specifier '_Nullable'}}
+  id _Nullable_result _Nonnull c; // expected-error{{nullability specifier '_Nonnull' conflicts with existing specifier _Nullable_result}}
+}
Index: clang/test/SemaObjC/nullability.m
===
--- clang/test/SemaObjC/nullability.m
+++ clang/test/SemaObjC/nullability.m
@@ -116,11 +116,13 @@
 - (nonnull id)returnsNonNull;
 - (nullable id)returnsNullable;
 - (null_unspecified id)returnsNullUnspecified;
+- (_Nullable_result id)returnsNullableResult;
 @end
 
 void test_receiver_merge(NSMergeReceiver *none,
  _Nonnull NSMergeReceiver *nonnull,
  _Nullable NSMergeReceiver *nullable,
+ _Nullable_result NSMergeReceiver *nullable_result,
  _Null_unspecified NSMergeRece

[PATCH] D92494: [clangd] Bundle code completion items when the include paths differ, but resolve to the same file.

2020-12-02 Thread Adam Czachorowski via Phabricator via cfe-commits
adamcz updated this revision to Diff 309003.
adamcz added a comment.

-bracket


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92494/new/

https://reviews.llvm.org/D92494

Files:
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp


Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -1628,6 +1628,29 @@
   EXPECT_EQ(A.SnippetSuffix, "($0)");
 }
 
+TEST(CompletionTest, OverloadBundlingSameFileDifferentURI) {
+  clangd::CodeCompleteOptions Opts;
+  Opts.BundleOverloads = true;
+
+  Symbol SymX = sym("ns::X", index::SymbolKind::Function, "@F@\\0#");
+  Symbol SymY = sym("ns::X", index::SymbolKind::Function, "@F@\\0#I#");
+  std::string BarHeader = testPath("bar.h");
+  auto BarURI = URI::create(BarHeader).toString();
+  SymX.CanonicalDeclaration.FileURI = BarURI.c_str();
+  SymY.CanonicalDeclaration.FileURI = BarURI.c_str();
+  // The include header is different, but really it's the same file.
+  SymX.IncludeHeaders.emplace_back("\"bar.h\"", 1);
+  SymY.IncludeHeaders.emplace_back(BarURI.c_str(), 1);
+
+  auto Results = completions("void f() { ::ns::^ }", {SymX, SymY}, Opts);
+  // Expect both results are bundled, despite the different-but-same
+  // IncludeHeader.
+  ASSERT_EQ(1u, Results.Completions.size());
+  const auto &R = Results.Completions.front();
+  EXPECT_EQ("X", R.Name);
+  EXPECT_EQ(2u, R.BundleSize);
+}
+
 TEST(CompletionTest, DocumentationFromChangedFileCrash) {
   MockFS FS;
   auto FooH = testPath("foo.h");
Index: clang-tools-extra/clangd/CodeComplete.cpp
===
--- clang-tools-extra/clangd/CodeComplete.cpp
+++ clang-tools-extra/clangd/CodeComplete.cpp
@@ -173,9 +173,22 @@
 
   // Returns a token identifying the overload set this is part of.
   // 0 indicates it's not part of any overload set.
-  size_t overloadSet(const CodeCompleteOptions &Opts) const {
+  size_t overloadSet(const CodeCompleteOptions &Opts, llvm::StringRef FileName,
+ IncludeInserter *Inserter) const {
 if (!Opts.BundleOverloads.getValueOr(false))
   return 0;
+
+// Depending on the index implementation, we can see different header
+// strings (literal or URI) mapping to the same file. We still want to
+// bundle those, so we must resolve the header to be included here.
+std::string HeaderForHash;
+if (Inserter)
+  if (auto Header = headerToInsertIfAllowed(Opts))
+if (auto HeaderFile = toHeaderFile(*Header, FileName))
+  if (auto Spelled =
+  Inserter->calculateIncludePath(*HeaderFile, FileName))
+HeaderForHash = *Spelled;
+
 llvm::SmallString<256> Scratch;
 if (IndexResult) {
   switch (IndexResult->SymInfo.Kind) {
@@ -192,7 +205,7 @@
 // This could break #include insertion.
 return llvm::hash_combine(
 (IndexResult->Scope + IndexResult->Name).toStringRef(Scratch),
-headerToInsertIfAllowed(Opts).getValueOr(""));
+HeaderForHash);
   default:
 return 0;
   }
@@ -206,8 +219,7 @@
 llvm::raw_svector_ostream OS(Scratch);
 D->printQualifiedName(OS);
   }
-  return llvm::hash_combine(Scratch,
-headerToInsertIfAllowed(Opts).getValueOr(""));
+  return llvm::hash_combine(Scratch, HeaderForHash);
 }
 assert(IdentifierResult);
 return 0;
@@ -1570,7 +1582,8 @@
 assert(IdentifierResult);
 C.Name = IdentifierResult->Name;
   }
-  if (auto OverloadSet = C.overloadSet(Opts)) {
+  if (auto OverloadSet = C.overloadSet(
+  Opts, FileName, Inserter ? Inserter.getPointer() : nullptr)) {
 auto Ret = BundleLookup.try_emplace(OverloadSet, Bundles.size());
 if (Ret.second)
   Bundles.emplace_back();


Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -1628,6 +1628,29 @@
   EXPECT_EQ(A.SnippetSuffix, "($0)");
 }
 
+TEST(CompletionTest, OverloadBundlingSameFileDifferentURI) {
+  clangd::CodeCompleteOptions Opts;
+  Opts.BundleOverloads = true;
+
+  Symbol SymX = sym("ns::X", index::SymbolKind::Function, "@F@\\0#");
+  Symbol SymY = sym("ns::X", index::SymbolKind::Function, "@F@\\0#I#");
+  std::string BarHeader = testPath("bar.h");
+  auto BarURI = URI::create(BarHeader).toString();
+  SymX.CanonicalDeclaration.FileURI = BarURI.c_str();
+  SymY.CanonicalDeclaration.FileURI = BarURI.c_str();
+  // The include header is different, but really it's the same file.
+  SymX.IncludeHeaders.em

[PATCH] D92494: [clangd] Bundle code completion items when the include paths differ, but resolve to the same file.

2020-12-02 Thread Adam Czachorowski via Phabricator via cfe-commits
adamcz created this revision.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman.
Herald added a project: clang.
adamcz requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

This can happen when, for example, merging results from an external
index that generates IncludeHeaders with full URI rather than just
literal include.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92494

Files:
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp


Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -1628,6 +1628,29 @@
   EXPECT_EQ(A.SnippetSuffix, "($0)");
 }
 
+TEST(CompletionTest, OverloadBundlingSameFileDifferentURI) {
+  clangd::CodeCompleteOptions Opts;
+  Opts.BundleOverloads = true;
+
+  Symbol SymX = sym("ns::X", index::SymbolKind::Function, "@F@\\0#");
+  Symbol SymY = sym("ns::X", index::SymbolKind::Function, "@F@\\0#I#");
+  std::string BarHeader = testPath("bar.h");
+  auto BarURI = URI::create(BarHeader).toString();
+  SymX.CanonicalDeclaration.FileURI = BarURI.c_str();
+  SymY.CanonicalDeclaration.FileURI = BarURI.c_str();
+  // The include header is different, but really it's the same file.
+  SymX.IncludeHeaders.emplace_back("\"bar.h\"", 1);
+  SymY.IncludeHeaders.emplace_back(BarURI.c_str(), 1);
+
+  auto Results = completions("void f() { ::ns::^ }", {SymX, SymY}, Opts);
+  // Expect both results are bundled, despite the different-but-same
+  // IncludeHeader.
+  ASSERT_EQ(1u, Results.Completions.size());
+  const auto &R = Results.Completions.front();
+  EXPECT_EQ("X", R.Name);
+  EXPECT_EQ(2u, R.BundleSize);
+}
+
 TEST(CompletionTest, DocumentationFromChangedFileCrash) {
   MockFS FS;
   auto FooH = testPath("foo.h");
Index: clang-tools-extra/clangd/CodeComplete.cpp
===
--- clang-tools-extra/clangd/CodeComplete.cpp
+++ clang-tools-extra/clangd/CodeComplete.cpp
@@ -173,9 +173,23 @@
 
   // Returns a token identifying the overload set this is part of.
   // 0 indicates it's not part of any overload set.
-  size_t overloadSet(const CodeCompleteOptions &Opts) const {
+  size_t overloadSet(const CodeCompleteOptions &Opts, llvm::StringRef FileName,
+ IncludeInserter *Inserter) const {
 if (!Opts.BundleOverloads.getValueOr(false))
   return 0;
+
+// Depending on the index implementation, we can see different header
+// strings (literal or URI) mapping to the same file. We still want to
+// bundle those, so we must resolve the header to be included here.
+std::string HeaderForHash;
+if (Inserter) {
+  if (auto Header = headerToInsertIfAllowed(Opts))
+if (auto HeaderFile = toHeaderFile(*Header, FileName))
+  if (auto Spelled =
+  Inserter->calculateIncludePath(*HeaderFile, FileName))
+HeaderForHash = *Spelled;
+}
+
 llvm::SmallString<256> Scratch;
 if (IndexResult) {
   switch (IndexResult->SymInfo.Kind) {
@@ -192,7 +206,7 @@
 // This could break #include insertion.
 return llvm::hash_combine(
 (IndexResult->Scope + IndexResult->Name).toStringRef(Scratch),
-headerToInsertIfAllowed(Opts).getValueOr(""));
+HeaderForHash);
   default:
 return 0;
   }
@@ -206,8 +220,7 @@
 llvm::raw_svector_ostream OS(Scratch);
 D->printQualifiedName(OS);
   }
-  return llvm::hash_combine(Scratch,
-headerToInsertIfAllowed(Opts).getValueOr(""));
+  return llvm::hash_combine(Scratch, HeaderForHash);
 }
 assert(IdentifierResult);
 return 0;
@@ -1570,7 +1583,8 @@
 assert(IdentifierResult);
 C.Name = IdentifierResult->Name;
   }
-  if (auto OverloadSet = C.overloadSet(Opts)) {
+  if (auto OverloadSet = C.overloadSet(
+  Opts, FileName, Inserter ? Inserter.getPointer() : nullptr)) {
 auto Ret = BundleLookup.try_emplace(OverloadSet, Bundles.size());
 if (Ret.second)
   Bundles.emplace_back();


Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -1628,6 +1628,29 @@
   EXPECT_EQ(A.SnippetSuffix, "($0)");
 }
 
+TEST(CompletionTest, OverloadBundlingSameFileDifferentURI) {
+  clangd::CodeCompleteOptions Opts;
+  Opts.BundleOverloads = true;
+
+  Symbol SymX = sym("ns::X", index::SymbolKind::Function, "@F@\\0#");
+  Symbol SymY = sym("ns::X", index::SymbolKind::Function, "@F@\\0#I#");
+  std::string BarHeader = testPath("bar.h");
+  auto BarURI = 

[PATCH] D92041: [clangd] Add hover info for `this` expr

2020-12-02 Thread xndcn via Phabricator via cfe-commits
xndcn updated this revision to Diff 308994.
xndcn added a comment.

`getHoverInfo(CXXThisExpr->getType()->getPointeeType(), ...)` does not output 
namespace scope and template parameters without specialization:
F14499632: Pointee.png 

while `getHoverInfo(CXXThisExpr->getType(), ...)` looks weird with partial 
specialization:
F14499662: QualType.png 

So I did some mix here...


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92041/new/

https://reviews.llvm.org/D92041

Files:
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp

Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -2019,6 +2019,41 @@
 HI.NamespaceScope = "";
 HI.Definition = "@interface MYObject\n@end";
   }},
+  {
+  R"cpp(// this expr
+  // comment
+  class Foo {
+Foo* bar() {
+  return [[t^his]];
+}
+  };
+  )cpp",
+  [](HoverInfo &HI) { HI.Name = "Foo *"; }},
+  {
+  R"cpp(// this expr for template class
+  namespace ns {
+template 
+class Foo {
+  Foo* bar() {
+return [[t^his]];
+  }
+};
+  }
+  )cpp",
+  [](HoverInfo &HI) { HI.Name = "ns::Foo *"; }},
+  {
+  R"cpp(// this expr for specialization struct
+  namespace ns {
+template  struct Foo {};
+template 
+struct Foo {
+  Foo* bar() {
+return [[thi^s]];
+  }
+};
+  }
+  )cpp",
+  [](HoverInfo &HI) { HI.Name = "ns::Foo *"; }},
   };
 
   // Create a tiny index, so tests above can verify documentation is fetched.
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -628,7 +628,7 @@
   return llvm::StringLiteral("expression");
 }
 
-// Generates hover info for evaluatable expressions.
+// Generates hover info for `this` and evaluatable expressions.
 // FIXME: Support hover for literals (esp user-defined)
 llvm::Optional getHoverContents(const Expr *E, ParsedAST &AST) {
   // There's not much value in hovering over "42" and getting a hover card
@@ -637,6 +637,41 @@
 return llvm::None;
 
   HoverInfo HI;
+  // For `this` expr we currently generate hover with class declaration.
+  if (const CXXThisExpr *CTE = dyn_cast(E)) {
+std::string Name;
+llvm::raw_string_ostream OS(Name);
+
+const NamedDecl *ND = CTE->getType()->getPointeeType()->getAsTagDecl();
+const auto NS = getNamespaceScope(ND);
+if (!NS.empty()) {
+  OS << NS << "::";
+}
+OS << printName(AST.getASTContext(), *ND);
+
+// printName(...) will not output template parameters without specialization
+// so fill in template params here
+if (const TemplateDecl *TD = ND->getDescribedTemplate()) {
+  OS << "<";
+  llvm::StringRef Sep = "";
+  const auto PP =
+  printingPolicyForDecls(AST.getASTContext().getPrintingPolicy());
+  for (const auto &P :
+   fetchTemplateParameters(TD->getTemplateParameters(), PP)) {
+OS << Sep;
+Sep = ", ";
+if (P.Name)
+  OS << P.Name;
+if (P.Default)
+  OS << " = " << P.Default;
+  }
+  OS << ">";
+}
+OS << " *";
+
+HI.Name = OS.str();
+return HI;
+  }
   // For expressions we currently print the type and the value, iff it is
   // evaluatable.
   if (auto Val = printExprValue(E, AST.getASTContext())) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92001: [ubsan] Fix crash on __builtin_assume_aligned

2020-12-02 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: clang/lib/CodeGen/CodeGenFunction.cpp:2524
   // defined.
-  if (Ty->getPointeeType().isVolatileQualified())
+  if (!Ty->getPointeeType().isNull() && 
Ty->getPointeeType().isVolatileQualified())
 return;

vsk wrote:
> Is the pointee type associated with a PointerType QualType ever supposed to 
> be null? I wonder why this happens, and whether it can cause problems in 
> other places.
Basically, we can't just use `getPointeeType()` here, but i'm not sure what 
should be used instead.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92001/new/

https://reviews.llvm.org/D92001

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


[PATCH] D92001: [ubsan] Fix crash on __builtin_assume_aligned

2020-12-02 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added inline comments.



Comment at: clang/lib/CodeGen/CodeGenFunction.cpp:2524
   // defined.
-  if (Ty->getPointeeType().isVolatileQualified())
+  if (!Ty->getPointeeType().isNull() && 
Ty->getPointeeType().isVolatileQualified())
 return;

Is the pointee type associated with a PointerType QualType ever supposed to be 
null? I wonder why this happens, and whether it can cause problems in other 
places.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92001/new/

https://reviews.llvm.org/D92001

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


[PATCH] D87216: [NewPM] Support --print-before/after in NPM

2020-12-02 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added a comment.

In D87216#2428359 , @jamieschmeiser 
wrote:

> I see you have made the requested changes (nit: clang-tidy complained about 
> the capitalization of the function) but why are there so many other, 
> unrelated changes shown?  Is there a problem with the patch?

Fixed the capitalization.

Do you mean moving around options/definitions into PrintPasses.cpp? The 
declarations/definitions don't really have a good place to live right now, I 
moved them to their own file to make it cleaner.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D87216/new/

https://reviews.llvm.org/D87216

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


[PATCH] D92439: Fix missing error for use of 128-bit integer inside SPIR64 device code.

2020-12-02 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 added inline comments.



Comment at: clang/lib/Sema/Sema.cpp:241
+  (Context.getAuxTargetInfo() &&
+   Context.getAuxTargetInfo()->hasInt128Type())) {
 // If either of the 128-bit integer types are unavailable to name lookup,

jdoerfert wrote:
> jyu2 wrote:
> > jdoerfert wrote:
> > > I don't understand why this (and the changes below) are necessary. Host 
> > > and device compilation are separate. This should not be any different to 
> > > CUDA, HIP, or OpenMP offload which seem not to require this.
> > As far as I can know, in real compile, the auxtarget should be also set for 
> > example SYCL.  May be that is only for our compiler.  I am not sure what do 
> > you mean by it should same with CUDA, HIP...?  Do you mean, CUDA(or HIP...) 
> > target should also not support 128-bit integer?  If so, I don't see any 
> > error emit for CUDA when I try with nvptx64-nvidia-cuda.
> > 
> > Thanks.
> > 
> I'm not saying auxtarget is not set. I'm trying to understand why this is 
> necessary. Why would you initialize `__int128_t` if your target doesn't 
> support it? What happens if you only include the SPIR.h change?
Without this change you will see error:

j3.c:2:15: error: unknown type name '__uint128_t'
typedef const __uint128_t  megeType;

bash-4.4$ cat j3.c

typedef const __uint128_t  megeType;

Without change in SemaOverload.c:
you will see error:
x.cpp:3:14: error: use of overloaded operator '==' is ambiguous (with operand 
types 'struct X' and '__int128')
  bool a = x == __int128(0);
   ~ ^  ~~~

bash-4.4$ cat x.cpp
namespace PR12964 {
  struct X { operator  __int128() const; } x;
  bool a = x == __int128(0);
}





Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92439/new/

https://reviews.llvm.org/D92439

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


[PATCH] D87216: [NewPM] Support --print-before/after in NPM

2020-12-02 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks updated this revision to Diff 309000.
aeubanks added a comment.

clean up some more unnecessary llvm::
add comments to function declarations in PrintPasses.h


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D87216/new/

https://reviews.llvm.org/D87216

Files:
  llvm/include/llvm/IR/IRPrintingPasses.h
  llvm/include/llvm/IR/PassInstrumentation.h
  llvm/include/llvm/IR/PrintPasses.h
  llvm/include/llvm/Passes/StandardInstrumentations.h
  llvm/lib/Analysis/CallGraphSCCPass.cpp
  llvm/lib/Analysis/LoopInfo.cpp
  llvm/lib/Analysis/LoopPass.cpp
  llvm/lib/CodeGen/MachineFunctionPrinterPass.cpp
  llvm/lib/IR/CMakeLists.txt
  llvm/lib/IR/IRPrintingPasses.cpp
  llvm/lib/IR/LegacyPassManager.cpp
  llvm/lib/IR/PassInstrumentation.cpp
  llvm/lib/IR/PrintPasses.cpp
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Passes/StandardInstrumentations.cpp
  llvm/test/CodeGen/Generic/print-after.ll
  llvm/test/Other/loop-pass-printer.ll
  llvm/test/Other/print-before-after.ll
  llvm/utils/gn/secondary/llvm/lib/IR/BUILD.gn

Index: llvm/utils/gn/secondary/llvm/lib/IR/BUILD.gn
===
--- llvm/utils/gn/secondary/llvm/lib/IR/BUILD.gn
+++ llvm/utils/gn/secondary/llvm/lib/IR/BUILD.gn
@@ -59,6 +59,7 @@
 "PassManager.cpp",
 "PassRegistry.cpp",
 "PassTimingInfo.cpp",
+"PrintPasses.cpp",
 "ProfileSummary.cpp",
 "SafepointIRVerifier.cpp",
 "Statepoint.cpp",
Index: llvm/test/Other/print-before-after.ll
===
--- /dev/null
+++ llvm/test/Other/print-before-after.ll
@@ -0,0 +1,33 @@
+; RUN: not --crash opt < %s -disable-output -passes='no-op-module' -print-before=bleh 2>&1 | FileCheck %s --check-prefix=NONE --allow-empty
+; RUN: not --crash opt < %s -disable-output -passes='no-op-module' -print-after=bleh 2>&1 | FileCheck %s --check-prefix=NONE --allow-empty
+; RUN: opt < %s -disable-output -passes='no-op-module' -print-before=no-op-function 2>&1 | FileCheck %s --check-prefix=NONE --allow-empty
+; RUN: opt < %s -disable-output -passes='no-op-module' -print-after=no-op-function 2>&1 | FileCheck %s --check-prefix=NONE --allow-empty
+; RUN: opt < %s -disable-output -passes='no-op-module,no-op-function' -print-before=no-op-module 2>&1 | FileCheck %s --check-prefix=ONCE
+; RUN: opt < %s -disable-output -passes='no-op-module,no-op-function' -print-after=no-op-module 2>&1 | FileCheck %s --check-prefix=ONCE
+; RUN: opt < %s -disable-output -passes='no-op-function' -print-before=no-op-function 2>&1 | FileCheck %s --check-prefix=ONCE
+; RUN: opt < %s -disable-output -passes='no-op-function' -print-after=no-op-function 2>&1 | FileCheck %s --check-prefix=ONCE
+; RUN: opt < %s -disable-output -passes='no-op-module,no-op-function' -print-before=no-op-function --print-module-scope 2>&1 | FileCheck %s --check-prefix=TWICE
+; RUN: opt < %s -disable-output -passes='no-op-module,no-op-function' -print-after=no-op-function --print-module-scope 2>&1 | FileCheck %s --check-prefix=TWICE
+
+; NONE-NOT: @foo
+; NONE-NOT: @bar
+
+; ONCE: @foo
+; ONCE: @bar
+; ONCE-NOT: @foo
+; ONCE-NOT: @bar
+
+; TWICE: @foo
+; TWICE: @bar
+; TWICE: @foo
+; TWICE: @bar
+; TWICE-NOT: @foo
+; TWICE-NOT: @bar
+
+define void @foo() {
+  ret void
+}
+
+define void @bar() {
+  ret void
+}
Index: llvm/test/Other/loop-pass-printer.ll
===
--- llvm/test/Other/loop-pass-printer.ll
+++ llvm/test/Other/loop-pass-printer.ll
@@ -1,23 +1,23 @@
 ; This test checks -print-after/before on loop passes
 ; Besides of the loop itself it should be dumping loop pre-header and exits.
 ;
-; RUN: opt -enable-new-pm=0 < %s 2>&1 -disable-output \
+; RUN: opt < %s 2>&1 -disable-output \
 ; RUN: 	   -loop-deletion -print-before=loop-deletion \
 ; RUN:	   | FileCheck %s -check-prefix=DEL
 ; RUN: opt < %s 2>&1 -disable-output \
-; RUN: 	   -passes='loop(loop-deletion)' -print-before-all \
+; RUN: 	   -passes='loop(loop-deletion)' -print-before=loop-deletion \
 ; RUN:	   | FileCheck %s -check-prefix=DEL
 ; RUN: opt -enable-new-pm=0 < %s 2>&1 -disable-output \
 ; RUN: 	   -loop-unroll -print-after=loop-unroll -filter-print-funcs=bar \
 ; RUN:	   | FileCheck %s -check-prefix=BAR -check-prefix=BAR-OLD
 ; RUN: opt < %s 2>&1 -disable-output \
-; RUN: 	   -passes='require,loop(loop-unroll-full)' -print-after-all -filter-print-funcs=bar \
+; RUN: 	   -passes='require,loop(loop-unroll-full)' -print-after=loop-unroll-full -filter-print-funcs=bar \
 ; RUN:	   | FileCheck %s -check-prefix=BAR
 ; RUN: opt -enable-new-pm=0 < %s 2>&1 -disable-output \
 ; RUN: 	   -loop-unroll -print-after=loop-unroll -filter-print-funcs=foo -print-module-scope \
 ; RUN:	   | FileCheck %s -check-prefix=FOO-MODULE -check-prefix=FOO-MODULE-OLD
 ; RUN: opt < %s 2>&1 -disable-output \
-; RUN: 	   -passes='require,loop(loop-unroll-full)' -print-after-all -filter-print-funcs=foo -print-module-sco

[PATCH] D87216: [NewPM] Support --print-before/after in NPM

2020-12-02 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks updated this revision to Diff 308995.
aeubanks added a comment.

fix capitalization
remove extra declaration and fixup includes


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D87216/new/

https://reviews.llvm.org/D87216

Files:
  llvm/include/llvm/IR/IRPrintingPasses.h
  llvm/include/llvm/IR/PassInstrumentation.h
  llvm/include/llvm/IR/PrintPasses.h
  llvm/include/llvm/Passes/StandardInstrumentations.h
  llvm/lib/Analysis/CallGraphSCCPass.cpp
  llvm/lib/Analysis/LoopInfo.cpp
  llvm/lib/Analysis/LoopPass.cpp
  llvm/lib/CodeGen/MachineFunctionPrinterPass.cpp
  llvm/lib/IR/CMakeLists.txt
  llvm/lib/IR/IRPrintingPasses.cpp
  llvm/lib/IR/LegacyPassManager.cpp
  llvm/lib/IR/PassInstrumentation.cpp
  llvm/lib/IR/PrintPasses.cpp
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Passes/StandardInstrumentations.cpp
  llvm/test/CodeGen/Generic/print-after.ll
  llvm/test/Other/loop-pass-printer.ll
  llvm/test/Other/print-before-after.ll
  llvm/utils/gn/secondary/llvm/lib/IR/BUILD.gn

Index: llvm/utils/gn/secondary/llvm/lib/IR/BUILD.gn
===
--- llvm/utils/gn/secondary/llvm/lib/IR/BUILD.gn
+++ llvm/utils/gn/secondary/llvm/lib/IR/BUILD.gn
@@ -59,6 +59,7 @@
 "PassManager.cpp",
 "PassRegistry.cpp",
 "PassTimingInfo.cpp",
+"PrintPasses.cpp",
 "ProfileSummary.cpp",
 "SafepointIRVerifier.cpp",
 "Statepoint.cpp",
Index: llvm/test/Other/print-before-after.ll
===
--- /dev/null
+++ llvm/test/Other/print-before-after.ll
@@ -0,0 +1,33 @@
+; RUN: not --crash opt < %s -disable-output -passes='no-op-module' -print-before=bleh 2>&1 | FileCheck %s --check-prefix=NONE --allow-empty
+; RUN: not --crash opt < %s -disable-output -passes='no-op-module' -print-after=bleh 2>&1 | FileCheck %s --check-prefix=NONE --allow-empty
+; RUN: opt < %s -disable-output -passes='no-op-module' -print-before=no-op-function 2>&1 | FileCheck %s --check-prefix=NONE --allow-empty
+; RUN: opt < %s -disable-output -passes='no-op-module' -print-after=no-op-function 2>&1 | FileCheck %s --check-prefix=NONE --allow-empty
+; RUN: opt < %s -disable-output -passes='no-op-module,no-op-function' -print-before=no-op-module 2>&1 | FileCheck %s --check-prefix=ONCE
+; RUN: opt < %s -disable-output -passes='no-op-module,no-op-function' -print-after=no-op-module 2>&1 | FileCheck %s --check-prefix=ONCE
+; RUN: opt < %s -disable-output -passes='no-op-function' -print-before=no-op-function 2>&1 | FileCheck %s --check-prefix=ONCE
+; RUN: opt < %s -disable-output -passes='no-op-function' -print-after=no-op-function 2>&1 | FileCheck %s --check-prefix=ONCE
+; RUN: opt < %s -disable-output -passes='no-op-module,no-op-function' -print-before=no-op-function --print-module-scope 2>&1 | FileCheck %s --check-prefix=TWICE
+; RUN: opt < %s -disable-output -passes='no-op-module,no-op-function' -print-after=no-op-function --print-module-scope 2>&1 | FileCheck %s --check-prefix=TWICE
+
+; NONE-NOT: @foo
+; NONE-NOT: @bar
+
+; ONCE: @foo
+; ONCE: @bar
+; ONCE-NOT: @foo
+; ONCE-NOT: @bar
+
+; TWICE: @foo
+; TWICE: @bar
+; TWICE: @foo
+; TWICE: @bar
+; TWICE-NOT: @foo
+; TWICE-NOT: @bar
+
+define void @foo() {
+  ret void
+}
+
+define void @bar() {
+  ret void
+}
Index: llvm/test/Other/loop-pass-printer.ll
===
--- llvm/test/Other/loop-pass-printer.ll
+++ llvm/test/Other/loop-pass-printer.ll
@@ -1,23 +1,23 @@
 ; This test checks -print-after/before on loop passes
 ; Besides of the loop itself it should be dumping loop pre-header and exits.
 ;
-; RUN: opt -enable-new-pm=0 < %s 2>&1 -disable-output \
+; RUN: opt < %s 2>&1 -disable-output \
 ; RUN: 	   -loop-deletion -print-before=loop-deletion \
 ; RUN:	   | FileCheck %s -check-prefix=DEL
 ; RUN: opt < %s 2>&1 -disable-output \
-; RUN: 	   -passes='loop(loop-deletion)' -print-before-all \
+; RUN: 	   -passes='loop(loop-deletion)' -print-before=loop-deletion \
 ; RUN:	   | FileCheck %s -check-prefix=DEL
 ; RUN: opt -enable-new-pm=0 < %s 2>&1 -disable-output \
 ; RUN: 	   -loop-unroll -print-after=loop-unroll -filter-print-funcs=bar \
 ; RUN:	   | FileCheck %s -check-prefix=BAR -check-prefix=BAR-OLD
 ; RUN: opt < %s 2>&1 -disable-output \
-; RUN: 	   -passes='require,loop(loop-unroll-full)' -print-after-all -filter-print-funcs=bar \
+; RUN: 	   -passes='require,loop(loop-unroll-full)' -print-after=loop-unroll-full -filter-print-funcs=bar \
 ; RUN:	   | FileCheck %s -check-prefix=BAR
 ; RUN: opt -enable-new-pm=0 < %s 2>&1 -disable-output \
 ; RUN: 	   -loop-unroll -print-after=loop-unroll -filter-print-funcs=foo -print-module-scope \
 ; RUN:	   | FileCheck %s -check-prefix=FOO-MODULE -check-prefix=FOO-MODULE-OLD
 ; RUN: opt < %s 2>&1 -disable-output \
-; RUN: 	   -passes='require,loop(loop-unroll-full)' -print-after-all -filter-print-funcs=foo -print-module-scope \
+; RUN: 	   -passes='requ

[PATCH] D92439: Fix missing error for use of 128-bit integer inside SPIR64 device code.

2020-12-02 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

So, NVPTX seems to do something sensible with i128, though I haven't done 
rigorous testing.




Comment at: clang/lib/Sema/Sema.cpp:241
+  (Context.getAuxTargetInfo() &&
+   Context.getAuxTargetInfo()->hasInt128Type())) {
 // If either of the 128-bit integer types are unavailable to name lookup,

jyu2 wrote:
> jdoerfert wrote:
> > I don't understand why this (and the changes below) are necessary. Host and 
> > device compilation are separate. This should not be any different to CUDA, 
> > HIP, or OpenMP offload which seem not to require this.
> As far as I can know, in real compile, the auxtarget should be also set for 
> example SYCL.  May be that is only for our compiler.  I am not sure what do 
> you mean by it should same with CUDA, HIP...?  Do you mean, CUDA(or HIP...) 
> target should also not support 128-bit integer?  If so, I don't see any error 
> emit for CUDA when I try with nvptx64-nvidia-cuda.
> 
> Thanks.
> 
I'm not saying auxtarget is not set. I'm trying to understand why this is 
necessary. Why would you initialize `__int128_t` if your target doesn't support 
it? What happens if you only include the SPIR.h change?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92439/new/

https://reviews.llvm.org/D92439

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


[PATCH] D52050: [Driver] Fix architecture triplets and search paths for Linux x32

2020-12-02 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added a comment.

In D52050#2428743 , @hvdijk wrote:

> In D52050#2428735 , @glaubitz wrote:
>
>> Hmm, I was pretty sure that autoconf can deal with x32 inside an x32 chroot.
>
> Most autoconf-using software won't be dealing with a copy of `config.guess` 
> that was last updated in 2011. Updating that to a more recent version should 
> also work. :)

Debian's config.guess supports x32, and the patch to do that in a way upstream 
was happy with finally landed earlier this year after being a long-standing 
issue.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D52050/new/

https://reviews.llvm.org/D52050

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


[PATCH] D52050: [Driver] Fix architecture triplets and search paths for Linux x32

2020-12-02 Thread John Paul Adrian Glaubitz via Phabricator via cfe-commits
glaubitz added a comment.

In D52050#2428743 , @hvdijk wrote:

> In D52050#2428735 , @glaubitz wrote:
>
>> Hmm, I was pretty sure that autoconf can deal with x32 inside an x32 chroot.
>
> Most autoconf-using software won't be dealing with a copy of `config.guess` 
> that was last updated in 2011. Updating that to a more recent version should 
> also work. :)

Ah, yes, that actually explains the problem :). Thanks a lot!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D52050/new/

https://reviews.llvm.org/D52050

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


[PATCH] D52050: [Driver] Fix architecture triplets and search paths for Linux x32

2020-12-02 Thread Harald van Dijk via Phabricator via cfe-commits
hvdijk added a comment.

In D52050#2428735 , @glaubitz wrote:

> Hmm, I was pretty sure that autoconf can deal with x32 inside an x32 chroot.

Most autoconf-using software won't be dealing with a copy of `config.guess` 
that was last updated in 2011. Updating that to a more recent version should 
also work. :)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D52050/new/

https://reviews.llvm.org/D52050

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


[PATCH] D92487: [AArch64][Driver][SVE] Push missing SVE feature error from driver to frontend

2020-12-02 Thread Peter Waller via Phabricator via cfe-commits
peterwaller-arm updated this revision to Diff 308989.
peterwaller-arm added a comment.

Tweak message to address review comment.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92487/new/

https://reviews.llvm.org/D92487

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Driver/ToolChains/Arch/AArch64.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/Driver/aarch64-sve-vector-bits.c
  clang/test/Sema/arm-vector-types-support.c
  clang/test/Sema/neon-vector-types-support.c

Index: clang/test/Sema/neon-vector-types-support.c
===
--- clang/test/Sema/neon-vector-types-support.c
+++ /dev/null
@@ -1,4 +0,0 @@
-// RUN: %clang_cc1 %s -triple armv7 -fsyntax-only -verify
-
-typedef __attribute__((neon_vector_type(2))) int int32x2_t; // expected-error{{'neon_vector_type' attribute is not supported for this target}}
-typedef __attribute__((neon_polyvector_type(16))) short poly8x16_t; // expected-error{{'neon_polyvector_type' attribute is not supported for this target}}
Index: clang/test/Sema/arm-vector-types-support.c
===
--- /dev/null
+++ clang/test/Sema/arm-vector-types-support.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 %s -triple armv7 -fsyntax-only -verify
+
+typedef __attribute__((neon_vector_type(2))) int int32x2_t; // expected-error{{'neon_vector_type' attribute is not supported on targets missing 'neon' or 'mve'; specify an appropriate -march= or -mcpu=}}
+typedef __attribute__((neon_polyvector_type(16))) short poly8x16_t; // expected-error{{'neon_polyvector_type' attribute is not supported on targets missing 'neon' or 'mve'; specify an appropriate -march= or -mcpu=}}
+typedef __attribute__((arm_sve_vector_bits(256))) void nosveflag; // expected-error{{'arm_sve_vector_bits' attribute is not supported on targets missing 'sve'; specify an appropriate -march= or -mcpu=}}
Index: clang/test/Driver/aarch64-sve-vector-bits.c
===
--- clang/test/Driver/aarch64-sve-vector-bits.c
+++ clang/test/Driver/aarch64-sve-vector-bits.c
@@ -22,21 +22,6 @@
 // CHECK-2048: "-msve-vector-bits=2048"
 // CHECK-SCALABLE-NOT: "-msve-vector-bits=
 
-// Bail out if -msve-vector-bits is specified without SVE enabled
-// -
-// RUN: %clang -c %s -### -target aarch64-none-linux-gnu -msve-vector-bits=128 \
-// RUN:  2>&1 | FileCheck --check-prefix=CHECK-NO-SVE-ERROR %s
-// RUN: %clang -c %s -### -target aarch64-none-linux-gnu -msve-vector-bits=256 \
-// RUN:  2>&1 | FileCheck --check-prefix=CHECK-NO-SVE-ERROR %s
-// RUN: %clang -c %s -### -target aarch64-none-linux-gnu -msve-vector-bits=512 \
-// RUN:  2>&1 | FileCheck --check-prefix=CHECK-NO-SVE-ERROR %s
-// RUN: %clang -c %s -### -target aarch64-none-linux-gnu -msve-vector-bits=1024 \
-// RUN:  2>&1 | FileCheck --check-prefix=CHECK-NO-SVE-ERROR %s
-// RUN: %clang -c %s -### -target aarch64-none-linux-gnu -msve-vector-bits=2048 \
-// RUN:  2>&1 | FileCheck --check-prefix=CHECK-NO-SVE-ERROR %s
-
-// CHECK-NO-SVE-ERROR: error: '-msve-vector-bits' is not supported without SVE enabled
-
 // Error out if an unsupported value is passed to -msve-vector-bits.
 // -
 // RUN: %clang -c %s -### -target aarch64-none-linux-gnu -march=armv8-a+sve \
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -7785,7 +7785,8 @@
   // not to need a separate attribute)
   if (!S.Context.getTargetInfo().hasFeature("neon") &&
   !S.Context.getTargetInfo().hasFeature("mve")) {
-S.Diag(Attr.getLoc(), diag::err_attribute_unsupported) << Attr;
+S.Diag(Attr.getLoc(), diag::err_attribute_unsupported)
+<< Attr << "'neon' or 'mve'";
 Attr.setInvalid();
 return;
   }
@@ -7828,7 +7829,8 @@
Sema &S) {
   // Target must have SVE.
   if (!S.Context.getTargetInfo().hasFeature("sve")) {
-S.Diag(Attr.getLoc(), diag::err_attribute_unsupported) << Attr;
+S.Diag(Attr.getLoc(), diag::err_attribute_unsupported)
+<< Attr << "'sve'";
 Attr.setInvalid();
 return;
   }
Index: clang/lib/Driver/ToolChains/Arch/AArch64.cpp
===
--- clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -376,12 +376,6 @@
   if (V8_6Pos != std::end(Features))
 V8_6Pos = Features.insert(std::next(V8_6Pos), {"+i8mm", "+bf16"});
 
-  bool HasSve = llvm::is_contained(Features, "+sve");
-  // -msve-vector-bits= flag is valid only if SVE is enabled.
-  if (Args.hasArg(options::OPT_msve_vector_bits_EQ))
-i

[PATCH] D52050: [Driver] Fix architecture triplets and search paths for Linux x32

2020-12-02 Thread John Paul Adrian Glaubitz via Phabricator via cfe-commits
glaubitz added a comment.

In D52050#2428709 , @hvdijk wrote:

> `sys::getDefaultTargetTriple()` defaults to `LLVM_DEFAULT_TARGET_TRIPLE`, 
> which in turn defaults to `LLVM_HOST_TRIPLE`, which in turn defaults to 
> `LLVM_INFERRED_HOST_TRIPLE`, which calls `config.guess` which never 
> automatically detects X32. Sorry, forgot to mention that on my system, I also 
> make sure to explicitly specify `LLVM_HOST_TRIPLE` to an X32 triple when 
> building LLVM.

Hmm, I was pretty sure that autoconf can deal with x32 inside an x32 chroot.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D52050/new/

https://reviews.llvm.org/D52050

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


  1   2   >