6

Fix miscompilation when cg_ssa is using multiple builders at the same time by bj...

 2 years ago
source link: https://github.com/rust-lang/rustc_codegen_gcc/pull/131
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

src/builder.rs

Outdated Show resolved

src/builder.rs

Outdated Show resolved

} else {

self.const_bitcast(value, ty)

}

self.const_bitcast(value, ty)

Copy link

Collaborator

@antoyo antoyo 10 days ago

This does not look right. bitsize could potentially be 1, so are you sure the type will be the same size?

Copy link

Contributor

Author

@bjorn3 bjorn3 10 days ago

Only for a bool can bitsize be 1. A bool is represented as self.bool_type which is also 1 bit.

Copy link

Collaborator

@antoyo antoyo 10 days ago

Oh, right, type_ix() will return self.i8_type which is 8 bits, like self.bool_type.
In any case, it seems like the size is always equal, since the tests pass, but I'd also like an assert for the size.

Copy link

Contributor

Author

@bjorn3 bjorn3 9 days ago

Looks like .get_size() doesn't work on pointer types. In addition it returns a byte size and not a bit size, so a bool would either be not supported or get a byte size of 1 despite having a bit size of 1.

Copy link

Collaborator

@antoyo antoyo 9 days ago

get_size() indeed only works on integers. If needed, I can make it work for pointer types.

That's a difference between LLVM and gcc: LLVM has a type i1 of "1 bit" for bool while GCC's bool is 8 bits.

Copy link

Contributor

Author

@bjorn3 bjorn3 9 days ago

type_ix(1) needs to be a bool_type. Seems like it is currently implemented as i8_type.

Copy link

Collaborator

@antoyo antoyo 9 days ago

Ok, can you add a TODO here saying to add an assert for the sizes, please?

Copy link

Contributor

Author

@bjorn3 bjorn3 9 days ago


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK