This is an archive of the discontinued LLVM Phabricator instance.

[HWAsan][NewPM] Handle hwasan like other sanitizers
ClosedPublic

Authored by aeubanks on Oct 6 2020, 4:30 PM.

Details

Summary

Move it as an EP callback (-O[123]) or in addSanitizersAtO0.

This makes it not run in ThinLTO pre-link (like the other sanitizers),
so don't check LTO runs in hwasan-new-pm.c. Changing its position also
seems to change the generated IR. I think we just need to make sure the
pass runs.

Diff Detail

Event Timeline

aeubanks created this revision.Oct 6 2020, 4:30 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 6 2020, 4:30 PM
aeubanks requested review of this revision.Oct 6 2020, 4:30 PM

To what extent does the IR change? My only concern is the right codegen is still produced.

diff for hwasan + -O1:

14a15

@__hwasan_shadow = external global [0 x i8]

72a74,109

declare void @__hwasan_loadN(i64, i64)

declare void @__hwasan_load1(i64)

declare void @__hwasan_load2(i64)

declare void @__hwasan_load4(i64)

declare void @__hwasan_load8(i64)

declare void @__hwasan_load16(i64)

declare void @__hwasan_storeN(i64, i64)

declare void @__hwasan_store1(i64)

declare void @__hwasan_store2(i64)

declare void @__hwasan_store4(i64)

declare void @__hwasan_store8(i64)

declare void @__hwasan_store16(i64)

declare void @__hwasan_tag_memory(i8*, i8, i64)

declare i8 @__hwasan_generate_tag()

declare i8* @__hwasan_memmove(i8*, i8*, i64)

declare i8* @__hwasan_memcpy(i8*, i8*, i64)

declare i8* @__hwasan_memset(i8*, i32, i64)

declare void @__hwasan_handle_vfork(i64)

diff for khwasan + -O1:

7a8

@__hwasan_shadow = external global [0 x i8]

34,35c35,36
< call void asm sideeffect "int3\0Anopl 66(%rax)", "{rdi}"(i64 %4)

< unreachable

call void asm sideeffect "int3\0Anopl 98(%rax)", "{rdi}"(i64 %4)
br label %27

51c52

< 27: ; preds = %22

27: ; preds = %16, %22

60a62,97

declare void @__hwasan_loadN_noabort(i64, i64)

declare void @__hwasan_load1_noabort(i64)

declare void @__hwasan_load2_noabort(i64)

declare void @__hwasan_load4_noabort(i64)

declare void @__hwasan_load8_noabort(i64)

declare void @__hwasan_load16_noabort(i64)

declare void @__hwasan_storeN_noabort(i64, i64)

declare void @__hwasan_store1_noabort(i64)

declare void @__hwasan_store2_noabort(i64)

declare void @__hwasan_store4_noabort(i64)

declare void @__hwasan_store8_noabort(i64)

declare void @__hwasan_store16_noabort(i64)

declare void @__hwasan_tag_memory(i8*, i8, i64)

declare i8 @__hwasan_generate_tag()

declare i8* @memmove(i8*, i8*, i64)

declare i8* @memcpy(i8*, i8*, i64)

declare i8* @memset(i8*, i32, i64)

Looks like the IR is the (mostly) same, just some declarations cleaned up.

leonardchan accepted this revision.Oct 8 2020, 11:49 AM

I see. LGTM

This revision is now accepted and ready to land.Oct 8 2020, 11:49 AM
This revision was automatically updated to reflect the committed changes.