[PATCH] D121171: [flang] Add ExternalNameConversionPass to flang-new pipeline

Diana Picus via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 7 15:48:42 PST 2022


rovka created this revision.
rovka added reviewers: awarzynski, schweitz, sscalpone, pmccormick, clementval.
rovka added a project: Flang.
Herald added a subscriber: jdoerfert.
Herald added a project: All.
rovka requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This seems to be the consensus in
https://github.com/flang-compiler/f18-llvm-project/issues/1316

One of the tests for lowering also needs to be updated, since it is
checking strictly for the function names with internal mangling. I can
think of 2 strategies to handle testing for this:

1. Add different check prefixes to the test, one for the bbc and one for

the flang-new run line, and strictly check the mangling for each one
(i.e. with or without this pass enabled).

2. Update the test to allow any mangling whatsoever.

I have a feeling that mangling is not part of the purpose of that test
in particular. Furthermore, there seem to be several other tests in the
same style in fir-dev, so if either the mangling or the pass pipelines 
change at some point for whatever reason there will be a lot of updating
to do.

I lean in favor of option 2 (which is what this patch goes with), plus
an additional test to make sure that flang-new is in fact running this
pass. I'm not sure if the second test should be in the same style as the
test modified in this patch (i.e. run bbc and flang-new on a small
snippet and strictly check the mangling in each case), or if we should
have a test that gets flang-new to dump the pass pipeline that it's
running and check that ExternalNameConversion is in that list. I'm
leaning in favor of the latter, since that will allow us to check the
whole pipeline looks as expected, but I'd love to hear input from
others.  Also, sorry if such a test already exists and I just missed it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121171

Files:
  flang/lib/Frontend/FrontendActions.cpp
  flang/test/Lower/Intrinsics/abs.f90


Index: flang/test/Lower/Intrinsics/abs.f90
===================================================================
--- flang/test/Lower/Intrinsics/abs.f90
+++ flang/test/Lower/Intrinsics/abs.f90
@@ -3,7 +3,7 @@
 
 ! Test abs intrinsic for various types (int, float, complex)
 
-! CHECK-LABEL: func @_QPabs_testi
+! CHECK-LABEL: func @{{.*}}abs_testi{{.*}}(
 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<i32>{{.*}}, %[[VAL_1:.*]]: !fir.ref<i32>
 subroutine abs_testi(a, b)
 ! CHECK:  %[[VAL_2:.*]] = fir.load %[[VAL_0]] : !fir.ref<i32>
@@ -17,7 +17,7 @@
   b = abs(a)
 end subroutine
 
-! CHECK-LABEL: func @_QPabs_testi16
+! CHECK-LABEL: func @{{.*}}abs_testi16{{.*}}(
 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<i128>{{.*}}, %[[VAL_1:.*]]: !fir.ref<i128>
 subroutine abs_testi16(a, b)
 ! CHECK:  %[[VAL_2:.*]] = fir.load %[[VAL_0]] : !fir.ref<i128>
@@ -31,7 +31,7 @@
   b = abs(a)
 end subroutine
 
-! CHECK-LABEL: func @_QPabs_testh(
+! CHECK-LABEL: func @{{.*}}abs_testh{{.*}}(
 ! CHECK-SAME:  %[[VAL_0:.*]]: !fir.ref<f16>{{.*}}, %[[VAL_1:.*]]: !fir.ref<f16>{{.*}}) {
 subroutine abs_testh(a, b)
 ! CHECK: %[[VAL_2:.*]] = fir.load %[[VAL_0]] : !fir.ref<f16>
@@ -44,7 +44,7 @@
   b = abs(a)
 end subroutine
 
-! CHECK-LABEL: func @_QPabs_testb(
+! CHECK-LABEL: func @{{.*}}abs_testb{{.*}}(
 ! CHECK-SAME:  %[[VAL_0:.*]]: !fir.ref<bf16>{{.*}}, %[[VAL_1:.*]]: !fir.ref<bf16>{{.*}}) {
 subroutine abs_testb(a, b)
 ! CHECK: %[[VAL_2:.*]] = fir.load %[[VAL_0]] : !fir.ref<bf16>
@@ -57,7 +57,7 @@
   b = abs(a)
 end subroutine
 
-! CHECK-LABEL: func @_QPabs_testr(
+! CHECK-LABEL: func @{{.*}}abs_testr{{.*}}(
 ! CHECK-SAME:  %[[VAL_0:.*]]: !fir.ref<f32>{{.*}}, %[[VAL_1:.*]]: !fir.ref<f32>{{.*}}) {
 subroutine abs_testr(a, b)
 ! CHECK: %[[VAL_2:.*]] = fir.load %[[VAL_0]] : !fir.ref<f32>
@@ -68,7 +68,7 @@
   b = abs(a)
 end subroutine
 
-! CHECK-LABEL: func @_QPabs_testd(
+! CHECK-LABEL: func @{{.*}}abs_testd{{.*}}(
 ! CHECK-SAME:  %[[VAL_0:.*]]: !fir.ref<f64>{{.*}}, %[[VAL_1:.*]]: !fir.ref<f64>{{.*}}) {
 subroutine abs_testd(a, b)
 ! CHECK: %[[VAL_2:.*]] = fir.load %[[VAL_0]] : !fir.ref<f64>
@@ -79,7 +79,7 @@
   b = abs(a)
 end subroutine
 
-! CHECK-LABEL: func @_QPabs_testzr(
+! CHECK-LABEL: func @{{.*}}abs_testzr{{.*}}(
 ! CHECK-SAME:  %[[VAL_0:.*]]: !fir.ref<!fir.complex<4>>{{.*}}, %[[VAL_1:.*]]: !fir.ref<f32>{{.*}}) {
 subroutine abs_testzr(a, b)
 ! CHECK:  %[[VAL_2:.*]] = fir.load %[[VAL_0]] : !fir.ref<!fir.complex<4>>
@@ -93,7 +93,7 @@
   b = abs(a)
 end subroutine abs_testzr
 
-! CHECK-LABEL: func @_QPabs_testzd(
+! CHECK-LABEL: func @{{.*}}abs_testzd{{.*}}(
 ! CHECK-SAME:  %[[VAL_0:.*]]: !fir.ref<!fir.complex<8>>{{.*}}, %[[VAL_1:.*]]: !fir.ref<f64>{{.*}}) {
 subroutine abs_testzd(a, b)
 ! CHECK:  %[[VAL_2:.*]] = fir.load %[[VAL_0]] : !fir.ref<!fir.complex<8>>
Index: flang/lib/Frontend/FrontendActions.cpp
===================================================================
--- flang/lib/Frontend/FrontendActions.cpp
+++ flang/lib/Frontend/FrontendActions.cpp
@@ -18,6 +18,7 @@
 #include "flang/Optimizer/Support/InitFIR.h"
 #include "flang/Optimizer/Support/KindMapping.h"
 #include "flang/Optimizer/Support/Utils.h"
+#include "flang/Optimizer/Transforms/Passes.h"
 #include "flang/Parser/dump-parse-tree.h"
 #include "flang/Parser/parsing.h"
 #include "flang/Parser/provenance.h"
@@ -90,6 +91,7 @@
 
   // Run the default passes.
   mlir::PassManager pm(mlirCtx.get(), mlir::OpPassManager::Nesting::Implicit);
+  pm.addPass(fir::createExternalNameConversionPass());
   pm.enableVerifier(/*verifyPasses=*/true);
   pm.addPass(std::make_unique<Fortran::lower::VerifierPass>());
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D121171.413649.patch
Type: text/x-patch
Size: 3590 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220307/d66611a0/attachment.bin>


More information about the llvm-commits mailing list