Skip to content

Commit b6da4bf

Browse files
committed
[NFC][HWASAN] Move getUARTag into the Entry
Reviewed By: kstoimenov, eugenis Differential Revision: https://reviews.llvm.org/D149221
1 parent 6e8b2a8 commit b6da4bf

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ class HWAddressSanitizer {
305305
void tagAlloca(IRBuilder<> &IRB, AllocaInst *AI, Value *Tag, size_t Size);
306306
Value *tagPointer(IRBuilder<> &IRB, Type *Ty, Value *PtrLong, Value *Tag);
307307
Value *untagPointer(IRBuilder<> &IRB, Value *PtrLong);
308-
bool instrumentStack(memtag::StackInfo &Info, Value *StackTag,
308+
bool instrumentStack(memtag::StackInfo &Info, Value *StackTag, Value *UARTag,
309309
const DominatorTree &DT, const PostDominatorTree &PDT,
310310
const LoopInfo &LI);
311311
Value *readRegister(IRBuilder<> &IRB, StringRef Name);
@@ -1047,7 +1047,7 @@ Value *HWAddressSanitizer::getNextTagWithCall(IRBuilder<> &IRB) {
10471047

10481048
Value *HWAddressSanitizer::getStackBaseTag(IRBuilder<> &IRB) {
10491049
if (ClGenerateTagsWithCalls)
1050-
return getNextTagWithCall(IRB);
1050+
return nullptr;
10511051
if (StackBaseTag)
10521052
return StackBaseTag;
10531053
// Extract some entropy from the stack pointer for the tags.
@@ -1276,7 +1276,7 @@ static bool isLifetimeIntrinsic(Value *V) {
12761276
}
12771277

12781278
bool HWAddressSanitizer::instrumentStack(memtag::StackInfo &SInfo,
1279-
Value *StackTag,
1279+
Value *StackTag, Value *UARTag,
12801280
const DominatorTree &DT,
12811281
const PostDominatorTree &PDT,
12821282
const LoopInfo &LI) {
@@ -1342,7 +1342,6 @@ bool HWAddressSanitizer::instrumentStack(memtag::StackInfo &SInfo,
13421342

13431343
auto TagEnd = [&](Instruction *Node) {
13441344
IRB.SetInsertPoint(Node);
1345-
Value *UARTag = getUARTag(IRB);
13461345
// When untagging, use the `AlignedSize` because we need to set the tags
13471346
// for the entire alloca to zero. If we used `Size` here, we would
13481347
// keep the last granule tagged, and store zero in the last byte of the
@@ -1446,9 +1445,9 @@ void HWAddressSanitizer::sanitizeFunction(Function &F,
14461445
const DominatorTree &DT = FAM.getResult<DominatorTreeAnalysis>(F);
14471446
const PostDominatorTree &PDT = FAM.getResult<PostDominatorTreeAnalysis>(F);
14481447
const LoopInfo &LI = FAM.getResult<LoopAnalysis>(F);
1449-
Value *StackTag =
1450-
ClGenerateTagsWithCalls ? nullptr : getStackBaseTag(EntryIRB);
1451-
instrumentStack(SInfo, StackTag, DT, PDT, LI);
1448+
Value *StackTag = getStackBaseTag(EntryIRB);
1449+
Value *UARTag = getUARTag(EntryIRB);
1450+
instrumentStack(SInfo, StackTag, UARTag, DT, PDT, LI);
14521451
}
14531452

14541453
// If we split the entry block, move any allocas that were originally in the

0 commit comments

Comments
 (0)