Skip to content
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

[C++20] [Modules] Record BMI Hash which is consistent if the interfaces doesn't change #71618

Open
ChuanqiXu9 opened this issue Nov 8, 2023 · 4 comments · May be fixed by #71627
Open

[C++20] [Modules] Record BMI Hash which is consistent if the interfaces doesn't change #71618

ChuanqiXu9 opened this issue Nov 8, 2023 · 4 comments · May be fixed by #71627
Assignees
Labels
clang:modules C++20 modules and Clang Header Modules

Comments

@ChuanqiXu9
Copy link
Member

The motivating example comes from #70569.

For example,

// a.cppm
export module a;
export int a() {
    return 43;
}

// use.cc
import a;
int use() {
    return a();
}

After we change the implementation of a() from return 43; to return 44;, we can avoid recompiling use.cc to use.o since the interface doesn't change.
This is pretty helpful to improve the user's experience by avoiding unnecessary recompilations as much as possible.

@ChuanqiXu9 ChuanqiXu9 added the clang:modules C++20 modules and Clang Header Modules label Nov 8, 2023
@ChuanqiXu9 ChuanqiXu9 self-assigned this Nov 8, 2023
@llvmbot
Copy link
Collaborator

llvmbot commented Nov 8, 2023

@llvm/issue-subscribers-clang-modules

Author: Chuanqi Xu (ChuanqiXu9)

The motivating example comes from https://github.com//issues/70569.

For example,

// a.cppm
export module a;
export int a() {
    return 43;
}

// use.cc
import a;
int use() {
    return a();
}

After we change the implementation of a() from return 43; to return 44;, we can avoid recompiling use.cc to use.o since the interface doesn't change.
This is pretty helpful to improve the user's experience by avoiding unnecessary recompilations as much as possible.

@dwblaikie
Copy link
Collaborator

(might be worth linking to the discourse thread from here so we don't duplicate the discussion)

@ChuanqiXu9
Copy link
Member Author

Good idea. We've discussed the ideas here: https://discourse.llvm.org/t/rfc-c-20-modules-introduce-thin-bmi-and-decls-hash/74755

@ChuanqiXu9
Copy link
Member Author

This is somehow covered by #86912 with -fexperimental-modules-reduced-bmi.

Now for the example with reduced BMI:

//--- A.cppm
export module A;
export int funcA() {
    return 43;
}

//--- A.v1.cppm
export module A;

export int funcA() {
    return 43;
}

//--- B.cppm
export module B;
import A;

export int funcB() {
    return funcA();
}

//--- C.cppm
export module C;
import B;

...

Now although B will almost always get changed if module A changes, but the BMI of B won't change if it doesn't affect the interface. Then we can avoid the recompilation of C.

Note that the original idea that avoid changing the BMI of A is considered not good now since we think the source location is significant.

Then I'd like to close the issue since we may not record and read a BMI hash but generate the same BMI directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:modules C++20 modules and Clang Header Modules
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants