rui314 / 8cc

A Small C Compiler
MIT License
6.13k stars 740 forks source link

Respect ty->usig in get_load_inst. #44

Closed tj90241 closed 9 years ago

tj90241 commented 9 years ago

get_load_inst needs to consider the signed-ness of the type that it's emitting a load instruction for. If the load is unsigned, emit zero-extended load instructions.

tj90241 commented 9 years ago

This also has the unfortunate side-effect of breaking the varargs test.

tj90241 commented 9 years ago

Making gp_offset and fp_offset of struct __va_elem type int (instead of unsigned int) makes the tests pass; hmm...

tj90241 commented 9 years ago

Ahh, forgot about x86_64 zero-extension weirdness; fixed and passing tests again! Please review and pull.

andrewchambers commented 9 years ago

You need to include a failing test case along with your fix.

tj90241 commented 9 years ago

Hm, thanks for the testcase request. I can only seem to make bc334b2 or 257c809 / 188b139 fail (but not both separately). I'll keep trying; I think it might be possible.

tj90241 commented 9 years ago

Seems like 257c809 / 188b139 are unnecessary. I'll close this pull request and open a new one with the minimal set of commits required.