Skip to content

[Flang][Driver] Add a flag to control zero initialization of global v… #122144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jan 15, 2025

Conversation

kiranchandramohan
Copy link
Contributor

…ariables

Patch adds a flag to control zero initialization of global variables without default initialization. The default is to zero initialize.

@llvmbot llvmbot added clang Clang issues not falling into any other category clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' flang:driver flang Flang issues not falling into any other category flang:fir-hlfir labels Jan 8, 2025
@llvmbot
Copy link
Member

llvmbot commented Jan 8, 2025

@llvm/pr-subscribers-flang-fir-hlfir
@llvm/pr-subscribers-flang-driver

@llvm/pr-subscribers-clang-driver

Author: Kiran Chandramohan (kiranchandramohan)

Changes

…ariables

Patch adds a flag to control zero initialization of global variables without default initialization. The default is to zero initialize.


Full diff: https://github.com/llvm/llvm-project/pull/122144.diff

7 Files Affected:

  • (modified) clang/include/clang/Driver/Options.td (+3)
  • (modified) clang/lib/Driver/ToolChains/Flang.cpp (+1)
  • (modified) flang/include/flang/Lower/LoweringOptions.def (+3)
  • (modified) flang/lib/Frontend/CompilerInvocation.cpp (+6)
  • (modified) flang/lib/Lower/ConvertVariable.cpp (+5-2)
  • (added) flang/test/Lower/zero_init.f90 (+16)
  • (added) flang/test/Lower/zero_init_default_init.f90 (+16)
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 52823430919de4..e8d18cf78e985a 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3494,6 +3494,9 @@ def fno_struct_path_tbaa : Flag<["-"], "fno-struct-path-tbaa">, Group<f_Group>;
 def fno_strict_enums : Flag<["-"], "fno-strict-enums">, Group<f_Group>;
 def fno_strict_overflow : Flag<["-"], "fno-strict-overflow">, Group<f_Group>,
   Visibility<[ClangOption, FlangOption]>;
+def fno_zero_init_global_without_init : Flag<["-"], "fno-zero-init-global-without-init">, Group<f_Group>,
+  Visibility<[FlangOption, FC1Option]>,
+  HelpText<"Do not zero initialize globals without default initialization">;
 def fno_pointer_tbaa : Flag<["-"], "fno-pointer-tbaa">, Group<f_Group>;
 def fno_temp_file : Flag<["-"], "fno-temp-file">, Group<f_Group>,
   Visibility<[ClangOption, CC1Option, CLOption, DXCOption]>, HelpText<
diff --git a/clang/lib/Driver/ToolChains/Flang.cpp b/clang/lib/Driver/ToolChains/Flang.cpp
index 75b10e88371ae7..609f5315426977 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -153,6 +153,7 @@ void Flang::addCodegenOptions(const ArgList &Args,
   Args.addAllArgs(CmdArgs, {options::OPT_flang_experimental_hlfir,
                             options::OPT_flang_deprecated_no_hlfir,
                             options::OPT_fno_ppc_native_vec_elem_order,
+                            options::OPT_fno_zero_init_global_without_init,
                             options::OPT_fppc_native_vec_elem_order});
 }
 
diff --git a/flang/include/flang/Lower/LoweringOptions.def b/flang/include/flang/Lower/LoweringOptions.def
index 5a6debfdffe030..acce21f5faab8b 100644
--- a/flang/include/flang/Lower/LoweringOptions.def
+++ b/flang/include/flang/Lower/LoweringOptions.def
@@ -44,5 +44,8 @@ ENUM_LOWERINGOPT(IntegerWrapAround, unsigned, 1, 0)
 /// If false, assume that the shapes/types/allocation-status match.
 ENUM_LOWERINGOPT(ReallocateLHS, unsigned, 1, 1)
 
+/// If true, initialize globals without initialization to zero.
+/// On by default.
+ENUM_LOWERINGOPT(ZeroInitGlobalsWithoutInit, unsigned, 1, 1)
 #undef LOWERINGOPT
 #undef ENUM_LOWERINGOPT
diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp
index 340efb1c63a5e5..fa91a0e2642bc8 100644
--- a/flang/lib/Frontend/CompilerInvocation.cpp
+++ b/flang/lib/Frontend/CompilerInvocation.cpp
@@ -1373,6 +1373,12 @@ bool CompilerInvocation::createFromArgs(
     invoc.loweringOpts.setNoPPCNativeVecElemOrder(true);
   }
 
+  // -fno-zero-init-global-without-init
+  if (args.hasArg(
+          clang::driver::options::OPT_fno_zero_init_global_without_init)) {
+    invoc.loweringOpts.setZeroInitGlobalsWithoutInit(false);
+  }
+
   // Preserve all the remark options requested, i.e. -Rpass, -Rpass-missed or
   // -Rpass-analysis. This will be used later when processing and outputting the
   // remarks generated by LLVM in ExecuteCompilerInvocation.cpp.
diff --git a/flang/lib/Lower/ConvertVariable.cpp b/flang/lib/Lower/ConvertVariable.cpp
index 9ee42d5cd88002..7a422b07dd6c11 100644
--- a/flang/lib/Lower/ConvertVariable.cpp
+++ b/flang/lib/Lower/ConvertVariable.cpp
@@ -50,7 +50,6 @@ static llvm::cl::opt<bool>
     allowAssumedRank("allow-assumed-rank",
                      llvm::cl::desc("Enable assumed rank lowering"),
                      llvm::cl::init(true));
-
 #define DEBUG_TYPE "flang-lower-variable"
 
 /// Helper to lower a scalar expression using a specific symbol mapping.
@@ -635,7 +634,11 @@ static fir::GlobalOp defineGlobal(Fortran::lower::AbstractConverter &converter,
       global.setLinkName(builder.createCommonLinkage());
     Fortran::lower::createGlobalInitialization(
         builder, global, [&](fir::FirOpBuilder &builder) {
-          mlir::Value initValue = builder.create<fir::ZeroOp>(loc, symTy);
+          mlir::Value initValue;
+          if (converter.getLoweringOptions().getZeroInitGlobalsWithoutInit())
+            initValue = builder.create<fir::ZeroOp>(loc, symTy);
+          else
+            initValue = builder.create<fir::UndefOp>(loc, symTy);
           builder.create<fir::HasValueOp>(loc, initValue);
         });
   }
diff --git a/flang/test/Lower/zero_init.f90 b/flang/test/Lower/zero_init.f90
new file mode 100644
index 00000000000000..76201eb0f0cbd0
--- /dev/null
+++ b/flang/test/Lower/zero_init.f90
@@ -0,0 +1,16 @@
+! RUN: %flang_fc1 -emit-hlfir -o - %s | FileCheck --check-prefix=CHECK-DEFAULT %s
+! RUN: %flang_fc1 -fno-zero-init-global-without-init -emit-hlfir -o - %s | FileCheck --check-prefix=CHECK-NO-ZERO-INIT %s
+
+module m1
+  real :: x
+end module m1
+
+!CHECK-DEFAULT: fir.global @_QMm1Ex : f32 {
+!CHECK-DEFAULT:   %[[UNDEF:.*]] = fir.zero_bits f32
+!CHECK-DEFAULT:   fir.has_value %[[UNDEF]] : f32
+!CHECK-DEFAULT: }
+
+!CHECK-NO-ZERO-INIT: fir.global @_QMm1Ex : f32 {
+!CHECK-NO-ZERO-INIT:   %[[UNDEF:.*]] = fir.undefined f32
+!CHECK-NO-ZERO-INIT:   fir.has_value %[[UNDEF]] : f32
+!CHECK-NO-ZERO-INIT: }
diff --git a/flang/test/Lower/zero_init_default_init.f90 b/flang/test/Lower/zero_init_default_init.f90
new file mode 100644
index 00000000000000..41ca473451b910
--- /dev/null
+++ b/flang/test/Lower/zero_init_default_init.f90
@@ -0,0 +1,16 @@
+! RUN: %flang_fc1 -emit-hlfir -o - %s | FileCheck %s
+! RUN: %flang_fc1 -fno-zero-init-global-without-init -emit-hlfir -o - %s | FileCheck %s
+
+module m2
+  type val
+    integer :: my_val = 1
+  end type val
+  type(val) :: v1
+end module m2
+
+!CHECK:  fir.global @_QMm2Ev1 : !fir.type<_QMm2Tval{my_val:i32}> {
+!CHECK:    %[[V1:.*]] = fir.undefined !fir.type<_QMm2Tval{my_val:i32}>
+!CHECK:    %[[ONE:.*]] = arith.constant 1 : i32
+!CHECK:    %[[V1_INIT:.*]] = fir.insert_value %[[V1]], %[[ONE]], ["my_val", !fir.type<_QMm2Tval{my_val:i32}>] : (!fir.type<_QMm2Tval{my_val:i32}>, i32) -> !fir.type<_QMm2Tval{my_val:i32}>
+!CHECK:    fir.has_value %[[V1_INIT]] : !fir.type<_QMm2Tval{my_val:i32}>
+!CHECK:  }

@llvmbot
Copy link
Member

llvmbot commented Jan 8, 2025

@llvm/pr-subscribers-clang

Author: Kiran Chandramohan (kiranchandramohan)

Changes

…ariables

Patch adds a flag to control zero initialization of global variables without default initialization. The default is to zero initialize.


Full diff: https://github.com/llvm/llvm-project/pull/122144.diff

7 Files Affected:

  • (modified) clang/include/clang/Driver/Options.td (+3)
  • (modified) clang/lib/Driver/ToolChains/Flang.cpp (+1)
  • (modified) flang/include/flang/Lower/LoweringOptions.def (+3)
  • (modified) flang/lib/Frontend/CompilerInvocation.cpp (+6)
  • (modified) flang/lib/Lower/ConvertVariable.cpp (+5-2)
  • (added) flang/test/Lower/zero_init.f90 (+16)
  • (added) flang/test/Lower/zero_init_default_init.f90 (+16)
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 52823430919de4..e8d18cf78e985a 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3494,6 +3494,9 @@ def fno_struct_path_tbaa : Flag<["-"], "fno-struct-path-tbaa">, Group<f_Group>;
 def fno_strict_enums : Flag<["-"], "fno-strict-enums">, Group<f_Group>;
 def fno_strict_overflow : Flag<["-"], "fno-strict-overflow">, Group<f_Group>,
   Visibility<[ClangOption, FlangOption]>;
+def fno_zero_init_global_without_init : Flag<["-"], "fno-zero-init-global-without-init">, Group<f_Group>,
+  Visibility<[FlangOption, FC1Option]>,
+  HelpText<"Do not zero initialize globals without default initialization">;
 def fno_pointer_tbaa : Flag<["-"], "fno-pointer-tbaa">, Group<f_Group>;
 def fno_temp_file : Flag<["-"], "fno-temp-file">, Group<f_Group>,
   Visibility<[ClangOption, CC1Option, CLOption, DXCOption]>, HelpText<
diff --git a/clang/lib/Driver/ToolChains/Flang.cpp b/clang/lib/Driver/ToolChains/Flang.cpp
index 75b10e88371ae7..609f5315426977 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -153,6 +153,7 @@ void Flang::addCodegenOptions(const ArgList &Args,
   Args.addAllArgs(CmdArgs, {options::OPT_flang_experimental_hlfir,
                             options::OPT_flang_deprecated_no_hlfir,
                             options::OPT_fno_ppc_native_vec_elem_order,
+                            options::OPT_fno_zero_init_global_without_init,
                             options::OPT_fppc_native_vec_elem_order});
 }
 
