This is an archive of the discontinued LLVM Phabricator instance.

[asan] Fixed a runtime crash.
ClosedPublic

Authored by kstoimenov on Aug 25 2021, 5:29 PM.

Details

Summary

Looks like the NoRegister has some effect on the final code that is generated. My guess is that some optimization kicks in at the end?

When I use -S to dump the assembly I get the correct version with 'shrq $3, %r8':

movq    %r9, %r8
shrq    $3, %r8
movsbl  2147450880(%r8), %r8d

But, when I disassemble the final binary I get RAX in stead of R8:

mov    %r9,%r8
shr    $0x3,%rax
movsbl 0x7fff8000(%r8),%r8d

Diff Detail

Event Timeline

kstoimenov created this revision.Aug 25 2021, 5:29 PM
kstoimenov requested review of this revision.Aug 25 2021, 5:29 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 25 2021, 5:29 PM
kstoimenov edited the summary of this revision. (Show Details)Aug 25 2021, 5:31 PM
kstoimenov added a reviewer: vitalybuka.

Can you add a test?

So the test will compile to an executable, so it will have to be a cpp file with a main. Then it will run 'objdump --disassemble=__asan_check_load4_rn53' and check that the machine code is properly generated. Where would be a good place to put this kind of test? The llvm/test/CodeGen/X86 location doesn't seem to be a good place as it has only .ll files in it.

kstoimenov edited the summary of this revision. (Show Details)Aug 26 2021, 9:14 AM

So the test will compile to an executable, so it will have to be a cpp file with a main. Then it will run 'objdump --disassemble=__asan_check_load4_rn53' and check that the machine code is properly generated. Where would be a good place to put this kind of test? The llvm/test/CodeGen/X86 location doesn't seem to be a good place as it has only .ll files in it.

No. I am asking about extending tests of original patch.
Something must be different. Maybe one of obj files contains code with different reg then the rest and linker just picked not the one you are expected.
Maybe flags used to compile that object file was somehow special.

Would be nice to find-out why. I am not comfortable (as with the same place in the original patch as well) with having code which makes a difference, but invisible to tests.

vitalybuka accepted this revision.Aug 26 2021, 12:56 PM

It would be nice if you find how you compiler that obj, but LGTM as is

This revision is now accepted and ready to land.Aug 26 2021, 12:56 PM
This revision was automatically updated to reflect the committed changes.