microsoft / llvm-mctoll

llvm-mctoll
Other
816 stars 125 forks source link

[X86-64] For CMPmi instructions, use the correct type to load from memory #128

Closed martin-fink closed 3 years ago

martin-fink commented 3 years ago

Previously the value from memory would be loaded using the immediate's type. This would result in the following instruction

cmp [rdi + 8], 0

being raised to the following:

%0 = inttoptr i64 %arg1 to i8*
%1 = load i8, i8* %0, align 1 ; loads only one of four bytes
...

After this commit, the raised bitcode looks like this:

%0 = inttoptr i64 %arg1 to i32*
%1 = load i32, i32* %0, align 1
...