snu-sf-class / swpp202401

Principles and Practices of Software Development Main Repository
13 stars 4 forks source link

[Project] backend not casting i32 index to i64 in getelementptr #80

Open Wits15730 opened 5 months ago

Wits15730 commented 5 months ago

컴파일러가 getelementptr 에서 index가 i32일 때 i64로 변환하지 않는 것 같습니다. 가령 기존의 최적화 패스만을 사용하여 다음과 같은 line을 얻을 수 있습니다. %21 = getelementptr inbounds i64, ptr %20, i32 0

그러나 i32 0을 i64로 변환하지 않아서 다음과 같은 에러가 발생하고 있습니다. static BinaryOperator llvm::BinaryOperator::Create(BinaryOps, Value , Value , const Twine &, Instruction ): Assertion `S1->getType() == S2->getType() && "Cannot create binary operator with two operands of differing type!"' failed.

이 문제는 src/lib/backend의 gep_eliminate.cpp line 68에서 op를 사용하기 전에, i64로 casting 하였더니 해결되는 것을 확인했습니다. 혹시 컴파일러 코드를 변경해 주실 수 있으신가요?

감사합니다.

strikef commented 5 months ago

컴파일러의 버그가 맞으며, 조금 더 면밀히 봐야 하겠으나 index의 타입을 맞춰주는 방향으로 수정 예정입니다.

strikef commented 5 months ago

5/14일자 백엔드 패치에서 수정되었습니다.