[PATCH] D63174: [clang][NewPM] Add RUNS for tests that produce slightly different IR under new PM

2019-07-29 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan abandoned this revision.
leonardchan added a comment.

Replaced with D65110 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63174



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


[PATCH] D63174: [clang][NewPM] Add RUNS for tests that produce slightly different IR under new PM

2019-06-21 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

In D63174#1553096 , @craig.topper 
wrote:

> I'm going to try to work on the X86 tests. Can we hold off on committing 
> those?


Ok. For now I'll just commit the convergent.cl test separately.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63174



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


[PATCH] D63174: [clang][NewPM] Add RUNS for tests that produce slightly different IR under new PM

2019-06-20 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

I'm going to try to work on the X86 tests. Can we hold off on committing those?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63174



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


[PATCH] D63174: [clang][NewPM] Add RUNS for tests that produce slightly different IR under new PM

2019-06-20 Thread Chandler Carruth via Phabricator via cfe-commits
chandlerc accepted this revision.
chandlerc added a comment.
This revision is now accepted and ready to land.

Eh, this seems close enough now. I'd like a better approach for the x86 
builtins, but no idea what it will end up being.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63174



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


[PATCH] D63174: [clang][NewPM] Add RUNS for tests that produce slightly different IR under new PM

2019-06-19 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 205727.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63174

Files:
  clang/test/CodeGen/avx512-reduceMinMaxIntrin.c
  clang/test/CodeGen/avx512f-builtins.c
  clang/test/CodeGen/avx512vl-builtins.c
  clang/test/CodeGen/avx512vlbw-builtins.c
  clang/test/CodeGenOpenCL/convergent.cl

Index: clang/test/CodeGenOpenCL/convergent.cl
===
--- clang/test/CodeGenOpenCL/convergent.cl
+++ clang/test/CodeGenOpenCL/convergent.cl
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -triple spir-unknown-unknown -emit-llvm %s -o - | opt -instnamer -S | FileCheck -enable-var-scope %s
+// RUN: %clang_cc1 -triple spir-unknown-unknown -emit-llvm %s -o - -fno-experimental-new-pass-manager | opt -instnamer -S | FileCheck -enable-var-scope %s --check-prefixes=CHECK,CHECK-LEGACY
+// RUN: %clang_cc1 -triple spir-unknown-unknown -emit-llvm %s -o - -fexperimental-new-pass-manager | opt -instnamer -S | FileCheck -enable-var-scope %s --check-prefixes=CHECK,CHECK-NEWPM
 
 // This is initially assumed convergent, but can be deduced to not require it.
 
@@ -117,7 +118,12 @@
 // CHECK: [[for_body]]:
 // CHECK:  tail call spir_func void @nodupfun() #[[attr5:[0-9]+]]
 // CHECK-NOT: call spir_func void @nodupfun()
