[PATCH] D72184: [BPF] support atomic instructions

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

use llvm_unreachable() in default case of the switch statement


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 d

[clang] 3fca6a7 - [Clang] Don't adjust align for IBM extended double

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

Author: Qiu Chaofan
Date: 2020-12-02T17:02:26+08:00
New Revision: 3fca6a7844b515496446667a18a9703c29cf6e88

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

LOG: [Clang] Don't adjust align for IBM extended double

Commit 6b1341eb fixed alignment for 128-bit FP types on PowerPC.
However, the quadword alignment adjustment shouldn't be applied to IBM
extended double (ppc_fp128 in IR) values.

Reviewed By: jsji

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

Added: 


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

Removed: 




diff  --git a/clang/lib/CodeGen/TargetInfo.cpp 
b/clang/lib/CodeGen/TargetInfo.cpp
index 3469bc6bf081..4815266371bc 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -5052,10 +5052,12 @@ CharUnits 
PPC64_SVR4_ABIInfo::getParamTypeAlignment(QualType Ty) const {
 return CharUnits::fromQuantity(16);
   } else if (Ty->isVectorType()) {
 return CharUnits::fromQuantity(getContext().getTypeSize(Ty) == 128 ? 16 : 
8);
-  } else if (Ty->isRealFloatingType() && getContext().getTypeSize(Ty) == 128) {
-// IEEE 128-bit floating numbers are also stored in vector registers.
-// And both IEEE quad-precision and IBM extended double (ppc_fp128) should
-// be quad-word aligned.
+  } else if (Ty->isRealFloatingType() &&
+ &getContext().getFloatTypeSemantics(Ty) ==
+ &llvm::APFloat::IEEEquad()) {
+// According to ABI document section 'Optional Save Areas': If extended
+// precision floating-point values in IEEE BINARY 128 QUADRUPLE PRECISION
+// format are supported, map them to a single quadword, quadword aligned.
 return CharUnits::fromQuantity(16);
   }
 

diff  --git a/clang/test/CodeGen/ppc64le-varargs-f128.c 
b/clang/test/CodeGen/ppc64le-varargs-f128.c
index 6562fe6f8fe4..5e9930ec716f 100644
--- a/clang/test/CodeGen/ppc64le-varargs-f128.c
+++ b/clang/test/CodeGen/ppc64le-varargs-f128.c
@@ -5,45 +5,92 @@
 // 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 
 
-// IEEE-LABEL: define fp128 @f128(i32 signext %n, ...)
-// IEEE: call void @llvm.va_start(i8* %{{[0-9a-zA-Z_.]+}})
-// IEEE: %[[P1:[0-9a-zA-Z_.]+]] = add i64 %{{[0-9a-zA-Z_.]+}}, 15
-// IEEE: %[[P2:[0-9a-zA-Z_.]+]] = and i64 %[[P1]], -16
-// IEEE: %[[P3:[0-9a-zA-Z_.]+]] = inttoptr i64 %[[P2]] to i8*
-// IEEE: %[[P4:[0-9a-zA-Z_.]+]] = bitcast i8* %[[P3]] to fp128*
-// IEEE: %{{[0-9a-zA-Z_.]+}} = load fp128, fp128* %[[P4]], align 16
-// IEEE: call void @llvm.va_end(i8* %{{[0-9a-zA-Z_.]+}})
-__float128 f128(int n, ...) {
+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]])
+// IEEE: %[[CUR:[0-9a-zA-Z_.]+]] = load i8*, i8** %[[AP]]
+// IEEE: %[[V0:[0-9a-zA-Z_.]+]] = ptrtoint i8* %[[CUR]] to i64
+// IEEE: %[[V1:[0-9a-zA-Z_.]+]] = add i64 %[[V0]], 15
+// IEEE: %[[V2:[0-9a-zA-Z_.]+]] = and i64 %[[V1]], -16
+// IEEE: %[[ALIGN:[0-9a-zA-Z_.]+]] = inttoptr i64 %[[V2]] to i8*
+// IEEE: %[[V3:[0-9a-zA-Z_.]+]] = bitcast i8* %

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

2020-12-02 Thread Qiu Chaofan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3fca6a7844b5: [Clang] Don't adjust align for IBM 
extended double (authored by qiucf).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92278

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/ppc64le-varargs-f128.c

Index: clang/test/CodeGen/ppc64le-varargs-f128.c
===
--- clang/test/CodeGen/ppc64le-varargs-f128.c
+++ clang/test/CodeGen/ppc64le-varargs-f128.c
@@ -5,45 +5,92 @@
 // 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 
 
-// IEEE-LABEL: define fp128 @f128(i32 signext %n, ...)
-// IEEE: call void @llvm.va_start(i8* %{{[0-9a-zA-Z_.]+}})
-// IEEE: %[[P1:[0-9a-zA-Z_.]+]] = add i64 %{{[0-9a-zA-Z_.]+}}, 15
-// IEEE: %[[P2:[0-9a-zA-Z_.]+]] = and i64 %[[P1]], -16
-// IEEE: %[[P3:[0-9a-zA-Z_.]+]] = inttoptr i64 %[[P2]] to i8*
-// IEEE: %[[P4:[0-9a-zA-Z_.]+]] = bitcast i8* %[[P3]] to fp128*
-// IEEE: %{{[0-9a-zA-Z_.]+}} = load fp128, fp128* %[[P4]], align 16
-// IEEE: call void @llvm.va_end(i8* %{{[0-9a-zA-Z_.]+}})
-__float128 f128(int n, ...) {
+void foo_ld(long double);
+void foo_fq(__float128);
+
+// Verify cases when OpenMP target's and host's long-double semantics differ.
+
+// 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]])
+// IEEE: %[[CUR:[0-9a-zA-Z_.]+]] = load i8*, i8** %[[AP]]
+// IEEE: %[[V0:[0-9a-zA-Z_.]+]] = ptrtoint i8* %[[CUR]] to i64
+// IEEE: %[[V1:[0-9a-zA-Z_.]+]] = add i64 %[[V0]], 15
+// IEEE: %[[V2:[0-9a-zA-Z_.]+]] = and i64 %[[V1]], -16
+// IEEE: %[[ALIGN:[0-9a-zA-Z_.]+]] = inttoptr i64 %[[V2]] to i8*
+// IEEE: %[[V3:[0-9a-zA-Z_.]+]] = bitcast i8* %[[ALIGN]] to fp128*
+// IEEE: %[[V4:[0-9a-zA-Z_.]+]] = load fp128, fp128* %[[V3]], align 16
+// IEEE: call void @foo_fq(fp128 %[[V4]])
+// IEEE: %[[AP2:[0-9a-zA-Z_.]+]] = bitcast i8** %[[AP]] to i8*
+// IEEE: call void @llvm.va_end(i8* %[[AP2]])
+void f128(int n, ...) {
   va_list ap;
   va_start(ap, n);
-  __float128 x = va_arg(ap, __float128);
+  foo_fq(va_arg(ap, __float128));
   va_end(ap);
-  return x;
 }
 
-// IEEE-LABEL: define fp128 @long_double(i32 signext %n, ...)
-// IEEE: call void @llvm.va_start(i8* %{{[0-9a-zA-Z_.]+}})
-// IEEE: %[[P1:[0-9a-zA-Z_.]+]] = add i64 %{{[0-9a-zA-Z_.]+}}, 15
-// IEEE: %[[P2:[0-9a-zA-Z_.]+]] = and i64 %[[P1]], -16
-// IEEE: %[[P3:[0-9a-zA-Z_.]+]] = inttoptr i64 %[[P2]] to i8*
-// IEEE: %[[P4:[0-9a-zA-Z_.]+]] = bitcast i8* %[[P3]] to fp128*
-// IEEE: %{{[0-9a-zA-Z_.]+}} = load fp128, fp128* %[[P4]], align 16
-// IEEE: call void @llvm.va_end(i8* %{{[0-9a-zA-Z_.]+}})
-
-// IBM-LABEL: define ppc_fp128 @long_double(i32 signext %n, ...)
-// IBM: call void @llvm.va_start(i8* %{{[0-9a-zA-Z_.]+}})
-// IBM: %[[P1:[0-9a-zA-Z_.]+]] = add i64 %{{[0-9a-zA-Z_.]+}}, 15
-// IBM: %[[P2:[0-9a-zA-Z_.]+]] = and i64 %[[P1]], -16
-// IBM: %[[P3:[0-9a-zA-Z_.]+]] = inttoptr i64 %[[P2]] to i8*
-// IBM: %[[P4:[0-9a-zA-Z_.]+]] = bitcast i8* %[[P3]] to ppc_fp128*
-// IBM: %{{[0-9a-zA-Z_.]+}} = load ppc_fp128, ppc_fp128* %[[P4]], align 16
-// IBM: call void @llvm.va_end(i8* %{{[0-9a-zA-Z_.]+}})
-long double long_double(int n, ...) {
+// IEEE-LABEL: define void @long_double
+// IEEE: %[[AP1:[

[PATCH] D91596: [PowerPC] [Clang] Fix alignment of 128-bit floating types

2020-12-02 Thread Qiu Chaofan via Phabricator via cfe-commits
qiucf added a comment.

The regression should be fixed in rG3fca6a7844b5 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91596

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


[PATCH] D92361: [trivial-abi] Support types without a copy or move constructor.

2020-12-02 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In D92361#2427652 , @zoecarver wrote:

>> If it is not possible to copy or move the type at all, it is not possible to 
>> copy or move it trivially.
>
> This was a bit confusing to me because I think this changed between C++14 and 
> 17. In C++14, a class was trivially copyable if it had no non-trivial 
> copy/move constructors. But now the standard requires at least one 
> non-trivial move/copy constructor. It looks like 
>  the type traits maybe haven't caught up.

Sorry, I know that the standard defines terms in this area, so what I said was 
unnecessarily confusing.

I'm describing the normative considerations that have gone into the language 
design of `trivial_abi`, not trying to state the rule in the standard.   It 
doesn't especially matter what the standard says because this is not a standard 
feature.  We want to fit in with the standard framework as much as possible 
because it simplifies the interactions, but ultimately if we don't think the 
standard permits what we want out of this extension, we'll just diverge.

>> So S0 may representationally depend on its address, and we should 
>> ignore/diagnose trivial_abi on aggregates containing an S0.
>
> I guess the question is, does a type with all copy/move constructors deleted 
> //and the trivial_abi attribute// depend on its address? And the whole point 
> of this patch is to make that answer, "no." But, a type //without// the 
> attribute, //does// depend on its address. And therefore a type holding `S0` 
> (without the attribute) also depends on its address because it implicitly has 
> no copy/move constructors. I'm not sure I understand why we need to diagnose 
> aggregates containing an `S0` or why the trivial_abi attribute couldn't be 
> applied to those types, though.

Okay, so, this is the problem with reasoning about this the C++ way.  I 
apologize if what follows is a little long.

Types have representational needs, and those needs dictate the properties of 
correctly-implemented value operations.  However, the C++ special members are 
designed around the C++ language model; we need to talk briefly about value 
operations on a deeper level.  There are four basic value operations at this 
deeper level: original initialization, copy, destructive move, and destruction. 
 Everything else can be thought of as a combination of these basic operations 
(like copy-assignment combining destruction and copy) or a twist on one (like 
C++'s non-destructive moves, which end up being a sort of optimized copy).  The 
basic representational choices of a type dictate the properties of these four 
basic operations, and they in turn dictate the properties of 
optimally-implemented special members.

So, for example, types that manage ownership of some resource pretty much 
necessarily make initialization and destruction non-trivial, and copy must be 
non-trivial or impossible, but a true destructive move can remain non-trivial.  
(This is why C++'s moves are more like a copy than a move at this conceptual 
level.)  Types with some sort of address sensitivity, like a relative or 
interior pointer, must make copy and destructive move non-trivial or 
impossible, but destruction can remain trivial (as can initialization, if 
you're willing to ignore a possibly invalid value).  Types that register their 
objects externally must make all the operations either non-trivial or 
impossible, and so on.

What `trivial_abi` really does is make a statement about the type's destructive 
move, which is otherwise something that C++ can't talk about at all.  Passing 
something in registers, or just in general copying its bits from one location 
to another and abandoning the old location, is a trivial destructive move, and 
`trivial_abi` says that that's okay for a type irrespective of the type's own 
special members as long it's okay for all its subobjects.  So we have to look 
at every subobject and ask if it allows trivial destructive moves, and if it 
does then we can honor `trivial_abi`.  That query basically turns into asking 
whether the subobjects are either trivially-copyable or themselves are marked 
`trivial_abi`.

>> Similarly, if a subobject type has only non-trivial copy/move constructors 
>> (but a trivial destructor), we should assume that it representationally 
>> depends on its address and prevent aggregates containing it from being 
>> passed directly, even if the containing type deletes all its copy/move 
>> constructors and uses trivial_abi.
>
> I concur with the first part of this, at least. That is, `S3` should //not// 
> be passed directly because it is non-trivially copyable (because of its 
> member) and does not have the attribute. Similar to above, I don't understand 
> why we couldn't pass it directly if it had the attribute, though.

If you have a type that deletes all its copy/move constructors and does not 
declare itself `trivial_abi`, it is say

[PATCH] D91806: [SVE] Remove warning from debug info on scalable vector.

2020-12-02 Thread Joe Ellis via Phabricator via cfe-commits
joechrisellis commandeered this revision.
joechrisellis edited reviewers, added: fpetrogalli; removed: joechrisellis.
joechrisellis added a comment.

I am finishing up this patch. 😄


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91806

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


[PATCH] D91806: [SVE] Remove warning from debug info on scalable vector.

2020-12-02 Thread Joe Ellis via Phabricator via cfe-commits
joechrisellis updated this revision to Diff 308910.
joechrisellis added a comment.

Reduce debug info in `debug-declare-no-warnings-on-scalable-vectors.ll`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91806

Files:
  llvm/lib/Transforms/Utils/Debugify.cpp
  llvm/lib/Transforms/Utils/Local.cpp
  
llvm/test/Transforms/InstCombine/debug-declare-no-warnings-on-scalable-vectors.ll

Index: llvm/test/Transforms/InstCombine/debug-declare-no-warnings-on-scalable-vectors.ll
===
--- /dev/null
+++ llvm/test/Transforms/InstCombine/debug-declare-no-warnings-on-scalable-vectors.ll
@@ -0,0 +1,31 @@
+; RUN: opt -mtriple aarch64-gnu-linux -mattr=+sve -instcombine -S < %s 2>%t | FileCheck %s
+; RUN: FileCheck --check-prefix=WARN --allow-empty %s <%t
+
+; If this check fails please read
+; clang/test/CodeGen/aarch64-sve-intrinsics/README for instructions on
+; how to resolve it.
+
+; WARN-NOT: warning
+
+; CHECK-LABEL: @debug_local_scalable(
+define  @debug_local_scalable( %tostore) {
+  %vx = alloca , align 16
+  call void @llvm.dbg.declare(metadata * %vx, metadata !3, metadata !DIExpression()), !dbg !5
+  store  %tostore, * %vx, align 16
+  %ret = call  @f(* %vx)
+  ret  %ret
+}
+
+declare  @f(*)
+
+; Function Attrs: nofree nosync nounwind readnone speculatable willreturn
+declare void @llvm.dbg.declare(metadata, metadata, metadata)
+
+!llvm.module.flags = !{!2}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1)
+!1 = !DIFile(filename: "/tmp/test.c", directory: "/tmp/")
+!2 = !{i32 2, !"Debug Info Version", i32 3}
+!3 = !DILocalVariable(scope: !4)
+!4 = distinct !DISubprogram(unit: !0)
+!5 = !DILocation(scope: !4)
Index: llvm/lib/Transforms/Utils/Local.cpp
===
--- llvm/lib/Transforms/Utils/Local.cpp
+++ llvm/lib/Transforms/Utils/Local.cpp
@@ -1368,16 +1368,22 @@
 /// least n bits.
 static bool valueCoversEntireFragment(Type *ValTy, DbgVariableIntrinsic *DII) {
   const DataLayout &DL = DII->getModule()->getDataLayout();
-  uint64_t ValueSize = DL.getTypeAllocSizeInBits(ValTy);
-  if (auto FragmentSize = DII->getFragmentSizeInBits())
-return ValueSize >= *FragmentSize;
+  TypeSize ValueSize = DL.getTypeAllocSizeInBits(ValTy);
+  if (Optional FragmentSize = DII->getFragmentSizeInBits()) {
+assert(!ValueSize.isScalable() &&
+   "Fragments don't work on scalable types.");
+return ValueSize.getFixedSize() >= *FragmentSize;
+  }
   // We can't always calculate the size of the DI variable (e.g. if it is a
   // VLA). Try to use the size of the alloca that the dbg intrinsic describes
   // intead.
   if (DII->isAddressOfVariable())
 if (auto *AI = dyn_cast_or_null(DII->getVariableLocation()))
-  if (auto FragmentSize = AI->getAllocationSizeInBits(DL))
-return ValueSize >= *FragmentSize;
+  if (Optional FragmentSize = AI->getAllocationSizeInBits(DL)) {
+assert(ValueSize.isScalable() == FragmentSize->isScalable() &&
+   "Both sizes should agree on the scalable flag.");
+return TypeSize::isKnownGE(ValueSize, *FragmentSize);
+  }
   // Could not determine size of variable. Conservatively return false.
   return false;
 }
Index: llvm/lib/Transforms/Utils/Debugify.cpp
===
--- llvm/lib/Transforms/Utils/Debugify.cpp
+++ llvm/lib/Transforms/Utils/Debugify.cpp
@@ -44,8 +44,9 @@
 
 raw_ostream &dbg() { return Quiet ? nulls() : errs(); }
 
-uint64_t getAllocSizeInBits(Module &M, Type *Ty) {
-  return Ty->isSized() ? M.getDataLayout().getTypeAllocSizeInBits(Ty) : 0;
+TypeSize getAllocSizeInBits(Module &M, Type *Ty) {
+  return Ty->isSized() ? M.getDataLayout().getTypeAllocSizeInBits(Ty)
+   : TypeSize::getFixed(0);
 }
 
 bool isFunctionSkipped(Function &F) {
@@ -276,7 +277,7 @@
 return false;
 
   Type *Ty = V->getType();
-  uint64_t ValueOperandSize = getAllocSizeInBits(M, Ty);
+  TypeSize ValueOperandSize = getAllocSizeInBits(M, Ty);
   Optional DbgVarSize = DVI->getFragmentSizeInBits();
   if (!ValueOperandSize || !DbgVarSize)
 return false;
@@ -285,7 +286,7 @@
   if (Ty->isIntegerTy()) {
 auto Signedness = DVI->getVariable()->getSignedness();
 if (Signedness && *Signedness == DIBasicType::Signedness::Signed)
-  HasBadSize = ValueOperandSize < *DbgVarSize;
+  HasBadSize = ValueOperandSize.getFixedSize() < *DbgVarSize;
   } else {
 HasBadSize = ValueOperandSize != *DbgVarSize;
   }
___
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 Gabor Marton via Phabricator via cfe-commits
martong added a comment.

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 `CXXDeductionGuideDecl`.


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] D92101: [Clang][Sema] Attempt to fix CTAD faulty copy of non-local typedefs

2020-12-02 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 308920.
martong added a comment.

- Move dependent context check into TransformTypedefType
- Add new test case for param with pointer type


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92101

Files:
  clang/lib/Sema/SemaTemplate.cpp
  clang/unittests/AST/ASTImporterTest.cpp

Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -5884,6 +5884,77 @@
   EXPECT_EQ(Record, CompletedTags.front());
 }
 
+// FIXME Move these tests out of ASTImporterTest. For that we need to factor
+// out the ASTImporter specific pars from ASTImporterOptionSpecificTestBase
+// into a new test Fixture. Then we should lift up this Fixture to its own
+// implementation file and only then could we reuse the Fixture in other AST
+// unitttests.
+struct CTAD : ASTImporterOptionSpecificTestBase {};
+
+TEST_P(CTAD, DeductionGuideShouldReferToANonLocalTypedef) {
+  Decl *TU = getTuDecl(
+  R"(
+  typedef int U;
+  template  struct A {
+A(U, T);
+  };
+  A a{(int)0, (int)0};
+  )",
+  Lang_CXX17, "input.cc");
+  auto *Guide = FirstDeclMatcher().match(
+  TU, cxxDeductionGuideDecl());
+  auto *Typedef = FirstDeclMatcher().match(
+  TU, typedefNameDecl(hasName("U")));
+  ParmVarDecl *Param = Guide->getParamDecl(0);
+  // The type of the first param (which is a typedef) should match the typedef
+  // in the global scope.
+  EXPECT_EQ(Param->getType()->getAs()->getDecl(), Typedef);
+}
+
+TEST_P(CTAD, DeductionGuideShouldReferToANonLocalTypedefInParamPtr) {
+  Decl *TU = getTuDecl(
+  R"(
+  typedef int U;
+  template  struct A {
+A(U*, T);
+  };
+  A a{(int*)0, (int)0};
+  )",
+  Lang_CXX17, "input.cc");
+  auto *Guide = FirstDeclMatcher().match(
+  TU, cxxDeductionGuideDecl());
+  auto *Typedef = FirstDeclMatcher().match(
+  TU, typedefNameDecl(hasName("U")));
+  ParmVarDecl *Param = Guide->getParamDecl(0);
+  EXPECT_EQ(Param->getType()
+->getAs()
+->getPointeeType()
+->getAs()
+->getDecl(),
+Typedef);
+}
+
+TEST_P(CTAD, DeductionGuideShouldCopyALocalTypedef) {
+  Decl *TU = getTuDecl(
+  R"(
+  template  struct A {
+typedef T U;
+A(U, T);
+  };
+  A a{(int)0, (int)0};
+  )",
+  Lang_CXX17, "input.cc");
+  auto *Guide = FirstDeclMatcher().match(
+  TU, cxxDeductionGuideDecl());
+  auto *Typedef = FirstDeclMatcher().match(
+  TU, typedefNameDecl(hasName("U")));
+  ParmVarDecl *Param = Guide->getParamDecl(0);
+  EXPECT_NE(Param->getType()->getAs()->getDecl(), Typedef);
+}
+
+INSTANTIATE_TEST_CASE_P(ParameterizedTests, CTAD,
+DefaultTestValuesForRunOptions, );
+
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ASTImporterLookupTableTest,
 DefaultTestValuesForRunOptions, );
 
Index: clang/lib/Sema/SemaTemplate.cpp
===
--- clang/lib/Sema/SemaTemplate.cpp
+++ clang/lib/Sema/SemaTemplate.cpp
@@ -2077,23 +2077,28 @@
   QualType TransformTypedefType(TypeLocBuilder &TLB, TypedefTypeLoc TL) {
 ASTContext &Context = SemaRef.getASTContext();
 TypedefNameDecl *OrigDecl = TL.getTypedefNameDecl();
+
 TypeLocBuilder InnerTLB;
 QualType Transformed =
 TransformType(InnerTLB, OrigDecl->getTypeSourceInfo()->getTypeLoc());
 TypeSourceInfo *TSI =
 TransformType(InnerTLB.getTypeSourceInfo(Context, Transformed));
 
-TypedefNameDecl *Decl = nullptr;
 
-if (isa(OrigDecl))
-  Decl = TypeAliasDecl::Create(
-  Context, Context.getTranslationUnitDecl(), OrigDecl->getBeginLoc(),
-  OrigDecl->getLocation(), OrigDecl->getIdentifier(), TSI);
-else {
-  assert(isa(OrigDecl) && "Not a Type alias or typedef");
-  Decl = TypedefDecl::Create(
-  Context, Context.getTranslationUnitDecl(), OrigDecl->getBeginLoc(),
-  OrigDecl->getLocation(), OrigDecl->getIdentifier(), TSI);
+TypedefNameDecl *Decl = OrigDecl;
+
+// Create a new Decl only if the typedef has a dependent context.
+if (OrigDecl->getDeclContext()->isDependentContext()) {
+  if (isa(OrigDecl))
+Decl = TypeAliasDecl::Create(
+Context, Context.getTranslationUnitDecl(), OrigDecl->getBeginLoc(),
+OrigDecl->getLocation(), OrigDecl->getIdentifier(), TSI);
+  else {
+assert(isa(OrigDecl) && "Not a Type alias or typedef");
+Decl = TypedefDecl::Create(
+Context, Context.getTranslationUnitDecl(), OrigDecl->getBeginLoc(),
+OrigDecl->getLocation(), OrigDecl->getIdentifier(), TSI);
+  }
 }
 
 MaterializedTypedefs.push_back(Decl);
_

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

2020-12-02 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 308922.
martong added a comment.

- Add to MaterializedTypedefs only when copying the Decl


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92101

Files:
  clang/lib/Sema/SemaTemplate.cpp
  clang/unittests/AST/ASTImporterTest.cpp

Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -5884,6 +5884,77 @@
   EXPECT_EQ(Record, CompletedTags.front());
 }
 
+// FIXME Move these tests out of ASTImporterTest. For that we need to factor
+// out the ASTImporter specific pars from ASTImporterOptionSpecificTestBase
+// into a new test Fixture. Then we should lift up this Fixture to its own
+// implementation file and only then could we reuse the Fixture in other AST
+// unitttests.
+struct CTAD : ASTImporterOptionSpecificTestBase {};
+
+TEST_P(CTAD, DeductionGuideShouldReferToANonLocalTypedef) {
+  Decl *TU = getTuDecl(
+  R"(
+  typedef int U;
+  template  struct A {
+A(U, T);
+  };
+  A a{(int)0, (int)0};
+  )",
+  Lang_CXX17, "input.cc");
+  auto *Guide = FirstDeclMatcher().match(
+  TU, cxxDeductionGuideDecl());
+  auto *Typedef = FirstDeclMatcher().match(
+  TU, typedefNameDecl(hasName("U")));
+  ParmVarDecl *Param = Guide->getParamDecl(0);
+  // The type of the first param (which is a typedef) should match the typedef
+  // in the global scope.
+  EXPECT_EQ(Param->getType()->getAs()->getDecl(), Typedef);
+}
+
+TEST_P(CTAD, DeductionGuideShouldReferToANonLocalTypedefInParamPtr) {
+  Decl *TU = getTuDecl(
+  R"(
+  typedef int U;
+  template  struct A {
+A(U*, T);
+  };
+  A a{(int*)0, (int)0};
+  )",
+  Lang_CXX17, "input.cc");
+  auto *Guide = FirstDeclMatcher().match(
+  TU, cxxDeductionGuideDecl());
+  auto *Typedef = FirstDeclMatcher().match(
+  TU, typedefNameDecl(hasName("U")));
+  ParmVarDecl *Param = Guide->getParamDecl(0);
+  EXPECT_EQ(Param->getType()
+->getAs()
+->getPointeeType()
+->getAs()
+->getDecl(),
+Typedef);
+}
+
+TEST_P(CTAD, DeductionGuideShouldCopyALocalTypedef) {
+  Decl *TU = getTuDecl(
+  R"(
+  template  struct A {
+typedef T U;
+A(U, T);
+  };
+  A a{(int)0, (int)0};
+  )",
+  Lang_CXX17, "input.cc");
+  auto *Guide = FirstDeclMatcher().match(
+  TU, cxxDeductionGuideDecl());
+  auto *Typedef = FirstDeclMatcher().match(
+  TU, typedefNameDecl(hasName("U")));
+  ParmVarDecl *Param = Guide->getParamDecl(0);
+  EXPECT_NE(Param->getType()->getAs()->getDecl(), Typedef);
+}
+
+INSTANTIATE_TEST_CASE_P(ParameterizedTests, CTAD,
+DefaultTestValuesForRunOptions, );
+
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ASTImporterLookupTableTest,
 DefaultTestValuesForRunOptions, );
 