diff --git a/flang/include/flang/Lower/LoweringOptions.def b/flang/include/flang/Lower/LoweringOptions.def
index 5a6debfdffe030..acce21f5faab8b 100644
--- a/flang/include/flang/Lower/LoweringOptions.def
+++ b/flang/include/flang/Lower/LoweringOptions.def
@@ -44,5 +44,8 @@ ENUM_LOWERINGOPT(IntegerWrapAround, unsigned, 1, 0)
 /// If false, assume that the shapes/types/allocation-status match.
 ENUM_LOWERINGOPT(ReallocateLHS, unsigned, 1, 1)
 
+/// If true, initialize globals without initialization to zero.
+/// On by default.
+ENUM_LOWERINGOPT(ZeroInitGlobalsWithoutInit, unsigned, 1, 1)
 #undef LOWERINGOPT
 #undef ENUM_LOWERINGOPT
diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp
index 340efb1c63a5e5..fa91a0e2642bc8 100644
--- a/flang/lib/Frontend/CompilerInvocation.cpp
+++ b/flang/lib/Frontend/CompilerInvocation.cpp
@@ -1373,6 +1373,12 @@ bool CompilerInvocation::createFromArgs(
     invoc.loweringOpts.setNoPPCNativeVecElemOrder(true);
   }
 
+  // -fno-zero-init-global-without-init
+  if (args.hasArg(
+          clang::driver::options::OPT_fno_zero_init_global_without_init)) {
+    invoc.loweringOpts.setZeroInitGlobalsWithoutInit(false);
+  }
+
   // Preserve all the remark options requested, i.e. -Rpass, -Rpass-missed or
   // -Rpass-analysis. This will be used later when processing and outputting the
   // remarks generated by LLVM in ExecuteCompilerInvocation.cpp.
diff --git a/flang/lib/Lower/ConvertVariable.cpp b/flang/lib/Lower/ConvertVariable.cpp
index 9ee42d5cd88002..7a422b07dd6c11 100644
--- a/flang/lib/Lower/ConvertVariable.cpp
+++ b/flang/lib/Lower/ConvertVariable.cpp
@@ -50,7 +50,6 @@ static llvm::cl::opt<bool>
     allowAssumedRank("allow-assumed-rank",
                      llvm::cl::desc("Enable assumed rank lowering"),
                      llvm::cl::init(true));
-
 #define DEBUG_TYPE "flang-lower-variable"
 
 /// Helper to lower a scalar expression using a specific symbol mapping.
@@ -635,7 +634,11 @@ static fir::GlobalOp defineGlobal(Fortran::lower::AbstractConverter &converter,
       global.setLinkName(builder.createCommonLinkage());
     Fortran::lower::createGlobalInitialization(
         builder, global, [&](fir::FirOpBuilder &builder) {
-          mlir::Value initValue = builder.create<fir::ZeroOp>(loc, symTy);
+          mlir::Value initValue;
+          if (converter.getLoweringOptions().getZeroInitGlobalsWithoutInit())
+            initValue = builder.create<fir::ZeroOp>(loc, symTy);
+          else
+            initValue = builder.create<fir::UndefOp>(loc, symTy);
           builder.create<fir::HasValueOp>(loc, initValue);
         });
   }
