mukul-rathi / bolt

Bolt is a language with in-built data-race freedom!
MIT License
573 stars 53 forks source link

Explicitly cast function argument types in LLVM IR #135

Closed mukul-rathi closed 4 years ago

mukul-rathi commented 4 years ago

If we have

class Foo { var int f  ....}
class Bar extends Foo{ var int g ....}

function void test(Foo x){}

let x = new Bar();
test(x) // LLVM complains as Bar * struct rather than Foo * struct

Since a Bar struct

 { 
int f, 
int g
}

just extends the Foo representation

 {
int f
}

this only requires a pointer bit-cast - just a small subtlety to keep LLVM happy.