Index: clang/lib/Sema/SemaTemplate.cpp
===
--- clang/lib/Sema/SemaTemplate.cpp
+++ clang/lib/Sema/SemaTemplate.cpp
@@ -2077,26 +2077,30 @@
   QualType TransformTypedefType(TypeLocBuilder &TLB, TypedefTypeLoc TL) {
 ASTContext &Context = SemaRef.getASTContext();
 TypedefNameDecl *OrigDecl = TL.getTypedefNameDecl();
+
 TypeLocBuilder InnerTLB;
 QualType Transformed =
 TransformType(InnerTLB, OrigDecl->getTypeSourceInfo()->getTypeLoc());
 TypeSourceInfo *TSI =
 TransformType(InnerTLB.getTypeSourceInfo(Context, Transformed));
 
-TypedefNameDecl *Decl = nullptr;
 
-if (isa(OrigDecl))
-  Decl = TypeAliasDecl::Create(
-  Context, Context.getTranslationUnitDecl(), OrigDecl->getBeginLoc(),
-  OrigDecl->getLocation(), OrigDecl->getIdentifier(), TSI);
-else {
-  assert(isa(OrigDecl) && "Not a Type alias or typedef");
-  Decl = TypedefDecl::Create(
-  Context, Context.getTranslationUnitDecl(), OrigDecl->getBeginLoc(),
-  OrigDecl->getLocation(), OrigDecl->getIdentifier(), TSI);
-}
+TypedefNameDecl *Decl = OrigDecl;
 
-MaterializedTypedefs.push_back(Decl);
+// Create a new Decl only if the typedef has a dependent context.
+if (OrigDecl->getDeclContext()->isDependentContext()) {
+  if (isa(OrigDecl))
+Decl = TypeAliasDecl::Create(
+Context, Context.getTranslationUnitDecl(), OrigDecl->getBeginLoc(),
+OrigDecl->getLocation(), OrigDecl->getIdentifier(), TSI);
+  else {
+assert(isa(OrigDecl) && "Not a Type alias or typedef");
+Decl = TypedefDecl::Create(
+Context, Context.getTranslationUnitDecl(), OrigDecl->getBeginLoc(),
+OrigDecl->getLocation(), OrigDecl->getIdentifier(), TSI);
+  }
+  MaterializedTypedefs.push_back(Decl);
+}
 
 QualType TDTy = Cont

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

2020-12-02 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

@rsmith I have moved the check into `TransformTypedefType`. We do not add the 
typedef to the `MaterializedTypedefs` list if it's context is dependent because 
later we set the deduction guide as the DC for all typedefs in the list:

  for (auto *TD : MaterializedTypedefs)
TD->setDeclContext(Guide);

Also, we have to push the original TypedefDecl to the `TypeLocBuilder`, 
otherwise an assertion would fire:

  llvm-project/clang/lib/Sema/TypeLocBuilder.h:103: clang::TypeSourceInfo* 
clang::TypeLocBuilder::getTypeSourceInfo(clang::ASTContext&, clang::QualType): 
Assertion `T == LastTy && "type doesn't match last type pushed!"' failed.


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] D92101: [Clang][Sema] Attempt to fix CTAD faulty copy of non-local typedefs

2020-12-02 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

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?


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] D92103: [ASTImporter] Import the default argument of TemplateTypeParmDecl

2020-12-02 Thread Gabor Marton via Phabricator via cfe-commits
martong added a subscriber: balazske.
martong added a comment.

Hey Raphael, thanks for looking into the CTU crash!

I also had a look and I could reproduce that on Linux Ubuntu 18.04 with GCC 7. 
I think the discrepancy stems from GCC's libstdc++ and MacOS's libc++ 
implementation differences of `basic_streambuf`. This is the CXXRecordDecl 
which does not need an injected class name type (so there is the assert). 
However, the situation is more complex because there is a 5 long redecl chain 
(streambuf is forward declared in many places).

Anyway, I don't think that this patch itself caused the crash, it just revealed 
some other issues that are related to the possibly flawed import logic of 
injected class (name) types. I am adding another college @balazske as a 
subscriber because he started to investigate the crash deeper.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92103

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


[PATCH] D92103: [ASTImporter] Import the default argument of TemplateTypeParmDecl

2020-12-02 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor added a comment.

In D92103#2428139 , @martong wrote:

> Hey Raphael, thanks for looking into the CTU crash!
>
> I also had a look and I could reproduce that on Linux Ubuntu 18.04 with GCC 
> 7. I think the discrepancy stems from GCC's libstdc++ and MacOS's libc++ 
> implementation differences of `basic_streambuf`. This is the CXXRecordDecl 
> which does not need an injected class name type (so there is the assert). 
> However, the situation is more complex because there is a 5 long redecl chain 
> (streambuf is forward declared in many places).
>
> Anyway, I don't think that this patch itself caused the crash, it just 
> revealed some other issues that are related to the possibly flawed import 
> logic of injected class (name) types. I am adding another college @balazske 
> as a subscriber because he started to investigate the crash deeper.

Quick note: I should have mention that I actually tried reproducing this issue 
with libstdc++/GCC 10.2.0 on Arch Linux.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92103

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


[PATCH] D92474: [analyzer][StdLibraryFunctionsChecker] Add return value constraint to functions with BufferSize

2020-12-02 Thread Gabor Marton via Phabricator via cfe-commits
martong created this revision.
martong added a reviewer: steakhal.
Herald added subscribers: cfe-commits, ASDenysPetrov, Charusso, gamesh411, 
dkrupp, donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, rnkovacs, szepet, 
baloghadamsoftware, xazax.hun, whisperity.
Herald added a reviewer: Szelethus.
Herald added a project: clang.
martong requested review of this revision.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92474

Files:
  clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp

Index: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -1235,9 +1235,8 @@
   // read()-like functions that never return more than buffer size.
   auto FreadSummary =
   Summary(NoEvalCall)
-  .Case({
-  ReturnValueCondition(LessThanOrEq, ArgNo(2)),
-  })
+  .Case({ReturnValueCondition(LessThanOrEq, ArgNo(2)),
+ ReturnValueCondition(WithinRange, Range(0, SizeMax))})
   .ArgConstraint(NotNull(ArgNo(0)))
   .ArgConstraint(NotNull(ArgNo(3)))
   .ArgConstraint(BufferSize(/*Buffer=*/ArgNo(0), /*BufSize=*/ArgNo(1),
@@ -1764,6 +1763,12 @@
 Signature(ArgTypes{ConstCharPtrRestrictTy, CharPtrRestrictTy, SizeTy},
   RetType{Ssize_tTy}),
 Summary(NoEvalCall)
+// Upon successful completion, these functions shall return the
+// count of bytes placed in the buffer. Otherwise, these functions
+// shall return a value of -1, leave the buffer unchanged, and set
+// errno to indicate the error.
+.Case({ReturnValueCondition(LessThanOrEq, ArgNo(2)),
+   ReturnValueCondition(WithinRange, Range(-1, Ssize_tMax))})
 .ArgConstraint(NotNull(ArgNo(0)))
 .ArgConstraint(NotNull(ArgNo(1)))
 .ArgConstraint(BufferSize(/*Buffer=*/ArgNo(1),
@@ -1779,6 +1784,8 @@
 ArgTypes{IntTy, ConstCharPtrRestrictTy, CharPtrRestrictTy, SizeTy},
 RetType{Ssize_tTy}),
 Summary(NoEvalCall)
+.Case({ReturnValueCondition(LessThanOrEq, ArgNo(3)),
+   ReturnValueCondition(WithinRange, Range(-1, Ssize_tMax))})
 .ArgConstraint(ArgumentCondition(0, WithinRange, Range(0, IntMax)))
 .ArgConstraint(NotNull(ArgNo(1)))
 .ArgConstraint(NotNull(ArgNo(2)))
@@ -1850,6 +1857,7 @@
 // constraints which require pointer types for the sockaddr param.
 auto Accept =
 Summary(NoEvalCall)
+.Case({ReturnValueCondition(WithinRange, Range(-1, IntMax))})
 .ArgConstraint(ArgumentCondition(0, WithinRange, Range(0, IntMax)));
 if (!addToFunctionSummaryMap(
 "accept",
@@ -1872,6 +1880,7 @@
 Signature(ArgTypes{IntTy, ConstStructSockaddrPtrTy, Socklen_tTy},
   RetType{IntTy}),
 Summary(NoEvalCall)
+.Case({ReturnValueCondition(WithinRange, Range(-1, 0))})
 .ArgConstraint(
 ArgumentCondition(0, WithinRange, Range(0, IntMax)))
 .ArgConstraint(NotNull(ArgNo(1)))
@@ -1884,6 +1893,7 @@
   "bind",
   Signature(ArgTypes{IntTy, Irrelevant, Socklen_tTy}, RetType{IntTy}),
   Summary(NoEvalCall)
+  .Case({ReturnValueCondition(WithinRange, Range(-1, 0))})
   .ArgConstraint(
   ArgumentCondition(0, WithinRange, Range(0, IntMax)))
   .ArgConstraint(
@@ -1897,6 +1907,7 @@
Socklen_tPtrRestrictTy},
   RetType{IntTy}),
 Summary(NoEvalCall)
+.Case({ReturnValueCondition(WithinRange, Range(-1, 0))})
 .ArgConstraint(
 ArgumentCondition(0, WithinRange, Range(0, IntMax)))
 .ArgConstraint(NotNull(ArgNo(1)))
@@ -1906,6 +1917,7 @@
   Signature(ArgTypes{IntTy, Irrelevant, Socklen_tPtrRestrictTy},
 RetType{IntTy}),
   Summary(NoEvalCall)
+  .Case({ReturnValueCondition(WithinRange, Range(-1, 0))})
   .ArgConstraint(
   ArgumentCondition(0, WithinRange, Range(0, IntMax;
 
@@ -1917,6 +1929,7 @@
Socklen_tPtrRestrictTy},
   RetType{IntTy}),
 Summary(NoEvalCall)
+.Case({ReturnValueCondition(WithinRange, Range(-1, 0))})
 .ArgConstraint(
 ArgumentCondition(0, WithinRange, Range(0, IntMax)))
 .ArgConstraint(NotNull(ArgNo(1)))
@@ -1926,6 +1939,7 @@
   Signature(ArgTypes{IntTy, Irrelevant, Socklen_tPtrRestrictTy},
 RetType{IntTy}),
   Summary(NoEvalCall)
+  .Case

[PATCH] D92432: [analyzer] Add a thin abstraction layer between libCrossTU and libAnalysis.

2020-12-02 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun accepted this revision.
xazax.hun added a comment.
This revision is now accepted and ready to land.

LGTM!


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

https://reviews.llvm.org/D92432

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


[PATCH] D91997: APINotes: add bitcode format schema definitions

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

Looks good, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91997

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


[PATCH] D88393: [cfe][M68k] (Patch 7/8) Basic Clang support

2020-12-02 Thread Renato Golin via Phabricator via cfe-commits
rengolin added a comment.

Thanks for the changes. This looks good to me but I'll let others check again 
and approve.


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

https://reviews.llvm.org/D88393

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


[PATCH] D92432: [analyzer] Add a thin abstraction layer between libCrossTU and libAnalysis.

2020-12-02 Thread Gabor Marton via Phabricator via cfe-commits
martong accepted this revision.
martong added a comment.

Looks good, thanks!


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

https://reviews.llvm.org/D92432

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


[PATCH] D92189: [OpenMPIRBuilder] forward arguments as pointers to outlined function

2020-12-02 Thread Alex Zinenko via Phabricator via cfe-commits
ftynse updated this revision to Diff 308933.
ftynse marked 6 inline comments as done.
ftynse added a comment.

Address all remaining review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92189

Files:
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/test/OpenMP/parallel_codegen.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  llvm/lib/Transforms/IPO/OpenMPOpt.cpp
  llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp

Index: llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
===
--- llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
+++ llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
@@ -60,6 +60,25 @@
   DebugLoc DL;
 };
 
+// Returns the value stored in the given allocation. Returns null if the given
+// value is not a result of an allocation, if no value is stored or if there is
+// more than one store.
+static Value *findStoredValue(Value *AllocaValue) {
+  Instruction *Alloca = dyn_cast(AllocaValue);
+  if (!Alloca)
+return nullptr;
+  StoreInst *Store = nullptr;
+  for (Use &U : Alloca->uses()) {
+if (auto *CandidateStore = dyn_cast(U.getUser())) {
+  EXPECT_EQ(Store, nullptr);
+  Store = CandidateStore;
+}
+  }
+  if (!Store)
+return nullptr;
+  return Store->getValueOperand();
+};
+
 TEST_F(OpenMPIRBuilderTest, CreateBarrier) {
   OpenMPIRBuilder OMPBuilder(*M);
   OMPBuilder.initialize();
@@ -341,20 +360,25 @@
   };
 
   auto PrivCB = [&](InsertPointTy AllocaIP, InsertPointTy CodeGenIP,
-Value &VPtr, Value *&ReplacementValue) -> InsertPointTy {
+Value &Orig, Value &Inner,
+Value *&ReplacementValue) -> InsertPointTy {
 ++NumPrivatizedVars;
 
-if (!isa(VPtr)) {
-  EXPECT_EQ(&VPtr, F->arg_begin());
-  ReplacementValue = &VPtr;
+if (!isa(Orig)) {
+  EXPECT_EQ(&Orig, F->arg_begin());
+  ReplacementValue = &Inner;
   return CodeGenIP;
 }
 
+// Since the original value is an allocation, it has a pointer type and
+// therefore no additional wrapping should happen.
+EXPECT_EQ(&Orig, &Inner);
+
 // Trivial copy (=firstprivate).
 Builder.restoreIP(AllocaIP);
-Type *VTy = VPtr.getType()->getPointerElementType();
-Value *V = Builder.CreateLoad(VTy, &VPtr, VPtr.getName() + ".reload");
-ReplacementValue = Builder.CreateAlloca(VTy, 0, VPtr.getName() + ".copy");
+Type *VTy = Inner.getType()->getPointerElementType();
+Value *V = Builder.CreateLoad(VTy, &Inner, Orig.getName() + ".reload");
+ReplacementValue = Builder.CreateAlloca(VTy, 0, Orig.getName() + ".copy");
 Builder.restoreIP(CodeGenIP);
 Builder.CreateStore(V, ReplacementValue);
 return CodeGenIP;
@@ -401,7 +425,7 @@
   EXPECT_EQ(ForkCI->getArgOperand(1),
 ConstantInt::get(Type::getInt32Ty(Ctx), 1U));
   EXPECT_EQ(ForkCI->getArgOperand(2), Usr);
-  EXPECT_EQ(ForkCI->getArgOperand(3), F->arg_begin());
+  EXPECT_EQ(findStoredValue(ForkCI->getArgOperand(3)), F->arg_begin());
 }
 
 TEST_F(OpenMPIRBuilderTest, ParallelNested) {
@@ -423,12 +447,13 @@
   };
 
   auto PrivCB = [&](InsertPointTy AllocaIP, InsertPointTy CodeGenIP,
-Value &VPtr, Value *&ReplacementValue) -> InsertPointTy {
+Value &Orig, Value &Inner,
+Value *&ReplacementValue) -> InsertPointTy {
 // Trivial copy (=firstprivate).
 Builder.restoreIP(AllocaIP);
-Type *VTy = VPtr.getType()->getPointerElementType();
-Value *V = Builder.CreateLoad(VTy, &VPtr, VPtr.getName() + ".reload");
-ReplacementValue = Builder.CreateAlloca(VTy, 0, VPtr.getName() + ".copy");
+Type *VTy = Inner.getType()->getPointerElementType();
+Value *V = Builder.CreateLoad(VTy, &Inner, Orig.getName() + ".reload");
+ReplacementValue = Builder.CreateAlloca(VTy, 0, Orig.getName() + ".copy");
 Builder.restoreIP(CodeGenIP);
 Builder.CreateStore(V, ReplacementValue);
 return CodeGenIP;
@@ -515,12 +540,13 @@
   };
 
   auto PrivCB = [&](InsertPointTy AllocaIP, InsertPointTy CodeGenIP,
-Value &VPtr, Value *&ReplacementValue) -> InsertPointTy {
+Value &Orig, Value &Inner,
+Value *&ReplacementValue) -> InsertPointTy {
 // Trivial copy (=firstprivate).
 Builder.restoreIP(AllocaIP);
-Type *VTy = VPtr.getType()->getPointerElementType();
-Value *V = Builder.CreateLoad(VTy, &VPtr, VPtr.getName() + ".reload");
-ReplacementValue = Builder.CreateAlloca(VTy, 0, VPtr.getName() + ".copy");
+Type *VTy = Inner.getType()->getPointerElementType();
+Value *V = Builder.CreateLoad(VTy, &Inner, Orig.getName() + ".reload");
+ReplacementValue = Builder.CreateAlloca(VTy, 0, Orig.getName() + ".copy");
 Builder.restoreIP(CodeGenIP);
 Builder.CreateStore(V, ReplacementValue);
 return Cod

[PATCH] D92269: [TableGen] Eliminate the 'code' type

2020-12-02 Thread Paul C. Anagnostopoulos via Phabricator via cfe-commits
Paul-C-Anagnostopoulos updated this revision to Diff 308711.
Paul-C-Anagnostopoulos added a comment.

Fixed some of the lint issues.


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

https://reviews.llvm.org/D92269

Files:
  clang/utils/TableGen/ClangOptionDocEmitter.cpp
  llvm/docs/TableGen/BackEnds.rst
  llvm/docs/TableGen/BackGuide.rst
  llvm/docs/TableGen/ProgRef.rst
  llvm/include/llvm/TableGen/Error.h
  llvm/include/llvm/TableGen/Record.h
  llvm/include/llvm/TableGen/SearchableTable.td
  llvm/lib/TableGen/Error.cpp
  llvm/lib/TableGen/JSONBackend.cpp
  llvm/lib/TableGen/Record.cpp
  llvm/lib/TableGen/TGLexer.cpp
  llvm/lib/TableGen/TGLexer.h
  llvm/lib/TableGen/TGParser.cpp
  llvm/lib/Target/AMDGPU/MIMGInstructions.td
  llvm/test/TableGen/code.td
  llvm/test/TableGen/generic-tables.td
  llvm/test/TableGen/interleave.td
  llvm/test/TableGen/unterminated-code-block.td
  llvm/utils/TableGen/AsmWriterEmitter.cpp
  llvm/utils/TableGen/DFAEmitter.cpp
  llvm/utils/TableGen/GICombinerEmitter.cpp
  llvm/utils/TableGen/RISCVCompressInstEmitter.cpp
  llvm/utils/TableGen/SearchableTableEmitter.cpp
  mlir/include/mlir/TableGen/Operator.h
  mlir/lib/TableGen/Attribute.cpp
  mlir/lib/TableGen/Dialect.cpp
  mlir/lib/TableGen/Operator.cpp
  mlir/lib/TableGen/Pattern.cpp
  mlir/lib/TableGen/Type.cpp
  mlir/lib/TableGen/TypeDef.cpp
  mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp

Index: mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
===
--- mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
+++ mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
@@ -137,7 +137,7 @@
 static inline bool hasStringAttribute(const Record &record,
   StringRef fieldName) {
   auto valueInit = record.getValueInit(fieldName);
-  return isa(valueInit);
+  return isa(valueInit);
 }
 
 static std::string getArgumentName(const Operator &op, int index) {
@@ -1797,15 +1797,15 @@
 return;
 
   auto valueInit = def.getValueInit("printer");
-  CodeInit *codeInit = dyn_cast(valueInit);
-  if (!codeInit)
+  StringInit *stringInit = dyn_cast(valueInit);
+  if (!stringInit)
 return;
 
   auto *method =
   opClass.addMethodAndPrune("void", "print", "::mlir::OpAsmPrinter &", "p");
   FmtContext fctx;
   fctx.addSubst("cppClass", opClass.getClassName());
-  auto printer = codeInit->getValue().ltrim().rtrim(" \t\v\f\r");
+  auto printer = stringInit->getValue().ltrim().rtrim(" \t\v\f\r");
   method->body() << "  " << tgfmt(printer, &fctx);
 }
 
@@ -1817,8 +1817,8 @@
<< "return ::mlir::failure();\n";
 
   auto *valueInit = def.getValueInit("verifier");
-  CodeInit *codeInit = dyn_cast(valueInit);
-  bool hasCustomVerify = codeInit && !codeInit->getValue().empty();
+  StringInit *stringInit = dyn_cast(valueInit);
+  bool hasCustomVerify = stringInit && !stringInit->getValue().empty();
   populateSubstitutions(op, "this->getAttr", "this->getODSOperands",
 "this->getODSResults", verifyCtx);
 
@@ -1842,7 +1842,7 @@
   if (hasCustomVerify) {
 FmtContext fctx;
 fctx.addSubst("cppClass", opClass.getClassName());
-auto printer = codeInit->getValue().ltrim().rtrim(" \t\v\f\r");
+auto printer = stringInit->getValue().ltrim().rtrim(" \t\v\f\r");
 body << "  " << tgfmt(printer, &fctx);
   } else {
 body << "  return ::mlir::success();\n";
Index: mlir/lib/TableGen/TypeDef.cpp
===
--- mlir/lib/TableGen/TypeDef.cpp
+++ mlir/lib/TableGen/TypeDef.cpp
@@ -78,10 +78,10 @@
   return def->getValueAsOptionalString("mnemonic");
 }
 llvm::Optional TypeDef::getPrinterCode() const {
-  return def->getValueAsOptionalCode("printer");
+  return def->getValueAsOptionalString("printer");
 }
 llvm::Optional TypeDef::getParserCode() const {
-  return def->getValueAsOptionalCode("parser");
+  return def->getValueAsOptionalString("parser");
 }
 bool TypeDef::genAccessors() const {
   return def->getValueAsBit("genAccessors");
@@ -114,7 +114,7 @@
 llvm::RecordVal *code = typeParameter->getDef()->getValue("allocator");
 if (!code)
   return llvm::Optional();
-if (llvm::CodeInit *ci = dyn_cast(code->getValue()))
+if (llvm::StringInit *ci = dyn_cast(code->getValue()))
   return ci->getValue();
 if (isa(code->getValue()))
   return llvm::Optional();
Index: mlir/lib/TableGen/Type.cpp
===
--- mlir/lib/TableGen/Type.cpp
+++ mlir/lib/TableGen/Type.cpp
@@ -46,7 +46,7 @@
   if (!builderCall || !builderCall->getValue())
 return llvm::None;
   return TypeSwitch>(builderCall->getValue())
-  .Case([&](auto *init) {
+  .Case([&](auto *init) {
 StringRef value = init->getValue();
 return value.empty() ? Optional() : value;
   })
Index: mlir/lib/TableGen/Pattern.cpp
===
--- mlir/lib/TableGen/Pattern

[PATCH] D92269: [TableGen] Eliminate the 'code' type

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

Woot!  Go Paul!


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

https://reviews.llvm.org/D92269

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


[PATCH] D79773: [clang-format] Improve clang-formats handling of concepts

2020-12-02 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added a comment.

@MyDeveloperDay, is there anything I can do to help you on that?

BTW, libc++ would like to use clang-format (more than it does currently) and 
having concepts support would be awesome as there are more and more 
concept-related patches coming in.
IMHO, even support for most common cases would be a great improvement.


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

https://reviews.llvm.org/D79773

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


[PATCH] D92474: [analyzer][StdLibraryFunctionsChecker] Add return value constraint to functions with BufferSize

2020-12-02 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

I've double-checked the return values of each touched summary.
Everything seems fine to me, besides the two I've highlighted.




Comment at: 
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:1771
+.Case({ReturnValueCondition(LessThanOrEq, ArgNo(2)),
+   ReturnValueCondition(WithinRange, Range(-1, Ssize_tMax))})
 .ArgConstraint(NotNull(ArgNo(0)))





Comment at: 
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:1788
+.Case({ReturnValueCondition(LessThanOrEq, ArgNo(3)),
+   ReturnValueCondition(WithinRange, Range(-1, Ssize_tMax))})
 .ArgConstraint(ArgumentCondition(0, WithinRange, Range(0, IntMax)))

Same here.



Comment at: 
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:1860
 Summary(NoEvalCall)
+.Case({ReturnValueCondition(WithinRange, Range(-1, IntMax))})
 .ArgConstraint(ArgumentCondition(0, WithinRange, Range(0, 
IntMax)));

Aaa, I get it. We deal with this in a single transition. Fine.



Comment at: 
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:2076
 Summary(NoEvalCall)
+.Case({ReturnValueCondition(WithinRange, Range(-1, 0))})
 .ArgConstraint(NotNull(ArgNo(3)))

BTW, this is quite frequently repeated.
Do you think worth hoisting such a return value constraint?

I'm thinking of something like `ReturnsZeroOrMinusOne`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92474

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


[PATCH] D92189: [OpenMPIRBuilder] forward arguments as pointers to outlined function

2020-12-02 Thread Alex Zinenko via Phabricator via cfe-commits
ftynse updated this revision to Diff 308938.
ftynse added a comment.
Herald added subscribers: teijeong, rdzhabarov, tatianashp, msifontes, jurahul, 
Kayjukh, grosul1, Joonsoo, stephenneuendorffer, liufengdb, aartbik, lucyrfox, 
mgester, arpith-jacob, nicolasvasilache, antiagainst, shauheen, rriddle, 
mehdi_amini.
Herald added a project: MLIR.

Fix a runaway MLIR use of createParallel


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92189

Files:
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/test/OpenMP/parallel_codegen.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  llvm/lib/Transforms/IPO/OpenMPOpt.cpp
  llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
  mlir/lib/Target/LLVMIR/ModuleTranslation.cpp

Index: mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
===
--- mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
+++ mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
@@ -433,7 +433,7 @@
   // attribute (shared, private, firstprivate, ...) of variables.
   // Currently defaults to shared.
   auto privCB = [&](InsertPointTy allocaIP, InsertPointTy codeGenIP,
-llvm::Value &vPtr,
+llvm::Value &, llvm::Value &vPtr,
 llvm::Value *&replacementValue) -> InsertPointTy {
 replacementValue = &vPtr;
 
Index: llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
===
--- llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
+++ llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
@@ -60,6 +60,25 @@
   DebugLoc DL;
 };
 
+// Returns the value stored in the given allocation. Returns null if the given
+// value is not a result of an allocation, if no value is stored or if there is
+// more than one store.
+static Value *findStoredValue(Value *AllocaValue) {
+  Instruction *Alloca = dyn_cast(AllocaValue);
+  if (!Alloca)
+return nullptr;
+  StoreInst *Store = nullptr;
+  for (Use &U : Alloca->uses()) {
+if (auto *CandidateStore = dyn_cast(U.getUser())) {
+  EXPECT_EQ(Store, nullptr);
+  Store = CandidateStore;
+}
+  }
+  if (!Store)
+return nullptr;
+  return Store->getValueOperand();
+};
+
 TEST_F(OpenMPIRBuilderTest, CreateBarrier) {
   OpenMPIRBuilder OMPBuilder(*M);
   OMPBuilder.initialize();
@@ -341,20 +360,25 @@
   };
 
   auto PrivCB = [&](InsertPointTy AllocaIP, InsertPointTy CodeGenIP,
-Value &VPtr, Value *&ReplacementValue) -> InsertPointTy {
+Value &Orig, Value &Inner,
+Value *&ReplacementValue) -> InsertPointTy {
 ++NumPrivatizedVars;
 
-if (!isa(VPtr)) {
-  EXPECT_EQ(&VPtr, F->arg_begin());
-  ReplacementValue = &VPtr;
+if (!isa(Orig)) {
+  EXPECT_EQ(&Orig, F->arg_begin());
+  ReplacementValue = &Inner;
   return CodeGenIP;
 }
 
+// Since the original value is an allocation, it has a pointer type and
+// therefore no additional wrapping should happen.
+EXPECT_EQ(&Orig, &Inner);
+
 // Trivial copy (=firstprivate).
 Builder.restoreIP(AllocaIP);
-Type *VTy = VPtr.getType()->getPointerElementType();
-Value *V = Builder.CreateLoad(VTy, &VPtr, VPtr.getName() + ".reload");
-ReplacementValue = Builder.CreateAlloca(VTy, 0, VPtr.getName() + ".copy");
+Type *VTy = Inner.getType()->getPointerElementType();
+Value *V = Builder.CreateLoad(VTy, &Inner, Orig.getName() + ".reload");
+ReplacementValue = Builder.CreateAlloca(VTy, 0, Orig.getName() + ".copy");
 Builder.restoreIP(CodeGenIP);
 Builder.CreateStore(V, ReplacementValue);
 return CodeGenIP;
@@ -401,7 +425,7 @@
   EXPECT_EQ(ForkCI->getArgOperand(1),
 ConstantInt::get(Type::getInt32Ty(Ctx), 1U));
   EXPECT_EQ(ForkCI->getArgOperand(2), Usr);
-  EXPECT_EQ(ForkCI->getArgOperand(3), F->arg_begin());
+  EXPECT_EQ(findStoredValue(ForkCI->getArgOperand(3)), F->arg_begin());
 }
 
 TEST_F(OpenMPIRBuilderTest, ParallelNested) {
@@ -423,12 +447,13 @@
   };
 
   auto PrivCB = [&](InsertPointTy AllocaIP, InsertPointTy CodeGenIP,
-Value &VPtr, Value *&ReplacementValue) -> InsertPointTy {
+Value &Orig, Value &Inner,
+Value *&ReplacementValue) -> InsertPointTy {
 // Trivial copy (=firstprivate).
 Builder.restoreIP(AllocaIP);
-Type *VTy = VPtr.getType()->getPointerElementType();
-Value *V = Builder.CreateLoad(VTy, &VPtr, VPtr.getName() + ".reload");
-ReplacementValue = Builder.CreateAlloca(VTy, 0, VPtr.getName() + ".copy");
+Type *VTy = Inner.getType()->getPointerElementType();
+Value *V = Builder.CreateLoad(VTy, &Inner, Orig.getName() + ".reload");
+ReplacementValue = Builder.CreateAlloca(VTy, 0, Orig.getName() + ".copy");
 Builder.restoreIP(CodeGenIP);
 Builder.CreateStore(V, ReplacementValue);
 return CodeGen

[clang] f770ec1 - [SystemZ][NFC]Move all SystemZ tests to init-s390x.c

2020-12-02 Thread Abhina Sreeskantharajan via cfe-commits

Author: Abhina Sreeskantharajan
Date: 2020-12-02T08:23:27-05:00
New Revision: f770ec1a4e8d9b274d205073e2c8b01d248cf9cb

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

LOG: [SystemZ][NFC]Move all SystemZ tests to init-s390x.c

This patch moves all s390x tests in init.c and init-zos.c to init-s390x.c.

Reviewed By: muiez

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

Added: 
clang/test/Preprocessor/init-s390x.c

Modified: 
clang/test/Preprocessor/init.c

Removed: 
clang/test/Preprocessor/init-zos.c



diff  --git a/clang/test/Preprocessor/init-s390x.c 
b/clang/test/Preprocessor/init-s390x.c
new file mode 100644
index ..b0e45b5348ce
--- /dev/null
+++ b/clang/test/Preprocessor/init-s390x.c
@@ -0,0 +1,205 @@
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=s390x-none-none 
-fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix S390X 
%s
+// RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -triple=s390x-none-none 
-fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix S390X 
-check-prefix S390X-CXX %s
+
+// S390X:#define __BIGGEST_ALIGNMENT__ 8
+// S390X:#define __CHAR16_TYPE__ unsigned short
+// S390X:#define __CHAR32_TYPE__ unsigned int
+// S390X:#define __CHAR_BIT__ 8
+// S390X:#define __CHAR_UNSIGNED__ 1
+// S390X:#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
+// S390X:#define __DBL_DIG__ 15
+// S390X:#define __DBL_EPSILON__ 2.2204460492503131e-16
+// S390X:#define __DBL_HAS_DENORM__ 1
+// S390X:#define __DBL_HAS_INFINITY__ 1
+// S390X:#define __DBL_HAS_QUIET_NAN__ 1
+// S390X:#define __DBL_MANT_DIG__ 53
+// S390X:#define __DBL_MAX_10_EXP__ 308
+// S390X:#define __DBL_MAX_EXP__ 1024
+// S390X:#define __DBL_MAX__ 1.7976931348623157e+308
+// S390X:#define __DBL_MIN_10_EXP__ (-307)
+// S390X:#define __DBL_MIN_EXP__ (-1021)
+// S390X:#define __DBL_MIN__ 2.2250738585072014e-308
+// S390X:#define __DECIMAL_DIG__ __LDBL_DECIMAL_DIG__
+// S390X:#define __FLT_DENORM_MIN__ 1.40129846e-45F
+// S390X:#define __FLT_DIG__ 6
+// S390X:#define __FLT_EPSILON__ 1.19209290e-7F
+// S390X:#define __FLT_EVAL_METHOD__ 0
+// S390X:#define __FLT_HAS_DENORM__ 1
+// S390X:#define __FLT_HAS_INFINITY__ 1
+// S390X:#define __FLT_HAS_QUIET_NAN__ 1
+// S390X:#define __FLT_MANT_DIG__ 24
+// S390X:#define __FLT_MAX_10_EXP__ 38
+// S390X:#define __FLT_MAX_EXP__ 128
+// S390X:#define __FLT_MAX__ 3.40282347e+38F
+// S390X:#define __FLT_MIN_10_EXP__ (-37)
+// S390X:#define __FLT_MIN_EXP__ (-125)
+// S390X:#define __FLT_MIN__ 1.17549435e-38F
+// S390X:#define __FLT_RADIX__ 2
+// S390X:#define __INT16_C_SUFFIX__
+// S390X:#define __INT16_FMTd__ "hd"
+// S390X:#define __INT16_FMTi__ "hi"
+// S390X:#define __INT16_MAX__ 32767
+// S390X:#define __INT16_TYPE__ short
+// S390X:#define __INT32_C_SUFFIX__
+// S390X:#define __INT32_FMTd__ "d"
+// S390X:#define __INT32_FMTi__ "i"
+// S390X:#define __INT32_MAX__ 2147483647
+// S390X:#define __INT32_TYPE__ int
+// S390X:#define __INT64_C_SUFFIX__ L
+// S390X:#define __INT64_FMTd__ "ld"
+// S390X:#define __INT64_FMTi__ "li"
+// S390X:#define __INT64_MAX__ 9223372036854775807L
+// S390X:#define __INT64_TYPE__ long int
+// S390X:#define __INT8_C_SUFFIX__
+// S390X:#define __INT8_FMTd__ "hhd"
+// S390X:#define __INT8_FMTi__ "hhi"
+// S390X:#define __INT8_MAX__ 127
+// S390X:#define __INT8_TYPE__ signed char
+// S390X:#define __INTMAX_C_SUFFIX__ L
+// S390X:#define __INTMAX_FMTd__ "ld"
+// S390X:#define __INTMAX_FMTi__ "li"
+// S390X:#define __INTMAX_MAX__ 9223372036854775807L
+// S390X:#define __INTMAX_TYPE__ long int
+// S390X:#define __INTMAX_WIDTH__ 64
+// S390X:#define __INTPTR_FMTd__ "ld"
+// S390X:#define __INTPTR_FMTi__ "li"
+// S390X:#define __INTPTR_MAX__ 9223372036854775807L
+// S390X:#define __INTPTR_TYPE__ long int
+// S390X:#define __INTPTR_WIDTH__ 64
+// S390X:#define __INT_FAST16_FMTd__ "hd"
+// S390X:#define __INT_FAST16_FMTi__ "hi"
+// S390X:#define __INT_FAST16_MAX__ 32767
+// S390X:#define __INT_FAST16_TYPE__ short
+// S390X:#define __INT_FAST32_FMTd__ "d"
+// S390X:#define __INT_FAST32_FMTi__ "i"
+// S390X:#define __INT_FAST32_MAX__ 2147483647
+// S390X:#define __INT_FAST32_TYPE__ int
+// S390X:#define __INT_FAST64_FMTd__ "ld"
+// S390X:#define __INT_FAST64_FMTi__ "li"
+// S390X:#define __INT_FAST64_MAX__ 9223372036854775807L
+// S390X:#define __INT_FAST64_TYPE__ long int
+// S390X:#define __INT_FAST8_FMTd__ "hhd"
+// S390X:#define __INT_FAST8_FMTi__ "hhi"
+// S390X:#define __INT_FAST8_MAX__ 127
+// S390X:#define __INT_FAST8_TYPE__ signed char
+// S390X:#define __INT_LEAST16_FMTd__ "hd"
+// S390X:#define __INT_LEAST16_FMTi__ "hi"
+// S390X:#define __INT_LEAST16_MAX__ 32767
+// S390X:#define __INT_LEAST16_TYPE__ short
+// S390X:#define __INT_LEAST32_FMTd__ "d"
+// S390X:#define __INT_LEAST32_FMTi__ "i"
+

[PATCH] D92048: [SystemZ][NFC]Move all SystemZ tests to init-s390x.c

2020-12-02 Thread Abhina Sree via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf770ec1a4e8d: [SystemZ][NFC]Move all SystemZ tests to 
init-s390x.c (authored by abhina.sreeskantharajan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92048

Files:
  clang/test/Preprocessor/init-s390x.c
  clang/test/Preprocessor/init-zos.c
  clang/test/Preprocessor/init.c

Index: clang/test/Preprocessor/init.c
===
--- clang/test/Preprocessor/init.c
+++ clang/test/Preprocessor/init.c
@@ -855,189 +855,6 @@
 // AMDGPU:#define cl_khr_local_int32_base_atomics 1
 // AMDGPU:#define cl_khr_local_int32_extended_atomics 1
 
-// RUN: %clang_cc1 -E -dM -ffreestanding -triple=s390x-none-none -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix S390X %s
-// RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -triple=s390x-none-none -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix S390X -check-prefix S390X-CXX %s
-//
-// S390X:#define __BIGGEST_ALIGNMENT__ 8
-// S390X:#define __CHAR16_TYPE__ unsigned short
-// S390X:#define __CHAR32_TYPE__ unsigned int
-// S390X:#define __CHAR_BIT__ 8
-// S390X:#define __CHAR_UNSIGNED__ 1
-// S390X:#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
-// S390X:#define __DBL_DIG__ 15
-// S390X:#define __DBL_EPSILON__ 2.2204460492503131e-16
-// S390X:#define __DBL_HAS_DENORM__ 1
-// S390X:#define __DBL_HAS_INFINITY__ 1
-// S390X:#define __DBL_HAS_QUIET_NAN__ 1
-// S390X:#define __DBL_MANT_DIG__ 53
-// S390X:#define __DBL_MAX_10_EXP__ 308
-// S390X:#define __DBL_MAX_EXP__ 1024
-// S390X:#define __DBL_MAX__ 1.7976931348623157e+308
-// S390X:#define __DBL_MIN_10_EXP__ (-307)
-// S390X:#define __DBL_MIN_EXP__ (-1021)
-// S390X:#define __DBL_MIN__ 2.2250738585072014e-308
-// S390X:#define __DECIMAL_DIG__ __LDBL_DECIMAL_DIG__
-// S390X:#define __FLT_DENORM_MIN__ 1.40129846e-45F
-// S390X:#define __FLT_DIG__ 6
-// S390X:#define __FLT_EPSILON__ 1.19209290e-7F
-// S390X:#define __FLT_EVAL_METHOD__ 0
-// S390X:#define __FLT_HAS_DENORM__ 1
-// S390X:#define __FLT_HAS_INFINITY__ 1
-// S390X:#define __FLT_HAS_QUIET_NAN__ 1
-// S390X:#define __FLT_MANT_DIG__ 24
-// S390X:#define __FLT_MAX_10_EXP__ 38
-// S390X:#define __FLT_MAX_EXP__ 128
-// S390X:#define __FLT_MAX__ 3.40282347e+38F
-// S390X:#define __FLT_MIN_10_EXP__ (-37)
-// S390X:#define __FLT_MIN_EXP__ (-125)
-// S390X:#define __FLT_MIN__ 1.17549435e-38F
-// S390X:#define __FLT_RADIX__ 2
-// S390X:#define __INT16_C_SUFFIX__
-// S390X:#define __INT16_FMTd__ "hd"
-// S390X:#define __INT16_FMTi__ "hi"
-// S390X:#define __INT16_MAX__ 32767
-// S390X:#define __INT16_TYPE__ short
-// S390X:#define __INT32_C_SUFFIX__
-// S390X:#define __INT32_FMTd__ "d"
-// S390X:#define __INT32_FMTi__ "i"
-// S390X:#define __INT32_MAX__ 2147483647
-// S390X:#define __INT32_TYPE__ int
-// S390X:#define __INT64_C_SUFFIX__ L
-// S390X:#define __INT64_FMTd__ "ld"
-// S390X:#define __INT64_FMTi__ "li"
-// S390X:#define __INT64_MAX__ 9223372036854775807L
-// S390X:#define __INT64_TYPE__ long int
-// S390X:#define __INT8_C_SUFFIX__
-// S390X:#define __INT8_FMTd__ "hhd"
-// S390X:#define __INT8_FMTi__ "hhi"
-// S390X:#define __INT8_MAX__ 127
-// S390X:#define __INT8_TYPE__ signed char
-// S390X:#define __INTMAX_C_SUFFIX__ L
-// S390X:#define __INTMAX_FMTd__ "ld"
-// S390X:#define __INTMAX_FMTi__ "li"
-// S390X:#define __INTMAX_MAX__ 9223372036854775807L
-// S390X:#define __INTMAX_TYPE__ long int
-// S390X:#define __INTMAX_WIDTH__ 64
-// S390X:#define __INTPTR_FMTd__ "ld"
-// S390X:#define __INTPTR_FMTi__ "li"
-// S390X:#define __INTPTR_MAX__ 9223372036854775807L
-// S390X:#define __INTPTR_TYPE__ long int
-// S390X:#define __INTPTR_WIDTH__ 64
-// S390X:#define __INT_FAST16_FMTd__ "hd"
-// S390X:#define __INT_FAST16_FMTi__ "hi"
-// S390X:#define __INT_FAST16_MAX__ 32767
-// S390X:#define __INT_FAST16_TYPE__ short
-// S390X:#define __INT_FAST32_FMTd__ "d"
-// S390X:#define __INT_FAST32_FMTi__ "i"
-// S390X:#define __INT_FAST32_MAX__ 2147483647
-// S390X:#define __INT_FAST32_TYPE__ int
-// S390X:#define __INT_FAST64_FMTd__ "ld"
-// S390X:#define __INT_FAST64_FMTi__ "li"
-// S390X:#define __INT_FAST64_MAX__ 9223372036854775807L
-// S390X:#define __INT_FAST64_TYPE__ long int
-// S390X:#define __INT_FAST8_FMTd__ "hhd"
-// S390X:#define __INT_FAST8_FMTi__ "hhi"
-// S390X:#define __INT_FAST8_MAX__ 127
-// S390X:#define __INT_FAST8_TYPE__ signed char
-// S390X:#define __INT_LEAST16_FMTd__ "hd"
-// S390X:#define __INT_LEAST16_FMTi__ "hi"
-// S390X:#define __INT_LEAST16_MAX__ 32767
-// S390X:#define __INT_LEAST16_TYPE__ short
-// S390X:#define __INT_LEAST32_FMTd__ "d"
-// S390X:#define __INT_LEAST32_FMTi__ "i"
-// S390X:#define __INT_LEAST32_MAX__ 2147483647
-// S390X:#define __INT_LEAST32_TYPE__ int
-// S390X:#define __INT_LEAST64_FMTd__ "ld"
-// S390X:#define __INT_LEAST64_FMTi__ "li"
-// S390X:#define __INT_LEA

[PATCH] D89987: [analyzer] [NFC] Rename SymbolRef to SymExprRef

2020-12-02 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment.

@steakhal

> Losing **git blame** would have a signifficant impact in deed, however we 
> always have the option to add the renaming commit to the 
> `.git-blame-ignore-revs`.

Using this git feature I can see no more obstacles to implement the renaming. 
Moreover LLVM repo already has similar instances in `.git-blame-ignore-revs`.

> To achieve that, we should probably have a better reason behind it besides 
> simply //renaming// stuff.

Untill we start this process we will mix this up every time. So, I would start 
the renaming with the `blame-ignore` marking.

Let's answer the question: What bad things can occur if we rename `SymbolRef` 
to `SymExprRef`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89987

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


[PATCH] D92189: [OpenMPIRBuilder] forward arguments as pointers to outlined function

2020-12-02 Thread Alex Zinenko via Phabricator via cfe-commits
ftynse added a comment.

Windows failure is unrelated, broken by an earlier commit to MLIR PDL.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92189

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


[clang] 240dd92 - [OpenMPIRBuilder] forward arguments as pointers to outlined function

2020-12-02 Thread Alex Zinenko via cfe-commits

Author: Alex Zinenko
Date: 2020-12-02T14:59:41+01:00
New Revision: 240dd92432ebbfbf24ef85779f2cdf93e6ddf605

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

LOG: [OpenMPIRBuilder] forward arguments as pointers to outlined function

OpenMPIRBuilder::createParallel outlines the body region of the parallel
construct into a new function that accepts any value previously defined outside
the region as a function argument. This function is called back by OpenMP
runtime function __kmpc_fork_call, which expects trailing arguments to be
pointers. If the region uses a value that is not of a pointer type, e.g. a
struct, the produced code would be invalid. In such cases, make createParallel
emit IR that stores the value on stack and pass the pointer to the outlined
function instead. The outlined function then loads the value back and uses as
normal.

Reviewed By: jdoerfert, llitchev

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

Added: 


Modified: 
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/test/OpenMP/parallel_codegen.cpp
llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
llvm/lib/Transforms/IPO/OpenMPOpt.cpp
llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
mlir/lib/Target/LLVMIR/ModuleTranslation.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp 
b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index 2fb4144930df..5e8d98cfe5ef 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -1693,7 +1693,7 @@ void CodeGenFunction::EmitOMPParallelDirective(const 
OMPParallelDirective &S) {
 //
 // TODO: This defaults to shared right now.
 auto PrivCB = [](InsertPointTy AllocaIP, InsertPointTy CodeGenIP,
- llvm::Value &Val, llvm::Value *&ReplVal) {
+ llvm::Value &, llvm::Value &Val, llvm::Value *&ReplVal) {
   // The next line is appropriate only for variables (Val) with the
   // data-sharing attribute "shared".
   ReplVal = &Val;

diff  --git a/clang/test/OpenMP/parallel_codegen.cpp 
b/clang/test/OpenMP/parallel_codegen.cpp
index bceab0637f6a..83561ce6f6a8 100644
--- a/clang/test/OpenMP/parallel_codegen.cpp
+++ b/clang/test/OpenMP/parallel_codegen.cpp
@@ -133,22 +133,26 @@ int main (int argc, char **argv) {
 // CHECK-DEBUG-DAG:   define internal void [[OMP_OUTLINED]](i32* noalias 
%.global_tid., i32* noalias %.bound_tid., i64 [[VLA_SIZE:%.+]], i32* {{.+}} 
[[VLA_ADDR:%[^)]+]])
 // CHECK-DEBUG-DAG:   call void [[OMP_OUTLINED_DEBUG]]
 
+// Note that OpenMPIRBuilder puts the trailing arguments in a 
diff erent order:
+// arguments that are wrapped into additional pointers precede the other
+// arguments. This is expected and not problematic because both the call and 
the
+// function are generated from the same place, and the function is internal.
 // ALL:   define linkonce_odr {{[a-z\_\b]*[ ]?i32}} [[TMAIN]](i8** %argc)
 // ALL:   store i8** %argc, i8*** [[ARGC_ADDR:%.+]],
 // CHECK:   call {{.*}}void (%struct.ident_t*, i32, void (i32*, i32*, 
...)*, ...) @__kmpc_fork_call(%struct.ident_t* [[DEF_LOC_2]], i32 2, void 
(i32*, i32*, ...)* bitcast (void (i32*, i32*, i8***, i{{64|32}})* 
[[OMP_OUTLINED:@.+]] to void (i32*, i32*, ...)*), i8*** [[ARGC_ADDR]], 
i{{64|32}} %{{.+}})
-// IRBUILDER:   call {{.*}}void (%struct.ident_t*, i32, void (i32*, i32*, 
...)*, ...) @__kmpc_fork_call(%struct.ident_t* [[DEF_LOC_2]], i32 2, void 
(i32*, i32*, ...)* bitcast (void (i32*, i32*, i8***, i{{64|32}})* 
[[OMP_OUTLINED:@.+]] to void (i32*, i32*, ...)*), i8*** [[ARGC_ADDR]], 
i{{64|32}} %{{.+}})
+// IRBUILDER:   call {{.*}}void (%struct.ident_t*, i32, void (i32*, i32*, 
...)*, ...) @__kmpc_fork_call(%struct.ident_t* [[DEF_LOC_2]], i32 2, void 
(i32*, i32*, ...)* bitcast (void (i32*, i32*, i{{64|32}}*, i8***)* 
[[OMP_OUTLINED:@.+]] to void (i32*, i32*, ...)*), i{{64|32}}* %{{.+}}, i8*** 
[[ARGC_ADDR]])
 // ALL:  ret i32 0
 // ALL-NEXT:  }
 // ALL-DEBUG:   define linkonce_odr i32 [[TMAIN]](i8** %argc)
 
 // CHECK-DEBUG:   store i8** %argc, i8*** [[ARGC_ADDR:%.+]],
 // CHECK-DEBUG:   call void (%struct.ident_t*, i32, void (i32*, i32*, 
...)*, ...) @__kmpc_fork_call(%struct.ident_t* @{{.*}}, i32 2, void (i32*, 
i32*, ...)* bitcast (void (i32*, i32*, i8***, i64)* [[OMP_OUTLINED:@.+]] to 
void (i32*, i32*, ...)*), i8*** [[ARGC_ADDR]], i64 %{{.+}})
-// IRBUILDER-DEBUG:   call void (%struct.ident_t*, i32, void (i32*, i32*, 
...)*, ...) @__kmpc_fork_call(%struct.ident_t* @{{.*}}, i32 2, void (i32*, 
i32*, ...)* bitcast (void (i32*, i32*, i8***, i64)* [[OMP_OUTLINED:@.+]] to 
void (i32*, i32*, ...)*), i8*** [[ARGC_ADDR]], i64 %{{.+}})
+// IRBUILDER-DEBUG:   call void (%struct.ident_t*, i32, void (i32*, i32*, 
...)*, ...)

[PATCH] D92189: [OpenMPIRBuilder] forward arguments as pointers to outlined function

2020-12-02 Thread Alex Zinenko 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 rG240dd92432eb: [OpenMPIRBuilder] forward arguments as 
pointers to outlined function (authored by ftynse).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92189

Files:
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/test/OpenMP/parallel_codegen.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  llvm/lib/Transforms/IPO/OpenMPOpt.cpp
  llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
  mlir/lib/Target/LLVMIR/ModuleTranslation.cpp

Index: mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
===
--- mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
+++ mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
@@ -433,7 +433,7 @@
   // attribute (shared, private, firstprivate, ...) of variables.
   // Currently defaults to shared.
   auto privCB = [&](InsertPointTy allocaIP, InsertPointTy codeGenIP,
-llvm::Value &vPtr,
+llvm::Value &, llvm::Value &vPtr,
 llvm::Value *&replacementValue) -> InsertPointTy {
 replacementValue = &vPtr;
 
Index: llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
===
--- llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
+++ llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
@@ -60,6 +60,25 @@
   DebugLoc DL;
 };
 
+// Returns the value stored in the given allocation. Returns null if the given
+// value is not a result of an allocation, if no value is stored or if there is
+// more than one store.
+static Value *findStoredValue(Value *AllocaValue) {
+  Instruction *Alloca = dyn_cast(AllocaValue);
+  if (!Alloca)
+return nullptr;
+  StoreInst *Store = nullptr;
+  for (Use &U : Alloca->uses()) {
+if (auto *CandidateStore = dyn_cast(U.getUser())) {
+  EXPECT_EQ(Store, nullptr);
+  Store = CandidateStore;
+}
+  }
+  if (!Store)
+return nullptr;
+  return Store->getValueOperand();
+};
+
 TEST_F(OpenMPIRBuilderTest, CreateBarrier) {
   OpenMPIRBuilder OMPBuilder(*M);
   OMPBuilder.initialize();
@@ -341,20 +360,25 @@
   };
 
   auto PrivCB = [&](InsertPointTy AllocaIP, InsertPointTy CodeGenIP,
-Value &VPtr, Value *&ReplacementValue) -> InsertPointTy {
+Value &Orig, Value &Inner,
+Value *&ReplacementValue) -> InsertPointTy {
 ++NumPrivatizedVars;
 
-if (!isa(VPtr)) {
-  EXPECT_EQ(&VPtr, F->arg_begin());
-  ReplacementValue = &VPtr;
+if (!isa(Orig)) {
+  EXPECT_EQ(&Orig, F->arg_begin());
+  ReplacementValue = &Inner;
   return CodeGenIP;
 }
 
+// Since the original value is an allocation, it has a pointer type and
+// therefore no additional wrapping should happen.
+EXPECT_EQ(&Orig, &Inner);
+
 // Trivial copy (=firstprivate).
 Builder.restoreIP(AllocaIP);
-Type *VTy = VPtr.getType()->getPointerElementType();
-Value *V = Builder.CreateLoad(VTy, &VPtr, VPtr.getName() + ".reload");
-ReplacementValue = Builder.CreateAlloca(VTy, 0, VPtr.getName() + ".copy");
+Type *VTy = Inner.getType()->getPointerElementType();
+Value *V = Builder.CreateLoad(VTy, &Inner, Orig.getName() + ".reload");
+ReplacementValue = Builder.CreateAlloca(VTy, 0, Orig.getName() + ".copy");
 Builder.restoreIP(CodeGenIP);
 Builder.CreateStore(V, ReplacementValue);
 return CodeGenIP;
@@ -401,7 +425,7 @@
   EXPECT_EQ(ForkCI->getArgOperand(1),
 ConstantInt::get(Type::getInt32Ty(Ctx), 1U));
   EXPECT_EQ(ForkCI->getArgOperand(2), Usr);
-  EXPECT_EQ(ForkCI->getArgOperand(3), F->arg_begin());
+  EXPECT_EQ(findStoredValue(ForkCI->getArgOperand(3)), F->arg_begin());
 }
 
 TEST_F(OpenMPIRBuilderTest, ParallelNested) {
@@ -423,12 +447,13 @@
   };
 
   auto PrivCB = [&](InsertPointTy AllocaIP, InsertPointTy CodeGenIP,
-Value &VPtr, Value *&ReplacementValue) -> InsertPointTy {
+Value &Orig, Value &Inner,
+Value *&ReplacementValue) -> InsertPointTy {
 // Trivial copy (=firstprivate).
 Builder.restoreIP(AllocaIP);
-Type *VTy = VPtr.getType()->getPointerElementType();
-Value *V = Builder.CreateLoad(VTy, &VPtr, VPtr.getName() + ".reload");
-ReplacementValue = Builder.CreateAlloca(VTy, 0, VPtr.getName() + ".copy");
+Type *VTy = Inner.getType()->getPointerElementType();
+Value *V = Builder.CreateLoad(VTy, &Inner, Orig.getName() + ".reload");
+ReplacementValue = Builder.CreateAlloca(VTy, 0, Orig.getName() + ".copy");
 Builder.restoreIP(CodeGenIP);
 Builder.CreateStore(V, ReplacementValue);
 return CodeGenIP;
@@ -515,12 +540,13 @@
   };
 
   auto PrivCB = [&](InsertPointTy AllocaIP, InsertPointTy CodeGenIP,
-Value &VP

[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 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?


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] 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.

Just as a heads-up, I haven't forgotten about this. Freeing up the server just 
takes a little longer as I need to backup files through a DSL line. Should be 
ready by tomorrow.


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] D92474: [analyzer][StdLibraryFunctionsChecker] Add return value constraint to functions with BufferSize

2020-12-02 Thread Gabor Marton via Phabricator via cfe-commits
martong marked 3 inline comments as done.
martong added inline comments.



Comment at: 
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:1771
+.Case({ReturnValueCondition(LessThanOrEq, ArgNo(2)),
+   ReturnValueCondition(WithinRange, Range(-1, Ssize_tMax))})
 .ArgConstraint(NotNull(ArgNo(0)))

steakhal wrote:
> 
The two constraints are applied in the same case (branch), the second is more 
generic. The first constraint may not have any effect if Arg2 is Unknown. 
Consequently, [-1, -1] would be too strict in such cases.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92474

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


[PATCH] D91088: [CUDA][HIP] Fix capturing reference to host variable

2020-12-02 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked 3 inline comments as done.
yaxunl added inline comments.



Comment at: clang/lib/Sema/SemaExpr.cpp:1957
+// host variable in a device or host device lambda.
+static bool isCapturingReferenceToHostVarInCUDADeviceLambda(Sema &S,
+VarDecl *VD) {

tra wrote:
> `const Sema&` ?
will do when committing


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

https://reviews.llvm.org/D91088

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


[PATCH] D92474: [analyzer][StdLibraryFunctionsChecker] Add return value constraint to functions with BufferSize

2020-12-02 Thread Gabor Marton via Phabricator via cfe-commits
martong marked 2 inline comments as done.
martong added inline comments.



Comment at: 
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:2076
 Summary(NoEvalCall)
+.Case({ReturnValueCondition(WithinRange, Range(-1, 0))})
 .ArgConstraint(NotNull(ArgNo(3)))

steakhal wrote:
> BTW, this is quite frequently repeated.
> Do you think worth hoisting such a return value constraint?
> 
> I'm thinking of something like `ReturnsZeroOrMinusOne`.
Good idea!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92474

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


[PATCH] D92474: [analyzer][StdLibraryFunctionsChecker] Add return value constraint to functions with BufferSize

2020-12-02 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 308951.
martong marked an inline comment as done.
martong added a comment.

- Remove comments
- Hoist Range(-1,0) to ReturnsZeroOrMinusOne


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92474

Files:
  clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp

Index: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -457,6 +457,10 @@
   CaseConstraints.push_back(std::move(CS));
   return *this;
 }
+Summary &Case(const ConstraintSet &CS) {
+  CaseConstraints.push_back(CS);
+  return *this;
+}
 Summary &ArgConstraint(ValueConstraintPtr VC) {
   assert(VC->getArgNo() != Ret &&
  "Arg constraint should not refer to the return value");
@@ -1235,9 +1239,8 @@
   // read()-like functions that never return more than buffer size.
   auto FreadSummary =
   Summary(NoEvalCall)
-  .Case({
-  ReturnValueCondition(LessThanOrEq, ArgNo(2)),
-  })
+  .Case({ReturnValueCondition(LessThanOrEq, ArgNo(2)),
+ ReturnValueCondition(WithinRange, Range(0, SizeMax))})
   .ArgConstraint(NotNull(ArgNo(0)))
   .ArgConstraint(NotNull(ArgNo(3)))
   .ArgConstraint(BufferSize(/*Buffer=*/ArgNo(0), /*BufSize=*/ArgNo(1),
@@ -1764,6 +1767,8 @@
 Signature(ArgTypes{ConstCharPtrRestrictTy, CharPtrRestrictTy, SizeTy},
   RetType{Ssize_tTy}),
 Summary(NoEvalCall)
+.Case({ReturnValueCondition(LessThanOrEq, ArgNo(2)),
+   ReturnValueCondition(WithinRange, Range(-1, Ssize_tMax))})
 .ArgConstraint(NotNull(ArgNo(0)))
 .ArgConstraint(NotNull(ArgNo(1)))
 .ArgConstraint(BufferSize(/*Buffer=*/ArgNo(1),
@@ -1779,6 +1784,8 @@
 ArgTypes{IntTy, ConstCharPtrRestrictTy, CharPtrRestrictTy, SizeTy},
 RetType{Ssize_tTy}),
 Summary(NoEvalCall)
+.Case({ReturnValueCondition(LessThanOrEq, ArgNo(3)),
+   ReturnValueCondition(WithinRange, Range(-1, Ssize_tMax))})
 .ArgConstraint(ArgumentCondition(0, WithinRange, Range(0, IntMax)))
 .ArgConstraint(NotNull(ArgNo(1)))
 .ArgConstraint(NotNull(ArgNo(2)))
@@ -1842,6 +1849,9 @@
 Optional Socklen_tPtrRestrictTy = getRestrictTy(Socklen_tPtrTy);
 Optional Socklen_tMax = getMaxValue(Socklen_tTy);
 
+const auto ReturnsZeroOrMinusOne =
+ConstraintSet{ReturnValueCondition(WithinRange, Range(-1, 0))};
+
 // In 'socket.h' of some libc implementations with C99, sockaddr parameter
 // is a transparent union of the underlying sockaddr_ family of pointers
 // instead of being a pointer to struct sockaddr. In these cases, the
@@ -1850,6 +1860,7 @@
 // constraints which require pointer types for the sockaddr param.
 auto Accept =
 Summary(NoEvalCall)
+.Case({ReturnValueCondition(WithinRange, Range(-1, IntMax))})
 .ArgConstraint(ArgumentCondition(0, WithinRange, Range(0, IntMax)));
 if (!addToFunctionSummaryMap(
 "accept",
@@ -1872,6 +1883,7 @@
 Signature(ArgTypes{IntTy, ConstStructSockaddrPtrTy, Socklen_tTy},
   RetType{IntTy}),
 Summary(NoEvalCall)
+.Case(ReturnsZeroOrMinusOne)
 .ArgConstraint(
 ArgumentCondition(0, WithinRange, Range(0, IntMax)))
 .ArgConstraint(NotNull(ArgNo(1)))
@@ -1884,6 +1896,7 @@
   "bind",
   Signature(ArgTypes{IntTy, Irrelevant, Socklen_tTy}, RetType{IntTy}),
   Summary(NoEvalCall)
+  .Case(ReturnsZeroOrMinusOne)
   .ArgConstraint(
   ArgumentCondition(0, WithinRange, Range(0, IntMax)))
   .ArgConstraint(
@@ -1897,6 +1910,7 @@
Socklen_tPtrRestrictTy},
   RetType{IntTy}),
 Summary(NoEvalCall)
+.Case(ReturnsZeroOrMinusOne)
 .ArgConstraint(
 ArgumentCondition(0, WithinRange, Range(0, IntMax)))
 .ArgConstraint(NotNull(ArgNo(1)))
@@ -1906,6 +1920,7 @@
   Signature(ArgTypes{IntTy, Irrelevant, Socklen_tPtrRestrictTy},
 RetType{IntTy}),
   Summary(NoEvalCall)
+  .Case(ReturnsZeroOrMinusOne)
   .ArgConstraint(
   ArgumentCondition(0, WithinRange, Range(0, IntMax;
 
@@ -1917,6 +1932,7 @@
Socklen_tPtrRestrictTy},
   RetType{IntTy}),
 Summary(NoEvalCall)
+.Case(ReturnsZeroOrMinusOne)
 .ArgConstr

[PATCH] D92484: [clangd] Relations should not be accounted when computing backing storage size

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

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92484

Files:
  clang-tools-extra/clangd/index/FileIndex.cpp


Index: clang-tools-extra/clangd/index/FileIndex.cpp
===
--- clang-tools-extra/clangd/index/FileIndex.cpp
+++ clang-tools-extra/clangd/index/FileIndex.cpp
@@ -348,8 +348,6 @@
 StorageSize += Slab->bytes();
   for (const auto &RefSlab : RefSlabs)
 StorageSize += RefSlab->bytes();
-  for (const auto &RelationSlab : RelationSlabs)
-StorageSize += RelationSlab->bytes();
 
   // Index must keep the slabs and contiguous ranges alive.
   switch (Type) {


Index: clang-tools-extra/clangd/index/FileIndex.cpp
===
--- clang-tools-extra/clangd/index/FileIndex.cpp
+++ clang-tools-extra/clangd/index/FileIndex.cpp
@@ -348,8 +348,6 @@
 StorageSize += Slab->bytes();
   for (const auto &RefSlab : RefSlabs)
 StorageSize += RefSlab->bytes();
-  for (const auto &RelationSlab : RelationSlabs)
-StorageSize += RelationSlab->bytes();
 
   // Index must keep the slabs and contiguous ranges alive.
   switch (Type) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91806: [SVE] Remove warning from debug info on scalable vector.

2020-12-02 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen added a comment.

Please rename `debug-declare-no-warnings-on-scalable-vectors.ll` to something 
different, because these 'warnings' are only temporary and will be replaced by 
errors in the future. Having 'no warnings' in the name of the test name seems 
wrong from that perspective.

In D91806#2413692 , @fpetrogalli wrote:

>> This patch needs to be retitled to what this is actually doing: changing the 
>> getTypeAllocationSizeInBits and getFragmentSizeInBits to return a TypeSize 
>> instead of unsigned.
>
> Given that the only change resulting from this patch is removing the warning, 
> I think it makes sense to keep the summary of the patch as it is.

Given that the generated warnings are temporary and only a side-effect of the 
implicit conversion 'hack', and thus not a feature or design choice, I still 
think the patch needs to be retitled to better phrase what it does, i.e. change 
getTypeAllocationSizeInBits to return TypeSize instead of unsigned.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91806

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


[clang] cd95338 - [CUDA][HIP] Fix capturing reference to host variable

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

Author: Yaxun (Sam) Liu
Date: 2020-12-02T10:14:46-05:00
New Revision: cd95338ee3022bffd658e52cd3eb9419b4c218ca

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

LOG: [CUDA][HIP] Fix capturing reference to host variable

In C++ when a reference variable is captured by copy, the lambda
is supposed to make a copy of the referenced variable in the captures
and refer to the copy in the lambda. Therefore, it is valid to capture
a reference to a host global variable in a device lambda since the
device lambda will refer to the copy of the host global variable instead
of access the host global variable directly.

However, clang tries to avoid capturing of reference to a host global variable
if it determines the use of the reference variable in the lambda function is
not odr-use. Clang also tries to emit load of the reference to a global variable
as load of the global variable if it determines that the reference variable is
a compile-time constant.

For a device lambda to capture a reference variable to host global variable
and use the captured value, clang needs to be taught that in such cases the use 
of the reference
variable is odr-use and the reference variable is not compile-time constant.

This patch fixes that.

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

Added: 
clang/test/CodeGenCUDA/lambda-reference-var.cu

Modified: 
clang/lib/CodeGen/CGExpr.cpp
clang/lib/Sema/SemaExpr.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 325801c83de9..92d0cba7a733 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -1522,6 +1522,29 @@ CodeGenFunction::tryEmitAsConstant(DeclRefExpr *refExpr) 
{
   if (result.HasSideEffects)
 return ConstantEmission();
 
+  // In CUDA/HIP device compilation, a lambda may capture a reference variable
+  // referencing a global host variable by copy. In this case the lambda should
+  // make a copy of the value of the global host variable. The DRE of the
+  // captured reference variable cannot be emitted as load from the host
+  // 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 &&
+  refExpr->refersToEnclosingVariableOrCapture()) {
+auto *MD = dyn_cast_or_null(CurCodeDecl);
+if (MD && MD->getParent()->isLambda() &&
+MD->getOverloadedOperator() == OO_Call) {
+  const APValue::LValueBase &base = result.Val.getLValueBase();
+  if (const ValueDecl *D = base.dyn_cast()) {
+if (const VarDecl *VD = dyn_cast(D)) {
+  if (!VD->hasAttr()) {
+return ConstantEmission();
+  }
+}
+  }
+}
+  }
+
   // Emit as a constant.
   auto C = ConstantEmitter(*this).emitAbstract(refExpr->getLocation(),
result.Val, resultType);

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 88dab26f2e3b..9c2fc1b9e6dd 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -1934,6 +1934,35 @@ Sema::BuildDeclRefExpr(ValueDecl *D, QualType Ty, 
ExprValueKind VK,
   TemplateArgs);
 }
 
+// CUDA/HIP: Check whether a captured reference variable is referencing a
+// host variable in a device or host device lambda.
+static bool isCapturingReferenceToHostVarInCUDADeviceLambda(const Sema &S,
+VarDecl *VD) {
+  if (!S.getLangOpts().CUDA || !VD->hasInit())
+return false;
+  assert(VD->getType()->isReferenceType());
+
+  // Check whether the reference variable is referencing a host variable.
+  auto *DRE = dyn_cast(VD->getInit());
+  if (!DRE)
+return false;
+  auto *Referee = dyn_cast(DRE->getDecl());
+  if (!Referee || !Referee->hasGlobalStorage() ||
+  Referee->hasAttr())
+return false;
+
+  // Check whether the current function is a device or host device lambda.
+  // Check whether the reference variable is a capture by getDeclContext()
+  // since refersToEnclosingVariableOrCapture() is not ready at this point.
+  auto *MD = dyn_cast_or_null(S.CurContext);
+  if (MD && MD->getParent()->isLambda() &&
+  MD->getOverloadedOperator() == OO_Call && MD->hasAttr() 
&&
+  VD->getDeclContext() != MD)
+return true;
+
+  return false;
+}
+
 NonOdrUseReason Sema::getNonOdrUseReasonInCurrentContext(ValueDecl *D) {
   // A declaration named in an unevaluated operand never constitutes an 
odr-use.
   if (isUnevaluatedContext())
@@ -1943,9 +1972,16 @@ NonOdrUseReason 
Sema::getNonOdrUseReasonInCurrentContext(ValueDecl *D) {
   //   A variable x whose name appears as a potentiall

[PATCH] D91088: [CUDA][HIP] Fix capturing reference to host variable

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 rGcd95338ee302: [CUDA][HIP] Fix capturing reference to host 
variable (authored by yaxunl).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D91088?vs=308519&id=308961#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91088

Files:
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGenCUDA/lambda-reference-var.cu

Index: clang/test/CodeGenCUDA/lambda-reference-var.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/lambda-reference-var.cu
@@ -0,0 +1,126 @@
+// RUN: %clang_cc1 -x hip -emit-llvm -std=c++11 %s -o - \
+// RUN:   -triple x86_64-linux-gnu \
+// RUN:   | FileCheck -check-prefix=HOST %s
+// RUN: %clang_cc1 -x hip -emit-llvm -std=c++11 %s -o - \
+// RUN:   -triple amdgcn-amd-amdhsa -fcuda-is-device \
+// RUN:   | FileCheck -check-prefix=DEV %s
+
+#include "Inputs/cuda.h"
+
+// HOST: %[[T1:.*]] = type <{ i32*, i32, [4 x i8] }>
+// HOST: %[[T2:.*]] = type { i32*, i32** }
+// HOST: %[[T3:.*]] = type <{ i32*, i32, [4 x i8] }>
+// DEV: %[[T1:.*]] = type { i32* }
+// DEV: %[[T2:.*]] = type { i32** }
+// DEV: %[[T3:.*]] = type <{ i32*, i32, [4 x i8] }>
+int global_host_var;
+__device__ int global_device_var;
+
+template
+__global__ void kern(F f) { f(); }
+
+// DEV-LABEL: @_ZZ27dev_capture_dev_ref_by_copyPiENKUlvE_clEv(
+// DEV: %[[VAL:.*]] = load i32, i32* addrspacecast (i32 addrspace(1)* @global_device_var to i32*)
+// DEV: store i32 %[[VAL]]
+__device__ void dev_capture_dev_ref_by_copy(int *out) {
+  int &ref = global_device_var;
+  [=](){ *out = ref;}();
+}
+
+// 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
+// DEV: store i32 %[[VAL2]], i32* addrspacecast (i32 addrspace(1)* @global_device_var to i32*)
+// DEV: %[[VAL:.*]] = load i32, i32* addrspacecast (i32 addrspace(1)* @global_device_var to i32*)
+// DEV: store i32 %[[VAL]]
+__device__ void dev_capture_dev_ref_by_ref(int *out) {
+  int &ref = global_device_var;
+  [&](){ ref++; *out = ref;}();
+}
+
+// DEV-LABEL: define void @_Z7dev_refPi(
+// DEV: %[[VAL:.*]] = load i32, i32* addrspacecast (i32 addrspace(1)* @global_device_var to i32*)
+// DEV: %[[VAL2:.*]] = add nsw i32 %[[VAL]], 1
+// DEV: store i32 %[[VAL2]], i32* addrspacecast (i32 addrspace(1)* @global_device_var to i32*)
+// DEV: %[[VAL:.*]] = load i32, i32* addrspacecast (i32 addrspace(1)* @global_device_var to i32*)
+// DEV: store i32 %[[VAL]]
+__device__ void dev_ref(int *out) {
+  int &ref = global_device_var;
+  ref++;
+  *out = ref;
+}
+
+// DEV-LABEL: @_ZZ14dev_lambda_refPiENKUlvE_clEv(
+// DEV: %[[VAL:.*]] = load i32, i32* addrspacecast (i32 addrspace(1)* @global_device_var to i32*)
+// DEV: %[[VAL2:.*]] = add nsw i32 %[[VAL]], 1
+// DEV: store i32 %[[VAL2]], i32* addrspacecast (i32 addrspace(1)* @global_device_var to i32*)
+// DEV: %[[VAL:.*]] = load i32, i32* addrspacecast (i32 addrspace(1)* @global_device_var to i32*)
+// DEV: store i32 %[[VAL]]
+__device__ void dev_lambda_ref(int *out) {
+  [=](){
+int &ref = global_device_var;
+ref++;
+*out = ref;
+  }();
+}
+
+// HOST-LABEL: @_ZZ29host_capture_host_ref_by_copyPiENKUlvE_clEv(
+// HOST: %[[VAL:.*]] = load i32, i32* @global_host_var
+// HOST: store i32 %[[VAL]]
+void host_capture_host_ref_by_copy(int *out) {
+  int &ref = global_host_var;
+  [=](){ *out = ref;}();
+}
+
+// HOST-LABEL: @_ZZ28host_capture_host_ref_by_refPiENKUlvE_clEv(
+// HOST: %[[CAP:.*]] = getelementptr inbounds %[[T2]], %[[T2]]* %this1, i32 0, i32 0
+// HOST: %[[REF:.*]] = load i32*, i32** %[[CAP]]
+// HOST: %[[VAL:.*]] = load i32, i32* %[[REF]]
+// HOST: %[[VAL2:.*]] = add nsw i32 %[[VAL]], 1
+// HOST: store i32 %[[VAL2]], i32* %[[REF]]
+// HOST: %[[VAL:.*]] = load i32, i32* @global_host_var
+// HOST: store i32 %[[VAL]]
+void host_capture_host_ref_by_ref(int *out) {
+  int &ref = global_host_var;
+  [&](){ ref++; *out = ref;}();
+}
+
+// HOST-LABEL: define void @_Z8host_refPi(
+// HOST: %[[VAL:.*]] = load i32, i32* @global_host_var
+// HOST: %[[VAL2:.*]] = add nsw i32 %[[VAL]], 1
+// HOST: store i32 %[[VAL2]], i32* @global_host_var
+// HOST: %[[VAL:.*]] = load i32, i32* @global_host_var
+// HOST: store i32 %[[VAL]]
+void host_ref(int *out) {
+  int &ref = global_host_var;
+  ref++;
+  *out = ref;
+}
+
+// HOST-LABEL: @_ZZ15host_lambda_refPiENKUlvE_clEv(
+// HOST: %[[VAL:.*]] = load i32, i32* @global_host_var
+// HOST: %[[VAL2:.*]] = add nsw i32 %[[VAL]], 1
+// HOST: store i32 %[[VAL2]], i32* @global_host_var
+// HOST: %[[VAL:.*]] = load i32, i32* @global_host_var
+// HOST: store i32 %[[VAL]]
+void host_lambda_ref(int *out) {
+  [=](){
+int &ref = global_h

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

2020-12-02 Thread Tom Rix via Phabricator via cfe-commits
trixirt updated this revision to Diff 308963.
trixirt added a comment.

address precheckin issues


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91789

Files:
  clang-tools-extra/clang-tidy/linuxkernel/CMakeLists.txt
  clang-tools-extra/clang-tidy/linuxkernel/ExtraSemiCheck.cpp
  clang-tools-extra/clang-tidy/linuxkernel/ExtraSemiCheck.h
  clang-tools-extra/clang-tidy/linuxkernel/LinuxKernelTidyModule.cpp
  clang-tools-extra/test/clang-tidy/checkers/linuxkernel-macro-trailing-semi.c
  clang-tools-extra/test/clang-tidy/checkers/linuxkernel-switch-semi.c

Index: clang-tools-extra/test/clang-tidy/checkers/linuxkernel-switch-semi.c
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/linuxkernel-switch-semi.c
@@ -0,0 +1,41 @@
+// RUN: %check_clang_tidy %s linuxkernel-extra-semi %t -- \
+// RUN:   -config="{CheckOptions: \
+// RUN: [{key: linuxkernel-extra-semi.Fixer, \
+// RUN:   value: 'Switch'}, \
+// RUN: ]}"
+
+int f(int a) {
+  switch (a) {
+  case 1:
+return 0;
+  default:
+break;
+  };
+  // CHECK-MESSAGES: :[[@LINE-1]]:4: warning: unneeded semicolon
+  // CHECK-FIXES:   }{{$}}
+  return 0;
+}
+
+// A normal switch, should not produce a warning
+int p1(int a) {
+  switch (a) {
+  case 1:
+return 0;
+  default:
+break;
+  }
+  return 0;
+}
+
+#define EMPTY_MACRO()
+// A corner case, do not fix an empty macro
+int p2(int a) {
+  switch (a) {
+  case 1:
+return 0;
+  default:
+break;
+  }
+  EMPTY_MACRO();
+  return 0;
+}
Index: clang-tools-extra/test/clang-tidy/checkers/linuxkernel-macro-trailing-semi.c
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/linuxkernel-macro-trailing-semi.c
@@ -0,0 +1,32 @@
+// RUN: %check_clang_tidy %s linuxkernel-extra-semi %t -- \
+// RUN:   -config="{CheckOptions: \
+// RUN: [{key: linuxkernel-extra-semi.Fixer, \
+// RUN:   value: 'TrailingMacro'}, \
+// RUN: ]}"
+
+#define M(a) a++;
+// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: unneeded semicolon
+// CHECK-FIXES: #define M(a) a++{{$}}
+
+int f() {
+  int v = 0;
+  M(v);
+  return v;
+}
+
+// A corner case
+// An empty macro could conditionally contain another path so
+// do not warn or fix.
+#ifdef UNSET_CONDITION
+#define E() ;
+#else
+#define E()
+#endif
+#define N(a) a++;
+
+int g() {
+  int v = 0;
+  N(v)
+  E();
+  return v;
+}
Index: clang-tools-extra/clang-tidy/linuxkernel/LinuxKernelTidyModule.cpp
===
--- clang-tools-extra/clang-tidy/linuxkernel/LinuxKernelTidyModule.cpp
+++ clang-tools-extra/clang-tidy/linuxkernel/LinuxKernelTidyModule.cpp
@@ -9,6 +9,7 @@
 #include "../ClangTidy.h"
 #include "../ClangTidyModule.h"
 #include "../ClangTidyModuleRegistry.h"
+#include "ExtraSemiCheck.h"
 #include "MustCheckErrsCheck.h"
 
 namespace clang {
@@ -19,6 +20,7 @@
 class LinuxKernelModule : public ClangTidyModule {
 public:
   void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
+CheckFactories.registerCheck("linuxkernel-extra-semi");
 CheckFactories.registerCheck(
 "linuxkernel-must-check-errs");
   }
Index: clang-tools-extra/clang-tidy/linuxkernel/ExtraSemiCheck.h
===
--- /dev/null
+++ clang-tools-extra/clang-tidy/linuxkernel/ExtraSemiCheck.h
@@ -0,0 +1,43 @@
+//===--- ExtraSemiCheck.h - clang-tidy --*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_LINUXKERNEL_EXTRASEMICHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_LINUXKERNEL_EXTRASEMICHECK_H
+
+#include "../ClangTidyCheck.h"
+#include "clang/Lex/MacroInfo.h"
+#include 
+
+namespace clang {
+namespace tidy {
+namespace linuxkernel {
+
+enum ExtraSemiFixerKind { ESFK_None, ESFK_Switch, ESFK_TrailingMacro };
+class ExtraSemiCheck : public ClangTidyCheck {
+public:
+  ExtraSemiCheck(StringRef Name, ClangTidyContext *Context);
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
+   Preprocessor *ModuleExpanderPP) override final;
+
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+  void checkMacro(SourceManager &SM, const Token &MacroNameTok,
+  const MacroInfo *MI);
+  void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
+
+private:
+  std::vector SuspectMacros;
+  enum ExtraSemiFixerKind FixerKind;
+  const std::string ExtraSemiFixerKi

[PATCH] D91806: [SVE] Remove warning from debug info on scalable vector.

2020-12-02 Thread Joe Ellis via Phabricator via cfe-commits
joechrisellis updated this revision to Diff 308964.
joechrisellis added a comment.

Address @sdesmalen's comments.

- Update commit message to better reflect the changes in this patch.
- Rename `debug-declare-no-warnings-on-scalable-vectors.ll` to 
`dbg-info-scalable-typesize-warning.ll`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91806

Files:
  llvm/lib/Transforms/Utils/Debugify.cpp
  llvm/lib/Transforms/Utils/Local.cpp
  llvm/test/Transforms/InstCombine/dbg-info-scalable-typesize-warning.ll

Index: llvm/test/Transforms/InstCombine/dbg-info-scalable-typesize-warning.ll
===
--- /dev/null
+++ llvm/test/Transforms/InstCombine/dbg-info-scalable-typesize-warning.ll
@@ -0,0 +1,36 @@
+; RUN: opt -mtriple aarch64-gnu-linux -mattr=+sve -instcombine -S < %s 2>%t | FileCheck %s
+; RUN: FileCheck --check-prefix=WARN --allow-empty %s <%t
+
+; This test is defending against a TypeSize warning raised in the method
+; `valueCoversEntireFragment` in Local.cpp because of an implicit cast from
+; `TypeSize` to `uint64_t`. This particular TypeSize warning only occurred when
+; debug info was available.
+
+; If this check fails please read
+; clang/test/CodeGen/aarch64-sve-intrinsics/README for instructions on
+; how to resolve it.
+
+; WARN-NOT: warning: {{.*}}TypeSize is not scalable
+
+; CHECK-LABEL: @debug_local_scalable(
+define  @debug_local_scalable( %tostore) {
+  %vx = alloca , align 16
+  call void @llvm.dbg.declare(metadata * %vx, metadata !3, metadata !DIExpression()), !dbg !5
+  store  %tostore, * %vx, align 16
+  %ret = call  @f(* %vx)
+  ret  %ret
+}
+
+declare  @f(*)
+
+; Function Attrs: nofree nosync nounwind readnone speculatable willreturn
+declare void @llvm.dbg.declare(metadata, metadata, metadata)
+
+!llvm.module.flags = !{!2}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1)
+!1 = !DIFile(filename: "/tmp/test.c", directory: "/tmp/")
+!2 = !{i32 2, !"Debug Info Version", i32 3}
+!3 = !DILocalVariable(scope: !4)
+!4 = distinct !DISubprogram(unit: !0)
+!5 = !DILocation(scope: !4)
Index: llvm/lib/Transforms/Utils/Local.cpp
===
--- llvm/lib/Transforms/Utils/Local.cpp
+++ llvm/lib/Transforms/Utils/Local.cpp
@@ -1368,16 +1368,22 @@
 /// least n bits.
 static bool valueCoversEntireFragment(Type *ValTy, DbgVariableIntrinsic *DII) {
   const DataLayout &DL = DII->getModule()->getDataLayout();
-  uint64_t ValueSize = DL.getTypeAllocSizeInBits(ValTy);
-  if (auto FragmentSize = DII->getFragmentSizeInBits())
-return ValueSize >= *FragmentSize;
+  TypeSize ValueSize = DL.getTypeAllocSizeInBits(ValTy);
+  if (Optional FragmentSize = DII->getFragmentSizeInBits()) {
+assert(!ValueSize.isScalable() &&
+   "Fragments don't work on scalable types.");
+return ValueSize.getFixedSize() >= *FragmentSize;
+  }
   // We can't always calculate the size of the DI variable (e.g. if it is a
   // VLA). Try to use the size of the alloca that the dbg intrinsic describes
   // intead.
   if (DII->isAddressOfVariable())
 if (auto *AI = dyn_cast_or_null(DII->getVariableLocation()))
-  if (auto FragmentSize = AI->getAllocationSizeInBits(DL))
-return ValueSize >= *FragmentSize;
+  if (Optional FragmentSize = AI->getAllocationSizeInBits(DL)) {
+assert(ValueSize.isScalable() == FragmentSize->isScalable() &&
+   "Both sizes should agree on the scalable flag.");
+return TypeSize::isKnownGE(ValueSize, *FragmentSize);
+  }
   // Could not determine size of variable. Conservatively return false.
   return false;
 }
Index: llvm/lib/Transforms/Utils/Debugify.cpp
===
--- llvm/lib/Transforms/Utils/Debugify.cpp
+++ llvm/lib/Transforms/Utils/Debugify.cpp
@@ -44,8 +44,9 @@
 
 raw_ostream &dbg() { return Quiet ? nulls() : errs(); }
 
-uint64_t getAllocSizeInBits(Module &M, Type *Ty) {
-  return Ty->isSized() ? M.getDataLayout().getTypeAllocSizeInBits(Ty) : 0;
+TypeSize getAllocSizeInBits(Module &M, Type *Ty) {
+  return Ty->isSized() ? M.getDataLayout().getTypeAllocSizeInBits(Ty)
+   : TypeSize::getFixed(0);
 }
 
 bool isFunctionSkipped(Function &F) {
@@ -276,7 +277,7 @@
 return false;
 
   Type *Ty = V->getType();
-  uint64_t ValueOperandSize = getAllocSizeInBits(M, Ty);
+  TypeSize ValueOperandSize = getAllocSizeInBits(M, Ty);
   Optional DbgVarSize = DVI->getFragmentSizeInBits();
   if (!ValueOperandSize || !DbgVarSize)
 return false;
@@ -285,7 +286,7 @@
   if (Ty->isIntegerTy()) {
 auto Signedness = DVI->getVariable()->getSignedness();
 if (Signedness && *Signedness == DIBasicType::Signedness::Signed)
-  HasBadSize = ValueOperandSize < *DbgVarSize;
+  HasBadSize = ValueOperandSize.getFixedSize() < *DbgVarSize;
   } else {
 HasBadSize = Valu

[clang] 5c8911d - [CUDA][HIP] Diagnose reference of host variable

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

Author: Yaxun (Sam) Liu
Date: 2020-12-02T10:15:56-05:00
New Revision: 5c8911d0ba3862119d2507aa55b94766263be13b

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

LOG: [CUDA][HIP] Diagnose reference of host variable

This patch diagnoses invalid references of global host variables in device,
global, or host device functions.

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

Added: 
clang/test/SemaCUDA/device-use-host-var.cu

Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaCUDA.cpp
clang/lib/Sema/SemaExpr.cpp
clang/test/CodeGenCUDA/function-overload.cu
clang/test/CodeGenCXX/builtin-amdgcn-atomic-inc-dec.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index f2b2b1d3ab6f..3067c077ddb2 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -8145,7 +8145,7 @@ def err_global_call_not_config : Error<
   "call to global function %0 not configured">;
 def err_ref_bad_target : Error<
   "reference to %select{__device__|__global__|__host__|__host__ __device__}0 "
-  "function %1 in %select{__device__|__global__|__host__|__host__ __device__}2 
function">;
+  "%select{function|variable}1 %2 in 
%select{__device__|__global__|__host__|__host__ __device__}3 function">;
 def err_ref_bad_target_global_initializer : Error<
   "reference to %select{__device__|__global__|__host__|__host__ __device__}0 "
   "function %1 in global initializer">;

diff  --git a/clang/lib/Sema/SemaCUDA.cpp b/clang/lib/Sema/SemaCUDA.cpp
index 12a28ab392f8..0f06adf38f7a 100644
--- a/clang/lib/Sema/SemaCUDA.cpp
+++ b/clang/lib/Sema/SemaCUDA.cpp
@@ -743,7 +743,8 @@ bool Sema::CheckCUDACall(SourceLocation Loc, FunctionDecl 
*Callee) {
 return true;
 
   SemaDiagnosticBuilder(DiagKind, Loc, diag::err_ref_bad_target, Caller, *this)
-  << IdentifyCUDATarget(Callee) << Callee << IdentifyCUDATarget(Caller);
+  << IdentifyCUDATarget(Callee) << /*function*/ 0 << Callee
+  << IdentifyCUDATarget(Caller);
   if (!Callee->getBuiltinID())
 SemaDiagnosticBuilder(DiagKind, Callee->getLocation(),
   diag::note_previous_decl, Caller, *this)

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 9c2fc1b9e6dd..527605ac4fb8 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -354,6 +354,24 @@ bool Sema::DiagnoseUseOfDecl(NamedDecl *D, 
ArrayRef Locs,
 
   diagnoseUseOfInternalDeclInInlineFunction(*this, D, Loc);
 
+  // CUDA/HIP: Diagnose invalid references of host global variables in device
+  // functions. Reference of device global variables in host functions is
+  // allowed through shadow variables therefore it is not diagnosed.
+  if (LangOpts.CUDAIsDevice) {
+auto *FD = dyn_cast_or_null(CurContext);
+auto Target = IdentifyCUDATarget(FD);
+if (FD && Target != CFT_Host) {
+  const auto *VD = dyn_cast(D);
+  if (VD && VD->hasGlobalStorage() && !VD->hasAttr() &&
+  !VD->hasAttr() && !VD->hasAttr() &&
+  !VD->getType()->isCUDADeviceBuiltinSurfaceType() &&
+  !VD->getType()->isCUDADeviceBuiltinTextureType() &&
+  !VD->isConstexpr() && !VD->getType().isConstQualified())
+targetDiag(*Locs.begin(), diag::err_ref_bad_target)
+<< /*host*/ 2 << /*variable*/ 1 << VD << Target;
+}
+  }
+
   if (LangOpts.SYCLIsDevice || (LangOpts.OpenMP && LangOpts.OpenMPIsDevice)) {
 if (const auto *VD = dyn_cast(D))
   checkDeviceDecl(VD, Loc);

diff  --git a/clang/test/CodeGenCUDA/function-overload.cu 
b/clang/test/CodeGenCUDA/function-overload.cu
index c82b2e96f6c3..9677a5b43b8c 100644
--- a/clang/test/CodeGenCUDA/function-overload.cu
+++ b/clang/test/CodeGenCUDA/function-overload.cu
@@ -12,6 +12,9 @@
 #include "Inputs/cuda.h"
 
 // Check constructors/destructors for D/H functions
+#ifdef __CUDA_ARCH__
+__device__
+#endif
 int x;
 struct s_cd_dh {
   __host__ s_cd_dh() { x = 11; }

diff  --git a/clang/test/CodeGenCXX/builtin-amdgcn-atomic-inc-dec.cpp 
b/clang/test/CodeGenCXX/builtin-amdgcn-atomic-inc-dec.cpp
index 77ea3d485c8a..16600d15f2c4 100644
--- a/clang/test/CodeGenCXX/builtin-amdgcn-atomic-inc-dec.cpp
+++ b/clang/test/CodeGenCXX/builtin-amdgcn-atomic-inc-dec.cpp
@@ -124,7 +124,7 @@ __attribute__((device)) void test_shared64() {
   val = __builtin_amdgcn_atomic_dec64(&val, val, __ATOMIC_SEQ_CST, 
"workgroup");
 }
 
-__UINT32_TYPE__ global_val32;
+__attribute__((device)) __UINT32_TYPE__ global_val32;
 __attribute__((device)) void test_global32() {
   // CHECK-LABEL: test_global32
   // CHECK: %0 = load i32, i32* addrspacecast (i32 addrspace(1)* @global_val32 
to i32*), align 4
@@ -138

[PATCH] D91281: [CUDA][HIP] Diagnose reference of host variable

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 rG5c8911d0ba38: [CUDA][HIP] Diagnose reference of host 
variable (authored by yaxunl).
Herald added a subscriber: jvesely.
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D91281?vs=304569&id=308965#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91281

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaCUDA.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGenCUDA/function-overload.cu
  clang/test/CodeGenCXX/builtin-amdgcn-atomic-inc-dec.cpp
  clang/test/SemaCUDA/device-use-host-var.cu

Index: clang/test/SemaCUDA/device-use-host-var.cu
===
--- /dev/null
+++ clang/test/SemaCUDA/device-use-host-var.cu
@@ -0,0 +1,160 @@
+// RUN: %clang_cc1 -std=c++11 -fcuda-is-device -fsyntax-only -verify=dev %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify=host %s
+
+// host-no-diagnostics
+
+#include "Inputs/cuda.h"
+
+int global_host_var;
+__device__ int global_dev_var;
+__constant__ int global_constant_var;
+__shared__ int global_shared_var;
+constexpr int global_constexpr_var = 1;
+const int global_const_var = 1;
+
+template
+__global__ void kernel(F f) { f(); } // dev-note2 {{called by 'kernel<(lambda}}
+
+__device__ void dev_fun(int *out) {
+  int &ref_host_var = global_host_var; // dev-error {{reference to __host__ variable 'global_host_var' in __device__ function}}
+  int &ref_dev_var = global_dev_var;
+  int &ref_constant_var = global_constant_var;
+  int &ref_shared_var = global_shared_var;
+  const int &ref_constexpr_var = global_constexpr_var;
+  const int &ref_const_var = global_const_var;
+
+  *out = global_host_var; // dev-error {{reference to __host__ variable 'global_host_var' in __device__ function}}
+  *out = global_dev_var;
+  *out = global_constant_var;
+  *out = global_shared_var;
+  *out = global_constexpr_var;
+  *out = global_const_var;
+
+  *out = ref_host_var;
+  *out = ref_dev_var;
+  *out = ref_constant_var;
+  *out = ref_shared_var;
+  *out = ref_constexpr_var;
+  *out = ref_const_var;
+}
+
+__global__ void global_fun(int *out) {
+  int &ref_host_var = global_host_var; // dev-error {{reference to __host__ variable 'global_host_var' in __global__ function}}
+  int &ref_dev_var = global_dev_var;
+  int &ref_constant_var = global_constant_var;
+  int &ref_shared_var = global_shared_var;
+  const int &ref_constexpr_var = global_constexpr_var;
+  const int &ref_const_var = global_const_var;
+
+  *out = global_host_var; // dev-error {{reference to __host__ variable 'global_host_var' in __global__ function}}
+  *out = global_dev_var;
+  *out = global_constant_var;
+  *out = global_shared_var;
+  *out = global_constexpr_var;
+  *out = global_const_var;
+
+  *out = ref_host_var;
+  *out = ref_dev_var;
+  *out = ref_constant_var;
+  *out = ref_shared_var;
+  *out = ref_constexpr_var;
+  *out = ref_const_var;
+}
+
+__host__ __device__ void host_dev_fun(int *out) {
+  int &ref_host_var = global_host_var; // dev-error {{reference to __host__ variable 'global_host_var' in __host__ __device__ function}}
+  int &ref_dev_var = global_dev_var;
+  int &ref_constant_var = global_constant_var;
+  int &ref_shared_var = global_shared_var;
+  const int &ref_constexpr_var = global_constexpr_var;
+  const int &ref_const_var = global_const_var;
+
+  *out = global_host_var; // dev-error {{reference to __host__ variable 'global_host_var' in __host__ __device__ function}}
+  *out = global_dev_var;
+  *out = global_constant_var;
+  *out = global_shared_var;
+  *out = global_constexpr_var;
+  *out = global_const_var;
+
+  *out = ref_host_var;
+  *out = ref_dev_var;
+  *out = ref_constant_var;
+  *out = ref_shared_var;
+  *out = ref_constexpr_var;
+  *out = ref_const_var;
+}
+
+inline __host__ __device__ void inline_host_dev_fun(int *out) {
+  int &ref_host_var = global_host_var;
+  int &ref_dev_var = global_dev_var;
+  int &ref_constant_var = global_constant_var;
+  int &ref_shared_var = global_shared_var;
+  const int &ref_constexpr_var = global_constexpr_var;
+  const int &ref_const_var = global_const_var;
+
+  *out = global_host_var;
+  *out = global_dev_var;
+  *out = global_constant_var;
+  *out = global_shared_var;
+  *out = global_constexpr_var;
+  *out = global_const_var;
+
+  *out = ref_host_var;
+  *out = ref_dev_var;
+  *out = ref_constant_var;
+  *out = ref_shared_var;
+  *out = ref_constexpr_var;
+  *out = ref_const_var;
+}
+
+void dev_lambda_capture_by_ref(int *out) {
+  int &ref_host_var = global_host_var;
+  kernel<<<1,1>>>([&]() {
+  int &ref_dev_var = global_dev_var;
+  int &ref_constant_var = global_constant_var;
+  int &ref_shared_var = global_shared_var;
+  const int &ref_constexpr_var = global_constexpr_var;
+  const int &ref_const_var = global_const_var;

[clang] d8949a8 - [hip] Fix host object creation from fatbin

2020-12-02 Thread Michael Liao via cfe-commits

Author: Michael Liao
Date: 2020-12-02T10:36:01-05:00
New Revision: d8949a8ad3ca2a39ffe69df76e2c3f5fd73efec0

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

LOG: [hip] Fix host object creation from fatbin

- `__hip_fatbin` should a symbol in `.hip_fatbin` section.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/HIP.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/HIP.cpp 
b/clang/lib/Driver/ToolChains/HIP.cpp
index a06835eee024..fc1103b48a99 100644
--- a/clang/lib/Driver/ToolChains/HIP.cpp
+++ b/clang/lib/Driver/ToolChains/HIP.cpp
@@ -178,8 +178,7 @@ void 
AMDGCN::Linker::constructGenerateObjFileFromHIPFatBinary(
   ObjStream << "#   HIP Object Generator\n";
   ObjStream << "# *** Automatically generated by Clang ***\n";
   ObjStream << "  .type __hip_fatbin,@object\n";
-  ObjStream << "  .section .hip_fatbin,\"aMS\",@progbits,1\n";
-  ObjStream << "  .data\n";
+  ObjStream << "  .section .hip_fatbin,\"a\",@progbits\n";
   ObjStream << "  .globl __hip_fatbin\n";
   ObjStream << "  .p2align " << llvm::Log2(llvm::Align(HIPCodeObjectAlign))
 << "\n";



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


[PATCH] D92418: [hip] Fix host object creation from fatbin

2020-12-02 Thread Michael Liao via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd8949a8ad3ca: [hip] Fix host object creation from fatbin 
(authored by hliao).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92418

Files:
  clang/lib/Driver/ToolChains/HIP.cpp


Index: clang/lib/Driver/ToolChains/HIP.cpp
===
--- clang/lib/Driver/ToolChains/HIP.cpp
+++ clang/lib/Driver/ToolChains/HIP.cpp
@@ -178,8 +178,7 @@
   ObjStream << "#   HIP Object Generator\n";
   ObjStream << "# *** Automatically generated by Clang ***\n";
   ObjStream << "  .type __hip_fatbin,@object\n";
-  ObjStream << "  .section .hip_fatbin,\"aMS\",@progbits,1\n";
-  ObjStream << "  .data\n";
+  ObjStream << "  .section .hip_fatbin,\"a\",@progbits\n";
   ObjStream << "  .globl __hip_fatbin\n";
   ObjStream << "  .p2align " << llvm::Log2(llvm::Align(HIPCodeObjectAlign))
 << "\n";


Index: clang/lib/Driver/ToolChains/HIP.cpp
===
--- clang/lib/Driver/ToolChains/HIP.cpp
+++ clang/lib/Driver/ToolChains/HIP.cpp
@@ -178,8 +178,7 @@
   ObjStream << "#   HIP Object Generator\n";
   ObjStream << "# *** Automatically generated by Clang ***\n";
   ObjStream << "  .type __hip_fatbin,@object\n";
-  ObjStream << "  .section .hip_fatbin,\"aMS\",@progbits,1\n";
-  ObjStream << "  .data\n";
+  ObjStream << "  .section .hip_fatbin,\"a\",@progbits\n";
   ObjStream << "  .globl __hip_fatbin\n";
   ObjStream << "  .p2align " << llvm::Log2(llvm::Align(HIPCodeObjectAlign))
 << "\n";
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92474: [analyzer][StdLibraryFunctionsChecker] Add return value constraint to functions with BufferSize

2020-12-02 Thread Balázs Benics via Phabricator via cfe-commits
steakhal accepted this revision.
steakhal added a comment.
This revision is now accepted and ready to land.

Awesome, thank you.




Comment at: 
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:1771
+.Case({ReturnValueCondition(LessThanOrEq, ArgNo(2)),
+   ReturnValueCondition(WithinRange, Range(-1, Ssize_tMax))})
 .ArgConstraint(NotNull(ArgNo(0)))

martong wrote:
> steakhal wrote:
> > 
> The two constraints are applied in the same case (branch), the second is more 
> generic. The first constraint may not have any effect if Arg2 is Unknown. 
> Consequently, [-1, -1] would be too strict in such cases.
I overlooked that we have a single `Case`, my bad.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92474

___
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.

I stumbled over one problem with my patch which is that when I run an x32 
version of clang in a x32 environment, it will still default to "-m64" instead 
of "-mx32".

Thus:

  glaubitz@epyc:..llvm-project/build> ./bin/clang hello.c -o hello
  /usr/bin/ld: cannot find crtbegin.o: No such file or directory
  /usr/bin/ld: cannot find -lgcc
  /usr/bin/ld: cannot find -lgcc_s
  clang-12: error: linker command failed with exit code 1 (use -v to see 
invocation)
  glaubitz@epyc:..llvm-project/build> ./bin/clang -mx32 hello.c -o hello
  glaubitz@epyc:..llvm-project/build> file hello
  hello: ELF 32-bit LSB executable, x86-64, version 1 (SYSV), dynamically 
linked, interpreter /libx32/ld-linux-x32.so.2, for GNU/Linux 3.4.0, not stripped
  glaubitz@epyc:..llvm-project/build> file bin/clang-12
  bin/clang-12: ELF 32-bit LSB executable, x86-64, version 1 (GNU/Linux), 
dynamically linked, interpreter /libx32/ld-linux-x32.so.2, 
BuildID[sha1]=6175851930c1e79df16060c731ecda2f596ef05a, for GNU/Linux 3.4.0, 
not stripped
  glaubitz@epyc:..llvm-project/build>

Any idea how it could make clang default to `-mx32` if this condition is met: 
`getToolChain().getTriple().getEnvironment() == llvm::Triple::GNUX32`?


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] D92445: [PowerPC] Add powerpcle target.

2020-12-02 Thread Sean Fertile via Phabricator via cfe-commits
sfertile added a comment.

> 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?


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] 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 created this revision.
Herald added subscribers: cfe-commits, psnobl, kristof.beyls, tschuett.
Herald added a reviewer: efriedma.
Herald added a project: clang.
peterwaller-arm requested review of this revision.

... and give more guidance to users.

If specifying -msve-vector-bits on a non-SVE target, clang would say:

  error: '-msve-vector-bits' is not supported without SVE enabled

1. The driver lacks logic for "implied features". This would result in this 
error being raised for -march=...+sve2, even though +sve2 implies +sve.

2. Feature implication is well modelled in LLVM, so push the error down the 
stack.

3. Hint to the user what flag they need to consider setting.

Now clang fails later, when the feature is used, saying:

  aarch64-sve-vector-bits.c:42:41: error: 'arm_sve_vector_bits' attribute is 
not supported on targets missing 'sve' feature flag; specify an appropriate 
-march= or -mcpu=
  typedef svint32_t noflag __attribute__((arm_sve_vector_bits(256)));

Move clang/test/Sema/{neon => arm}-vector-types-support.c and put tests for
this warning together in one place.


Repository:
  rG LLVM Github Monorepo

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' feature flag; 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' feature flag; 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' feature flag; 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)
+<

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

2020-12-02 Thread Tom Stellard via Phabricator via cfe-commits
tstellar added a comment.

Could you add some more information to the commit message to better describe 
the powerpcle target.  It's not clear from the target name exactly what it is 
for.


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] 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#2428560 , @glaubitz wrote:

> Any idea how it could make clang default to `-mx32` if this condition is met: 
> `getToolChain().getTriple().getEnvironment() == llvm::Triple::GNUX32`?

That sounds like it's one thing in 
https://lists.llvm.org/pipermail/llvm-dev/2020-October/146049.html I haven't 
extracted into a separate patch for submission yet: LLVM does not call 
`Triple::normalize` everywhere it should, and misinterprets x86_64-linux-gnux32 
as x86_64-somethingelse when it's set as the default target because of it. For 
testing this change, it may be easiest to just explicitly specify the triple or 
`-mx32`.


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] D92354: [clang] add a new `swift_attr` attribute

2020-12-02 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington added a comment.

Do we need to add APINotes support for this?




Comment at: clang/include/clang/Basic/Attr.td:2155
+  let Args = [StringArgument<"Attribute">];
+  let Documentation = [SwiftAttrDocs];
+}

Should we limit this to appear on certain subjects? Presumably the swift 
importer is only going to look for this in certain places, so I think it makes 
sense to call out places where it'll be ignored in clang. WDYT?


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] D79773: [clang-format] Improve clang-formats handling of concepts

2020-12-02 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

I don't think it was far off, I just I agreed with @klimek in trying to address 
the many different cases that came up I started to feel that  
`parseConstraintExpression` was becoming fragile

Having said that I like to think because they are in concepts specific parse 
code I won't break too much (famous last words!), any if you've tried to format 
concept code with the current clang-format well good luck with that.

Perhaps something is better than nothing?

if you think it has merits, if it covers most cases ok, then I'd be happy to 
see it land and work on any refinements from there.


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

https://reviews.llvm.org/D79773

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


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

2020-12-02 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked 2 inline comments as done.
yaxunl added a comment.

In D80450#2426507 , @tra wrote:

> LGTM.
>
> I'd suggest adding more details on the background of this change to the 
> commit log (point to the comment in the `isBetterOverloadCandidate` ?) and 
> outline the intention to enable the new way to do overloading after some soak 
> time.

Will do.

> 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.




Comment at: clang/lib/Sema/SemaOverload.cpp:9621
+  // is never shown up here. The worst preference shown up here is 'wrong 
side',
+  // e.g. a host function called by a device host function in device
+  // compilation. This is valid AST as long as the host device function is not

tra wrote:
> The comment uses device/host for both function attributes and when it refers 
> to the compilation phase. It would help to make it more readable if function 
> attributes would be distinct from compilation phase. E.g. by using `__host__ 
> __device__` or `HD`. 
will use H/D/HD for function attribute when committing.


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] D92054: [Driver] Default Generic_GCC ppc/ppc64/ppc64le to -fasynchronous-unwind-tables

2020-12-02 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

Ping:)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92054

___
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 Erik Pilkington via Phabricator via cfe-commits
erik.pilkington accepted this revision.
erik.pilkington added a comment.
This revision is now accepted and ready to land.

LGTM!




Comment at: clang/include/clang/Basic/AttrDocs.td:3640
+The argument is a string literal that contains the Swift name of the function 
or
+method. The name may be a compound Swift name. The function of method with such
+an attribute must have more than zero parameters, as its last parameter is

`function or method`


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] 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#2428590 , @hvdijk wrote:

> That sounds like it's one thing in 
> https://lists.llvm.org/pipermail/llvm-dev/2020-October/146049.html I haven't 
> extracted into a separate patch for submission yet: LLVM does not call 
> `Triple::normalize` everywhere it should, and misinterprets 
> x86_64-linux-gnux32 as x86_64-somethingelse when it's set as the default 
> target because of it. For testing this change, it may be easiest to just 
> explicitly specify the triple or `-mx32`.

That doesn't help, unfortunately

The problem is that invoking `clang` on a Debian x32 defaults to `-m64` while 
it should default to `-mx32`. See my test run above.

I have not found the place yet in clang where to adjust that.


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] 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/Basic/Targets/SPIR.h:108
+
+  virtual bool hasInt128Type() const { return false; }
 };

jdoerfert wrote:
> Not virtual but override.
Thank you.  I will change that.



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:
> 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.



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 John Paul Adrian Glaubitz via Phabricator via cfe-commits
glaubitz added a comment.

In D52050#2428685 , @glaubitz wrote:

> I have not found the place yet in clang where to adjust that.

Maybe `sys::getDefaultTargetTriple()` needs to be adjusted. I'll have a look.


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


[clang] b40b319 - [analyzer][StdLibraryFunctionsChecker] Add return value constraint to functions with BufferSize

2020-12-02 Thread Gabor Marton via cfe-commits

Author: Gabor Marton
Date: 2020-12-02T17:54:48+01:00
New Revision: b40b3196b32110f00b7610851f4ef182ac751ba0

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

LOG: [analyzer][StdLibraryFunctionsChecker] Add return value constraint to 
functions with BufferSize

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

Added: 


Modified: 
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
index f8eafde3218d..8a34950ce734 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -457,6 +457,10 @@ class StdLibraryFunctionsChecker
   CaseConstraints.push_back(std::move(CS));
   return *this;
 }
+Summary &Case(const ConstraintSet &CS) {
+  CaseConstraints.push_back(CS);
+  return *this;
+}
 Summary &ArgConstraint(ValueConstraintPtr VC) {
   assert(VC->getArgNo() != Ret &&
  "Arg constraint should not refer to the return value");
@@ -1235,9 +1239,8 @@ void StdLibraryFunctionsChecker::initFunctionSummaries(
   // read()-like functions that never return more than buffer size.
   auto FreadSummary =
   Summary(NoEvalCall)
-  .Case({
-  ReturnValueCondition(LessThanOrEq, ArgNo(2)),
-  })
+  .Case({ReturnValueCondition(LessThanOrEq, ArgNo(2)),
+ ReturnValueCondition(WithinRange, Range(0, SizeMax))})
   .ArgConstraint(NotNull(ArgNo(0)))
   .ArgConstraint(NotNull(ArgNo(3)))
   .ArgConstraint(BufferSize(/*Buffer=*/ArgNo(0), /*BufSize=*/ArgNo(1),
@@ -1764,6 +1767,8 @@ void StdLibraryFunctionsChecker::initFunctionSummaries(
 Signature(ArgTypes{ConstCharPtrRestrictTy, CharPtrRestrictTy, SizeTy},
   RetType{Ssize_tTy}),
 Summary(NoEvalCall)
+.Case({ReturnValueCondition(LessThanOrEq, ArgNo(2)),
+   ReturnValueCondition(WithinRange, Range(-1, Ssize_tMax))})
 .ArgConstraint(NotNull(ArgNo(0)))
 .ArgConstraint(NotNull(ArgNo(1)))
 .ArgConstraint(BufferSize(/*Buffer=*/ArgNo(1),
@@ -1779,6 +1784,8 @@ void StdLibraryFunctionsChecker::initFunctionSummaries(
 ArgTypes{IntTy, ConstCharPtrRestrictTy, CharPtrRestrictTy, SizeTy},
 RetType{Ssize_tTy}),
 Summary(NoEvalCall)
+.Case({ReturnValueCondition(LessThanOrEq, ArgNo(3)),
+   ReturnValueCondition(WithinRange, Range(-1, Ssize_tMax))})
 .ArgConstraint(ArgumentCondition(0, WithinRange, Range(0, IntMax)))
 .ArgConstraint(NotNull(ArgNo(1)))
 .ArgConstraint(NotNull(ArgNo(2)))
@@ -1842,6 +1849,9 @@ void StdLibraryFunctionsChecker::initFunctionSummaries(
 Optional Socklen_tPtrRestrictTy = getRestrictTy(Socklen_tPtrTy);
 Optional Socklen_tMax = getMaxValue(Socklen_tTy);
 
+const auto ReturnsZeroOrMinusOne =
+ConstraintSet{ReturnValueCondition(WithinRange, Range(-1, 0))};
+
 // In 'socket.h' of some libc implementations with C99, sockaddr parameter
 // is a transparent union of the underlying sockaddr_ family of pointers
 // instead of being a pointer to struct sockaddr. In these cases, the
@@ -1850,6 +1860,7 @@ void StdLibraryFunctionsChecker::initFunctionSummaries(
 // constraints which require pointer types for the sockaddr param.
 auto Accept =
 Summary(NoEvalCall)
+.Case({ReturnValueCondition(WithinRange, Range(-1, IntMax))})
 .ArgConstraint(ArgumentCondition(0, WithinRange, Range(0, 
IntMax)));
 if (!addToFunctionSummaryMap(
 "accept",
@@ -1872,6 +1883,7 @@ void StdLibraryFunctionsChecker::initFunctionSummaries(
 Signature(ArgTypes{IntTy, ConstStructSockaddrPtrTy, Socklen_tTy},
   RetType{IntTy}),
 Summary(NoEvalCall)
+.Case(ReturnsZeroOrMinusOne)
 .ArgConstraint(
 ArgumentCondition(0, WithinRange, Range(0, IntMax)))
 .ArgConstraint(NotNull(ArgNo(1)))
@@ -1884,6 +1896,7 @@ void StdLibraryFunctionsChecker::initFunctionSummaries(
   "bind",
   Signature(ArgTypes{IntTy, Irrelevant, Socklen_tTy}, RetType{IntTy}),
   Summary(NoEvalCall)
+  .Case(ReturnsZeroOrMinusOne)
   .ArgConstraint(
   ArgumentCondition(0, WithinRange, Range(0, IntMax)))
   .ArgConstraint(
@@ -1897,6 +1910,7 @@ void StdLibraryFunctionsChecker::initFunctionSummaries(
Socklen_tPtrRestrictTy},
   Ret

[PATCH] D92474: [analyzer][StdLibraryFunctionsChecker] Add return value constraint to functions with BufferSize

2020-12-02 Thread Gabor Marton via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb40b3196b321: [analyzer][StdLibraryFunctionsChecker] Add 
return value constraint to functions… (authored by martong).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92474

Files:
  clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp

Index: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -457,6 +457,10 @@
   CaseConstraints.push_back(std::move(CS));
   return *this;
 }
+Summary &Case(const ConstraintSet &CS) {
+  CaseConstraints.push_back(CS);
+  return *this;
+}
 Summary &ArgConstraint(ValueConstraintPtr VC) {
   assert(VC->getArgNo() != Ret &&
  "Arg constraint should not refer to the return value");
@@ -1235,9 +1239,8 @@
   // read()-like functions that never return more than buffer size.
   auto FreadSummary =
   Summary(NoEvalCall)
-  .Case({
-  ReturnValueCondition(LessThanOrEq, ArgNo(2)),
-  })
+  .Case({ReturnValueCondition(LessThanOrEq, ArgNo(2)),
+ ReturnValueCondition(WithinRange, Range(0, SizeMax))})
   .ArgConstraint(NotNull(ArgNo(0)))
   .ArgConstraint(NotNull(ArgNo(3)))
   .ArgConstraint(BufferSize(/*Buffer=*/ArgNo(0), /*BufSize=*/ArgNo(1),
@@ -1764,6 +1767,8 @@
 Signature(ArgTypes{ConstCharPtrRestrictTy, CharPtrRestrictTy, SizeTy},
   RetType{Ssize_tTy}),
 Summary(NoEvalCall)
+.Case({ReturnValueCondition(LessThanOrEq, ArgNo(2)),
+   ReturnValueCondition(WithinRange, Range(-1, Ssize_tMax))})
 .ArgConstraint(NotNull(ArgNo(0)))
 .ArgConstraint(NotNull(ArgNo(1)))
 .ArgConstraint(BufferSize(/*Buffer=*/ArgNo(1),
@@ -1779,6 +1784,8 @@
 ArgTypes{IntTy, ConstCharPtrRestrictTy, CharPtrRestrictTy, SizeTy},
 RetType{Ssize_tTy}),
 Summary(NoEvalCall)
+.Case({ReturnValueCondition(LessThanOrEq, ArgNo(3)),
+   ReturnValueCondition(WithinRange, Range(-1, Ssize_tMax))})
 .ArgConstraint(ArgumentCondition(0, WithinRange, Range(0, IntMax)))
 .ArgConstraint(NotNull(ArgNo(1)))
 .ArgConstraint(NotNull(ArgNo(2)))
@@ -1842,6 +1849,9 @@
 Optional Socklen_tPtrRestrictTy = getRestrictTy(Socklen_tPtrTy);
 Optional Socklen_tMax = getMaxValue(Socklen_tTy);
 
+const auto ReturnsZeroOrMinusOne =
+ConstraintSet{ReturnValueCondition(WithinRange, Range(-1, 0))};
+
 // In 'socket.h' of some libc implementations with C99, sockaddr parameter
 // is a transparent union of the underlying sockaddr_ family of pointers
 // instead of being a pointer to struct sockaddr. In these cases, the
@@ -1850,6 +1860,7 @@
 // constraints which require pointer types for the sockaddr param.
 auto Accept =
 Summary(NoEvalCall)
+.Case({ReturnValueCondition(WithinRange, Range(-1, IntMax))})
 .ArgConstraint(ArgumentCondition(0, WithinRange, Range(0, IntMax)));
 if (!addToFunctionSummaryMap(
 "accept",
@@ -1872,6 +1883,7 @@
 Signature(ArgTypes{IntTy, ConstStructSockaddrPtrTy, Socklen_tTy},
   RetType{IntTy}),
 Summary(NoEvalCall)
+.Case(ReturnsZeroOrMinusOne)
 .ArgConstraint(
 ArgumentCondition(0, WithinRange, Range(0, IntMax)))
 .ArgConstraint(NotNull(ArgNo(1)))
@@ -1884,6 +1896,7 @@
   "bind",
   Signature(ArgTypes{IntTy, Irrelevant, Socklen_tTy}, RetType{IntTy}),
   Summary(NoEvalCall)
+  .Case(ReturnsZeroOrMinusOne)
   .ArgConstraint(
   ArgumentCondition(0, WithinRange, Range(0, IntMax)))
   .ArgConstraint(
@@ -1897,6 +1910,7 @@
Socklen_tPtrRestrictTy},
   RetType{IntTy}),
 Summary(NoEvalCall)
+.Case(ReturnsZeroOrMinusOne)
 .ArgConstraint(
 ArgumentCondition(0, WithinRange, Range(0, IntMax)))
 .ArgConstraint(NotNull(ArgNo(1)))
@@ -1906,6 +1920,7 @@
   Signature(ArgTypes{IntTy, Irrelevant, Socklen_tPtrRestrictTy},
 RetType{IntTy}),
   Summary(NoEvalCall)
+  .Case(ReturnsZeroOrMinusOne)
   .ArgConstraint(
   ArgumentCondition(0, WithinRange, Range(0, IntMax;
 
@@ -1917,6 +1932,7 @@
Socklen_tPtrRestrictTy},
   RetType{IntTy}),
 Summary(NoEvalCall)
+.Case(ReturnsZeroOrMin

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

2020-12-02 Thread Orivej Desh via Phabricator via cfe-commits
orivej added a comment.

Could somebody review this?


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] D92487: [AArch64][Driver][SVE] Push missing SVE feature error from driver to frontend

2020-12-02 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen accepted this revision.
sdesmalen added a comment.
This revision is now accepted and ready to land.

Other than the nit, LGTM.




Comment at: clang/lib/Sema/SemaType.cpp:7789
+S.Diag(Attr.getLoc(), diag::err_attribute_unsupported)
+<< Attr << "'neon' or 'mve' feature flag";
 Attr.setInvalid();

nit: s/ feature flag//
(otherwise, for this case it should be 'feature flags' and the case below would 
need 'the ' in front of it, to read nicely).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92487

___
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#2428693 , @glaubitz wrote:

> Maybe `sys::getDefaultTargetTriple()` needs to be adjusted. I'll have a look.

`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.


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.

The problem seems to be that `LLVM_HOST_TRIPLE:STRING` is set to 
`x86_64-unknown-linux-gnu` instead of ``x86_64-unknown-linux-gnux32`.

I haven't found the place to fix that yet.


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#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


[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 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] 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 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] 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] 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] 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] 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 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] 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] 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] 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] 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] 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] 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] 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] 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


[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] 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:  

[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] 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] 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] 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] 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] 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] 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


[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] 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


[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


[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] 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


[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

  1   2   >