diff --git a/flang/test/Lower/zero_init.f90 b/flang/test/Lower/zero_init.f90
new file mode 100644
index 00000000000000..76201eb0f0cbd0
--- /dev/null
+++ b/flang/test/Lower/zero_init.f90
@@ -0,0 +1,16 @@
+! RUN: %flang_fc1 -emit-hlfir -o - %s | FileCheck --check-prefix=CHECK-DEFAULT %s
+! RUN: %flang_fc1 -fno-zero-init-global-without-init -emit-hlfir -o - %s | FileCheck --check-prefix=CHECK-NO-ZERO-INIT %s
+
+module m1
+  real :: x
+end module m1
+
+!CHECK-DEFAULT: fir.global @_QMm1Ex : f32 {
+!CHECK-DEFAULT:   %[[UNDEF:.*]] = fir.zero_bits f32
+!CHECK-DEFAULT:   fir.has_value %[[UNDEF]] : f32
+!CHECK-DEFAULT: }
+
+!CHECK-NO-ZERO-INIT: fir.global @_QMm1Ex : f32 {
+!CHECK-NO-ZERO-INIT:   %[[UNDEF:.*]] = fir.undefined f32
+!CHECK-NO-ZERO-INIT:   fir.has_value %[[UNDEF]] : f32
+!CHECK-NO-ZERO-INIT: }
diff --git a/flang/test/Lower/zero_init_default_init.f90 b/flang/test/Lower/zero_init_default_init.f90
new file mode 100644
index 00000000000000..41ca473451b910
--- /dev/null
+++ b/flang/test/Lower/zero_init_default_init.f90
@@ -0,0 +1,16 @@
+! RUN: %flang_fc1 -emit-hlfir -o - %s | FileCheck %s
+! RUN: %flang_fc1 -fno-zero-init-global-without-init -emit-hlfir -o - %s | FileCheck %s
+
+module m2
+  type val
+    integer :: my_val = 1
+  end type val
+  type(val) :: v1
+end module m2
+
+!CHECK:  fir.global @_QMm2Ev1 : !fir.type<_QMm2Tval{my_val:i32}> {
+!CHECK:    %[[V1:.*]] = fir.undefined !fir.type<_QMm2Tval{my_val:i32}>
+!CHECK:    %[[ONE:.*]] = arith.constant 1 : i32
+!CHECK:    %[[V1_INIT:.*]] = fir.insert_value %[[V1]], %[[ONE]], ["my_val", !fir.type<_QMm2Tval{my_val:i32}>] : (!fir.type<_QMm2Tval{my_val:i32}>, i32) -> !fir.type<_QMm2Tval{my_val:i32}>
+!CHECK:    fir.has_value %[[V1_INIT]] : !fir.type<_QMm2Tval{my_val:i32}>
+!CHECK:  }

Copy link
Contributor

@tarunprabhu tarunprabhu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks Kiran.

…ariables

Patch adds a flag to control zero initialization of global variables
without default initialization. The default is to zero initialize.
@kiranchandramohan
Copy link
Contributor Author

LGTM. Thanks Kiran.

Is the name of the flag alrite?

@tarunprabhu
Copy link
Contributor

Is the name of the flag alrite?

Haha. You read my mind. I spent some time thinking about it and even consulted the Fortran standard. They refer to default initialization as well, so I eventually decided that it was ok. Maybe -fno-init-global-without-default-init is clearer, but it's longer. I was thinking of -fno-init-uninitialized-globals, which I, a C/C++ programmer, find more intuitive. But maybe Fortran programmers are used to thinking of "default initialization".

@tarunprabhu
Copy link
Contributor

Perhaps leave this up for a bit longer to see if we can think of something better. Or others may have some suggestions

Copy link
Contributor

@jeanPerier jeanPerier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Kiran!
Regarding the name, I never have strong opinions about them. Maybe fno-zero-init-globals is enough (the description talks about the without-init part, and it is rather obvious I think that this will not affect/control user define initialization). I also like -fno-init-uninitialized-globals.

gfortran has -finit-local-zero which flang will likely eventually have. It has no such options for globals (it is putting everything is .bss ASFAIK). Maybe -fno-init-global-zero would be consistent whit that existing name.

Maybe ask in the flang slack channel for opinions?

@kiranchandramohan
Copy link
Contributor Author

-fno-init-global-zero

Thanks @tarunprabhu @jeanPerier, Changed to fno-init-global-zero and also added a positive version-fno-init-global-zero.

Copy link

github-actions bot commented Jan 13, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

Copy link
Contributor

@jeanPerier jeanPerier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beware there is a formatting issue (see github CI). LGTM otherwise, thanks Kiran!

