Skip to content

Add unit tests for Fortran's type finalization feature #13

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

Closed
wants to merge 1 commit into from

Conversation

rouson
Copy link
Contributor

@rouson rouson commented Sep 16, 2022

No description provided.

Copy link
Contributor

@rovka rovka left a comment

Choose a reason for hiding this comment

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

Thanks for working on this! I have a couple of comments inline, and also a more general question: Is there any magic you could use to disable some or all of these tests if the compiler doesn't support this feature?

test_results = get_test_results()

do i=1,size(test_results)
print *, report(test_results(i)%outcome), test_results(i)%description
Copy link
Contributor

Choose a reason for hiding this comment

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

List-directed output leaves room for all sorts of delimiters between values (one or more blanks, comma, semicolon), so it makes it more difficult to compare the output with a reference. I would recommend using a well-defined format, to force all compilers to produce the exact same output.

@@ -0,0 +1,6 @@
add_executable( test_finalization
Copy link
Contributor

Choose a reason for hiding this comment

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

This adds an executable, but doesn't actually run the test. You should add a reference output and some boilerplate similar to what's been done for SNAP. Note that that implementation is a bit messy at the moment - if you have some cycles to spend on this, you could try to extract some CMake helpers to use both here and in SNAP, similar to what we have for C++ tests.

@kiranchandramohan
Copy link
Contributor

@rovka Are Pull Requests accepted in this repository?

@rovka
Copy link
Contributor

rovka commented Sep 16, 2022

@kiranchandramohan I'm seeing a "Merge pull request" button, so... maybe? In any case, that's a good point. I don't mind reviewing here, but we should probably add a link to the PR in the commit message (similar to how we have the "Differential Revision" tag for Phabricator reviews), so people can easily find the discussion.

@clementval
Copy link
Contributor

clementval commented Jan 27, 2023

@rouson There is a patch up for review for the derived-type finalization in flang (https://reviews.llvm.org/D142707). It currently passes 9/10 tests. BLOCK construct is not yet implemented.
The specification expression test needs to be compiled and run separately since the compile_command, execute_command_line and compiler_version are still TODOs.

@rouson
Copy link
Contributor Author

rouson commented Jan 27, 2023

@clementval that's great progress! Thanks for the update.

@Meinersbur
Copy link
Member

In principle, the same policies as for https://github.com/llvm/llvm-project applies: It has a bot that automatically closes all pull requests (see e.g. llvm/llvm-project#60154), but it seems that they are not configured the same way.

@kiranchandramohan I'm seeing a "Merge pull request" button, so... maybe?

That not good, we still don't want merge commits, but a linear history. Rebase should be the only option.

clementval added a commit to llvm/llvm-project that referenced this pull request Jan 31, 2023
This patch implements the derived-type finalization for
monomorphic and polymorphic derived-type.

The finalization is done through a call to the `Destroy`
runtime function so the allocatable component object are also
finalized correctly when needed. It would be possible to finalize
monomorphic derived-type with non finalizable component with a
direct call to their finalize subroutine.

7.5.6.3 point 1: LHS nonallocatable object and LHS allocatable
object finalization. Done with call to `Destroy` for monomorphic
derived-type and through `Assign` for polymorphic entities.

7.5.6.3 point 2: Done within the deallocation calls.

7.5.6.3 point 3: A function context is added to the bridge to
attach finalization that need to happen on function/subroutine
exit.

7.5.6.3 point 4: BLOCK construct not yet implemented.

7.5.6.3 point 5/6: Finalization attach to the stmtCtx in a
similar way than 9.7.3.2 point 4.

7.5.6.3 point 7: INTENT(OUT) finalization done with a
call to `Destroy` runtime function call.

This patch passes 9/10 tests in the proposed test-suite
llvm/llvm-test-suite#13

- The case with BLOCK construct will be implemented later when
  BLOCK are implemented upstream.

- Automatic deallocation is not yet implemented. Finalization triggered
  by automatic deallocation is then not triggered.

Reviewed By: jeanPerier, PeteSteinfeld

Differential Revision: https://reviews.llvm.org/D142707
@zbeekman
Copy link
Contributor

zbeekman commented Mar 9, 2023

Greetings @rovka, @kiranchandramohan, @clementval and @Meinersbur. @rouson has tasked me with getting this submission to llvm-test-suite over the finish line. I have relatively extensive CMake and git experience, so, from a technical perspective I'm relatively comfortable with the feedback so far, however this is my first endeavor submitting a patch to LLVM.

I have read https://llvm.org/docs/Contributing.html and https://llvm.org/docs/Phabricator.html and have created a phabricator account (https://reviews.llvm.org/p/zbeekman/) but I'm still wading through some of the details and trying to figure out how to set up git-clang-format the fastest/most straightforward way on macOS and trying to decipher how to submit the patch with phabricator/arcanist. Any additional tips/tricks/concise advice is certainly welcome.

@clementval
Copy link
Contributor

I think contribution to the test suite can go through github PR directly. No need for a phab review.

Last time I check there was some tests requiring "not yet implemented" features. Do you plan to implement those or disable the tests for the moment?

@zbeekman
Copy link
Contributor

zbeekman commented Mar 9, 2023

I think contribution to the test suite can go through github PR directly. No need for a phab review.

OK, great! That's a bit of a relief. I should still probably figure out phabricator and the normal review process but I'm glad to hear I can iterate on GitHub.

Last time I check there was some tests requiring "not yet implemented" features. Do you plan to implement those or disable the tests for the moment?

I don't believe I have the expertise required to implement the tests that fail because they rely on "not yet implemented" features. If there is a canonical way to mark a test as being relevant to a not-yet-implemented feature please let me know. Otherwise I could set the WILL_FAIL property on the test and add a comment to the CMake files so that once implemented the property can be removed.

From your previous comment:

@rouson There is a patch up for review for the derived-type finalization in flang (https://reviews.llvm.org/D142707). It currently passes 9/10 tests. BLOCK construct is not yet implemented.

I can mark the test for BLOCK construct as WILL_FAIL in CMake, or follow whatever the recommended best practice is for tests of heretofore unimplemented features.

The specification expression test needs to be compiled and run separately since the compile_command, execute_command_line and compiler_version are still TODOs.

The preferred approach is for all the relevant testing code to be compiled and run via CMake, and trying to match the style of existing flang/llvm infrastructure, correct?

@clementval
Copy link
Contributor

I can mark the test for BLOCK construct as WILL_FAIL in CMake, or follow whatever the recommended best practice is for tests of heretofore unimplemented features.

BLOCK should be fine now. The test that compile and execute the second file should give you build failure with not yet implemented error.

@joker-eph
Copy link
Contributor

I think contribution to the test suite can go through github PR directly. No need for a phab review.

I don't see any pull request ever landed in this repo (all commits seem reviewed on Phab instead), did anything change recently?

@clementval
Copy link
Contributor

I think contribution to the test suite can go through github PR directly. No need for a phab review.

I don't see any pull request ever landed in this repo (all commits seem reviewed on Phab instead), did anything change recently?

Right. I was puzzled by the fact we can open PR here. But @joker-eph is right, phab is the way also here.

@zbeekman zbeekman force-pushed the fortran-type-finalization branch 3 times, most recently from 88de4e9 to 09e5344 Compare April 7, 2023 18:27
@zbeekman
Copy link
Contributor

zbeekman commented Apr 7, 2023

@clementval @rovka:

Ok, it seems like I need to go through phab.. I'll have to figure out how to finish getting that setup and how to initiate the process. In the meantime, any feedback that you are able to provide here would be most welcome (hopefully to reduce cycles spent going back and forth in phabricator).

I have:

  • Broken the tests into individual files.
  • Replaced list directed IO with well formatted (I hope!) repeatable edit descriptors (I'm just using "(A)".
  • Created a .reference_output file for each test
  • Integrated the tests with CMake using llvm_singlesource()

To attempt to keep the tests in a single source file from CMake's perspective and to strike a balance between complexity and avoiding duplicating code, I used old school include statements (include "object_type_m.f90") at the top of most test source files to pull in most of a relatively small module that defines a few derived types, procedures, module variables etc. Stylistically speaking I don't love this approach, however, there's no other immediately obvious good way to do this without a lot of code duplication.

@rouson: All the tests pass with flang-new as of at least today: d585a8afdf2f70159759dccb11d775cdf432aba4

...
size..gnu.hash: 28
size..gnu.version: 124
size..gnu.version_r: 80
size..got: 64
size..got.plt: 440
size..init: 27
size..init_array: 16
size..interp: 28
size..note.ABI-tag: 32
size..plt: 848
size..rela.dyn: 23904
size..rela.plt: 1248
size..rodata: 28640
size..text: 577202
**********

Testing Time: 0.06s
  Passed: 10

Comment on lines 155 to 159
- Version tested: `git` commit `76911b5f75907eef53a30cc3`
- Result: Fails with the error message `not yet implemented: derived type finalization`

- Version tested: `git` commit `27b6ddbf6ea632389f582c0ca1481ed370f0af45` on 2023-04-06.
- Result: Fails with the error message:
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess you need to update the results here.

@clementval
Copy link
Contributor

Besides updating the README with your latest result I think you can go ahead and submit a phab review.

@zbeekman
Copy link
Contributor

zbeekman commented Apr 8, 2023 via email

@zbeekman zbeekman force-pushed the fortran-type-finalization branch from 09e5344 to 1c2806f Compare April 13, 2023 21:20
@zbeekman zbeekman force-pushed the fortran-type-finalization branch 4 times, most recently from 5c31a8e to b1215a4 Compare May 3, 2023 17:23
@zbeekman zbeekman force-pushed the fortran-type-finalization branch 4 times, most recently from 28852c2 to 2bdede1 Compare May 5, 2023 13:38
This suite of tests was created  originally by  Wileam Phan, Damian Rouson,
and Brad Richardson as part of the
[[ https://github.com/sourceryinstitute/smart-pointers | Smart-Pointers ]]
library's test suite.
All compilers, except for NAG, did not initially have a working/correct
implmentation of finalization.

The original adaptation for inclusion in the llvm-test-suite can be found here:

* https://github.com/BerkeleyLab/llvm-test-suite/tree/damians-fortran-type-finalization
  SHA: `0268bcf0048e67cd1280f9ef65aebd2aa402130b`
* https://github.com/BerkeleyLab/llvm-test-suite/tree/berkely-lab-damian-v0.1
  SHA: `0268bcf0048e67cd1280f9ef65aebd2aa402130b`

The test suite was then adapted to be made appropriate for inclusion
in a compiler test suite by Izaak Beekman.

A summary of the tests can be found in the README.md file added in
the `Fortran/UnitTests` subdirectory.

Co-Authored-by: Damian Rouson <[email protected]>
@zbeekman zbeekman force-pushed the fortran-type-finalization branch from 2bdede1 to 21e7593 Compare May 8, 2023 20:03
@tarunprabhu
Copy link
Contributor

This has been merged in 65b897.

@tarunprabhu tarunprabhu closed this Sep 5, 2023
veselypeta pushed a commit to veselypeta/cherillvm that referenced this pull request Aug 7, 2024
This patch implements the derived-type finalization for
monomorphic and polymorphic derived-type.

The finalization is done through a call to the `Destroy`
runtime function so the allocatable component object are also
finalized correctly when needed. It would be possible to finalize
monomorphic derived-type with non finalizable component with a
direct call to their finalize subroutine.

7.5.6.3 point 1: LHS nonallocatable object and LHS allocatable
object finalization. Done with call to `Destroy` for monomorphic
derived-type and through `Assign` for polymorphic entities.

7.5.6.3 point 2: Done within the deallocation calls.

7.5.6.3 point 3: A function context is added to the bridge to
attach finalization that need to happen on function/subroutine
exit.

7.5.6.3 point 4: BLOCK construct not yet implemented.

7.5.6.3 point 5/6: Finalization attach to the stmtCtx in a
similar way than 9.7.3.2 point 4.

7.5.6.3 point 7: INTENT(OUT) finalization done with a
call to `Destroy` runtime function call.

This patch passes 9/10 tests in the proposed test-suite
llvm/llvm-test-suite#13

- The case with BLOCK construct will be implemented later when
  BLOCK are implemented upstream.

- Automatic deallocation is not yet implemented. Finalization triggered
  by automatic deallocation is then not triggered.

Reviewed By: jeanPerier, PeteSteinfeld

Differential Revision: https://reviews.llvm.org/D142707
veselypeta pushed a commit to veselypeta/cherillvm that referenced this pull request Aug 14, 2024
This patch implements the derived-type finalization for
monomorphic and polymorphic derived-type.

The finalization is done through a call to the `Destroy`
runtime function so the allocatable component object are also
finalized correctly when needed. It would be possible to finalize
monomorphic derived-type with non finalizable component with a
direct call to their finalize subroutine.

7.5.6.3 point 1: LHS nonallocatable object and LHS allocatable
object finalization. Done with call to `Destroy` for monomorphic
derived-type and through `Assign` for polymorphic entities.

7.5.6.3 point 2: Done within the deallocation calls.

7.5.6.3 point 3: A function context is added to the bridge to
attach finalization that need to happen on function/subroutine
exit.

7.5.6.3 point 4: BLOCK construct not yet implemented.

7.5.6.3 point 5/6: Finalization attach to the stmtCtx in a
similar way than 9.7.3.2 point 4.

7.5.6.3 point 7: INTENT(OUT) finalization done with a
call to `Destroy` runtime function call.

This patch passes 9/10 tests in the proposed test-suite
llvm/llvm-test-suite#13

- The case with BLOCK construct will be implemented later when
  BLOCK are implemented upstream.

- Automatic deallocation is not yet implemented. Finalization triggered
  by automatic deallocation is then not triggered.

Reviewed By: jeanPerier, PeteSteinfeld

Differential Revision: https://reviews.llvm.org/D142707
ekilmer added a commit to trail-of-forks/instafix-llvm-test-suite that referenced this pull request Jun 10, 2025
[6/7] : && /home/erickilmer/src/llvm-test-suite/build/tools/timeit --summary MultiSource/Benchmarks/tramp3d-v4/tramp3d-v4.link.time /home/erickilmer/src/instafix/out/build/linux/bin/instafix-front/instafix-front --ld-path=instafix-lld-tool --for-linker=--fake-executable=/home/erickilmer/src/instafix/out/build/linux/bin/instafix-ld/instafix-ld    -O3 -DNDEBUG  MultiSource/Benchmarks/tramp3d-v4/CMakeFiles/tramp3d-v4.dir/tramp3d-v4.cpp.o -o MultiSource/Benchmarks/tramp3d-v4/tramp3d-v4   && cd /home/erickilmer/src/llvm-test-suite/build/MultiSource/Benchmarks/tramp3d-v4 && /usr/bin/cmake -E create_symlink /home/erickilmer/src/llvm-test-suite/MultiSource/Benchmarks/tramp3d-v4/tramp3d-v4.reference_output /home/erickilmer/src/llvm-test-suite/build/MultiSource/Benchmarks/tramp3d-v4/tramp3d-v4.reference_output
FAILED: MultiSource/Benchmarks/tramp3d-v4/tramp3d-v4
: && /home/erickilmer/src/llvm-test-suite/build/tools/timeit --summary MultiSource/Benchmarks/tramp3d-v4/tramp3d-v4.link.time /home/erickilmer/src/instafix/out/build/linux/bin/instafix-front/instafix-front --ld-path=instafix-lld-tool --for-linker=--fake-executable=/home/erickilmer/src/instafix/out/build/linux/bin/instafix-ld/instafix-ld    -O3 -DNDEBUG  MultiSource/Benchmarks/tramp3d-v4/CMakeFiles/tramp3d-v4.dir/tramp3d-v4.cpp.o -o MultiSource/Benchmarks/tramp3d-v4/tramp3d-v4   && cd /home/erickilmer/src/llvm-test-suite/build/MultiSource/Benchmarks/tramp3d-v4 && /usr/bin/cmake -E create_symlink /home/erickilmer/src/llvm-test-suite/MultiSource/Benchmarks/tramp3d-v4/tramp3d-v4.reference_output /home/erickilmer/src/llvm-test-suite/build/MultiSource/Benchmarks/tramp3d-v4/tramp3d-v4.reference_output
ClangLoc: /home/erickilmer/src/instafix-llvm/llvm/out/install/linux/bin/clang
Executing a non indexed phase: "/home/erickilmer/src/instafix/out/build/linux/instafix-lld/instafix-lld-tool" -z relro --hash-style=gnu --eh-frame-hdr -m elf_x86_64 -pie -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o MultiSource/Benchmarks/tramp3d-v4/tramp3d-v4 /lib/x86_64-linux-gnu/Scrt1.o /lib/x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/13/crtbeginS.o -L/usr/lib/gcc/x86_64-linux-gnu/13 -L/usr/lib/gcc/x86_64-linux-gnu/13/../../../../lib64 -L/lib/x86_64-linux-gnu -L/lib/../lib64 -L/usr/lib/x86_64-linux-gnu -L/usr/lib64 -L/lib -L/usr/lib --fake-executable=/home/erickilmer/src/instafix/out/build/linux/bin/instafix-ld/instafix-ld MultiSource/Benchmarks/tramp3d-v4/CMakeFiles/tramp3d-v4.dir/tramp3d-v4.cpp.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/x86_64-linux-gnu/13/crtendS.o /lib/x86_64-linux-gnu/crtn.o
program_name: /home/erickilmer/src/instafix/out/build/linux/instafix-lld/instafix-lld-tool
input_file: /lib/x86_64-linux-gnu/Scrt1.o
input_file: /lib/x86_64-linux-gnu/crti.o
input_file: /usr/lib/gcc/x86_64-linux-gnu/13/crtbeginS.o
input_file: MultiSource/Benchmarks/tramp3d-v4/CMakeFiles/tramp3d-v4.dir/tramp3d-v4.cpp.o
input_file: /usr/lib/gcc/x86_64-linux-gnu/13/crtendS.o
input_file: /lib/x86_64-linux-gnu/crtn.o
instafix-lld-tool: /home/erickilmer/src/instafix-llvm/llvm/include/llvm/ADT/SmallVector.h:313: const_reference llvm::SmallVectorTemplateCommon<mlir::Operation *>::back() const [T = mlir::Operation *]: Assertion `!empty()' failed.
could not parse main module
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: /home/erickilmer/src/instafix/out/build/linux/bin/instafix-front/instafix-front --ld-path=instafix-lld-tool --for-linker=--fake-executable=/home/erickilmer/src/instafix/out/build/linux/bin/instafix-ld/instafix-ld -O3 -DNDEBUG MultiSource/Benchmarks/tramp3d-v4/CMakeFiles/tramp3d-v4.dir/tramp3d-v4.cpp.o -o MultiSource/Benchmarks/tramp3d-v4/tramp3d-v4
 #0 0x00005b86b8f13d41 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/erickilmer/src/instafix-llvm/llvm/lib/Support/Unix/Signals.inc:804:11
 #1 0x00005b86b8f1423b PrintStackTraceSignalHandler(void*) /home/erickilmer/src/instafix-llvm/llvm/lib/Support/Unix/Signals.inc:880:1
 #2 0x00005b86b8f119a6 llvm::sys::RunSignalHandlers() /home/erickilmer/src/instafix-llvm/llvm/lib/Support/Signals.cpp:105:5
 llvm#3 0x00005b86b8f14a1d SignalHandler(int, siginfo_t*, void*) /home/erickilmer/src/instafix-llvm/llvm/lib/Support/Unix/Signals.inc:418:7
 llvm#4 0x00007601f3845330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)
 llvm#5 0x00005b86abc1a58a mlir::Operation::getRegion(unsigned int) /home/erickilmer/src/instafix-llvm/llvm/out/install/linux/include/mlir/IR/Operation.h:688:5
 llvm#6 0x00005b86ac94eb1f mlir::ModuleOp::getBodyRegion() /home/erickilmer/src/instafix-llvm/llvm/out/build/linux/tools/mlir/include/mlir/IR/BuiltinOps.h.inc:200:5
 llvm#7 0x00005b86affa97b2 mlir::link::LinkState::LinkState(mlir::ModuleOp) /home/erickilmer/src/instafix-llvm/mlir/include/mlir/Linker/LinkerInterface.h:40:61
 llvm#8 0x00005b86affa7108 mlir::link::Linker::link(bool) /home/erickilmer/src/instafix-llvm/mlir/lib/Linker/Linker.cpp:74:13
 llvm#9 0x00005b86abbffd34 instafix::Loader::LinkInstafixLLVM() /home/erickilmer/src/instafix/instafix/lib/instafix.cpp:818:35
llvm#10 0x00005b86abc36dc2 instafix::LLDLoader::NativeLinkAndJIT(int, llvm::ArrayRef<char const*>, bool) /home/erickilmer/src/instafix/instafix/lib/LLDLoader.cpp:42:27
llvm#11 0x00005b86abbfa649 instafix::instafix_main(int, char**) /home/erickilmer/src/instafix/instafix/lib/instafix.cpp:264:32
llvm#12 0x00005b86abbf6992 main /home/erickilmer/src/instafix/bin/instafix-front/Main.cpp:25:3
llvm#13 0x00007601f382a1ca __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3
llvm#14 0x00007601f382a28b call_init ./csu/../csu/libc-start.c:128:20
llvm#15 0x00007601f382a28b __libc_start_main ./csu/../csu/libc-start.c:347:5
llvm#16 0x00005b86abbf68a5 _start (/home/erickilmer/src/instafix/out/build/linux/bin/instafix-front/instafix-front+0x688a8a5)
ekilmer added a commit to trail-of-forks/instafix-llvm-test-suite that referenced this pull request Jun 10, 2025
Just one example, but others are likely similar (at least with same
stacktrace)

```
[1/7] : && /home/erickilmer/src/instafix/out/build/linux/bin/instafix-front/instafix-front --ld-path=instafix-lld-tool --for-linker=--fake-executable=/home/erickilmer/src/instafix/out/build/linux/bin/instafix-ld/instafix-ld    -O3 -DNDEB
UG  tools/CMakeFiles/not.dir/not.cpp.o -o tools/not   && :
FAILED: tools/not
: && /home/erickilmer/src/instafix/out/build/linux/bin/instafix-front/instafix-front --ld-path=instafix-lld-tool --for-linker=--fake-executable=/home/erickilmer/src/instafix/out/build/linux/bin/instafix-ld/instafix-ld    -O3 -DNDEBUG  tools/CMakeFiles/not.dir/not.cpp.o -o tools/not   && :
ClangLoc: /home/erickilmer/src/instafix-llvm/llvm/out/install/linux/bin/clang
Executing a non indexed phase: "/home/erickilmer/src/instafix/out/build/linux/instafix-lld/instafix-lld-tool" -z relro --hash-style=gnu --eh-frame-hdr -m elf_x86_64 -pie -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o tools/not /lib/x86_64-linux-gnu/Scrt1.o /lib/x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/13/crtbeginS.o -L/usr/lib/gcc/x86_64-linux-gnu/13 -L/usr/lib/gcc/x86_64-linux-gnu/13/../../../../lib64 -L/lib/x86_64-linux-gnu -L/lib/../lib64 -L/usr/lib/x86_64-linux-gnu -L/usr/lib64 -L/lib -L/usr/lib --fake-executable=/home/erickilmer/src/instafix/out/build/linux/bin/instafix-ld/instafix-ld tools/CMakeFiles/not.dir/not.cpp.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/x86_64-linux-gnu/13/crtendS.o /lib/x86_64-linux-gnu/crtn.o
program_name: /home/erickilmer/src/instafix/out/build/linux/instafix-lld/instafix-lld-tool
input_file: /lib/x86_64-linux-gnu/Scrt1.o
input_file: /lib/x86_64-linux-gnu/crti.o
input_file: /usr/lib/gcc/x86_64-linux-gnu/13/crtbeginS.o
input_file: tools/CMakeFiles/not.dir/not.cpp.o
input_file: /usr/lib/gcc/x86_64-linux-gnu/13/crtendS.o
input_file: /lib/x86_64-linux-gnu/crtn.o
loc("/lib/x86_64-linux-gnu/libc.so":1:1): error: unexpected character
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: /home/erickilmer/src/instafix/out/build/linux/bin/instafix-front/instafix-front --ld-path=instafix-lld-tool --for-linker=--fake-executable=/home/erickilmer/src/instafix/out/build/linux/bin/instafix-ld/instafix-ld -O3 -DNDEBUG tools/CMakeFiles/not.dir/not.cpp.o -o tools/not
 #0 0x000064b890eb6d41 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/erickilmer/src/instafix-llvm/llvm/lib/Support/Unix/Signals.inc:804:11
 #1 0x000064b890eb723b PrintStackTraceSignalHandler(void*) /home/erickilmer/src/instafix-llvm/llvm/lib/Support/Unix/Signals.inc:880:1
 #2 0x000064b890eb49a6 llvm::sys::RunSignalHandlers() /home/erickilmer/src/instafix-llvm/llvm/lib/Support/Signals.cpp:105:5
 llvm#3 0x000064b890eb7a1d SignalHandler(int, siginfo_t*, void*) /home/erickilmer/src/instafix-llvm/llvm/lib/Support/Unix/Signals.inc:418:7
 llvm#4 0x00007c3845445330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)
 llvm#5 0x000064b883cd967c llvm::Value::getType() const /home/erickilmer/src/instafix-llvm/llvm/include/llvm/IR/Value.h:255:34
 llvm#6 0x000064b88fc554d2 llvm::CastInst::castIsValid(llvm::Instruction::CastOps, llvm::Value*, llvm::Type*) /home/erickilmer/src/instafix-llvm/llvm/include/llvm/IR/InstrTypes.h:623:31
 llvm#7 0x000064b890752419 llvm::ConstantExpr::getBitCast(llvm::Constant*, llvm::Type*, bool) /home/erickilmer/src/instafix-llvm/llvm/lib/IR/Constants.cpp:2325:3
 llvm#8 0x000064b887051e16 mlir::LLVM::detail::getLLVMConstant(llvm::Type*, mlir::Attribute, mlir::Location, mlir::LLVM::ModuleTranslation const&) /home/erickilmer/src/instafix-llvm/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp:602:5
 llvm#9 0x000064b88705bb47 mlir::LLVM::ModuleTranslation::convertOneFunction(mlir::LLVM::LLVMFuncOp) /home/erickilmer/src/instafix-llvm/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp:1465:25
llvm#10 0x000064b88705eea3 mlir::LLVM::ModuleTranslation::convertFunctions() /home/erickilmer/src/instafix-llvm/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp:1804:16
llvm#11 0x000064b88706144d mlir::translateModuleToLLVMIR(mlir::Operation*, llvm::LLVMContext&, llvm::StringRef, bool) /home/erickilmer/src/instafix-llvm/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp:2218:25
llvm#12 0x000064b883ba2fda instafix::Loader::LinkInstafixLLVM() /home/erickilmer/src/instafix/instafix/lib/instafix.cpp:837:7
llvm#13 0x000064b883bd9dc2 instafix::LLDLoader::NativeLinkAndJIT(int, llvm::ArrayRef<char const*>, bool) /home/erickilmer/src/instafix/instafix/lib/LLDLoader.cpp:42:27
llvm#14 0x000064b883b9d649 instafix::instafix_main(int, char**) /home/erickilmer/src/instafix/instafix/lib/instafix.cpp:264:32
llvm#15 0x000064b883b99992 main /home/erickilmer/src/instafix/bin/instafix-front/Main.cpp:25:3
llvm#16 0x00007c384542a1ca __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3
llvm#17 0x00007c384542a28b call_init ./csu/../csu/libc-start.c:128:20
llvm#18 0x00007c384542a28b __libc_start_main ./csu/../csu/libc-start.c:347:5
llvm#19 0x000064b883b998a5 _start (/home/erickilmer/src/instafix/out/build/linux/bin/instafix-front/instafix-front+0x688a8a5)
Segmentation fault (core dumped)
```

with gdb stacktrace:

```
$ cd build
$ gdb --args /home/erickilmer/src/instafix/out/build/linux/bin/instafix-front/instafix-front --ld-path=instafix-lld-tool --for-linker=--fake-executable=/home/erickilmer/src/instafix/out/build/linux/bin/instafix-ld/instafix-ld -O3 -DNDEBUG tools/CMakeFiles/not.dir/not.cpp.o -o tools/not
[...]
(gdb) r
[...]
Thread 1 "instafix-front" received signal SIGSEGV, Segmentation fault.
llvm::Value::getType (this=0x0) at /home/erickilmer/src/instafix-llvm/llvm/include/llvm/IR/Value.h:255
255	  Type *getType() const { return VTy; }
(gdb) bt
#0  llvm::Value::getType (this=0x0) at /home/erickilmer/src/instafix-llvm/llvm/include/llvm/IR/Value.h:255
#1  0x0000555567e9a4d2 in llvm::CastInst::castIsValid (op=llvm::Instruction::BitCast, S=0x0, DstTy=0x555569811470) at /home/erickilmer/src/instafix-llvm/llvm/include/llvm/IR/InstrTypes.h:623
#2  0x0000555568997419 in llvm::ConstantExpr::getBitCast (C=0x0, DstTy=0x555569811470, OnlyIfReduced=false) at /home/erickilmer/src/instafix-llvm/llvm/lib/IR/Constants.cpp:2325
llvm#3  0x000055555f296e16 in mlir::LLVM::detail::getLLVMConstant (llvmType=0x555569811470, attr=..., loc=..., moduleTranslation=...) at /home/erickilmer/src/instafix-llvm/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp:602
llvm#4  0x000055555f2a0b47 in mlir::LLVM::ModuleTranslation::convertOneFunction (this=0x7fffffff3710, func=...) at /home/erickilmer/src/instafix-llvm/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp:1465
llvm#5  0x000055555f2a3ea3 in mlir::LLVM::ModuleTranslation::convertFunctions (this=0x7fffffff3710) at /home/erickilmer/src/instafix-llvm/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp:1804
llvm#6  0x000055555f2a644d in mlir::translateModuleToLLVMIR (module=0x5555697e32b0, llvmContext=..., name=..., disableVerification=false) at /home/erickilmer/src/instafix-llvm/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp:2218
llvm#7  0x000055555bde7fda in instafix::Loader::LinkInstafixLLVM (this=0x55556979ea80) at /home/erickilmer/src/instafix/instafix/lib/instafix.cpp:837
llvm#8  0x000055555be1edc2 in instafix::LLDLoader::NativeLinkAndJIT (this=0x55556979ea80, argc=7, argv=..., exec=false) at /home/erickilmer/src/instafix/instafix/lib/LLDLoader.cpp:42
llvm#9  0x000055555bde2649 in instafix::instafix_main (argc=8, argv=0x7fffffffccc8) at /home/erickilmer/src/instafix/instafix/lib/instafix.cpp:264
llvm#10 0x000055555bdde992 in main (argc=8, argv=0x7fffffffccc8) at /home/erickilmer/src/instafix/bin/instafix-front/Main.cpp:25
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants