This is an archive of the discontinued LLVM Phabricator instance.

[asan] Refactor instrumentation of globals.
ClosedPublic

Authored by eugenis on Jan 11 2017, 5:21 PM.

Details

Reviewers
rgov
pcc
rnk
Summary

Move instrumentation code for different platforms (coff/macho/generic) to separate functions.
+50 lines of code, but way more readable, especially if (or when) we end up adding elf-specific instrumentation.

This is https://reviews.llvm.org/D28498 without any new functionality.

Diff Detail

Repository
rL LLVM

Event Timeline

eugenis updated this revision to Diff 84059.Jan 11 2017, 5:21 PM
eugenis retitled this revision from to [asan] Refactor instrumentation of globals..
eugenis updated this object.
eugenis added reviewers: rnk, pcc.
eugenis set the repository for this revision to rL LLVM.
eugenis added a subscriber: llvm-commits.
pcc edited edge metadata.Jan 11 2017, 5:46 PM

Thanks for working on this!

lib/Transforms/Instrumentation/AddressSanitizer.cpp
605–614

These could all take ArrayRefs.

1621–1628

I guess we can move this part into InstrumentGlobalsCOFF as a separate functional change.

1654

.

1899–1900

Fold these into their only use.

1907–1910

Why not just

} else {
  InstrumentGlobalsWithMetadataArray(IRB, M, NewGlobals, Initializers);
}

?

eugenis updated this revision to Diff 84156.Jan 12 2017, 11:47 AM
eugenis edited edge metadata.
eugenis marked 2 inline comments as done.
eugenis added inline comments.
lib/Transforms/Instrumentation/AddressSanitizer.cpp
1621–1628

Actually this is not COFF-specific. See https://reviews.llvm.org/D28573. The comment update got lost somehow.

1654

?

eugenis updated this revision to Diff 84157.Jan 12 2017, 11:48 AM
eugenis marked an inline comment as done.
pcc added inline comments.Jan 12 2017, 11:52 AM
lib/Transforms/Instrumentation/AddressSanitizer.cpp
1621–1628

Can you please update the comment, then?

1654

Ignore this, phab wouldn't delete my comment

eugenis added inline comments.Jan 12 2017, 11:55 AM
lib/Transforms/Instrumentation/AddressSanitizer.cpp
1621–1628

I think I've done that.

pcc added inline comments.Jan 12 2017, 12:03 PM
lib/Transforms/Instrumentation/AddressSanitizer.cpp
1621–1628

The way the comment is currently worded, it seems to be about just MSVC. I would explain why the alignment is needed in the first sentence, and reword the second sentence to something like "Also, the MSVC linker..."

eugenis added inline comments.
lib/Transforms/Instrumentation/AddressSanitizer.cpp
1621–1628

In fact, I don't see why we can not simply use the default alignment on non-COFF targets. As long as the size of the global is divisible by the alignment, there should be no padding. By over-aligning, we waste up to 56 bytes.

pcc accepted this revision.Jan 12 2017, 2:54 PM
pcc edited edge metadata.

LGTM

lib/Transforms/Instrumentation/AddressSanitizer.cpp
1621–1628

Makes sense to me. I'd make a separate change to use default alignment on non-COFF and see what the bots think.

This revision is now accepted and ready to land.Jan 12 2017, 2:54 PM
eugenis closed this revision.Jan 12 2017, 3:14 PM

Landed in r291858