Skip to content

Commit e5018cd

Browse files
committed
[𝘀𝗽𝗿] initial version
Created using spr 1.3.4
1 parent 0100c63 commit e5018cd

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1793,8 +1793,15 @@ void HWAddressSanitizer::instrumentGlobal(GlobalVariable *GV, uint8_t Tag) {
17931793
}
17941794

17951795
void HWAddressSanitizer::instrumentGlobals() {
1796-
std::vector<GlobalVariable *> Globals;
1797-
for (GlobalVariable &GV : M.globals()) {
1796+
MD5 Hasher;
1797+
Hasher.update(M.getSourceFileName());
1798+
MD5::MD5Result Hash;
1799+
Hasher.final(Hash);
1800+
uint8_t Tag = Hash[0];
1801+
1802+
assert(TagMaskByte >= 16);
1803+
1804+
for (GlobalVariable &GV : make_early_inc_range(M.globals())) {
17981805
if (GV.hasSanitizerMetadata() && GV.getSanitizerMetadata().NoHWAddress)
17991806
continue;
18001807

@@ -1812,24 +1819,12 @@ void HWAddressSanitizer::instrumentGlobals() {
18121819
if (GV.hasSection())
18131820
continue;
18141821

1815-
Globals.push_back(&GV);
1816-
}
1817-
1818-
MD5 Hasher;
1819-
Hasher.update(M.getSourceFileName());
1820-
MD5::MD5Result Hash;
1821-
Hasher.final(Hash);
1822-
uint8_t Tag = Hash[0];
1823-
1824-
assert(TagMaskByte >= 16);
1825-
1826-
for (GlobalVariable *GV : Globals) {
18271822
// Don't allow globals to be tagged with something that looks like a
18281823
// short-granule tag, otherwise we lose inter-granule overflow detection, as
18291824
// the fast path shadow-vs-address check succeeds.
18301825
if (Tag < 16 || Tag > TagMaskByte)
18311826
Tag = 16;
1832-
instrumentGlobal(GV, Tag++);
1827+
instrumentGlobal(&GV, Tag++);
18331828
}
18341829
}
18351830

0 commit comments

Comments
 (0)