-// CHECK:  br i1 %{{.+}}, label %[[for_body]], label %[[for_cond_cleanup]]
+
+// The new PM produces a slightly different IR for the loop from the legacy PM,
+// but the test still checks that the loop is not unrolled.
+// CHECK-LEGACY:  br i1 %{{.+}}, label %[[for_body]], label %[[for_cond_cleanup]]
+// CHECK-NEW: br i1 %{{.+}}, label %[[for_body_crit_edge:.+]], label %[[for_cond_cleanup]]
+// CHECK-NEW: [[for_body_crit_edge]]:
 
 void test_not_unroll() {
   for (int i = 0; i < 10; i++)
Index: clang/test/CodeGen/avx512vlbw-builtins.c
===
--- clang/test/CodeGen/avx512vlbw-builtins.c
+++ clang/test/CodeGen/avx512vlbw-builtins.c
@@ -1,6 +1,10 @@
-// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +avx512bw -target-feature +avx512vl -emit-llvm -o - -Wall -Werror | FileCheck %s
-// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +avx512bw -target-feature +avx512vl -fno-signed-char -emit-llvm -o - -Wall -Werror | FileCheck %s
+// RUN: %clang_cc1 -ffreestanding %s -fno-experimental-new-pass-manager -triple=x86_64-apple-darwin -target-feature +avx512bw -target-feature +avx512vl -emit-llvm -o - -Wall -Werror | FileCheck %s
+// RUN: %clang_cc1 -ffreestanding %s -fno-experimental-new-pass-manager -triple=x86_64-apple-darwin -target-feature +avx512bw -target-feature +avx512vl -fno-signed-char -emit-llvm -o - -Wall -Werror | FileCheck %s
 
+// There are a few cases where instead accpeting the result of an instruction
+// directly as an argument to a select, it instead goes through some bitcasts.
+// RUN: %clang_cc1 -ffreestanding %s -fexperimental-new-pass-manager -triple=x86_64-apple-darwin -target-feature +avx512bw -target-feature +avx512vl -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes=CHECK,CHECK-NEWPM
+// RUN: %clang_cc1 -ffreestanding %s -fexperimental-new-pass-manager -triple=x86_64-apple-darwin -target-feature +avx512bw -target-feature +avx512vl -fno-signed-char -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes=CHECK,CHECK-NEWPM
 
 #include 
 
@@ -901,6 +905,8 @@
   // CHECK: [[SUB:%.*]] = sub <16 x i8> zeroinitializer, [[A:%.*]]
   // CHECK: [[CMP:%.*]] = icmp sgt <16 x i8> [[A]], zeroinitializer
   // CHECK: [[SEL:%.*]] = select <16 x i1> [[CMP]], <16 x i8> [[A]], <16 x i8> [[SUB]]
+  // CHECK-NEWPM: [[TMP:%.*]] = bitcast [[SRCTY:<.*>]] [[SEL]] to [[DSTTY:<.*>]]
+  // CHECK-NEWPM: [[SEL:%.*]] = bitcast [[DSTTY]] [[TMP]] to [[SRCTY]]
   // CHECK: select <16 x i1> %{{.*}}, <16 x i8> [[SEL]], <16 x i8> %{{.*}}
   return _mm_mask_abs_epi8(__W,__U,__A); 
 }
@@ -910,6 +916,8 @@
   // CHECK: [[SUB:%.*]] = sub <16 x i8> zeroinitializer, [[A:%.*]]
   // CHECK: [[CMP:%.*]] = icmp sgt <16 x i8> [[A]], zeroinitializer
   // CHECK: [[SEL:%.*]] = select <16 x i1> [[CMP]], <16 x i8> [[A]], <16 x i8> [[SUB]]
+  // CHECK-NEWPM: [[TMP:%.*]] = bitcast [[SRCTY:<.*>]] [[SEL]] to [[DSTTY:<.*>]]
+  // CHECK-NEWPM: [[SEL:%.*]] = bitcast [[DSTTY]] [[TMP]] to [[SRCTY]]
   // CHECK: select <16 x i1> %{{.*}}, <16 x i8> [[SEL]], <16 x i8> %{{.*}}
   return _mm_maskz_abs_epi8(__U,__A); 
 }
@@ -919,6 +927,8 @@
   // CHECK: [[SUB:%.*]] = sub <32 x i8> zeroinitializer, [[A:%.*]]
   // CHECK: [[CMP:%.*]] = icmp sgt <32 x i8> [[A]], zeroinitializer
   // CHECK: [[SEL:%.*]] = select <32 x i1> [[CMP]], <32 x i8> [[A]], <32 x i8> [[SUB]]
+  // CHECK-NEWPM: [[TMP:%.*]] = bitcast [[SRCTY:<.*>]] [[SEL]] to [[DSTTY:<.*>]]
+  // CHECK-NEWPM: [[SEL:%.*]] = bitcast [[DSTTY]] [[TMP]] to [[SRCTY]]
   // CHECK: select <32 x i1> %{{.*}}, <32 x i8> 

[PATCH] D63174: [clang][NewPM] Add RUNS for tests that produce slightly different IR under new PM

2019-06-19 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

In D63174#1549601 , @chandlerc wrote:

> OMG, I'm so sorry, I had no idea that the tests would explode like that... 
> Yeah, I don't think that's useful
>
> Maybe a better approach is to just explicitly run the code through `opt 
> -passes=instsimplify` before handing it to FileCheck? That should produce 
> almost identical results to the old PM's inliner?
>
> Feel free to just try this out and report back -- if it isn't looking good, 
> don't invest a bunch of time in it, we should talk to Craig and figure out 
> what the right long-term strategy here is.


Hmm so `-instsimplify` and combinations of other passes like `intsnamer` and 
`instcombine` don't seem to clean this up any further. The IR still differs 
between PMs (at -O0), and I can provide the diffs if necessary.

In the short term, I imagine an "ok" solution for now would be to just run the 
original tests with `-fno-experimental-new-pas-manager`, and either have a 
separate file with these new PM `-O1` checks at or separate runs in the same 
file to prevent regressions. I emailed Craig for his insight and info on these 
tests.

For now I reverted back to an early diff for this with the -O0 tests only.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63174



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


[PATCH] D63174: [clang][NewPM] Add RUNS for tests that produce slightly different IR under new PM

2019-06-19 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 205722.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63174

Files:
  clang/test/CodeGen/avx512-reduceMinMaxIntrin.c
  clang/test/CodeGen/avx512f-builtins.c
  clang/test/CodeGen/avx512vl-builtins.c
  clang/test/CodeGen/avx512vlbw-builtins.c
  clang/test/CodeGenOpenCL/convergent.cl

Index: clang/test/CodeGenOpenCL/convergent.cl
===
--- clang/test/CodeGenOpenCL/convergent.cl
+++ clang/test/CodeGenOpenCL/convergent.cl
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -triple spir-unknown-unknown -emit-llvm %s -o - | opt -instnamer -S | FileCheck -enable-var-scope %s
+// RUN: %clang_cc1 -triple spir-unknown-unknown -emit-llvm %s -o - -fno-experimental-new-pass-manager | opt -instnamer -S | FileCheck -enable-var-scope %s --check-prefixes=CHECK,CHECK-LEGACY
+// RUN: %clang_cc1 -triple spir-unknown-unknown -emit-llvm %s -o - -fexperimental-new-pass-manager | opt -instnamer -S | FileCheck -enable-var-scope %s --check-prefixes=CHECK,CHECK-NEWPM
 
 // This is initially assumed convergent, but can be deduced to not require it.
 
@@ -117,7 +118,12 @@
 // CHECK: [[for_body]]:
 // CHECK:  tail call spir_func void @nodupfun() #[[attr5:[0-9]+]]
 // CHECK-NOT: call spir_func void @nodupfun()
-// CHECK:  br i1 %{{.+}}, label %[[for_body]], label %[[for_cond_cleanup]]
+
+// The new PM produces a slightly different IR for the loop from the legacy PM,
+// but the test still checks that the loop is not unrolled.
+// CHECK-LEGACY:  br i1 %{{.+}}, label %[[for_body]], label %[[for_cond_cleanup]]
+// CHECK-NEW: br i1 %{{.+}}, label %[[for_body_crit_edge:.+]], label %[[for_cond_cleanup]]
+// CHECK-NEW: [[for_body_crit_edge]]:
 
 void test_not_unroll() {
   for (int i = 0; i < 10; i++)
Index: clang/test/CodeGen/avx512vlbw-builtins.c
===
--- clang/test/CodeGen/avx512vlbw-builtins.c
+++ clang/test/CodeGen/avx512vlbw-builtins.c
@@ -1,6 +1,10 @@
-// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +avx512bw -target-feature +avx512vl -emit-llvm -o - -Wall -Werror | FileCheck %s
-// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +avx512bw -target-feature +avx512vl -fno-signed-char -emit-llvm -o - -Wall -Werror | FileCheck %s
+// RUN: %clang_cc1 -ffreestanding %s -fno-experimental-new-pass-manager -triple=x86_64-apple-darwin -target-feature +avx512bw -target-feature +avx512vl -emit-llvm -o - -Wall -Werror | FileCheck %s
+// RUN: %clang_cc1 -ffreestanding %s -fno-experimental-new-pass-manager -triple=x86_64-apple-darwin -target-feature +avx512bw -target-feature +avx512vl -fno-signed-char -emit-llvm -o - -Wall -Werror | FileCheck %s
 
+// There are a few cases where instead accpeting the result of an instruction
+// directly as an argument to a select, it instead goes through some bitcasts.
+// RUN: %clang_cc1 -ffreestanding %s -fexperimental-new-pass-manager -triple=x86_64-apple-darwin -target-feature +avx512bw -target-feature +avx512vl -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes=CHECK,CHECK-NEWPM
+// RUN: %clang_cc1 -ffreestanding %s -fexperimental-new-pass-manager -triple=x86_64-apple-darwin -target-feature +avx512bw -target-feature +avx512vl -fno-signed-char -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes=CHECK,CHECK-NEWPM
 
 #include 
 
@@ -901,6 +905,8 @@
   // CHECK: [[SUB:%.*]] = sub <16 x i8> zeroinitializer, [[A:%.*]]
   // CHECK: [[CMP:%.*]] = icmp sgt <16 x i8> [[A]], zeroinitializer
   // CHECK: [[SEL:%.*]] = select <16 x i1> [[CMP]], <16 x i8> [[A]], <16 x i8> [[SUB]]
+  // CHECK-NEWPM: [[TMP:%.*]] = bitcast [[SRCTY:<.*>]] [[SEL]] to [[DSTTY:<.*>]]
+  // CHECK-NEWPM: [[SEL:%.*]] = bitcast [[DSTTY]] [[TMP]] to [[SRCTY]]
   // CHECK: select <16 x i1> %{{.*}}, <16 x i8> [[SEL]], <16 x i8> %{{.*}}
   return _mm_mask_abs_epi8(__W,__U,__A); 
 }
@@ -910,6 +916,8 @@
   // CHECK: [[SUB:%.*]] = sub <16 x i8> zeroinitializer, [[A:%.*]]
   // CHECK: [[CMP:%.*]] = icmp sgt <16 x i8> [[A]], zeroinitializer
   // CHECK: [[SEL:%.*]] = select <16 x i1> [[CMP]], <16 x i8> [[A]], <16 x i8> [[SUB]]
+  // CHECK-NEWPM: [[TMP:%.*]] = bitcast [[SRCTY:<.*>]] [[SEL]] to [[DSTTY:<.*>]]
+  // CHECK-NEWPM: [[SEL:%.*]] = bitcast [[DSTTY]] [[TMP]] to [[SRCTY]]
   // CHECK: select <16 x i1> %{{.*}}, <16 x i8> [[SEL]], <16 x i8> %{{.*}}
   return _mm_maskz_abs_epi8(__U,__A); 
 }
@@ -919,6 +927,8 @@
   // CHECK: [[SUB:%.*]] = sub <32 x i8> zeroinitializer, [[A:%.*]]
   // CHECK: [[CMP:%.*]] = icmp sgt <32 x i8> [[A]], zeroinitializer
   // CHECK: [[SEL:%.*]] = select <32 x i1> [[CMP]], <32 x i8> [[A]], <32 x i8> [[SUB]]
+  // CHECK-NEWPM: [[TMP:%.*]] = bitcast [[SRCTY:<.*>]] [[SEL]] to [[DSTTY:<.*>]]
+  // CHECK-NEWPM: [[SEL:%.*]] = bitcast [[DSTTY]] [[TMP]] to [[SRCTY]]
   // CHECK: select <32 x i1> %{{.*}}, <32 x i8> 

[PATCH] D63174: [clang][NewPM] Add RUNS for tests that produce slightly different IR under new PM

2019-06-19 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 205707.
Herald added subscribers: dexonsmith, steven_wu, javed.absar, mehdi_amini.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63174

Files:
  clang/test/CodeGen/aggregate-assign-call.c
  clang/test/CodeGen/arm_acle.c
  clang/test/CodeGen/cspgo-instrumentation.c
  clang/test/CodeGen/cspgo-instrumentation_lto.c
  clang/test/CodeGen/cspgo-instrumentation_thinlto.c
  clang/test/CodeGen/pgo-instrumentation.c
  clang/test/CodeGen/pgo-sample.c
  clang/test/CodeGen/thinlto-debug-pm.c
  clang/test/CodeGenCXX/auto-var-init.cpp
  clang/test/CodeGenCXX/conditional-temporaries.cpp
  clang/test/CodeGenCXX/member-function-pointer-calls.cpp
  clang/test/CodeGenObjC/os_log.m
  clang/test/CodeGenObjCXX/os_log.mm
  clang/test/Misc/pr32207.c

Index: clang/test/Misc/pr32207.c
===
--- clang/test/Misc/pr32207.c
+++ clang/test/Misc/pr32207.c
@@ -1,4 +1,4 @@
 // test for r305179
-// RUN: %clang_cc1 -emit-llvm -O -mllvm -print-after-all %s -o %t 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -O2 -fno-experimental-new-pass-manager -mllvm -print-after-all %s -o %t 2>&1 | FileCheck %s
 // CHECK: *** IR Dump After Function Integration/Inlining ***
 void foo() {}
Index: clang/test/CodeGenObjCXX/os_log.mm
===
--- clang/test/CodeGenObjCXX/os_log.mm
+++ clang/test/CodeGenObjCXX/os_log.mm
@@ -1,5 +1,7 @@
 // RUN: %clang_cc1 %s -emit-llvm -o - -triple x86_64-darwin-apple -fobjc-arc \
-// RUN:   -fexceptions -fcxx-exceptions -O1 | FileCheck %s
+// RUN:   -fexceptions -fcxx-exceptions -O1 -fno-experimental-new-pass-manager | FileCheck %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple x86_64-darwin-apple -fobjc-arc \
+// RUN:   -fexceptions -fcxx-exceptions -O1 -fexperimental-new-pass-manager -fno-inline | FileCheck %s
 
 // Check that no EH cleanup is emitted around the call to __os_log_helper.
 namespace no_eh_cleanup {
Index: clang/test/CodeGenObjC/os_log.m
===
--- clang/test/CodeGenObjC/os_log.m
+++ clang/test/CodeGenObjC/os_log.m
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 %s -emit-llvm -o - -triple x86_64-darwin-apple -fobjc-arc -O2 | FileCheck %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple x86_64-darwin-apple -fobjc-arc -O2 -fno-experimental-new-pass-manager | FileCheck %s --check-prefixes=CHECK,CHECK-LEGACY
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple x86_64-darwin-apple -fobjc-arc -O2 -fexperimental-new-pass-manager | FileCheck %s --check-prefixes=CHECK,CHECK-NEWPM
 // RUN: %clang_cc1 %s -emit-llvm -o - -triple x86_64-darwin-apple -fobjc-arc -O0 | FileCheck %s -check-prefix=CHECK-O0
 
 // Make sure we emit clang.arc.use before calling objc_release as part of the
@@ -22,7 +23,8 @@
   // CHECK: %[[CALL:.*]] = tail call %[[TY0:.*]]* (...) @GenString()
   // CHECK: %[[V0:.*]] = bitcast %[[TY0]]* %[[CALL]] to i8*
   // CHECK: %[[V1:.*]] = notail call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* %[[V0]])
-  // CHECK: %[[V2:.*]] = ptrtoint %[[TY0]]* %[[CALL]] to i64
+  // CHECK-LEGACY: %[[V2:.*]] = ptrtoint %[[TY0]]* %[[CALL]] to i64
+  // CHECK-NEWPM: %[[V2:.*]] = ptrtoint i8* %[[V1]] to i64
   // CHECK: store i8 2, i8* %[[BUF]], align 1
   // CHECK: %[[NUMARGS_I:.*]] = getelementptr i8, i8* %[[BUF]], i64 1
   // CHECK: store i8 1, i8* %[[NUMARGS_I]], align 1
@@ -33,8 +35,10 @@
   // CHECK: %[[ARGDATA_I:.*]] = getelementptr i8, i8* %[[BUF]], i64 4
   // CHECK: %[[ARGDATACAST_I:.*]] = bitcast i8* %[[ARGDATA_I]] to i64*
   // CHECK: store i64 %[[V2]], i64* %[[ARGDATACAST_I]], align 1
-  // CHECK: tail call void (...) @llvm.objc.clang.arc.use(%[[TY0]]* %[[CALL]])
-  // CHECK: tail call void @llvm.objc.release(i8* %[[V0]])
+  // CHECK-LEGACY: tail call void (...) @llvm.objc.clang.arc.use(%[[TY0]]* %[[CALL]])
+  // CHECK-LEGACY: tail call void @llvm.objc.release(i8* %[[V0]])
+  // CHECK-NEWPM: tail call void (...) @llvm.objc.clang.arc.use(i8* %[[V1]])
+  // CHECK-NEWPM: tail call void @llvm.objc.release(i8* %[[V1]])
   // CHECK: ret i8* %[[BUF]]
 
   // clang.arc.use is used and removed in IR optimizations. At O0, we should not
Index: clang/test/CodeGenCXX/member-function-pointer-calls.cpp
===
--- clang/test/CodeGenCXX/member-function-pointer-calls.cpp
+++ clang/test/CodeGenCXX/member-function-pointer-calls.cpp
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -O3 -o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -O3 -fno-experimental-new-pass-manager  -o - | FileCheck %s --check-prefixes=CHECK,CHECK-LEGACY
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -O3 -fexperimental-new-pass-manager  -o - | FileCheck %s --check-prefixes=CHECK,CHECK-NEWPM
 // RUN: %clang_cc1 %s 

[PATCH] D63174: [clang][NewPM] Add RUNS for tests that produce slightly different IR under new PM

2019-06-18 Thread Chandler Carruth via Phabricator via cfe-commits
chandlerc added a comment.

OMG, I'm so sorry, I had no idea that the tests would explode like that... 
Yeah, I don't think that's useful

Maybe a better approach is to just explicitly run the code through `opt 
-passes=instsimplify` before handing it to FileCheck? That should produce 
almost identical results to the old PM's inliner?

Feel free to just try this out and report back -- if it isn't looking good, 
don't invest a bunch of time in it, we should talk to Craig and figure out what 
the right long-term strategy here is.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63174



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


[PATCH] D63174: [clang][NewPM] Add RUNS for tests that produce slightly different IR under new PM

2019-06-18 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

OK so I instead wrote a script that generated the tests for me since changing 
each individual case by hand was painful. All the `-cc1` tests now match, 
although I don't know any ways of simplifying the IR further to help reduce 
test size. I would definitely love to know if there are any ways to simplify 
the instructions. Unfortunately for `convergent.cl`, the codegen still differs 
slightly around the end of the loop when using `-instcombine` in addition to 
`instnamer`:

  < for.body: ; preds = %for.body, 
%entry
  <   %i.03 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
  ---
  > for.body: ; preds = 
%for.body.for.body_crit_edge, %entry
  >   %inc.phi = phi i32 [ 1, %entry ], [ %inc.1, %for.body.for.body_crit_edge ]
  92,94c92,97
  <   %inc = add nuw nsw i32 %i.03, 1
  <   %cmp = icmp ult i32 %inc, 10
  <   br i1 %cmp, label %for.body, label %for.cond.cleanup
  ---
  >   %cmp = icmp ult i32 %inc.phi, 10
  >   br i1 %cmp, label %for.body.for.body_crit_edge, label %for.cond.cleanup
  > 
  > for.body.for.body_crit_edge:  ; preds = %for.body
  >   %inc.1 = add nuw nsw i32 %inc.phi, 1
  >   br label %for.body

Also adding @craig.topper in case he as any insight on the updated tests.




Comment at: clang/test/CodeGenOpenCL/convergent.cl:2
+// RUN: %clang_cc1 -triple spir-unknown-unknown -emit-llvm %s -o - 
-fno-experimental-new-pass-manager | opt -instnamer -S | FileCheck 
-enable-var-scope %s --check-prefixes=CHECK,CHECK-LEGACY
+// RUN: %clang_cc1 -triple spir-unknown-unknown -emit-llvm %s -o - 
-fexperimental-new-pass-manager | opt -instnamer -S | FileCheck 
-enable-var-scope %s --check-prefixes=CHECK,CHECK-NEWPM
 

chandlerc wrote:
> Probably want to use `opt -passes=instnamer` or some such to use the new PM 
> in the `opt` invocation as well...
Unfortunately there doesn't seem to be a new PM equivalent for `instnamer` (but 
one does exist for `instcombine`). For simplicity, should we stick with using 
the legacy driver for now?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63174



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


