llvm.org GIT mirror llvm / e6b56b9
[Attributor][FIX] Avoid modifying naked/optnone functions The check for naked/optnone was insufficient for different reasons. We now check before we initialize an abstract attribute and we do it for all abstract attributes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@374694 91177308-0d34-0410-b5e6-96231b3b80d8 Johannes Doerfert 1 year, 1 month ago
3 changed file(s) with 36 addition(s) and 9 deletion(s). Raw diff Collapse all Expand all
912912 // Use the static create method.
913913 auto &AA = AAType::createForPosition(IRP, *this);
914914 registerAA(AA);
915 AA.initialize(*this);
915
916 // For now we ignore naked and optnone functions.
917 bool Invalidate = Whitelist && !Whitelist->count(&AAType::ID);
918 if (const Function *Fn = IRP.getAnchorScope())
919 Invalidate |= Fn->hasFnAttribute(Attribute::Naked) ||
920 Fn->hasFnAttribute(Attribute::OptimizeNone);
916921
917922 // Bootstrap the new attribute with an initial update to propagate
918923 // information, e.g., function -> call site. If it is not on a given
919924 // whitelist we will not perform updates at all.
920 if (Whitelist && !Whitelist->count(&AAType::ID))
925 if (Invalidate) {
921926 AA.getState().indicatePessimisticFixpoint();
922 else
923 AA.update(*this);
927 return AA;
928 }
929
930 AA.initialize(*this);
931 AA.update(*this);
924932
925933 if (TrackDependence && AA.getState().isValidState())
926934 QueryMap[&AA].insert(const_cast(QueryingAA));
48464846 else
48474847 NumFnWithoutExactDefinition++;
48484848
4849 // For now we ignore naked and optnone functions.
4850 if (F.hasFnAttribute(Attribute::Naked) ||
4851 F.hasFnAttribute(Attribute::OptimizeNone))
4852 continue;
4853
48544849 // We look at internal functions only on-demand but if any use is not a
48554850 // direct call, we have to do it eagerly.
48564851 if (F.hasLocalLinkage()) {
544544 ret void
545545 }
546546
547 ; Expect nonnull
548 ; ATTRIBUTOR: define internal void @control(i32* nocapture nonnull readnone align 16 dereferenceable(8) %a)
549 define internal void @control(i32* dereferenceable(4) %a) {
550 call void @use_i32_ptr(i32* %a)
551 ret void
552 }
553 ; Avoid nonnull as we do not touch naked functions
554 ; ATTRIBUTOR: define internal void @naked(i32* dereferenceable(4) %a)
555 define internal void @naked(i32* dereferenceable(4) %a) naked {
556 call void @use_i32_ptr(i32* %a)
557 ret void
558 }
559 ; Avoid nonnull as we do not touch optnone
560 ; ATTRIBUTOR: define internal void @optnone(i32* dereferenceable(4) %a)
561 define internal void @optnone(i32* dereferenceable(4) %a) optnone noinline {
562 call void @use_i32_ptr(i32* %a)
563 ret void
564 }
565 define void @make_live(i32* nonnull dereferenceable(8) %a) {
566 call void @naked(i32* nonnull dereferenceable(8) align 16 %a)
567 call void @control(i32* nonnull dereferenceable(8) align 16 %a)
568 call void @optnone(i32* nonnull dereferenceable(8) align 16 %a)
569 ret void
570 }
547571
548572 attributes #0 = { "null-pointer-is-valid"="true" }
549573 attributes #1 = { nounwind willreturn}