@kiranchandramohan kiranchandramohan merged commit c593e3d into llvm:main Jan 15, 2025
8 checks passed
@llvm-ci
Copy link
Collaborator

llvm-ci commented Jan 15, 2025

LLVM Buildbot has detected a new failure on builder flang-aarch64-libcxx running on linaro-flang-aarch64-libcxx while building clang,flang at step 6 "test-build-unified-tree-check-flang".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/89/builds/14422

Here is the relevant piece of the build log for the reference
Step 6 (test-build-unified-tree-check-flang) failure: test (failure)

@llvm-ci
Copy link
Collaborator

llvm-ci commented Jan 15, 2025

LLVM Buildbot has detected a new failure on builder ppc64le-flang-rhel-clang running on ppc64le-flang-rhel-test while building clang,flang at step 6 "test-build-unified-tree-check-flang".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/157/builds/17277

Here is the relevant piece of the build log for the reference
Step 6 (test-build-unified-tree-check-flang) failure: test (failure)

@llvm-ci
Copy link
Collaborator

llvm-ci commented Jan 15, 2025

LLVM Buildbot has detected a new failure on builder flang-aarch64-debug-reverse-iteration running on linaro-flang-aarch64-debug-reverse-iteration while building clang,flang at step 6 "test-build-unified-tree-check-flang".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/20/builds/7750

Here is the relevant piece of the build log for the reference
Step 6 (test-build-unified-tree-check-flang) failure: test (failure)
******************** TEST 'Flang :: Lower/module_use.f90' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
RUN: at line 1: bbc -emit-fir /home/tcwg-buildbot/worker/flang-aarch64-debug-reverse-iteration/llvm-project/flang/test/Lower/module_definition.f90
+ bbc -emit-fir /home/tcwg-buildbot/worker/flang-aarch64-debug-reverse-iteration/llvm-project/flang/test/Lower/module_definition.f90
RUN: at line 2: bbc -emit-fir /home/tcwg-buildbot/worker/flang-aarch64-debug-reverse-iteration/llvm-project/flang/test/Lower/module_use.f90 -o - | /home/tcwg-buildbot/worker/flang-aarch64-debug-reverse-iteration/build/bin/FileCheck /home/tcwg-buildbot/worker/flang-aarch64-debug-reverse-iteration/llvm-project/flang/test/Lower/module_use.f90
+ /home/tcwg-buildbot/worker/flang-aarch64-debug-reverse-iteration/build/bin/FileCheck /home/tcwg-buildbot/worker/flang-aarch64-debug-reverse-iteration/llvm-project/flang/test/Lower/module_use.f90
+ bbc -emit-fir /home/tcwg-buildbot/worker/flang-aarch64-debug-reverse-iteration/llvm-project/flang/test/Lower/module_use.f90 -o -
/home/tcwg-buildbot/worker/flang-aarch64-debug-reverse-iteration/llvm-project/flang/test/Lower/module_use.f90:16:15: error: CHECK-DAG: expected string not found in input
 ! CHECK-DAG: fir.address_of(@_QMm1Ey) : !fir.ref<!fir.array<100xi32>>
              ^
<stdin>:5:23: note: scanning from here
 func.func @_QPm1use() -> f32 {
                      ^
<stdin>:10:7: note: possible intended match here
 %3 = fir.address_of(@_QMm1Ex) : !fir.ref<f32>
      ^
/home/tcwg-buildbot/worker/flang-aarch64-debug-reverse-iteration/llvm-project/flang/test/Lower/module_use.f90:43:14: error: CHECK-DAG: expected string not found in input
! CHECK-DAG: fir.global @_QMm1Ey : !fir.array<100xi32>
             ^
<stdin>:20:31: note: scanning from here
 func.func @_QPmodcommon1use() -> f32 {
                              ^
<stdin>:49:2: note: possible intended match here
 fir.global @_QMm1Ex : f32
 ^

Input file: <stdin>
Check file: /home/tcwg-buildbot/worker/flang-aarch64-debug-reverse-iteration/llvm-project/flang/test/Lower/module_use.f90

-dump-input=help explains the following input dump.

Input was:
<<<<<<
          1: module attributes {dlti.dl_spec = #dlti.dl_spec<!llvm.ptr = dense<64> : vector<4xi64>, i1 = dense<8> : vector<2xi64>, i32 = dense<32> : vector<2xi64>, i128 = dense<128> : vector<2xi64>, i64 = dense<64> : vector<2xi64>, i8 = dense<[8, 32]> : vector<2xi64>, i16 = dense<[16, 32]> : vector<2xi64>, !llvm.ptr<270> = dense<32> : vector<4xi64>, f16 = dense<16> : vector<2xi64>, !llvm.ptr<272> = dense<64> : vector<4xi64>, f128 = dense<128> : vector<2xi64>, f64 = dense<64> : vector<2xi64>, !llvm.ptr<271> = dense<32> : vector<4xi64>, "dlti.stack_alignment" = 128 : i64, "dlti.endianness" = "little">, fir.defaultkind = "a1c4d8i4l4r4", fir.kindmap = "", llvm.data_layout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32", llvm.ident = "flang version 20.0.0 (https://github.com/llvm/llvm-project.git c593e3d0f77509ce65a6f5bd744f2d1ea9935c47)", llvm.target_triple = "aarch64-unknown-linux-gnu"} { 
          2:  fir.global common @__BLNK__(dense<0> : vector<4xi8>) {alignment = 4 : i64} : !fir.array<4xi8> 
          3:  fir.global common @named1_(dense<0> : vector<4xi8>) {alignment = 4 : i64} : !fir.array<4xi8> 
          4:  fir.global common @named2_(dense<0> : vector<4xi8>) {alignment = 4 : i64} : !fir.array<4xi8> 
          5:  func.func @_QPm1use() -> f32 { 
dag:16'0                           X~~~~~~~~~ error: no match found
          6:  %c1_i32 = arith.constant 1 : i32 
dag:16'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          7:  %0 = fir.alloca i32 {adapt.valuebyref} 
dag:16'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          8:  %1 = fir.alloca f32 {bindc_name = "m1use", uniq_name = "_QFm1useEm1use"} 
dag:16'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          9:  %2 = fir.declare %1 {uniq_name = "_QFm1useEm1use"} : (!fir.ref<f32>) -> !fir.ref<f32> 
dag:16'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...

@llvm-ci
Copy link
Collaborator

llvm-ci commented Jan 15, 2025

LLVM Buildbot has detected a new failure on builder flang-aarch64-rel-assert running on linaro-flang-aarch64-rel-assert while building clang,flang at step 6 "test-build-unified-tree-check-flang".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/29/builds/9053

Here is the relevant piece of the build log for the reference
Step 6 (test-build-unified-tree-check-flang) failure: test (failure)
******************** TEST 'Flang :: Lower/module_use.f90' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
RUN: at line 1: bbc -emit-fir /home/tcwg-buildbot/worker/flang-aarch64-rel-assert/llvm-project/flang/test/Lower/module_definition.f90
+ bbc -emit-fir /home/tcwg-buildbot/worker/flang-aarch64-rel-assert/llvm-project/flang/test/Lower/module_definition.f90
RUN: at line 2: bbc -emit-fir /home/tcwg-buildbot/worker/flang-aarch64-rel-assert/llvm-project/flang/test/Lower/module_use.f90 -o - | /home/tcwg-buildbot/worker/flang-aarch64-rel-assert/build/bin/FileCheck /home/tcwg-buildbot/worker/flang-aarch64-rel-assert/llvm-project/flang/test/Lower/module_use.f90
+ /home/tcwg-buildbot/worker/flang-aarch64-rel-assert/build/bin/FileCheck /home/tcwg-buildbot/worker/flang-aarch64-rel-assert/llvm-project/flang/test/Lower/module_use.f90
+ bbc -emit-fir /home/tcwg-buildbot/worker/flang-aarch64-rel-assert/llvm-project/flang/test/Lower/module_use.f90 -o -
/home/tcwg-buildbot/worker/flang-aarch64-rel-assert/llvm-project/flang/test/Lower/module_use.f90:16:15: error: CHECK-DAG: expected string not found in input
 ! CHECK-DAG: fir.address_of(@_QMm1Ey) : !fir.ref<!fir.array<100xi32>>
              ^
<stdin>:5:23: note: scanning from here
 func.func @_QPm1use() -> f32 {
                      ^
<stdin>:10:7: note: possible intended match here
 %3 = fir.address_of(@_QMm1Ex) : !fir.ref<f32>
      ^
/home/tcwg-buildbot/worker/flang-aarch64-rel-assert/llvm-project/flang/test/Lower/module_use.f90:43:14: error: CHECK-DAG: expected string not found in input
! CHECK-DAG: fir.global @_QMm1Ey : !fir.array<100xi32>
             ^
<stdin>:20:31: note: scanning from here
 func.func @_QPmodcommon1use() -> f32 {
                              ^
<stdin>:49:2: note: possible intended match here
 fir.global @_QMm1Ex : f32
 ^

Input file: <stdin>
Check file: /home/tcwg-buildbot/worker/flang-aarch64-rel-assert/llvm-project/flang/test/Lower/module_use.f90

-dump-input=help explains the following input dump.

Input was:
<<<<<<
          1: module attributes {dlti.dl_spec = #dlti.dl_spec<i32 = dense<32> : vector<2xi64>, !llvm.ptr<270> = dense<32> : vector<4xi64>, f16 = dense<16> : vector<2xi64>, i1 = dense<8> : vector<2xi64>, !llvm.ptr = dense<64> : vector<4xi64>, i16 = dense<[16, 32]> : vector<2xi64>, i128 = dense<128> : vector<2xi64>, i64 = dense<64> : vector<2xi64>, !llvm.ptr<272> = dense<64> : vector<4xi64>, !llvm.ptr<271> = dense<32> : vector<4xi64>, f64 = dense<64> : vector<2xi64>, i8 = dense<[8, 32]> : vector<2xi64>, f128 = dense<128> : vector<2xi64>, "dlti.endianness" = "little", "dlti.stack_alignment" = 128 : i64>, fir.defaultkind = "a1c4d8i4l4r4", fir.kindmap = "", llvm.data_layout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32", llvm.ident = "flang version 20.0.0 (https://github.com/llvm/llvm-project.git c593e3d0f77509ce65a6f5bd744f2d1ea9935c47)", llvm.target_triple = "aarch64-unknown-linux-gnu"} { 
          2:  fir.global common @__BLNK__(dense<0> : vector<4xi8>) {alignment = 4 : i64} : !fir.array<4xi8> 
          3:  fir.global common @named1_(dense<0> : vector<4xi8>) {alignment = 4 : i64} : !fir.array<4xi8> 
          4:  fir.global common @named2_(dense<0> : vector<4xi8>) {alignment = 4 : i64} : !fir.array<4xi8> 
          5:  func.func @_QPm1use() -> f32 { 
dag:16'0                           X~~~~~~~~~ error: no match found
          6:  %c1_i32 = arith.constant 1 : i32 
dag:16'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          7:  %0 = fir.alloca i32 {adapt.valuebyref} 
dag:16'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          8:  %1 = fir.alloca f32 {bindc_name = "m1use", uniq_name = "_QFm1useEm1use"} 
dag:16'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          9:  %2 = fir.declare %1 {uniq_name = "_QFm1useEm1use"} : (!fir.ref<f32>) -> !fir.ref<f32> 
dag:16'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' clang Clang issues not falling into any other category flang:driver flang:fir-hlfir flang Flang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants