ChuanqiXu9 wrote:

> Thanks! With all the explanation, the patch makes a lot of sense. Generally 
> LG, I just have a few more NITs and feel it's good to go.

Thanks.

> 
> I am surprised to hear we have less TypeIDs than DeclIDs. My mental model was 
> that for every type Decl we introduce, we'd have at least a few types with it 
> (the type itself, pointer to that type, reference to that type, functions 
> returning that type, etc). And every non-type declaration will have it's own 
> type (the functions often have unique signatures). Do we end up reusing the 
> types from the current compilation and other modules we imported often enough 
> that the amount of newly introduced types ends up being small? Or is my logic 
> flawed in some ways?

Since most of the time, the types are reused. For example, if we have,

```
export module A;
export struct A { int a; }
export A getA(A) { return {43}; }
```

```
export module B;
import A;
export struct B {
     A v1;
     A v2;
     A v3;
};

export A getAFromB(A p) { ... }
```

In the above example, in module B, there will be (in my mind, I didn't 
experiment actually) 6 new decls (a new `struct decl` for `B`, 3 new `field 
decl` for `v1`, `v2` and `v3`. a new `function decl` for `getAFromB` and a new 
parm decl for `p`). However, there will only be only one new type, the struct 
type B. The function type `A *(A)` is reused. 

So I feel it pretty makes sense that the number of type ID is much less than 
Decl ID.



https://github.com/llvm/llvm-project/pull/92511
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to