[PATCH] D63174: [clang][NewPM] Add RUNS for tests that produce slightly different IR under new PM

2019-06-18 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 205496.
leonardchan marked an inline comment as done.
leonardchan added a reviewer: craig.topper.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63174

Files:
  clang/test/CodeGen/avx512-reduceMinMaxIntrin.c
  clang/test/CodeGen/avx512f-builtins.c
  clang/test/CodeGen/avx512vl-builtins.c
  clang/test/CodeGen/avx512vlbw-builtins.c
  clang/test/CodeGenOpenCL/convergent.cl



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


[PATCH] D63174: [clang][NewPM] Add RUNS for tests that produce slightly different IR under new PM

2019-06-14 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

For the avx tests, I don't suppose you know a simple way to generate these 
tests? They're about 10k lines long and it's taking a while to go through it by 
hand to replace the current IR checks with codegen for `-O1`.  (Perhaps 
something along the lines of `utils/update_llc_test_checks.py` in llvm?)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63174



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


[PATCH] D63174: [clang][NewPM] Add RUNS for tests that produce slightly different IR under new PM

2019-06-14 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63174



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


[PATCH] D63174: [clang][NewPM] Add RUNS for tests that produce slightly different IR under new PM

2019-06-12 Thread Chandler Carruth via Phabricator via cfe-commits
chandlerc added a comment.

This really confused me. We shouldn't be seeing this kind of difference in the 
new PM.

But I think I figured it out.

Both PMs have to run *some* inliner at -O0. This is because we need to inline 
`always_inline` functions. The new PM has a *super* simple (and fast 
compile-time wise) inliner designed for this. It's really good at its job. The 
old PM runs the normal inliner. This thing isn't simple at all. It does complex 
stuff to incrementally simplify code while inlining because that can have a 
huge effect on the overall efficiency of the compiler *when doing full 
optimization passes*. But we're not doing that.

The result is that because all of these tests check code that is emitted by 
`always_inline` functions in our builtin headers, and then *inlined* into the 
test functions, the inliner in the old pass manager did a bunch of "cleanup" of 
the code that the new PM doesn't do.

Honestly, I think the new PM's behavior is correct for -O0, but I think it 
makes these tests less easy to understand. I think we should instead change the 
command running here, and when we do I think we will find a set of checks that 
work for both PMs.

When we are willing to do something like run `opt` in addition to clang (the 
`convergent.cl` case), instead of just doing `-instnamer` we should also do 
`-instcombine`. I suspect this will remove the differences.

When we're just directly using `%clang_cc1` I suspect that rather than checking 
the completely unoptimized code we should check with `-O1` to make the IR much 
more stable and easy to inspect. It should also result in identical results 
from the two PMs.




Comment at: clang/test/CodeGenOpenCL/convergent.cl:2
+// RUN: %clang_cc1 -triple spir-unknown-unknown -emit-llvm %s -o - 
-fno-experimental-new-pass-manager | opt -instnamer -S | FileCheck 
-enable-var-scope %s --check-prefixes=CHECK,CHECK-LEGACY
+// RUN: %clang_cc1 -triple spir-unknown-unknown -emit-llvm %s -o - 
-fexperimental-new-pass-manager | opt -instnamer -S | FileCheck 
-enable-var-scope %s --check-prefixes=CHECK,CHECK-NEWPM
 

Probably want to use `opt -passes=instnamer` or some such to use the new PM in 
the `opt` invocation as well...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63174



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


[PATCH] D63174: [clang][NewPM] Add RUNS for tests that produce slightly different IR under new PM

2019-06-11 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan created this revision.
leonardchan added reviewers: chandlerc, echristo, phosek, serge-sans-paille.
leonardchan added a project: clang.
Herald added subscribers: dmgreen, Anastasia.

With the new pass manager enabled by default, some tests produce slightly 
different IR from the legacy PM. This patch just adds separate new PM runs and 
checks for the new PM IR.

This fixes:

  Clang :: CodeGen/avx512-reduceMinMaxIntrin.c
  Clang :: CodeGen/avx512f-builtins.c
  Clang :: CodeGen/avx512vl-builtins.c
  Clang :: CodeGen/avx512vlbw-builtins.c
  Clang :: CodeGenOpenCL/convergent.cl

For `CodeGenOpenCL/convergent.cl`, the new PM produced a slightly different for 
loop, but this still checks for no loop unrolling as intended.

For the avx-builtins tests, the new PM would produce extra bitcasts that did 
not affect the overall logic of the function, but I do not know a simple way to 
get rid of these bitcasts.

For `CodeGen/avx512-reduceMinMaxIntrin.c`, temporary local variables are 
produced in the codegen, but the allocas are out of order and the tests were 
pretty strict on order even though the logic/use of these variables was the 
same. Nearly all checks in this large file were broken, so I was hoping we 
could  run it with legacy only for now and come back to it later to make this 
easier.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D63174

Files:
  clang/test/CodeGen/avx512-reduceMinMaxIntrin.c
  clang/test/CodeGen/avx512f-builtins.c
  clang/test/CodeGen/avx512vl-builtins.c
  clang/test/CodeGen/avx512vlbw-builtins.c
  clang/test/CodeGenOpenCL/convergent.cl

Index: clang/test/CodeGenOpenCL/convergent.cl
===
--- clang/test/CodeGenOpenCL/convergent.cl
+++ clang/test/CodeGenOpenCL/convergent.cl
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -triple spir-unknown-unknown -emit-llvm %s -o - | opt -instnamer -S | FileCheck -enable-var-scope %s
+// RUN: %clang_cc1 -triple spir-unknown-unknown -emit-llvm %s -o - -fno-experimental-new-pass-manager | opt -instnamer -S | FileCheck -enable-var-scope %s --check-prefixes=CHECK,CHECK-LEGACY
+// RUN: %clang_cc1 -triple spir-unknown-unknown -emit-llvm %s -o - -fexperimental-new-pass-manager | opt -instnamer -S | FileCheck -enable-var-scope %s --check-prefixes=CHECK,CHECK-NEWPM
 
 // This is initially assumed convergent, but can be deduced to not require it.
 
@@ -117,7 +118,12 @@
 // CHECK: [[for_body]]:
 // CHECK:  tail call spir_func void @nodupfun() #[[attr5:[0-9]+]]
 // CHECK-NOT: call spir_func void @nodupfun()
-// CHECK:  br i1 %{{.+}}, label %[[for_body]], label %[[for_cond_cleanup]]
+
+// The new PM produces a slightly different IR for the loop from the legacy PM,
+// but the test still checks that the loop is not unrolled.
+// CHECK-LEGACY:  br i1 %{{.+}}, label %[[for_body]], label %[[for_cond_cleanup]]
+// CHECK-NEW: br i1 %{{.+}}, label %[[for_body_crit_edge:.+]], label %[[for_cond_cleanup]]
+// CHECK-NEW: [[for_body_crit_edge]]:
 
 void test_not_unroll() {
   for (int i = 0; i < 10; i++)
Index: clang/test/CodeGen/avx512vlbw-builtins.c
===
--- clang/test/CodeGen/avx512vlbw-builtins.c
+++ clang/test/CodeGen/avx512vlbw-builtins.c
@@ -1,6 +1,10 @@
-// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +avx512bw -target-feature +avx512vl -emit-llvm -o - -Wall -Werror | FileCheck %s
-// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +avx512bw -target-feature +avx512vl -fno-signed-char -emit-llvm -o - -Wall -Werror | FileCheck %s
+// RUN: %clang_cc1 -ffreestanding %s -fno-experimental-new-pass-manager -triple=x86_64-apple-darwin -target-feature +avx512bw -target-feature +avx512vl -emit-llvm -o - -Wall -Werror | FileCheck %s
+// RUN: %clang_cc1 -ffreestanding %s -fno-experimental-new-pass-manager -triple=x86_64-apple-darwin -target-feature +avx512bw -target-feature +avx512vl -fno-signed-char -emit-llvm -o - -Wall -Werror | FileCheck %s
 
+// There are a few cases where instead accpeting the result of an instruction
+// directly as an argument to a select, it instead goes through some bitcasts.
+// RUN: %clang_cc1 -ffreestanding %s -fexperimental-new-pass-manager -triple=x86_64-apple-darwin -target-feature +avx512bw -target-feature +avx512vl -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes=CHECK,CHECK-NEWPM
+// RUN: %clang_cc1 -ffreestanding %s -fexperimental-new-pass-manager -triple=x86_64-apple-darwin -target-feature +avx512bw -target-feature +avx512vl -fno-signed-char -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes=CHECK,CHECK-NEWPM
 
 #include 
 
@@ -901,6 +905,8 @@
   // CHECK: [[SUB:%.*]] = sub <16 x i8> zeroinitializer, [[A:%.*]]
   // CHECK: [[CMP:%.*]] = icmp sgt <16 x i8> [[A]], zeroinitializer
   // CHECK: [[SEL:%.*]] = select <16 x i1> [[CMP]], <16 x i8> [[A]], <16 x i8> [[SUB]]
+  // CHECK-NEWPM: [[TMP:%.*]] = bitcast