[PATCH] D107183: [Preprocessor] Ensure newline after #pragma introduced by -fms-extensions.

2021-07-31 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur updated this revision to Diff 363334.
Meinersbur added a comment.

- Use %clang_cc1 because %clang adds options according to it triple, i.e. 
-fms-extensions is added implicitly for Windows targets.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107183

Files:
  clang/lib/Frontend/PrintPreprocessedOutput.cpp
  clang/test/Preprocessor/whitespace-ms-extensions.c


Index: clang/test/Preprocessor/whitespace-ms-extensions.c
===
--- /dev/null
+++ clang/test/Preprocessor/whitespace-ms-extensions.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -E -P %s -o - | FileCheck %s
+// RUN: %clang_cc1 -E -P -fms-extensions %s -o - | FileCheck %s 
--check-prefix=MSEXT
+
+// -fms-extensions changes __pragma into #pragma
+// Ensure that there is a newline after the #pragma line.
+
+#define MACRO\
+text \
+__pragma(PRAGMA) \
+after
+
+before MACRO text
+
+
+// CHECK:  before text __pragma(PRAGMA) after text
+
+// MSEXT:  before text
+// MSEXT-NEXT: #pragma PRAGMA
+// MSEXT-NEXT: after text
Index: clang/lib/Frontend/PrintPreprocessedOutput.cpp
===
--- clang/lib/Frontend/PrintPreprocessedOutput.cpp
+++ clang/lib/Frontend/PrintPreprocessedOutput.cpp
@@ -646,7 +646,9 @@
!Tok.is(tok::annot_module_begin) && !Tok.is(tok::annot_module_end)))
 return;
 
-  if (!RequireSameLine && MoveToLine(Tok, /*RequireStartOfLine=*/false)) {
+  // EmittedDirectiveOnThisLine takes priority over RequireSameLine.
+  if ((!RequireSameLine || EmittedDirectiveOnThisLine) &&
+  MoveToLine(Tok, /*RequireStartOfLine=*/EmittedDirectiveOnThisLine)) {
 if (MinimizeWhitespace) {
   // Avoid interpreting hash as a directive under -fpreprocessed.
   if (Tok.is(tok::hash))


Index: clang/test/Preprocessor/whitespace-ms-extensions.c
===
--- /dev/null
+++ clang/test/Preprocessor/whitespace-ms-extensions.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -E -P %s -o - | FileCheck %s
+// RUN: %clang_cc1 -E -P -fms-extensions %s -o - | FileCheck %s --check-prefix=MSEXT
+
+// -fms-extensions changes __pragma into #pragma
+// Ensure that there is a newline after the #pragma line.
+
+#define MACRO\
+text \
+__pragma(PRAGMA) \
+after
+
+before MACRO text
+
+
+// CHECK:  before text __pragma(PRAGMA) after text
+
+// MSEXT:  before text
+// MSEXT-NEXT: #pragma PRAGMA
+// MSEXT-NEXT: after text
Index: clang/lib/Frontend/PrintPreprocessedOutput.cpp
===
--- clang/lib/Frontend/PrintPreprocessedOutput.cpp
+++ clang/lib/Frontend/PrintPreprocessedOutput.cpp
@@ -646,7 +646,9 @@
!Tok.is(tok::annot_module_begin) && !Tok.is(tok::annot_module_end)))
 return;
 
-  if (!RequireSameLine && MoveToLine(Tok, /*RequireStartOfLine=*/false)) {
+  // EmittedDirectiveOnThisLine takes priority over RequireSameLine.
+  if ((!RequireSameLine || EmittedDirectiveOnThisLine) &&
+  MoveToLine(Tok, /*RequireStartOfLine=*/EmittedDirectiveOnThisLine)) {
 if (MinimizeWhitespace) {
   // Avoid interpreting hash as a directive under -fpreprocessed.
   if (Tok.is(tok::hash))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D99353: [driver] Make `clang` warn rather then error on `flang` options

2021-07-31 Thread Joachim Protze via Phabricator via cfe-commits
protze.joachim added a comment.

Any chance that we get this into llvm/13?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99353

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


[PATCH] D107139: [RISCV] Rename vector inline constraint from 'v' to 'vr' and 'vm' in IR.

2021-07-31 Thread Hsiangkai Wang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8b33839f010f: [RISCV] Rename vector inline constraint from 
v to vr and vm in IR. (authored by 
HsiangKai).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107139

Files:
  clang/lib/Basic/Targets/RISCV.cpp
  clang/test/CodeGen/RISCV/riscv-inline-asm-rvv.c
  llvm/lib/Target/RISCV/RISCVISelLowering.cpp
  llvm/test/CodeGen/RISCV/rvv/inline-asm.ll

Index: llvm/test/CodeGen/RISCV/rvv/inline-asm.ll
===
--- llvm/test/CodeGen/RISCV/rvv/inline-asm.ll
+++ llvm/test/CodeGen/RISCV/rvv/inline-asm.ll
@@ -10,7 +10,7 @@
 ; CHECK-NEXT:#NO_APP
 ; CHECK-NEXT:ret
 entry:
-  %0 = tail call  asm "vmand.mm $0, $1, $2", "=v,v,v"( %in,  %in2)
+  %0 = tail call  asm "vmand.mm $0, $1, $2", "=^vm,^vm,^vm"( %in,  %in2)
   ret  %0
 }
 
@@ -22,7 +22,7 @@
 ; CHECK-NEXT:#NO_APP
 ; CHECK-NEXT:ret
 entry:
-  %0 = tail call  asm "vmand.mm $0, $1, $2", "=v,v,v"( %in,  %in2)
+  %0 = tail call  asm "vmand.mm $0, $1, $2", "=^vm,^vm,^vm"( %in,  %in2)
   ret  %0
 }
 
@@ -34,7 +34,7 @@
 ; CHECK-NEXT:#NO_APP
 ; CHECK-NEXT:ret
 entry:
-  %0 = tail call  asm "vmand.mm $0, $1, $2", "=v,v,v"( %in,  %in2)
+  %0 = tail call  asm "vmand.mm $0, $1, $2", "=^vm,^vm,^vm"( %in,  %in2)
   ret  %0
 }
 
@@ -46,7 +46,7 @@
 ; CHECK-NEXT:#NO_APP
 ; CHECK-NEXT:ret
 entry:
-  %0 = tail call  asm "vmand.mm $0, $1, $2", "=v,v,v"( %in,  %in2)
+  %0 = tail call  asm "vmand.mm $0, $1, $2", "=^vm,^vm,^vm"( %in,  %in2)
   ret  %0
 }
 
@@ -58,7 +58,7 @@
 ; CHECK-NEXT:#NO_APP
 ; CHECK-NEXT:ret
 entry:
-  %0 = tail call  asm "vmand.mm $0, $1, $2", "=v,v,v"( %in,  %in2)
+  %0 = tail call  asm "vmand.mm $0, $1, $2", "=^vm,^vm,^vm"( %in,  %in2)
   ret  %0
 }
 
@@ -70,7 +70,7 @@
 ; CHECK-NEXT:#NO_APP
 ; CHECK-NEXT:ret
 entry:
-  %0 = tail call  asm "vmand.mm $0, $1, $2", "=v,v,v"( %in,  %in2)
+  %0 = tail call  asm "vmand.mm $0, $1, $2", "=^vm,^vm,^vm"( %in,  %in2)
   ret  %0
 }
 
@@ -82,7 +82,7 @@
 ; CHECK-NEXT:#NO_APP
 ; CHECK-NEXT:ret
 entry:
-  %0 = tail call  asm "vmand.mm $0, $1, $2", "=v,v,v"( %in,  %in2)
+  %0 = tail call  asm "vmand.mm $0, $1, $2", "=^vm,^vm,^vm"( %in,  %in2)
   ret  %0
 }
 
@@ -94,7 +94,7 @@
 ; CHECK-NEXT:#NO_APP
 ; CHECK-NEXT:ret
 entry:
-  %0 = tail call  asm "vadd.vv $0, $1, $2", "=v,v,v"( %in,  %in2)
+  %0 = tail call  asm "vadd.vv $0, $1, $2", "=^vr,^vr,^vr"( %in,  %in2)
   ret  %0
 }
 
@@ -106,7 +106,7 @@
 ; CHECK-NEXT:#NO_APP
 ; CHECK-NEXT:ret
 entry:
-  %0 = tail call  asm "vadd.vv $0, $1, $2", "=v,v,v"( %in,  %in2)
+  %0 = tail call  asm "vadd.vv $0, $1, $2", "=^vr,^vr,^vr"( %in,  %in2)
   ret  %0
 }
 
@@ -118,7 +118,7 @@
 ; CHECK-NEXT:#NO_APP
 ; CHECK-NEXT:ret
 entry:
-  %0 = tail call  asm "vadd.vv $0, $1, $2", "=v,v,v"( %in,  %in2)
+  %0 = tail call  asm "vadd.vv $0, $1, $2", "=^vr,^vr,^vr"( %in,  %in2)
   ret  %0
 }
 
@@ -130,7 +130,7 @@
 ; CHECK-NEXT:#NO_APP
 ; CHECK-NEXT:ret
 entry:
-  %0 = tail call  asm "vadd.vv $0, $1, $2", "=v,v,v"( %in,  %in2)
+  %0 = tail call  asm "vadd.vv $0, $1, $2", "=^vr,^vr,^vr"( %in,  %in2)
   ret  %0
 }
 
@@ -142,7 +142,7 @@
 ; CHECK-NEXT:#NO_APP
 ; CHECK-NEXT:ret
 entry:
-  %0 = tail call  asm "vadd.vv $0, $1, $2", "=v,v,v"( %in,  %in2)
+  %0 = tail call  asm "vadd.vv $0, $1, $2", "=^vr,^vr,^vr"( %in,  %in2)
   ret  %0
 }
 
@@ -154,7 +154,7 @@
 ; CHECK-NEXT:#NO_APP
 ; CHECK-NEXT:ret
 entry:
-  %0 = tail call  asm "vadd.vv $0, $1, $2", "=v,v,v"( %in,  %in2)
+  %0 = tail call  asm "vadd.vv $0, $1, $2", "=^vr,^vr,^vr"( %in,  %in2)
   ret  %0
 }
 
@@ -166,7 +166,7 @@
 ; CHECK-NEXT:#NO_APP
 ; CHECK-NEXT:ret
 entry:
-  %0 = tail call  asm "vadd.vv $0, $1, $2", "=v,v,v"( %in,  %in2)
+  %0 = tail call  asm "vadd.vv $0, $1, $2", "=^vr,^vr,^vr"( %in,  %in2)
   ret  %0
 }
 
@@ -178,7 +178,7 @@
 ; CHECK-NEXT:#NO_APP
 ; CHECK-NEXT:ret
 entry:
-  %0 = tail call  asm "vadd.vv $0, $1, $2", "=v,v,v"( %in,  %in2)
+  %0 = tail call  asm "vadd.vv $0, $1, $2", "=^vr,^vr,^vr"( %in,  %in2)
   ret  %0
 }
 
@@ -190,7 +190,7 @@
 ; CHECK-NEXT:#NO_APP
 ; CHECK-NEXT:ret
 entry:
-  %0 = tail call  asm "vadd.vv $0, $1, $2", "=v,v,v"( %in,  %in2)
+  %0 = tail call  asm "vadd.vv $0, $1, $2", "=^vr,^vr,^vr"( %in,  %in2)
   ret  %0
 }
 
@@ -202,7 +202,7 @@
 ; CHECK-NEXT:#NO_APP
 ; CHECK-NEXT:ret
 entry:
-  %0 = tail call  asm "vadd.vv $0, $1, $2", "=v,v,v"( %in,  %in2)
+  %0 = tail call  asm "vadd.vv $0, $1, $2", "=^vr,^vr,^vr"( %in,  %in2)
   ret  %0
 }
 
@@ -214,7 +214,7 @@
 ; CHECK-NEXT:#NO_APP
 ; CHECK-NEXT:ret
 entry:
-  %0 = tail call  asm "vadd.vv $0, $1, $2", "=v,v,v"( %in,  %in2)
+  %0 = tail call  asm "vadd.vv $0, $1, $2", "=^vr,^vr,^vr"( %in,  %in2)
   ret  %0
 }
 
@@ -226,7 +226,7 @@
 ; CHECK-NEXT:#NO_APP
 ; CHECK-NEXT:ret
 entry:
-  %0 = tail 

[clang] 8b33839 - [RISCV] Rename vector inline constraint from 'v' to 'vr' and 'vm' in IR.

2021-07-31 Thread Hsiangkai Wang via cfe-commits

Author: Hsiangkai Wang
Date: 2021-08-01T05:58:17+08:00
New Revision: 8b33839f010fe780fdaf68160be7c45d07fdfcad

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

LOG: [RISCV] Rename vector inline constraint from 'v' to 'vr' and 'vm' in IR.

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

Added: 


Modified: 
clang/lib/Basic/Targets/RISCV.cpp
clang/test/CodeGen/RISCV/riscv-inline-asm-rvv.c
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
llvm/test/CodeGen/RISCV/rvv/inline-asm.ll

Removed: 




diff  --git a/clang/lib/Basic/Targets/RISCV.cpp 
b/clang/lib/Basic/Targets/RISCV.cpp
index 9705129b39d8f..567f600871352 100644
--- a/clang/lib/Basic/Targets/RISCV.cpp
+++ b/clang/lib/Basic/Targets/RISCV.cpp
@@ -105,7 +105,7 @@ std::string RISCVTargetInfo::convertConstraint(const char 
*) const {
   std::string R;
   switch (*Constraint) {
   case 'v':
-R = std::string("v");
+R = std::string("^") + std::string(Constraint, 2);
 Constraint += 1;
 break;
   default:

diff  --git a/clang/test/CodeGen/RISCV/riscv-inline-asm-rvv.c 
b/clang/test/CodeGen/RISCV/riscv-inline-asm-rvv.c
index 14558778278e7..ecd229bf37465 100644
--- a/clang/test/CodeGen/RISCV/riscv-inline-asm-rvv.c
+++ b/clang/test/CodeGen/RISCV/riscv-inline-asm-rvv.c
@@ -21,7 +21,7 @@ void test_v_reg() {
 
 vint32m1_t test_vr(vint32m1_t a, vint32m1_t b) {
 // CHECK-LABEL: define{{.*}} @test_vr
-// CHECK: %0 = tail call  asm sideeffect "vadd.vv $0, $1, 
$2", "=v,v,v"( %a,  %b)
+// CHECK: %0 = tail call  asm sideeffect "vadd.vv $0, $1, 
$2", "=^vr,^vr,^vr"( %a,  %b)
   vint32m1_t ret;
   asm volatile ("vadd.vv %0, %1, %2" : "=vr"(ret) : "vr"(a), "vr"(b));
   return ret;
@@ -29,7 +29,7 @@ vint32m1_t test_vr(vint32m1_t a, vint32m1_t b) {
 
 vbool1_t test_vm(vbool1_t a, vbool1_t b) {
 // CHECK-LABEL: define{{.*}} @test_vm
-// CHECK: %0 = tail call  asm sideeffect "vmand.mm $0, $1, 
$2", "=v,v,v"( %a,  %b)
+// CHECK: %0 = tail call  asm sideeffect "vmand.mm $0, $1, 
$2", "=^vm,^vm,^vm"( %a,  %b)
   vbool1_t ret;
   asm volatile ("vmand.mm %0, %1, %2" : "=vm"(ret) : "vm"(a), "vm"(b));
   return ret;

diff  --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp 
b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index ad6297108dd47..e021f8da44605 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -8474,7 +8474,6 @@ RISCVTargetLowering::getConstraintType(StringRef 
Constraint) const {
 default:
   break;
 case 'f':
-case 'v':
   return C_RegisterClass;
 case 'I':
 case 'J':
@@ -8485,6 +8484,9 @@ RISCVTargetLowering::getConstraintType(StringRef 
Constraint) const {
 case 'S': // A symbolic address
   return C_Other;
 }
+  } else {
+if (Constraint == "vr" || Constraint == "vm")
+  return C_RegisterClass;
   }
   return TargetLowering::getConstraintType(Constraint);
 }
@@ -8507,16 +8509,19 @@ RISCVTargetLowering::getRegForInlineAsmConstraint(const 
TargetRegisterInfo *TRI,
   if (Subtarget.hasStdExtD() && VT == MVT::f64)
 return std::make_pair(0U, ::FPR64RegClass);
   break;
-case 'v':
-  for (const auto *RC :
-   {::VMRegClass, ::VRRegClass, ::VRM2RegClass,
-::VRM4RegClass, ::VRM8RegClass}) {
+default:
+  break;
+}
+  } else {
+if (Constraint == "vr") {
+  for (const auto *RC : {::VRRegClass, ::VRM2RegClass,
+ ::VRM4RegClass, ::VRM8RegClass}) {
 if (TRI->isTypeLegalForClass(*RC, VT.SimpleTy))
   return std::make_pair(0U, RC);
   }
-  break;
-default:
-  break;
+} else if (Constraint == "vm") {
+  if (TRI->isTypeLegalForClass(RISCV::VMRegClass, VT.SimpleTy))
+return std::make_pair(0U, ::VMRegClass);
 }
   }
 

diff  --git a/llvm/test/CodeGen/RISCV/rvv/inline-asm.ll 
b/llvm/test/CodeGen/RISCV/rvv/inline-asm.ll
index 624eb188a4988..a09de7ac56142 100644
--- a/llvm/test/CodeGen/RISCV/rvv/inline-asm.ll
+++ b/llvm/test/CodeGen/RISCV/rvv/inline-asm.ll
@@ -10,7 +10,7 @@ define  @test_1xi1( %in, 
 %in
 ; CHECK-NEXT:#NO_APP
 ; CHECK-NEXT:ret
 entry:
-  %0 = tail call  asm "vmand.mm $0, $1, $2", "=v,v,v"( %in,  %in2)
+  %0 = tail call  asm "vmand.mm $0, $1, $2", 
"=^vm,^vm,^vm"( %in,  %in2)
   ret  %0
 }
 
@@ -22,7 +22,7 @@ define  @test_2xi1( %in, 
 %in
 ; CHECK-NEXT:#NO_APP
 ; CHECK-NEXT:ret
 entry:
-  %0 = tail call  asm "vmand.mm $0, $1, $2", "=v,v,v"( %in,  %in2)
+  %0 = tail call  asm "vmand.mm $0, $1, $2", 
"=^vm,^vm,^vm"( %in,  %in2)
   ret  %0
 }
 
@@ -34,7 +34,7 @@ define  @test_4xi1( %in, 
 %in
 ; CHECK-NEXT:#NO_APP
 ; CHECK-NEXT:ret
 entry:
-  %0 = tail call  asm "vmand.mm $0, $1, $2", "=v,v,v"( %in,  %in2)
+  %0 = tail call  asm "vmand.mm $0, $1, $2", 

[PATCH] D107116: [ConstantFold] Get rid of special cases for sizeof etc.

2021-07-31 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

Just committed 6eb2ffba 
 to fix a 
couple regression tests.

Seems low-risk to cherry-pick to 13.x.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107116

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


[clang] 6eb2ffb - Fix a couple regression tests I missed updating in 2a284782

2021-07-31 Thread Eli Friedman via cfe-commits

Author: Eli Friedman
Date: 2021-07-31T13:41:15-07:00
New Revision: 6eb2ffbaeb56c8b08ad17c823e1699b964e10b8b

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

LOG: Fix a couple regression tests I missed updating in 2a284782

Added: 


Modified: 
clang/test/CodeGen/catch-nullptr-and-nonzero-offset.c
mlir/test/Target/LLVMIR/openacc-llvm.mlir

Removed: 




diff  --git a/clang/test/CodeGen/catch-nullptr-and-nonzero-offset.c 
b/clang/test/CodeGen/catch-nullptr-and-nonzero-offset.c
index 233a1fa8797c2..5c233a6ce2644 100644
--- a/clang/test/CodeGen/catch-nullptr-and-nonzero-offset.c
+++ b/clang/test/CodeGen/catch-nullptr-and-nonzero-offset.c
@@ -230,10 +230,10 @@ char *nullptr_allones_BAD() {
   // CHECK:   define{{.*}} i8* @nullptr_allones_BAD()
   // CHECK-NEXT:  [[ENTRY:.*]]:
   // CHECK-SANITIZE-C-NEXT: br i1 false, label %[[CONT:.*]], label 
%[[HANDLER_POINTER_OVERFLOW:[^,]+]],{{.*}} !nosanitize
-  // CHECK-SANITIZE-CPP-NEXT:   br i1 icmp eq (i64 mul (i64 ptrtoint 
(i8* getelementptr (i8, i8* null, i32 1) to i64), i64 -1), i64 0), label 
%[[CONT:.*]], label %[[HANDLER_POINTER_OVERFLOW:[^,]+]],{{.*}} !nosanitize
+  // CHECK-SANITIZE-CPP-NEXT:   br i1 icmp eq (i64 ptrtoint (i8* 
getelementptr inbounds (i8, i8* null, i64 -1) to i64), i64 0), label 
%[[CONT:.*]], label %[[HANDLER_POINTER_OVERFLOW:[^,]+]],{{.*}} !nosanitize
   // CHECK-SANITIZE:  [[HANDLER_POINTER_OVERFLOW]]:
   // CHECK-SANITIZE-NORECOVER-NEXT: call void 
@__ubsan_handle_pointer_overflow_abort(i8* bitcast ({ {{{.*}}} }* @[[LINE_800]] 
to i8*), i64 0, i64 ptrtoint (i8* getelementptr inbounds (i8, i8* null, i64 -1) 
to i64))
-  // CHECK-SANITIZE-RECOVER-NEXT:   call void 
@__ubsan_handle_pointer_overflow(i8* bitcast ({ {{{.*}}} }* @[[LINE_800]] to 
i8*), i64 0, i64 mul (i64 ptrtoint (i8* getelementptr (i8, i8* null, i32 1) to 
i64), i64 -1))
+  // CHECK-SANITIZE-RECOVER-NEXT:   call void 
@__ubsan_handle_pointer_overflow(i8* bitcast ({ {{{.*}}} }* @[[LINE_800]] to 
i8*), i64 0, i64 ptrtoint (i8* getelementptr inbounds (i8, i8* null, i64 -1) to 
i64))
   // CHECK-SANITIZE-TRAP-NEXT:  call void @llvm.ubsantrap(i8 
19){{.*}}, !nosanitize
   // CHECK-SANITIZE-UNREACHABLE-NEXT:   unreachable, !nosanitize
   // CHECK-SANITIZE:  [[CONT]]:

diff  --git a/mlir/test/Target/LLVMIR/openacc-llvm.mlir 
b/mlir/test/Target/LLVMIR/openacc-llvm.mlir
index f0fb7ff82c9bd..867213d152764 100644
--- a/mlir/test/Target/LLVMIR/openacc-llvm.mlir
+++ b/mlir/test/Target/LLVMIR/openacc-llvm.mlir
@@ -54,7 +54,7 @@ llvm.func @testenterdataop(%arg0: !llvm.ptr, %arg1: 
!llvm.ptr, %arg2:
 // CHECK: [[ARGGEPCAST:%.*]] = bitcast i8** [[ARGGEP]] to float**
 // CHECK: store float* [[SIMPLEPTR]], float** [[ARGGEPCAST]], align 8
 // CHECK: [[SIZEGEP:%.*]] = getelementptr inbounds [2 x i64], [2 x i64]* 
[[SIZE_ALLOCA]], i32 0, i32 1
-// CHECK: store i64 ptrtoint (i1** getelementptr (i1*, i1** null, i32 1) to 
i64), i64* [[SIZEGEP]], align 4
+// CHECK: store i64 ptrtoint (float** getelementptr (float*, float** null, i32 
1) to i64), i64* [[SIZEGEP]], align 4
 
 // CHECK: [[ARGBASE_ALLOCA_GEP:%.*]] = getelementptr inbounds [2 x i8*], [2 x 
i8*]* [[ARGBASE_ALLOCA]], i32 0, i32 0
 // CHECK: [[ARG_ALLOCA_GEP:%.*]] = getelementptr inbounds [2 x i8*], [2 x 
i8*]* [[ARG_ALLOCA]], i32 0, i32 0
@@ -114,7 +114,7 @@ llvm.func @testexitdataop(%arg0: !llvm.struct<(ptr, 
ptr, i64, array<1
 // CHECK: [[ARGGEPCAST:%.*]] = bitcast i8** [[ARGGEP]] to float**
 // CHECK: store float* [[SIMPLEPTR]], float** [[ARGGEPCAST]], align 8
 // CHECK: [[SIZEGEP:%.*]] = getelementptr inbounds [2 x i64], [2 x i64]* 
[[SIZE_ALLOCA]], i32 0, i32 1
-// CHECK: store i64 ptrtoint (i1** getelementptr (i1*, i1** null, i32 1) to 
i64), i64* [[SIZEGEP]], align 4
+// CHECK: store i64 ptrtoint (float** getelementptr (float*, float** null, i32 
1) to i64), i64* [[SIZEGEP]], align 4
 
 // CHECK: [[ARGBASE_ALLOCA_GEP:%.*]] = getelementptr inbounds [2 x i8*], [2 x 
i8*]* [[ARGBASE_ALLOCA]], i32 0, i32 0
 // CHECK: [[ARG_ALLOCA_GEP:%.*]] = getelementptr inbounds [2 x i8*], [2 x 
i8*]* [[ARG_ALLOCA]], i32 0, i32 0
@@ -173,7 +173,7 @@ llvm.func @testupdateop(%arg0: !llvm.struct<(ptr, 
ptr, i64, array<1 x
 // CHECK: [[ARGGEPCAST:%.*]] = bitcast i8** [[ARGGEP]] to float**
 // CHECK: store float* [[SIMPLEPTR]], float** [[ARGGEPCAST]], align 8
 // CHECK: [[SIZEGEP:%.*]] = getelementptr inbounds [2 x i64], [2 x i64]* 
[[SIZE_ALLOCA]], i32 0, i32 1
-// CHECK: store i64 ptrtoint (i1** getelementptr (i1*, i1** null, i32 1) to 
i64), i64* [[SIZEGEP]], align 4
+// CHECK: store i64 ptrtoint (float** getelementptr (float*, float** null, i32 
1) to i64), i64* [[SIZEGEP]], align 4
 
 // CHECK: 

[PATCH] D107116: [ConstantFold] Get rid of special cases for sizeof etc.

2021-07-31 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

Thanks! Do you think this would be suitable for the 13.x release branch too?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107116

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


[PATCH] D107116: [ConstantFold] Get rid of special cases for sizeof etc.

2021-07-31 Thread Eli Friedman 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 rG2a2847823f0d: [ConstantFold] Get rid of special cases for 
sizeof etc. (authored by efriedma).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D107116?vs=362922=363319#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107116

Files:
  clang/test/CodeGen/catch-nullptr-and-nonzero-offset-in-offsetof-idiom.c
  clang/test/CodeGen/catch-nullptr-and-nonzero-offset.c
  clang/test/CodeGenCXX/catch-nullptr-and-nonzero-offset-in-offsetof-idiom.cpp
  clang/test/OpenMP/for_reduction_codegen.cpp
  clang/test/OpenMP/master_taskloop_reduction_codegen.cpp
  clang/test/OpenMP/master_taskloop_simd_reduction_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_reduction_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_simd_reduction_codegen.cpp
  clang/test/OpenMP/taskloop_reduction_codegen.cpp
  clang/test/OpenMP/taskloop_simd_reduction_codegen.cpp
  llvm/lib/IR/ConstantFold.cpp
  llvm/test/Other/constant-fold-gep.ll
  llvm/test/Transforms/LowerTypeTests/function-disjoint.ll
  llvm/test/tools/llvm-as/slow-ptrtoint.ll

Index: llvm/test/tools/llvm-as/slow-ptrtoint.ll
===
--- llvm/test/tools/llvm-as/slow-ptrtoint.ll
+++ llvm/test/tools/llvm-as/slow-ptrtoint.ll
@@ -19,12 +19,12 @@
 ; to constant fold the size of %0
 define i64 @f_i64() {
 ; CHECK-LABEL: @f_i64
-; CHECK: ret i64 mul (i64 ptrtoint (i32* getelementptr (i32, i32* null, i32 1) to i64), i64 1099511627776)
+; CHECK: ret i64 ptrtoint (%0* getelementptr (%0, %0* null, i32 1) to i64)
   ret i64 ptrtoint (%0* getelementptr (%0, %0* null, i32 1) to i64)
 }
 
 define i32 @f_i32() {
 ; CHECK-LABEL: @f_i32
-; CHECK: ret i32 mul (i32 ptrtoint (i32* getelementptr (i32, i32* null, i32 1) to i32), i32 -2147483648)
+; CHECK: ret i32 ptrtoint (%3* getelementptr (%3, %3* null, i32 1) to i32)
   ret i32 ptrtoint (%3* getelementptr (%3, %3* null, i32 1) to i32)
 }
Index: llvm/test/Transforms/LowerTypeTests/function-disjoint.ll
===
--- llvm/test/Transforms/LowerTypeTests/function-disjoint.ll
+++ llvm/test/Transforms/LowerTypeTests/function-disjoint.ll
@@ -33,7 +33,7 @@
   ; WASM32: icmp eq i64 {{.*}}, ptrtoint (i8* getelementptr (i8, i8* null, i64 1) to i64)
   %x = call i1 @llvm.type.test(i8* %p, metadata !"typeid1")
   ; X64: icmp eq i64 {{.*}}, ptrtoint (void ()* @[[JT1]] to i64)
-  ; WASM32: icmp eq i64 {{.*}}, mul (i64 ptrtoint (i8* getelementptr (i8, i8* null, i32 1) to i64), i64 2)
+  ; WASM32: icmp eq i64 {{.*}}, ptrtoint (i8* getelementptr (i8, i8* null, i64 2) to i64)
   %y = call i1 @llvm.type.test(i8* %p, metadata !"typeid2")
   %z = add i1 %x, %y
   ret i1 %z
Index: llvm/test/Other/constant-fold-gep.ll
===
--- llvm/test/Other/constant-fold-gep.ll
+++ llvm/test/Other/constant-fold-gep.ll
@@ -49,15 +49,15 @@
 ; simplifications on sizeof, alignof, and offsetof expressions. The
 ; target-dependent folder should fold these down to constants.
 
-; PLAIN: @a = constant i64 mul (i64 ptrtoint (double* getelementptr (double, double* null, i32 1) to i64), i64 2310)
-; PLAIN: @b = constant i64 ptrtoint (double* getelementptr ({ i1, double }, { i1, double }* null, i64 0, i32 1) to i64)
-; PLAIN: @c = constant i64 mul nuw (i64 ptrtoint (double* getelementptr (double, double* null, i32 1) to i64), i64 2)
-; PLAIN: @d = constant i64 mul nuw (i64 ptrtoint (double* getelementptr (double, double* null, i32 1) to i64), i64 11)
+; PLAIN: @a = constant i64 mul (i64 ptrtoint ({ [7 x double], [7 x double] }* getelementptr ({ [7 x double], [7 x double] }, { [7 x double], [7 x double] }* null, i64 11) to i64), i64 15)
+; PLAIN: @b = constant i64 ptrtoint ([13 x double]* getelementptr ({ i1, [13 x double] }, { i1, [13 x double] }* null, i64 0, i32 1) to i64)
+; PLAIN: @c = constant i64 ptrtoint (double* getelementptr ({ double, double, double, double }, { double, double, double, double }* null, i64 0, i32 2) to i64)
+; PLAIN: @d = constant i64 ptrtoint (double* getelementptr ([13 x double], [13 x double]* null, i64 0, i32 11) to i64)
 ; PLAIN: @e = constant i64 ptrtoint (double* getelementptr ({ double, float, double, double }, { double, float, double, double }* null, i64 0, i32 2) to i64)
-; PLAIN: @f = constant i64 1
-; PLAIN: @g = constant i64 ptrtoint (double* getelementptr ({ i1, double }, { i1, double }* null, i64 0, i32 1) to i64)
-; PLAIN: @h = constant i64 ptrtoint (i1** getelementptr (i1*, i1** null, i32 1) to i64)
-; PLAIN: @i = constant i64 ptrtoint (i1** getelementptr ({ i1, i1* }, { i1, i1* }* null, i64 0, i32 1) to i64)
+; PLAIN: @f = constant 

[clang] 2a28478 - [ConstantFold] Get rid of special cases for sizeof etc.

2021-07-31 Thread Eli Friedman via cfe-commits

Author: Eli Friedman
Date: 2021-07-31T13:20:47-07:00
New Revision: 2a2847823f0d13188c43ebdd0baf42a95df750c7

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

LOG: [ConstantFold] Get rid of special cases for sizeof etc.

Target-dependent constant folding will fold these down to simple
constants (or at least, expressions that don't involve a GEP).  We don't
need heroics to try to optimize the form of the expression before that
happens.

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

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

Added: 


Modified: 
clang/test/CodeGen/catch-nullptr-and-nonzero-offset-in-offsetof-idiom.c
clang/test/CodeGen/catch-nullptr-and-nonzero-offset.c
clang/test/CodeGenCXX/catch-nullptr-and-nonzero-offset-in-offsetof-idiom.cpp
clang/test/OpenMP/for_reduction_codegen.cpp
clang/test/OpenMP/master_taskloop_reduction_codegen.cpp
clang/test/OpenMP/master_taskloop_simd_reduction_codegen.cpp
clang/test/OpenMP/parallel_master_taskloop_reduction_codegen.cpp
clang/test/OpenMP/parallel_master_taskloop_simd_reduction_codegen.cpp
clang/test/OpenMP/taskloop_reduction_codegen.cpp
clang/test/OpenMP/taskloop_simd_reduction_codegen.cpp
llvm/lib/IR/ConstantFold.cpp
llvm/test/Other/constant-fold-gep.ll
llvm/test/Transforms/LowerTypeTests/function-disjoint.ll
llvm/test/tools/llvm-as/slow-ptrtoint.ll

Removed: 




diff  --git 
a/clang/test/CodeGen/catch-nullptr-and-nonzero-offset-in-offsetof-idiom.c 
b/clang/test/CodeGen/catch-nullptr-and-nonzero-offset-in-offsetof-idiom.c
index a079b2898bc8d..636d33344699c 100644
--- a/clang/test/CodeGen/catch-nullptr-and-nonzero-offset-in-offsetof-idiom.c
+++ b/clang/test/CodeGen/catch-nullptr-and-nonzero-offset-in-offsetof-idiom.c
@@ -1,3 +1,4 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
 // RUN: %clang_cc1 -x c   -emit-llvm %s -o - -triple x86_64-linux-gnu | 
FileCheck %s
 // RUN: %clang_cc1 -x c   -fsanitize=pointer-overflow 
-fno-sanitize-recover=pointer-overflow -emit-llvm %s -o - -triple 
x86_64-linux-gnu | FileCheck %s
 
@@ -14,19 +15,19 @@ struct S {
   int x, y;
 };
 
-// CHECK-LABEL: define{{.*}} i64 @{{.*}}get_offset_of_y_naively{{.*}}(
+// CHECK-LABEL: @get_offset_of_y_naively(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:ret i64 ptrtoint (i32* getelementptr inbounds 
([[STRUCT_S:%.*]], %struct.S* null, i32 0, i32 1) to i64)
+//
 uintptr_t get_offset_of_y_naively() {
-  // CHECK: [[ENTRY:.*]]:
-  // CHECK-NEXT:   ret i64 ptrtoint (i32* getelementptr (i32, i32* null, i32 
1) to i64)
-  // CHECK-NEXT: }
   return ((uintptr_t)(&(((struct S *)0)->y)));
 }
 
-// CHECK-LABEL: define{{.*}} i64 @{{.*}}get_offset_of_y_via_builtin{{.*}}(
+// CHECK-LABEL: @get_offset_of_y_via_builtin(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:ret i64 4
+//
 uintptr_t get_offset_of_y_via_builtin() {
-  // CHECK: [[ENTRY:.*]]:
-  // CHECK-NEXT:   ret i64 4
-  // CHECK-NEXT: }
   return __builtin_offsetof(struct S, y);
 }
 

diff  --git a/clang/test/CodeGen/catch-nullptr-and-nonzero-offset.c 
b/clang/test/CodeGen/catch-nullptr-and-nonzero-offset.c
index e30e1efd2bbee..233a1fa8797c2 100644
--- a/clang/test/CodeGen/catch-nullptr-and-nonzero-offset.c
+++ b/clang/test/CodeGen/catch-nullptr-and-nonzero-offset.c
@@ -232,7 +232,7 @@ char *nullptr_allones_BAD() {
   // CHECK-SANITIZE-C-NEXT: br i1 false, label %[[CONT:.*]], label 
%[[HANDLER_POINTER_OVERFLOW:[^,]+]],{{.*}} !nosanitize
   // CHECK-SANITIZE-CPP-NEXT:   br i1 icmp eq (i64 mul (i64 ptrtoint 
(i8* getelementptr (i8, i8* null, i32 1) to i64), i64 -1), i64 0), label 
%[[CONT:.*]], label %[[HANDLER_POINTER_OVERFLOW:[^,]+]],{{.*}} !nosanitize
   // CHECK-SANITIZE:  [[HANDLER_POINTER_OVERFLOW]]:
-  // CHECK-SANITIZE-NORECOVER-NEXT: call void 
@__ubsan_handle_pointer_overflow_abort(i8* bitcast ({ {{{.*}}} }* @[[LINE_800]] 
to i8*), i64 0, i64 mul (i64 ptrtoint (i8* getelementptr (i8, i8* null, i32 1) 
to i64), i64 -1))
+  // CHECK-SANITIZE-NORECOVER-NEXT: call void 
@__ubsan_handle_pointer_overflow_abort(i8* bitcast ({ {{{.*}}} }* @[[LINE_800]] 
to i8*), i64 0, i64 ptrtoint (i8* getelementptr inbounds (i8, i8* null, i64 -1) 
to i64))
   // CHECK-SANITIZE-RECOVER-NEXT:   call void 
@__ubsan_handle_pointer_overflow(i8* bitcast ({ {{{.*}}} }* @[[LINE_800]] to 
i8*), i64 0, i64 mul (i64 ptrtoint (i8* getelementptr (i8, i8* null, i32 1) to 
i64), i64 -1))
   // CHECK-SANITIZE-TRAP-NEXT:  call void @llvm.ubsantrap(i8 
19){{.*}}, !nosanitize
   // CHECK-SANITIZE-UNREACHABLE-NEXT:   unreachable, !nosanitize

diff  --git 
a/clang/test/CodeGenCXX/catch-nullptr-and-nonzero-offset-in-offsetof-idiom.cpp 

[PATCH] D107231: [clang-repl] Fix building with win32 dylibs

2021-07-31 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo created this revision.
mstorsjo added reviewers: v.g.vassilev, teemperor.
Herald added a subscriber: mgorny.
mstorsjo requested review of this revision.
Herald added a project: clang.

Use `clang_target_link_libraries` to avoid duplicate libraries when
the same symbol is provided both by a static library and a larger
dylib, fixing linking with win32 dylibs. This fixes errors like
these:

  ld.lld: error: duplicate symbol: 
llvm::createStringError(std::__1::error_code, char const*)
  >>> defined at libLLVMSupport.a(Error.cpp.obj)
  >>> defined at libLLVM-14git.dll

This matches how other clang tools declare their dependencies.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107231

Files:
  clang/tools/clang-repl/CMakeLists.txt


Index: clang/tools/clang-repl/CMakeLists.txt
===
--- clang/tools/clang-repl/CMakeLists.txt
+++ clang/tools/clang-repl/CMakeLists.txt
@@ -10,7 +10,7 @@
   ClangRepl.cpp
   )
 
-target_link_libraries(clang-repl PUBLIC
+clang_target_link_libraries(clang-repl PUBLIC
   clangBasic
   clangInterpreter
   clangTooling


Index: clang/tools/clang-repl/CMakeLists.txt
===
--- clang/tools/clang-repl/CMakeLists.txt
+++ clang/tools/clang-repl/CMakeLists.txt
@@ -10,7 +10,7 @@
   ClangRepl.cpp
   )
 
-target_link_libraries(clang-repl PUBLIC
+clang_target_link_libraries(clang-repl PUBLIC
   clangBasic
   clangInterpreter
   clangTooling
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D94639: [DebugInfo][CodeView] Change in line tables only mode to emit parent/context scopes for functions, using declarations for types

2021-07-31 Thread Sergey Makarov via Phabricator via cfe-commits
SeTSeR added a comment.

In D94639#2917445 , @rnk wrote:

> In D94639#2917340 , @SeTSeR wrote:
>
>> Hello! As far as I understand, Clang does not preserve info about namespace 
>> for functions declared in namespaces with `-gline-numbers-only` flag. Is 
>> there any way to retrieve this info for DWARF? I thought FIXME at line 261 
>> in CGDebugInfo was addressing exactly this issue.
>
> No, I don't think there is a way to achieve this.
>
> The current -gcodeview -gline-tables-only behavior as I understand it is to 
> emit regular debug info, but skip two key source of info:
>
> - never emit complete class declarations, always use forward decls
> - never emit variable locations, only emit source locations
>
> For DWARF, I think we also try to skip namespace scopes, class forward decls, 
> function types, and other things like that, but I forget the details.
>
> I happen to know that many users of -gline-tables-only are very space 
> constrained: we can't simply port this change from CV to DWARF. We'd have to 
> add a new flag. The bar for such a flag is high. If someone provides a 
> well-motivated use case, we could consider it.

Thank you for the detailed answer. I'll discuss our use case with our team. 
Should I create a separate ticket for this? Or maybe it would be better if I 
submitted the PR adding this flag?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94639

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


[PATCH] D104854: Introduce intrinsic llvm.isnan

2021-07-31 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

LGTM.  (Since there have been a bunch of reviewers involved, please give a few 
days before you merge.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104854

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


[PATCH] D104601: [Preprocessor] Implement -fminimize-whitespace.

2021-07-31 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

FYI, 13.0.0 rc1 is getting tagged on Monday, so it’d be good to have the branch 
in a usable state by then, either with all fixes we currently have in main, or 
reverted.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104601

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


[PATCH] D106349: [clang-format] respect AfterEnum for enums

2021-07-31 Thread Luna Kirkby via Phabricator via cfe-commits
lunasorcery added a comment.

Copying over the comment I left on D99840  
explaining it - my existing change only works because it gets bailed out by 
further code in TokenAnnotator.cpp.
I think your change still is valuable since it's more correct.

> Looking at this again I think the change is flawed. The InitialToken is taken 
> *after* the enum token, and additionally the invocation of 
> ShouldBreakBeforeBrace is falling through to the return false; case every 
> time. As such the call to addUnwrappedLine() is _always_ skipped. This 
> removes the newline for both the Attach and Break styles - but the Break 
> style is then fixed up by some code in TokenAnnotator.cpp that I don't fully 
> understand, which adds the newline back in.
>
> So [D99840 ] _works_, but not quite for the 
> right reasons.
>
> D106349  appears to implement this in a 
> slightly more correct manner, taking the InitialToken _before_ we've advanced 
> past the enum token, and handling the enum case inside ShouldBreakBeforeBrace.




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

https://reviews.llvm.org/D106349

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


[PATCH] D106349: [clang-format] respect AfterEnum for enums

2021-07-31 Thread Michael Zimmermann via Phabricator via cfe-commits
m1cha added a comment.

Well it's pretty much exactly the same except for the change in 
`ShouldBreakBeforeBrace`.
Somebody with more knowledge about clang-format than me should try to figure 
out why it's not needed.

If it's actually not needed than this change does not need to be merged.


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

https://reviews.llvm.org/D106349

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


[PATCH] D107155: [clang][deps] Substitute clang-scan-deps executable in lit tests

2021-07-31 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

Just because I was curious. Some grep/seding. Nothing definitive:

  10188 %clang
   1289 %clang_analyze_cc1
  32253 %clang_cc1
 22 clang-check
503 %clang_cl
 59 clang-offload-bundler
  2 clang-offload-wrapper
 69 clang-rename
  2 clang-repl
 52 clang-scan-deps
212 %clangxx
257 %s
 14 %scan-build

So bit of a mix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107155

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


[PATCH] D106349: [clang-format] respect AfterEnum for enums

2021-07-31 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added a comment.

In D106349#2914448 , @m1cha wrote:

> I don't have commit access. How does that even work? The documentation is 
> very scarce about this but for security reasons I'd expect there to be a very 
> limited set of people with commit access
>
> Here's my author info:
> `Michael Zimmermann `

https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access I don't 
think it is limited, I'm also //just some guy// which applied for it some 7 
months ago. Since the next release is far away, you can apply for the access 
and commit it yourself. I did only wait one day. ;)

In D106349#2914500 , @lunasorcery 
wrote:

> Note also there's significant overlap with the now-committed D99840 
> , though that's missing the change inside 
> ShouldBreakBeforeBrace().
> In retrospect I'm a little confused as to why D99840 
>  appears to work without it.

I thought it looked familiar, but did not find what it was. Does this change 
needs to be rebased before it can be applied?


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

https://reviews.llvm.org/D106349

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


[PATCH] D106909: [clang] Add clang builtins support for gfx90a

2021-07-31 Thread Anshil Gandhi via Phabricator via cfe-commits
gandhi21299 updated this revision to Diff 363196.
gandhi21299 added a comment.

refreshing patch


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106909

Files:
  clang/include/clang/Basic/BuiltinsAMDGPU.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGenOpenCL/builtins-fp-atomics.cl

Index: clang/test/CodeGenOpenCL/builtins-fp-atomics.cl
===
--- /dev/null
+++ clang/test/CodeGenOpenCL/builtins-fp-atomics.cl
@@ -0,0 +1,132 @@
+// RUN: %clang_cc1 -O0 -cl-std=CL2.0 -triple amdgcn-amd-amdhsa -target-cpu gfx90a \
+// RUN:   %s -S -emit-llvm -o - | FileCheck %s -check-prefix=CHECK
+
+// RUN: %clang_cc1 -O0 -cl-std=CL2.0 -triple amdgcn-amd-amdhsa -target-cpu gfx90a \
+// RUN:   -S -o - %s | FileCheck -check-prefix=GFX90A %s
+
+
+typedef enum memory_order {
+  memory_order_relaxed = __ATOMIC_RELAXED,
+  memory_order_acquire = __ATOMIC_ACQUIRE,
+  memory_order_release = __ATOMIC_RELEASE,
+  memory_order_acq_rel = __ATOMIC_ACQ_REL,
+  memory_order_seq_cst = __ATOMIC_SEQ_CST
+} memory_order;
+
+typedef half __attribute__((ext_vector_type(2))) half2;
+
+// CHECK-LABEL: test_global_add
+// CHECK: call double @llvm.amdgcn.global.atomic.fadd.f64.p1f64.f64(double addrspace(1)* %{{.*}}, double %{{.*}})
+// GFX90A-LABEL:  test_global_add$local:
+// GFX90A:  global_atomic_add_f64
+void test_global_add(__global double *addr, double x) {
+  double *rtn;
+  *rtn = __builtin_amdgcn_global_atomic_fadd_f64(addr, x, memory_order_relaxed);
+}
+
+// CHECK-LABEL: test_global_addf
+// CHECK: call float @llvm.amdgcn.global.atomic.fadd.f32.p1f32.f32(float addrspace(1)* %{{.*}}, float %{{.*}})
+// GFX90A-LABEL:  test_global_addf$local:
+// GFX90A: global_atomic_add_f32
+void test_global_addf(__global float *addr, float x) {
+  float *rtn;
+  *rtn = __builtin_amdgcn_global_atomic_fadd_f32(addr, x, memory_order_relaxed);
+}
+
+// CHECK-LABEL: test_global_add2h
+// CHECK: call <2 x half> @llvm.amdgcn.global.atomic.fadd.v2f16.p1v2f16.v2f16(<2 x half> addrspace(1)* %{{.*}}, <2 x half> %{{.*}})
+// GFX90A-LABEL:  test_global_add2h$local
+// GFX90A: global_atomic_pk_add_f16
+void test_global_add2h(__global half2 *addr, half2 x, __global half2 *out){
+  *out = __builtin_amdgcn_global_atomic_fadd_v2f16(addr, x, memory_order_relaxed);
+}
+
+// CHECK-LABEL: test_global_global_min
+// CHECK: call double @llvm.amdgcn.global.atomic.fmin.f64.p1f64.f64(double addrspace(1)* %{{.*}}, double %{{.*}})
+// GFX90A-LABEL:  test_global_global_min$local
+// GFX90A:  global_atomic_min_f64
+void test_global_global_min(__global double *addr, double x){
+  double *rtn;
+  *rtn = __builtin_amdgcn_global_atomic_fmin_f64(addr, x, memory_order_relaxed);
+}
+
+// CHECK-LABEL: test_global_max
+// CHECK: call double @llvm.amdgcn.global.atomic.fmax.f64.p1f64.f64(double addrspace(1)* %{{.*}}, double %{{.*}})
+// GFX90A-LABEL:  test_global_max$local
+// GFX90A:  global_atomic_max_f64
+void test_global_max(__global double *addr, double x){
+  double *rtn;
+  *rtn = __builtin_amdgcn_global_atomic_fmax_f64(addr, x, memory_order_relaxed);
+}
+
+// CHECK-LABEL: test_flat_add_local
+// CHECK: call double @llvm.amdgcn.flat.atomic.fadd.f64.p3f64.f64(double addrspace(3)* %{{.*}}, double %{{.*}})
+// GFX90A-LABEL:  test_flat_add_local$local
+// GFX90A:  ds_add_rtn_f64
+void test_flat_add_local(__local double *addr, double x){
+  double *rtn;
+  *rtn = __builtin_amdgcn_flat_atomic_fadd_f64(addr, x, memory_order_relaxed);
+}
+
+// CHECK-LABEL: test_flat_global_add
+// CHECK: call double @llvm.amdgcn.flat.atomic.fadd.f64.p1f64.f64(double addrspace(1)* %{{.*}}, double %{{.*}})
+// GFX90A-LABEL:  test_flat_global_add$local
+// GFX90A:  global_atomic_add_f64
+void test_flat_global_add(__global double *addr, double x){
+  double *rtn;
+  *rtn = __builtin_amdgcn_flat_atomic_fadd_f64(addr, x, memory_order_relaxed);
+}
+
+// CHECK-LABEL: test_flat_min_constant
+// CHECK: call double @llvm.amdgcn.flat.atomic.fmin.f64.p0f64.f64(double* %{{.*}}, double %{{.*}})
+// GFX90A-LABEL:  test_flat_min_constant$local
+// GFX90A:  flat_atomic_min_f64
+void test_flat_min_constant(__generic double *addr, double x){
+  double *rtn;
+  *rtn = __builtin_amdgcn_flat_atomic_fmin_f64(addr, x, memory_order_relaxed);
+}
+
+// CHECK-LABEL: test_flat_global_min
+// CHECK: call double @llvm.amdgcn.flat.atomic.fmin.f64.p1f64.f64(double addrspace(1)* %{{.*}}, double %{{.*}})
+// GFX90A:  test_flat_global_min$local
+// GFX90A:  global_atomic_min_f64
+void test_flat_global_min(__global double *addr, double x){
+  double *rtn;
+  *rtn = __builtin_amdgcn_flat_atomic_fmin_f64(addr, x, memory_order_relaxed);
+}
+
+// CHECK-LABEL: test_flat_max_constant
+// CHECK: call double @llvm.amdgcn.flat.atomic.fmax.f64.p0f64.f64(double* %{{.*}}, double %{{.*}})
+// GFX90A-LABEL:  test_flat_max_constant$local
+// GFX90A:  flat_atomic_max_f64
+void test_flat_max_constant(__generic double 

[PATCH] D104556: [InstrProfiling] Make CountersPtr in __profd_ relative

2021-07-31 Thread Fangrui Song 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 rGa1532ed27582: [InstrProfiling] Make CountersPtr in __profd_ 
relative (authored by MaskRay).

Changed prior to commit:
  https://reviews.llvm.org/D104556?vs=356310=363171#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104556

Files:
  clang/test/Profile/c-linkage-available_externally.c
  compiler-rt/include/profile/InstrProfData.inc
  compiler-rt/lib/profile/InstrProfilingMerge.c
  compiler-rt/lib/profile/InstrProfilingWriter.c
  llvm/include/llvm/ProfileData/InstrProfData.inc
  llvm/lib/ProfileData/InstrProfReader.cpp
  llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
  llvm/test/Instrumentation/InstrProfiling/icall.ll
  llvm/test/Instrumentation/InstrProfiling/profiling.ll
  llvm/test/Transforms/PGOProfile/comdat_internal.ll
  llvm/test/Transforms/PGOProfile/indirect_call_profile.ll
  llvm/test/Transforms/PGOProfile/memcpy.ll
  llvm/test/tools/llvm-profdata/Inputs/c-general.profraw
  llvm/test/tools/llvm-profdata/raw-32-bits-be.test
  llvm/test/tools/llvm-profdata/raw-32-bits-le.test
  llvm/test/tools/llvm-profdata/raw-64-bits-be.test
  llvm/test/tools/llvm-profdata/raw-64-bits-le.test

Index: llvm/test/tools/llvm-profdata/raw-64-bits-le.test
===
--- llvm/test/tools/llvm-profdata/raw-64-bits-le.test
+++ llvm/test/tools/llvm-profdata/raw-64-bits-le.test
@@ -19,7 +19,7 @@
 
 RUN: printf '\067\265\035\031\112\165\023\344' >> %t
 RUN: printf '\02\0\0\0\0\0\0\0' >> %t
-RUN: printf '\10\0\4\0\1\0\0\0' >> %t
+RUN: printf '\xd8\xff\3\0\1\0\0\0' >> %t
 RUN: printf '\0\0\0\0\0\0\0\0' >> %t
 RUN: printf '\0\0\0\0\0\0\0\0' >> %t
 RUN: printf '\02\0\0\0\0\0\0\0' >> %t
Index: llvm/test/tools/llvm-profdata/raw-64-bits-be.test
===
--- llvm/test/tools/llvm-profdata/raw-64-bits-be.test
+++ llvm/test/tools/llvm-profdata/raw-64-bits-be.test
@@ -19,7 +19,7 @@
 
 RUN: printf '\344\023\165\112\031\035\265\067' >> %t
 RUN: printf '\0\0\0\0\0\0\0\02' >> %t
-RUN: printf '\0\0\0\1\0\4\0\10' >> %t
+RUN: printf '\0\0\0\1\0\3\xff\xd8' >> %t
 RUN: printf '\0\0\0\0\0\0\0\0' >> %t
 RUN: printf '\0\0\0\0\0\0\0\0' >> %t
 RUN: printf '\0\0\0\02\0\0\0\0' >> %t
Index: llvm/test/tools/llvm-profdata/raw-32-bits-le.test
===
--- llvm/test/tools/llvm-profdata/raw-32-bits-le.test
+++ llvm/test/tools/llvm-profdata/raw-32-bits-le.test
@@ -20,7 +20,7 @@
 
 RUN: printf '\067\265\035\031\112\165\023\344' >> %t
 RUN: printf '\02\0\0\0\0\0\0\0' >> %t
-RUN: printf '\10\0\0\1' >> %t
+RUN: printf '\xe0\xff\xff\0' >> %t
 RUN: printf '\0\0\0\0' >> %t
 RUN: printf '\0\0\0\0' >> %t
 RUN: printf '\2\0\0\0' >> %t
Index: llvm/test/tools/llvm-profdata/raw-32-bits-be.test
===
--- llvm/test/tools/llvm-profdata/raw-32-bits-be.test
+++ llvm/test/tools/llvm-profdata/raw-32-bits-be.test
@@ -20,7 +20,7 @@
 
 RUN: printf '\344\023\165\112\031\035\265\067' >> %t
 RUN: printf '\0\0\0\0\0\0\0\2' >> %t
-RUN: printf '\1\0\0\10' >> %t
+RUN: printf '\0\xff\xff\xe0' >> %t
 RUN: printf '\0\0\0\0' >> %t
 RUN: printf '\0\0\0\0' >> %t
 RUN: printf '\0\0\0\2' >> %t
Index: llvm/test/Transforms/PGOProfile/memcpy.ll
===
--- llvm/test/Transforms/PGOProfile/memcpy.ll
+++ llvm/test/Transforms/PGOProfile/memcpy.ll
@@ -23,7 +23,7 @@
 
 for.body3:
   %conv = sext i32 %add to i64
-; CHECK: call void @__llvm_profile_instrument_memop(i64 %conv, i8* bitcast ({ i64, i64, i64*, i8*, i8*, i32, [2 x i16] }* @__profd_foo to i8*), i32 0)
+; CHECK: call void @__llvm_profile_instrument_memop(i64 %conv, i8* bitcast ({ i64, i64, i64, i8*, i8*, i32, [2 x i16] }* @__profd_foo to i8*), i32 0)
   call void @llvm.memcpy.p0i8.p0i8.i64(i8* %dst, i8* %src, i64 %conv, i1 false)
   %inc = add nsw i32 %j.0, 1
   br label %for.cond1
Index: llvm/test/Transforms/PGOProfile/indirect_call_profile.ll
===
--- llvm/test/Transforms/PGOProfile/indirect_call_profile.ll
+++ llvm/test/Transforms/PGOProfile/indirect_call_profile.ll
@@ -39,7 +39,7 @@
   %tmp = load void ()*, void ()** @bar, align 8
 ; GEN: [[ICALL_TARGET:%[0-9]+]] = ptrtoint void ()* %tmp to i64
 ; GEN-NEXT: call void @llvm.instrprof.value.profile(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @__profn_foo, i32 0, i32 0), i64 [[#FOO_HASH]], i64 [[ICALL_TARGET]], i32 0, i32 0)
-; LOWER: call void @__llvm_profile_instrument_target(i64 %1, i8* bitcast ({ i64, i64, i64*, i8*, i8*, i32, [2 x i16] }* @__profd_foo to i8*), i32 0)
+; LOWER: call void @__llvm_profile_instrument_target(i64 %1, i8* bitcast ({ i64, i64, i64, i8*, i8*, i32, [2 x i16] }* 

[PATCH] D106909: [clang] Add clang builtins support for gfx90a

2021-07-31 Thread Anshil Gandhi via Phabricator via cfe-commits
gandhi21299 updated this revision to Diff 363159.
gandhi21299 marked an inline comment as done.
gandhi21299 added a comment.

addressed reviewers' feedback:

- changed a builtin name,
- corrected tests,
- minor formatting nits


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106909

Files:
  clang/include/clang/Basic/BuiltinsAMDGPU.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGenOpenCL/builtins-fp-atomics.cl

Index: clang/test/CodeGenOpenCL/builtins-fp-atomics.cl
===
--- /dev/null
+++ clang/test/CodeGenOpenCL/builtins-fp-atomics.cl
@@ -0,0 +1,132 @@
+// RUN: %clang_cc1 -O0 -cl-std=CL2.0 -triple amdgcn-amd-amdhsa -target-cpu gfx90a \
+// RUN:   %s -S -emit-llvm -o - | FileCheck %s -check-prefix=CHECK
+
+// RUN: %clang_cc1 -O0 -cl-std=CL2.0 -triple amdgcn-amd-amdhsa -target-cpu gfx90a \
+// RUN:   -S -o - %s | FileCheck -check-prefix=GFX90A %s
+
+
+typedef enum memory_order {
+  memory_order_relaxed = __ATOMIC_RELAXED,
+  memory_order_acquire = __ATOMIC_ACQUIRE,
+  memory_order_release = __ATOMIC_RELEASE,
+  memory_order_acq_rel = __ATOMIC_ACQ_REL,
+  memory_order_seq_cst = __ATOMIC_SEQ_CST
+} memory_order;
+
+typedef half __attribute__((ext_vector_type(2))) half2;
+
+// CHECK-LABEL: test_global_add
+// CHECK: call double @llvm.amdgcn.global.atomic.fadd.f64.p1f64.f64(double addrspace(1)* %{{.*}}, double %{{.*}})
+// GFX90A-LABEL:  test_global_add$local:
+// GFX90A:  global_atomic_add_f64
+void test_global_add(__global double *addr, double x) {
+  double *rtn;
+  *rtn = __builtin_amdgcn_global_atomic_fadd_f64(addr, x, memory_order_relaxed);
+}
+
+// CHECK-LABEL: test_global_addf
+// CHECK: call float @llvm.amdgcn.global.atomic.fadd.f32.p1f32.f32(float addrspace(1)* %{{.*}}, float %{{.*}})
+// GFX90A-LABEL:  test_global_addf$local:
+// GFX90A: global_atomic_add_f32
+void test_global_addf(__global float *addr, float x) {
+  float *rtn;
+  *rtn = __builtin_amdgcn_global_atomic_fadd_f32(addr, x, memory_order_relaxed);
+}
+
+// CHECK-LABEL: test_global_add2h
+// CHECK: call <2 x half> @llvm.amdgcn.global.atomic.fadd.v2f16.p1v2f16.v2f16(<2 x half> addrspace(1)* %{{.*}}, <2 x half> %{{.*}})
+// GFX90A-LABEL:  test_global_add2h$local
+// GFX90A: global_atomic_pk_add_f16
+void test_global_add2h(__global half2 *addr, half2 x, __global half2 *out){
+  *out = __builtin_amdgcn_global_atomic_fadd_v2f16(addr, x, memory_order_relaxed);
+}
+
+// CHECK-LABEL: test_global_global_min
+// CHECK: call double @llvm.amdgcn.global.atomic.fmin.f64.p1f64.f64(double addrspace(1)* %{{.*}}, double %{{.*}})
+// GFX90A-LABEL:  test_global_global_min$local
+// GFX90A:  global_atomic_min_f64
+void test_global_global_min(__global double *addr, double x){
+  double *rtn;
+  *rtn = __builtin_amdgcn_global_atomic_fmin_f64(addr, x, memory_order_relaxed);
+}
+
+// CHECK-LABEL: test_global_max
+// CHECK: call double @llvm.amdgcn.global.atomic.fmax.f64.p1f64.f64(double addrspace(1)* %{{.*}}, double %{{.*}})
+// GFX90A-LABEL:  test_global_max$local
+// GFX90A:  global_atomic_max_f64
+void test_global_max(__global double *addr, double x){
+  double *rtn;
+  *rtn = __builtin_amdgcn_global_atomic_fmax_f64(addr, x, memory_order_relaxed);
+}
+
+// CHECK-LABEL: test_flat_add_local
+// CHECK: call double @llvm.amdgcn.flat.atomic.fadd.f64.p3f64.f64(double addrspace(3)* %{{.*}}, double %{{.*}})
+// GFX90A-LABEL:  test_flat_add_local$local
+// GFX90A:  ds_add_rtn_f64
+void test_flat_add_local(__local double *addr, double x){
+  double *rtn;
+  *rtn = __builtin_amdgcn_flat_atomic_fadd_f64(addr, x, memory_order_relaxed);
+}
+
+// CHECK-LABEL: test_flat_global_add
+// CHECK: call double @llvm.amdgcn.flat.atomic.fadd.f64.p1f64.f64(double addrspace(1)* %{{.*}}, double %{{.*}})
+// GFX90A-LABEL:  test_flat_global_add$local
+// GFX90A:  global_atomic_add_f64
+void test_flat_global_add(__global double *addr, double x){
+  double *rtn;
+  *rtn = __builtin_amdgcn_flat_atomic_fadd_f64(addr, x, memory_order_relaxed);
+}
+
+// CHECK-LABEL: test_flat_min_constant
+// CHECK: call double @llvm.amdgcn.flat.atomic.fmin.f64.p0f64.f64(double* %{{.*}}, double %{{.*}})
+// GFX90A-LABEL:  test_flat_min_constant$local
+// GFX90A:  flat_atomic_min_f64
+void test_flat_min_constant(__generic double *addr, double x){
+  double *rtn;
+  *rtn = __builtin_amdgcn_flat_atomic_fmin_f64(addr, x, memory_order_relaxed);
+}
+
+// CHECK-LABEL: test_flat_global_min
+// CHECK: call double @llvm.amdgcn.flat.atomic.fmin.f64.p1f64.f64(double addrspace(1)* %{{.*}}, double %{{.*}})
+// GFX90A:  test_flat_global_min$local
+// GFX90A:  global_atomic_min_f64
+void test_flat_global_min(__global double *addr, double x){
+  double *rtn;
+  *rtn = __builtin_amdgcn_flat_atomic_fmin_f64(addr, x, memory_order_relaxed);
+}
+
+// CHECK-LABEL: test_flat_max_constant
+// CHECK: call double @llvm.amdgcn.flat.atomic.fmax.f64.p0f64.f64(double* %{{.*}}, double 

[PATCH] D104854: Introduce intrinsic llvm.isnan

2021-07-31 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff added inline comments.



Comment at: llvm/test/Transforms/InstCombine/fpclass.ll:29
+  ret <2 x i1> %t
+}
+

RKSimon wrote:
> You probably need some negative tests (no flags, ninf instead of nnan etc.)?
Added few such tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104854

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


[PATCH] D107049: [clang-repl] Re-implement clang-interpreter as a test case.

2021-07-31 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev updated this revision to Diff 363289.
v.g.vassilev added a comment.

Try to fix the issues reported by the pre-merge-checks. clang-format.


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

https://reviews.llvm.org/D107049

Files:
  clang/docs/ClangFormattedStatus.rst
  clang/examples/CMakeLists.txt
  clang/examples/clang-interpreter/CMakeLists.txt
  clang/examples/clang-interpreter/README.txt
  clang/examples/clang-interpreter/Test.cxx
  clang/examples/clang-interpreter/main.cpp
  clang/include/clang/Interpreter/Interpreter.h
  clang/lib/Interpreter/IncrementalExecutor.cpp
  clang/lib/Interpreter/IncrementalExecutor.h
  clang/lib/Interpreter/Interpreter.cpp
  clang/test/CMakeLists.txt
  clang/test/Misc/interpreter.c
  clang/test/lit.cfg.py
  clang/unittests/Interpreter/CMakeLists.txt
  clang/unittests/Interpreter/InterpreterTest.cpp

Index: clang/unittests/Interpreter/InterpreterTest.cpp
===
--- clang/unittests/Interpreter/InterpreterTest.cpp
+++ clang/unittests/Interpreter/InterpreterTest.cpp
@@ -14,10 +14,14 @@
 
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclGroup.h"
+#include "clang/Basic/Version.h"
+#include "clang/Config/config.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/TextDiagnosticPrinter.h"
 
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/ExecutionEngine/Orc/LLJIT.h"
+#include "llvm/Support/TargetSelect.h"
 
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
@@ -53,6 +57,92 @@
   EXPECT_EQ(1U, DeclsSize(R2.TUPart));
 }
 
+// This function isn't referenced outside its translation unit, but it
+// can't use the "static" keyword because its address is used for
+// GetMainExecutable (since some platforms don't support taking the
+// address of main, and some platforms can't implement GetMainExecutable
+// without being given the address of a function in the main executable).
+std::string GetExecutablePath(const char *Argv0, void *MainAddr) {
+  return llvm::sys::fs::getMainExecutable(Argv0, MainAddr);
+}
+
+static std::string MakeResourcesPath() {
+  // Dir is bin/ or lib/, depending on where BinaryPath is.
+  void *MainAddr = (void *)(intptr_t)GetExecutablePath;
+  std::string BinaryPath = GetExecutablePath(/*Argv0=*/nullptr, MainAddr);
+
+  // build/tools/clang/unittests/Interpreter/Executable -> build/
+  llvm::StringRef Dir = llvm::sys::path::parent_path(BinaryPath);
+
+  Dir = llvm::sys::path::parent_path(Dir);
+  Dir = llvm::sys::path::parent_path(Dir);
+  Dir = llvm::sys::path::parent_path(Dir);
+  Dir = llvm::sys::path::parent_path(Dir);
+  SmallString<128> P(Dir);
+  llvm::sys::path::append(P, Twine("lib") + CLANG_LIBDIR_SUFFIX, "clang",
+  CLANG_VERSION_STRING);
+
+  return std::string(P.str());
+}
+
+#ifdef _MSC_VER
+// Tell the windows linker to export the type_info symbol required by exceptions
+#pragma comment(linker, "/export:??_7type_info@@6B@")
+#endif // _MSC_VER
+TEST(InterpreterTest, CatchException) {
+  llvm::InitializeNativeTarget();
+  llvm::InitializeNativeTargetAsmPrinter();
+
+  {
+auto J = llvm::orc::LLJITBuilder().create();
+if (!J) {
+  // The platform does not support JITs.
+  llvm::consumeError(J.takeError());
+  return;
+}
+  }
+  const char ExceptionCode[] =
+  R"(
+#include 
+#include 
+
+static void ThrowerAnError(const char* Name) {
+  throw std::runtime_error(Name);
+}
+
+int main(int argc, const char** argv) {
+  // FIXME: Somehow when we build this test in release mode argc is not 0.
+  // printf("%d\n", argc);
+  // for (int I = 0; I < argc; ++I)
+  //   printf("arg[%d]='%s'\n", I, argv[I]);
+
+  try {
+ThrowerAnError("In JIT");
+  } catch (const std::exception& E) {
+printf("Caught: '%s'\n", E.what());
+  } catch (...) {
+printf("Unknown exception\n");
+  }
+  ThrowerAnError("From JIT");
+  return 0;
+}
+)";
+  std::string ResourceDir = MakeResourcesPath();
+  std::unique_ptr Interp =
+  createInterpreter({"-resource-dir", ResourceDir.c_str()});
+  // Adjust the resource-dir
+  llvm::cantFail(Interp->ParseAndExecute(ExceptionCode));
+#if !defined(NDEBUG) && GTEST_HAS_DEATH_TEST
+  testing::internal::CaptureStdout();
+  auto Main = (int (*)(...))llvm::cantFail(Interp->getSymbolAddress("main"));
+  // Compiling this file with exceptions on is problematic on some platforms.
+  // Instead we expect std::terminate to be called upon thrown exception.
+  EXPECT_DEATH(Main(), "terminate called after throwing an instance of '.*'");
+  std::string CapturedStdOut = testing::internal::GetCapturedStdout();
+  EXPECT_EQ(CapturedStdOut, "Caught: 'In JIT'\n");
+#endif
+}
+
 static std::string DeclToString(Decl *D) {
   return llvm::cast(D)->getQualifiedNameAsString();
 }
Index: clang/unittests/Interpreter/CMakeLists.txt
===
--- clang/unittests/Interpreter/CMakeLists.txt
+++ 

[PATCH] D94098: [Clang][AArch64] Inline assembly support for the ACLE type 'data512_t'.

2021-07-31 Thread Alexandros Lamprineas 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 rG29b263a34f1a: [Clang][AArch64] Inline assembly support for 
the ACLE type data512_t (authored by labrinea).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94098

Files:
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/CodeGen/TargetInfo.h
  clang/test/CodeGen/aarch64-ls64-inline-asm.c

Index: clang/test/CodeGen/aarch64-ls64-inline-asm.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-ls64-inline-asm.c
@@ -0,0 +1,84 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple aarch64-eabi -target-feature +ls64 -O1 -S -emit-llvm -x c %s -o - | FileCheck %s
+
+struct foo { unsigned long long x[8]; };
+
+// CHECK-LABEL: @load(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = call i512 asm sideeffect "ld64b $0,[$1]", "=r,r,~{memory}"(i8* [[ADDR:%.*]]) #[[ATTR1:[0-9]+]], !srcloc !6
+// CHECK-NEXT:[[TMP1:%.*]] = bitcast %struct.foo* [[OUTPUT:%.*]] to i512*
+// CHECK-NEXT:store i512 [[TMP0]], i512* [[TMP1]], align 8
+// CHECK-NEXT:ret void
+//
+void load(struct foo *output, void *addr)
+{
+__asm__ volatile ("ld64b %0,[%1]" : "=r" (*output) : "r" (addr) : "memory");
+}
+
+// CHECK-LABEL: @store(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = bitcast %struct.foo* [[INPUT:%.*]] to i512*
+// CHECK-NEXT:[[TMP1:%.*]] = load i512, i512* [[TMP0]], align 8
+// CHECK-NEXT:call void asm sideeffect "st64b $0,[$1]", "r,r,~{memory}"(i512 [[TMP1]], i8* [[ADDR:%.*]]) #[[ATTR1]], !srcloc !7
+// CHECK-NEXT:ret void
+//
+void store(const struct foo *input, void *addr)
+{
+__asm__ volatile ("st64b %0,[%1]" : : "r" (*input), "r" (addr) : "memory" );
+}
+
+// CHECK-LABEL: @store2(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = load i32, i32* [[IN:%.*]], align 4, !tbaa [[TBAA8:![0-9]+]]
+// CHECK-NEXT:[[CONV:%.*]] = sext i32 [[TMP0]] to i64
+// CHECK-NEXT:[[ARRAYIDX1:%.*]] = getelementptr inbounds i32, i32* [[IN]], i64 1
+// CHECK-NEXT:[[TMP1:%.*]] = load i32, i32* [[ARRAYIDX1]], align 4, !tbaa [[TBAA8]]
+// CHECK-NEXT:[[CONV2:%.*]] = sext i32 [[TMP1]] to i64
+// CHECK-NEXT:[[ARRAYIDX4:%.*]] = getelementptr inbounds i32, i32* [[IN]], i64 4
+// CHECK-NEXT:[[TMP2:%.*]] = load i32, i32* [[ARRAYIDX4]], align 4, !tbaa [[TBAA8]]
+// CHECK-NEXT:[[CONV5:%.*]] = sext i32 [[TMP2]] to i64
+// CHECK-NEXT:[[ARRAYIDX7:%.*]] = getelementptr inbounds i32, i32* [[IN]], i64 16
+// CHECK-NEXT:[[TMP3:%.*]] = load i32, i32* [[ARRAYIDX7]], align 4, !tbaa [[TBAA8]]
+// CHECK-NEXT:[[CONV8:%.*]] = sext i32 [[TMP3]] to i64
+// CHECK-NEXT:[[ARRAYIDX10:%.*]] = getelementptr inbounds i32, i32* [[IN]], i64 25
+// CHECK-NEXT:[[TMP4:%.*]] = load i32, i32* [[ARRAYIDX10]], align 4, !tbaa [[TBAA8]]
+// CHECK-NEXT:[[CONV11:%.*]] = sext i32 [[TMP4]] to i64
+// CHECK-NEXT:[[ARRAYIDX13:%.*]] = getelementptr inbounds i32, i32* [[IN]], i64 36
+// CHECK-NEXT:[[TMP5:%.*]] = load i32, i32* [[ARRAYIDX13]], align 4, !tbaa [[TBAA8]]
+// CHECK-NEXT:[[CONV14:%.*]] = sext i32 [[TMP5]] to i64
+// CHECK-NEXT:[[ARRAYIDX16:%.*]] = getelementptr inbounds i32, i32* [[IN]], i64 49
+// CHECK-NEXT:[[TMP6:%.*]] = load i32, i32* [[ARRAYIDX16]], align 4, !tbaa [[TBAA8]]
+// CHECK-NEXT:[[CONV17:%.*]] = sext i32 [[TMP6]] to i64
+// CHECK-NEXT:[[ARRAYIDX19:%.*]] = getelementptr inbounds i32, i32* [[IN]], i64 64
+// CHECK-NEXT:[[TMP7:%.*]] = load i32, i32* [[ARRAYIDX19]], align 4, !tbaa [[TBAA8]]
+// CHECK-NEXT:[[CONV20:%.*]] = sext i32 [[TMP7]] to i64
+// CHECK-NEXT:[[S_SROA_10_0_INSERT_EXT:%.*]] = zext i64 [[CONV20]] to i512
+// CHECK-NEXT:[[S_SROA_10_0_INSERT_SHIFT:%.*]] = shl nuw i512 [[S_SROA_10_0_INSERT_EXT]], 448
+// CHECK-NEXT:[[S_SROA_9_0_INSERT_EXT:%.*]] = zext i64 [[CONV17]] to i512
+// CHECK-NEXT:[[S_SROA_9_0_INSERT_SHIFT:%.*]] = shl nuw nsw i512 [[S_SROA_9_0_INSERT_EXT]], 384
+// CHECK-NEXT:[[S_SROA_9_0_INSERT_INSERT:%.*]] = or i512 [[S_SROA_10_0_INSERT_SHIFT]], [[S_SROA_9_0_INSERT_SHIFT]]
+// CHECK-NEXT:[[S_SROA_8_0_INSERT_EXT:%.*]] = zext i64 [[CONV14]] to i512
+// CHECK-NEXT:[[S_SROA_8_0_INSERT_SHIFT:%.*]] = shl nuw nsw i512 [[S_SROA_8_0_INSERT_EXT]], 320
+// CHECK-NEXT:[[S_SROA_8_0_INSERT_INSERT:%.*]] = or i512 [[S_SROA_9_0_INSERT_INSERT]], [[S_SROA_8_0_INSERT_SHIFT]]
+// CHECK-NEXT:[[S_SROA_7_0_INSERT_EXT:%.*]] = zext i64 [[CONV11]] to i512
+// CHECK-NEXT:[[S_SROA_7_0_INSERT_SHIFT:%.*]] = shl nuw nsw i512 [[S_SROA_7_0_INSERT_EXT]], 256
+// CHECK-NEXT:[[S_SROA_7_0_INSERT_INSERT:%.*]] = or i512 [[S_SROA_8_0_INSERT_INSERT]], [[S_SROA_7_0_INSERT_SHIFT]]
+// CHECK-NEXT:

[clang] 29b263a - [Clang][AArch64] Inline assembly support for the ACLE type 'data512_t'

2021-07-31 Thread Alexandros Lamprineas via cfe-commits

Author: Alexandros Lamprineas
Date: 2021-07-31T09:51:28+01:00
New Revision: 29b263a34f1afbae9c95bf48eab7e8aac8132a80

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

LOG: [Clang][AArch64] Inline assembly support for the ACLE type 'data512_t'

In LLVM IR terms the ACLE type 'data512_t' is essentially an aggregate
type { [8 x i64] }. When emitting code for inline assembly operands,
clang tries to scalarize aggregate types to an integer of the equivalent
length, otherwise it passes them by-reference. This patch adds a target
hook to tell whether a given inline assembly operand is scalarizable
so that clang can emit code to pass/return it by-value.

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

Added: 
clang/test/CodeGen/aarch64-ls64-inline-asm.c

Modified: 
clang/lib/Basic/Targets/AArch64.cpp
clang/lib/CodeGen/CGStmt.cpp
clang/lib/CodeGen/TargetInfo.cpp
clang/lib/CodeGen/TargetInfo.h

Removed: 




diff  --git a/clang/lib/Basic/Targets/AArch64.cpp 
b/clang/lib/Basic/Targets/AArch64.cpp
index 4070ac727d165..e163ebfa2348b 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -431,7 +431,8 @@ bool AArch64TargetInfo::hasFeature(StringRef Feature) const 
{
Feature == "sve2-aes" || Feature == "sve2-sha3" ||
Feature == "sve2-sm4" || Feature == "f64mm" || Feature == "f32mm" ||
Feature == "i8mm" || Feature == "bf16") &&
-  (FPU & SveMode));
+  (FPU & SveMode)) ||
+ (Feature == "ls64" && HasLS64);
 }
 
 bool AArch64TargetInfo::handleTargetFeatures(std::vector 
,
@@ -752,6 +753,9 @@ bool AArch64TargetInfo::validateConstraintModifier(
   if (Size == 64)
 return true;
 
+  if (Size == 512)
+return HasLS64;
+
   SuggestedModifier = "w";
   return false;
 }

diff  --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp
index aeb319ca15819..0a3a722fa6533 100644
--- a/clang/lib/CodeGen/CGStmt.cpp
+++ b/clang/lib/CodeGen/CGStmt.cpp
@@ -2097,7 +2097,8 @@ CodeGenFunction::EmitAsmInputLValue(const 
TargetInfo::ConstraintInfo ,
 } else {
   llvm::Type *Ty = ConvertType(InputType);
   uint64_t Size = CGM.getDataLayout().getTypeSizeInBits(Ty);
-  if (Size <= 64 && llvm::isPowerOf2_64(Size)) {
+  if ((Size <= 64 && llvm::isPowerOf2_64(Size)) ||
+  getTargetHooks().isScalarizableAsmOperand(*this, Ty)) {
 Ty = llvm::IntegerType::get(getLLVMContext(), Size);
 Ty = llvm::PointerType::getUnqual(Ty);
 
@@ -2320,23 +2321,28 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt ) {
 
 // If this is a register output, then make the inline asm return it
 // by-value.  If this is a memory result, return the value by-reference.
-bool isScalarizableAggregate =
-hasAggregateEvaluationKind(OutExpr->getType());
-if (!Info.allowsMemory() && (hasScalarEvaluationKind(OutExpr->getType()) ||
- isScalarizableAggregate)) {
+QualType QTy = OutExpr->getType();
+const bool IsScalarOrAggregate = hasScalarEvaluationKind(QTy) ||
+ hasAggregateEvaluationKind(QTy);
+if (!Info.allowsMemory() && IsScalarOrAggregate) {
+
   Constraints += "=" + OutputConstraint;
-  ResultRegQualTys.push_back(OutExpr->getType());
+  ResultRegQualTys.push_back(QTy);
   ResultRegDests.push_back(Dest);
-  ResultTruncRegTypes.push_back(ConvertTypeForMem(OutExpr->getType()));
-  if (Info.allowsRegister() && isScalarizableAggregate) {
-ResultTypeRequiresCast.push_back(true);
-unsigned Size = getContext().getTypeSize(OutExpr->getType());
-llvm::Type *ConvTy = llvm::IntegerType::get(getLLVMContext(), Size);
-ResultRegTypes.push_back(ConvTy);
-  } else {
-ResultTypeRequiresCast.push_back(false);
-ResultRegTypes.push_back(ResultTruncRegTypes.back());
+
+  llvm::Type *Ty = ConvertTypeForMem(QTy);
+  const bool RequiresCast = Info.allowsRegister() &&
+  (getTargetHooks().isScalarizableAsmOperand(*this, Ty) ||
+   Ty->isAggregateType());
+
+  ResultTruncRegTypes.push_back(Ty);
+  ResultTypeRequiresCast.push_back(RequiresCast);
+
+  if (RequiresCast) {
+unsigned Size = getContext().getTypeSize(QTy);
+Ty = llvm::IntegerType::get(getLLVMContext(), Size);
   }
+  ResultRegTypes.push_back(Ty);
   // If this output is tied to an input, and if the input is larger, then
   // we need to set the actual result type of the inline asm node to be the
   // same as the input type.
@@ -2638,11 +2644,11 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt ) {
   assert(ResultTypeRequiresCast.size() <= ResultRegDests.size());