@@ -371,26 +371,10 @@ static bool isStructPathTBAA(const MDNode *MD) {
371371 return isa<MDNode>(MD->getOperand (0 )) && MD->getNumOperands () >= 3 ;
372372}
373373
374- // When using the TypeSanitizer, don't use TBAA information for alias analysis.
375- // This might cause us to remove memory accesses that we need to verify at
376- // runtime.
377- static bool usingSanitizeType (const Value *V) {
378- const Function *F;
379-
380- if (auto *I = dyn_cast<Instruction>(V))
381- F = I->getParent ()->getParent ();
382- else if (auto *A = dyn_cast<Argument>(V))
383- F = A->getParent ();
384- else
385- return false ;
386-
387- return F->hasFnAttribute (Attribute::SanitizeType);
388- }
389-
390374AliasResult TypeBasedAAResult::alias (const MemoryLocation &LocA,
391375 const MemoryLocation &LocB,
392376 AAQueryInfo &AAQI, const Instruction *) {
393- if (!EnableTBAA || usingSanitizeType (LocA. Ptr ) || usingSanitizeType (LocB. Ptr ) )
377+ if (!EnableTBAA || UsingTypeSanitizer || UsingTypeSanitizer )
394378 return AAResultBase::alias (LocA, LocB, AAQI, nullptr );
395379
396380 if (Aliases (LocA.AATags .TBAA , LocB.AATags .TBAA ))
@@ -441,7 +425,7 @@ MemoryEffects TypeBasedAAResult::getMemoryEffects(const Function *F) {
441425ModRefInfo TypeBasedAAResult::getModRefInfo (const CallBase *Call,
442426 const MemoryLocation &Loc,
443427 AAQueryInfo &AAQI) {
444- if (!EnableTBAA || usingSanitizeType (Call) )
428+ if (!EnableTBAA || UsingTypeSanitizer )
445429 return AAResultBase::getModRefInfo (Call, Loc, AAQI);
446430
447431 if (const MDNode *L = Loc.AATags .TBAA )
@@ -455,7 +439,7 @@ ModRefInfo TypeBasedAAResult::getModRefInfo(const CallBase *Call,
455439ModRefInfo TypeBasedAAResult::getModRefInfo (const CallBase *Call1,
456440 const CallBase *Call2,
457441 AAQueryInfo &AAQI) {
458- if (!EnableTBAA || usingSanitizeType (Call1) )
442+ if (!EnableTBAA || UsingTypeSanitizer )
459443 return AAResultBase::getModRefInfo (Call1, Call2, AAQI);
460444
461445 if (const MDNode *M1 = Call1->getMetadata (LLVMContext::MD_tbaa))
@@ -722,7 +706,7 @@ bool TypeBasedAAResult::Aliases(const MDNode *A, const MDNode *B) const {
722706AnalysisKey TypeBasedAA::Key;
723707
724708TypeBasedAAResult TypeBasedAA::run (Function &F, FunctionAnalysisManager &AM) {
725- return TypeBasedAAResult ();
709+ return TypeBasedAAResult (F. hasFnAttribute (Attribute::SanitizeType) );
726710}
727711
728712char TypeBasedAAWrapperPass::ID = 0 ;
@@ -738,7 +722,7 @@ TypeBasedAAWrapperPass::TypeBasedAAWrapperPass() : ImmutablePass(ID) {
738722}
739723
740724bool TypeBasedAAWrapperPass::doInitialization (Module &M) {
741- Result.reset (new TypeBasedAAResult ());
725+ Result.reset (new TypeBasedAAResult (false ));
742726 return false ;
743727}
744728
0 commit comments