Page MenuHomePhabricator

[flang] Fix assert on constant folding of extended types
AbandonedPublic

Authored by PeteSteinfeld on Aug 18 2020, 2:56 PM.

Details

Summary

When we define a derived type that extends another derived type, we can then
create a structure constructor that contains values for the fields of both the
child type and its parent. The compiler's internal representation of that
value contained the name of the parent type where a component name would
normally appear. This caused an assert during contant folding.

I fixed this by changing the function "CreateComponent()" in
lib/Semantics/expression.cpp to no longer include type names in values of type
"evaluate::Component".

I also added the test Evaluate/folding12.f90 to exercise the affected code.

Diff Detail

Unit TestsFailed

TimeTest
22,630 mslinux > MLIR.Examples/standalone::test.toy
Script: -- : 'RUN: at line 1'; /usr/bin/cmake /mnt/disks/ssd0/agent/llvm-project/mlir/examples/standalone -DCMAKE_CXX_COMPILER=/usr/bin/clang++ -DCMAKE_C_COMPILER=/usr/bin/clang -DMLIR_DIR=%llvm_lib_dir/cmake/mlir ; /usr/bin/cmake --build . --target check-standalone | tee /mnt/disks/ssd0/agent/llvm-project/build/tools/mlir/test/Examples/standalone/Output/test.toy.tmp | /mnt/disks/ssd0/agent/llvm-project/build/bin/FileCheck /mnt/disks/ssd0/agent/llvm-project/mlir/test/Examples/standalone/test.toy
60 mslinux > flang-Unit.Lower/_/FlangLoweringOpenMPTests::OpenMPLoweringTest.Barrier
Note: Google Test filter = OpenMPLoweringTest.Barrier [==========] Running 1 test from 1 test case. [----------] Global test environment set-up.
60 mslinux > flang-Unit.Lower/_/FlangLoweringOpenMPTests::OpenMPLoweringTest.EmptyParallel
Note: Google Test filter = OpenMPLoweringTest.EmptyParallel [==========] Running 1 test from 1 test case. [----------] Global test environment set-up.
70 mslinux > flang-Unit.Lower/_/FlangLoweringOpenMPTests::OpenMPLoweringTest.TaskWait
Note: Google Test filter = OpenMPLoweringTest.TaskWait [==========] Running 1 test from 1 test case. [----------] Global test environment set-up.
70 mslinux > flang-Unit.Lower/_/FlangLoweringOpenMPTests::OpenMPLoweringTest.TaskYield
Note: Google Test filter = OpenMPLoweringTest.TaskYield [==========] Running 1 test from 1 test case. [----------] Global test environment set-up.

Event Timeline

PeteSteinfeld created this revision.Aug 18 2020, 2:56 PM
Herald added a project: Restricted Project. · View Herald Transcript
PeteSteinfeld requested review of this revision.Aug 18 2020, 2:56 PM
PeteSteinfeld added a project: Restricted Project.Aug 18 2020, 2:56 PM

Be advised, there is indeed a "parent component" in every derived type that extends another, and it can be used as if the parent type were a component in the type that extends it. Structure constructors must allow for this (C798).

Be advised, there is indeed a "parent component" in every derived type that extends another, and it can be used as if the parent type were a component in the type that extends it. Structure constructors must allow for this (C798).

Thanks for the pointer. I'll take a look and make sure that I cover that parent component both in tests and implementation.

DavidTruby resigned from this revision.Sep 1 2020, 3:39 AM
PeteSteinfeld abandoned this revision.Sep 4 2020, 8:54 AM

This change is superseded by D87151.