llvm / llvm/llvm-project

module IR code is not dumped on exit in kaleidoscope example

Open
#168,114 0 comments 0 reactions 0 assignees View on GitHub
kaleidoscope
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

[Documentation](https://llvm.org/docs/tutorial/MyFirstLanguageFrontend/LangImpl03.html#driver-changes-and-closing-thoughts) states that on `^D` on `Linux`(I checked on `MacOS`) the llvm module should [dump](https://github.com/llvm/llvm-project/blob/main/llvm/examples/Kaleidoscope/Chapter3/toy.cpp#L619) all generated `IR` code. It seems that somehow the code is flushed off before being printed, the only output is something like:
```
; ModuleID = 'global_module'
source_filename = "global_module"
```

The workaround was to implement a more deterministic program exit [control](https://github.com/popescun/Learning/blob/main/llvm/kaleidoscope/ast.cpp#L559) using a predefined input token, e.g. `exit`.

Contributor guide

Open the contributing guide

Research direction

Start with the Kaleidoscope documentation section on driver changes and the linked llvm/examples/Kaleidoscope/Chapter3/toy.cpp around line 619. Reproduce the ^D exit behavior on the example and inspect how generated IR is emitted during shutdown. Done means the documented EOF path dumps the generated module rather than only its header.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.