diff --git a/llvm/include/llvm/IR/Intrinsics.td b/llvm/include/llvm/IR/Intrinsics.td --- a/llvm/include/llvm/IR/Intrinsics.td +++ b/llvm/include/llvm/IR/Intrinsics.td @@ -541,10 +541,10 @@ def int_readcyclecounter : DefaultAttrsIntrinsic<[llvm_i64_ty]>; -// The assume intrinsic is marked as arbitrarily writing so that proper -// control dependencies will be maintained. -def int_assume : DefaultAttrsIntrinsic<[], [llvm_i1_ty], [IntrWillReturn, - NoUndef>]>; +// The assume intrinsic is marked InaccessibleMemOnly so that proper control +// dependencies will be maintained. +def int_assume : DefaultAttrsIntrinsic< + [], [llvm_i1_ty], [IntrInaccessibleMemOnly, NoUndef>]>; // 'llvm.experimental.noalias.scope.decl' intrinsic: Inserted at the location of // noalias scope declaration. Makes it possible to identify that a noalias scope @@ -972,18 +972,19 @@ //===---------------- Generic Variable Attribute Intrinsics----------------===// // -def int_var_annotation : DefaultAttrsIntrinsic<[], - [llvm_ptr_ty, llvm_ptr_ty, - llvm_ptr_ty, llvm_i32_ty, llvm_ptr_ty], - [IntrWillReturn], "llvm.var.annotation">; -def int_ptr_annotation : DefaultAttrsIntrinsic<[LLVMAnyPointerType], - [LLVMMatchType<0>, llvm_ptr_ty, llvm_ptr_ty, - llvm_i32_ty, llvm_ptr_ty], - [IntrWillReturn], "llvm.ptr.annotation">; -def int_annotation : DefaultAttrsIntrinsic<[llvm_anyint_ty], - [LLVMMatchType<0>, llvm_ptr_ty, - llvm_ptr_ty, llvm_i32_ty], - [IntrWillReturn], "llvm.annotation">; +def int_var_annotation : DefaultAttrsIntrinsic< + [], [llvm_ptr_ty, llvm_ptr_ty, llvm_ptr_ty, llvm_i32_ty, llvm_ptr_ty], + [IntrInaccessibleMemOnly], "llvm.var.annotation">; + +def int_ptr_annotation : DefaultAttrsIntrinsic< + [LLVMAnyPointerType], + [LLVMMatchType<0>, llvm_ptr_ty, llvm_ptr_ty, llvm_i32_ty, llvm_ptr_ty], + [IntrInaccessibleMemOnly], "llvm.ptr.annotation">; + +def int_annotation : DefaultAttrsIntrinsic< + [llvm_anyint_ty], + [LLVMMatchType<0>, llvm_ptr_ty, llvm_ptr_ty, llvm_i32_ty], + [IntrInaccessibleMemOnly], "llvm.annotation">; // Annotates the current program point with metadata strings which are emitted // as CodeView debug info records. This is expensive, as it disables inlining diff --git a/llvm/lib/Analysis/BasicAliasAnalysis.cpp b/llvm/lib/Analysis/BasicAliasAnalysis.cpp --- a/llvm/lib/Analysis/BasicAliasAnalysis.cpp +++ b/llvm/lib/Analysis/BasicAliasAnalysis.cpp @@ -939,15 +939,9 @@ return rv; } - // While the assume intrinsic is marked as arbitrarily writing so that - // proper control dependencies will be maintained, it never aliases any - // particular memory location. - if (isIntrinsicCall(Call, Intrinsic::assume)) - return ModRefInfo::NoModRef; - - // Like assumes, guard intrinsics are also marked as arbitrarily writing so - // that proper control dependencies are maintained but they never mods any - // particular memory location. + // Guard intrinsics are marked as arbitrarily writing so that proper control + // dependencies are maintained but they never mods any particular memory + // location. // // *Unlike* assumes, guard intrinsics are modeled as reading memory since the // heap state at the point the guard is issued needs to be consistent in case @@ -991,16 +985,9 @@ ModRefInfo BasicAAResult::getModRefInfo(const CallBase *Call1, const CallBase *Call2, AAQueryInfo &AAQI) { - // While the assume intrinsic is marked as arbitrarily writing so that - // proper control dependencies will be maintained, it never aliases any - // particular memory location. - if (isIntrinsicCall(Call1, Intrinsic::assume) || - isIntrinsicCall(Call2, Intrinsic::assume)) - return ModRefInfo::NoModRef; - - // Like assumes, guard intrinsics are also marked as arbitrarily writing so - // that proper control dependencies are maintained but they never mod any - // particular memory location. + // Guard intrinsics are marked as arbitrarily writing so that proper control + // dependencies are maintained but they never mods any particular memory + // location. // // *Unlike* assumes, guard intrinsics are modeled as reading memory since the // heap state at the point the guard is issued needs to be consistent in case diff --git a/llvm/test/Transforms/Attributor/dereferenceable-1.ll b/llvm/test/Transforms/Attributor/dereferenceable-1.ll --- a/llvm/test/Transforms/Attributor/dereferenceable-1.ll +++ b/llvm/test/Transforms/Attributor/dereferenceable-1.ll @@ -1154,7 +1154,7 @@ ; IS__TUNIT_OPM: attributes #[[ATTR2]] = { argmemonly nofree nosync nounwind willreturn writeonly } ; IS__TUNIT_OPM: attributes #[[ATTR3]] = { argmemonly nofree nosync nounwind writeonly } ; IS__TUNIT_OPM: attributes #[[ATTR4]] = { argmemonly nofree nosync nounwind } -; IS__TUNIT_OPM: attributes #[[ATTR5:[0-9]+]] = { nofree nosync nounwind willreturn } +; IS__TUNIT_OPM: attributes #[[ATTR5:[0-9]+]] = { inaccessiblememonly nofree nosync nounwind willreturn } ; IS__TUNIT_OPM: attributes #[[ATTR6]] = { nofree nosync nounwind writeonly } ; IS__TUNIT_OPM: attributes #[[ATTR7]] = { willreturn } ; IS__TUNIT_OPM: attributes #[[ATTR8]] = { nounwind } @@ -1164,7 +1164,7 @@ ; IS__TUNIT_NPM: attributes #[[ATTR2]] = { argmemonly nofree nosync nounwind willreturn writeonly } ; IS__TUNIT_NPM: attributes #[[ATTR3]] = { argmemonly nofree nosync nounwind willreturn } ; IS__TUNIT_NPM: attributes #[[ATTR4]] = { argmemonly nofree nosync nounwind writeonly } -; IS__TUNIT_NPM: attributes #[[ATTR5:[0-9]+]] = { nofree nosync nounwind willreturn } +; IS__TUNIT_NPM: attributes #[[ATTR5:[0-9]+]] = { inaccessiblememonly nofree nosync nounwind willreturn } ; IS__TUNIT_NPM: attributes #[[ATTR6]] = { nofree nosync nounwind willreturn writeonly } ; IS__TUNIT_NPM: attributes #[[ATTR7]] = { nofree nosync nounwind writeonly } ; IS__TUNIT_NPM: attributes #[[ATTR8]] = { willreturn } @@ -1176,7 +1176,7 @@ ; IS__CGSCC_OPM: attributes #[[ATTR3]] = { argmemonly nofree norecurse nosync nounwind writeonly } ; IS__CGSCC_OPM: attributes #[[ATTR4]] = { argmemonly nofree norecurse nosync nounwind } ; IS__CGSCC_OPM: attributes #[[ATTR5]] = { argmemonly nofree nosync nounwind writeonly } -; IS__CGSCC_OPM: attributes #[[ATTR6:[0-9]+]] = { nofree nosync nounwind willreturn } +; IS__CGSCC_OPM: attributes #[[ATTR6:[0-9]+]] = { inaccessiblememonly nofree nosync nounwind willreturn } ; IS__CGSCC_OPM: attributes #[[ATTR7]] = { nosync nounwind writeonly } ; IS__CGSCC_OPM: attributes #[[ATTR8]] = { nofree nosync nounwind writeonly } ; IS__CGSCC_OPM: attributes #[[ATTR9]] = { willreturn } @@ -1187,7 +1187,7 @@ ; IS__CGSCC_NPM: attributes #[[ATTR2]] = { argmemonly nofree norecurse nosync nounwind willreturn writeonly } ; IS__CGSCC_NPM: attributes #[[ATTR3]] = { argmemonly nofree norecurse nosync nounwind willreturn } ; IS__CGSCC_NPM: attributes #[[ATTR4]] = { argmemonly nofree nosync nounwind writeonly } -; IS__CGSCC_NPM: attributes #[[ATTR5:[0-9]+]] = { nofree nosync nounwind willreturn } +; IS__CGSCC_NPM: attributes #[[ATTR5:[0-9]+]] = { inaccessiblememonly nofree nosync nounwind willreturn } ; IS__CGSCC_NPM: attributes #[[ATTR6]] = { nosync nounwind willreturn writeonly } ; IS__CGSCC_NPM: attributes #[[ATTR7]] = { nofree nosync nounwind writeonly } ; IS__CGSCC_NPM: attributes #[[ATTR8]] = { willreturn } diff --git a/llvm/test/Transforms/Attributor/lvi-after-jumpthreading.ll b/llvm/test/Transforms/Attributor/lvi-after-jumpthreading.ll --- a/llvm/test/Transforms/Attributor/lvi-after-jumpthreading.ll +++ b/llvm/test/Transforms/Attributor/lvi-after-jumpthreading.ll @@ -320,22 +320,22 @@ declare void @llvm.experimental.guard(i1, ...) ;. ; IS__TUNIT_OPM: attributes #[[ATTR0]] = { nofree nosync nounwind readnone } -; IS__TUNIT_OPM: attributes #[[ATTR1:[0-9]+]] = { nofree nosync nounwind willreturn } +; IS__TUNIT_OPM: attributes #[[ATTR1:[0-9]+]] = { inaccessiblememonly nofree nosync nounwind willreturn } ; IS__TUNIT_OPM: attributes #[[ATTR2]] = { nounwind } ; IS__TUNIT_OPM: attributes #[[ATTR3:[0-9]+]] = { nofree nosync willreturn } ;. ; IS__TUNIT_NPM: attributes #[[ATTR0]] = { nofree nosync nounwind readnone willreturn } -; IS__TUNIT_NPM: attributes #[[ATTR1:[0-9]+]] = { nofree nosync nounwind willreturn } +; IS__TUNIT_NPM: attributes #[[ATTR1:[0-9]+]] = { inaccessiblememonly nofree nosync nounwind willreturn } ; IS__TUNIT_NPM: attributes #[[ATTR2]] = { nounwind } ; IS__TUNIT_NPM: attributes #[[ATTR3:[0-9]+]] = { nofree nosync willreturn } ;. ; IS__CGSCC_OPM: attributes #[[ATTR0]] = { nofree norecurse nosync nounwind readnone } -; IS__CGSCC_OPM: attributes #[[ATTR1:[0-9]+]] = { nofree nosync nounwind willreturn } +; IS__CGSCC_OPM: attributes #[[ATTR1:[0-9]+]] = { inaccessiblememonly nofree nosync nounwind willreturn } ; IS__CGSCC_OPM: attributes #[[ATTR2]] = { nounwind } ; IS__CGSCC_OPM: attributes #[[ATTR3:[0-9]+]] = { nofree nosync willreturn } ;. ; IS__CGSCC_NPM: attributes #[[ATTR0]] = { nofree norecurse nosync nounwind readnone willreturn } -; IS__CGSCC_NPM: attributes #[[ATTR1:[0-9]+]] = { nofree nosync nounwind willreturn } +; IS__CGSCC_NPM: attributes #[[ATTR1:[0-9]+]] = { inaccessiblememonly nofree nosync nounwind willreturn } ; IS__CGSCC_NPM: attributes #[[ATTR2]] = { nounwind } ; IS__CGSCC_NPM: attributes #[[ATTR3:[0-9]+]] = { nofree nosync willreturn } ;. diff --git a/llvm/test/Transforms/Attributor/nofree.ll b/llvm/test/Transforms/Attributor/nofree.ll --- a/llvm/test/Transforms/Attributor/nofree.ll +++ b/llvm/test/Transforms/Attributor/nofree.ll @@ -478,7 +478,7 @@ ; IS__TUNIT____: attributes #[[ATTR6:[0-9]+]] = { nofree nosync nounwind readnone speculatable willreturn } ; IS__TUNIT____: attributes #[[ATTR7]] = { nofree nounwind } ; IS__TUNIT____: attributes #[[ATTR8:[0-9]+]] = { nobuiltin nofree nounwind } -; IS__TUNIT____: attributes #[[ATTR9:[0-9]+]] = { nofree nosync nounwind willreturn } +; IS__TUNIT____: attributes #[[ATTR9:[0-9]+]] = { inaccessiblememonly nofree nosync nounwind willreturn } ; IS__TUNIT____: attributes #[[ATTR10:[0-9]+]] = { nounwind willreturn } ; IS__TUNIT____: attributes #[[ATTR11]] = { readnone willreturn } ; IS__TUNIT____: attributes #[[ATTR12]] = { willreturn } @@ -493,7 +493,7 @@ ; IS__CGSCC_OPM: attributes #[[ATTR7]] = { nofree noinline nosync nounwind readnone uwtable willreturn } ; IS__CGSCC_OPM: attributes #[[ATTR8]] = { nofree nounwind } ; IS__CGSCC_OPM: attributes #[[ATTR9:[0-9]+]] = { nobuiltin nofree nounwind } -; IS__CGSCC_OPM: attributes #[[ATTR10:[0-9]+]] = { nofree nosync nounwind willreturn } +; IS__CGSCC_OPM: attributes #[[ATTR10:[0-9]+]] = { inaccessiblememonly nofree nosync nounwind willreturn } ; IS__CGSCC_OPM: attributes #[[ATTR11:[0-9]+]] = { nounwind willreturn } ; IS__CGSCC_OPM: attributes #[[ATTR12]] = { readnone willreturn } ; IS__CGSCC_OPM: attributes #[[ATTR13]] = { willreturn } @@ -508,7 +508,7 @@ ; IS__CGSCC_NPM: attributes #[[ATTR7]] = { nofree noinline nosync nounwind readnone uwtable willreturn } ; IS__CGSCC_NPM: attributes #[[ATTR8]] = { nofree nounwind } ; IS__CGSCC_NPM: attributes #[[ATTR9:[0-9]+]] = { nobuiltin nofree nounwind } -; IS__CGSCC_NPM: attributes #[[ATTR10:[0-9]+]] = { nofree nosync nounwind willreturn } +; IS__CGSCC_NPM: attributes #[[ATTR10:[0-9]+]] = { inaccessiblememonly nofree nosync nounwind willreturn } ; IS__CGSCC_NPM: attributes #[[ATTR11:[0-9]+]] = { nounwind willreturn } ; IS__CGSCC_NPM: attributes #[[ATTR12]] = { readnone willreturn } ; IS__CGSCC_NPM: attributes #[[ATTR13]] = { willreturn } diff --git a/llvm/test/Transforms/Attributor/nonnull.ll b/llvm/test/Transforms/Attributor/nonnull.ll --- a/llvm/test/Transforms/Attributor/nonnull.ll +++ b/llvm/test/Transforms/Attributor/nonnull.ll @@ -37,7 +37,7 @@ define i8* @test2A(i1 %c, i8* %ret) { ; ATTRIBUTOR: define nonnull i8* @test2A(i1 %c, i8* nofree nonnull readnone returned %ret) -; NOT_CGSCC_OPM: Function Attrs: nofree nosync nounwind willreturn +; NOT_CGSCC_OPM: Function Attrs: inaccessiblememonly nofree nosync nounwind willreturn ; NOT_CGSCC_OPM-LABEL: define {{[^@]+}}@test2A ; NOT_CGSCC_OPM-SAME: (i1 [[C:%.*]], i8* nofree nonnull readnone returned "no-capture-maybe-returned" [[RET:%.*]]) #[[ATTR0:[0-9]+]] { ; NOT_CGSCC_OPM-NEXT: br i1 [[C]], label [[A:%.*]], label [[B:%.*]] @@ -48,7 +48,7 @@ ; NOT_CGSCC_OPM-NEXT: call void @llvm.assume(i1 noundef true) #[[ATTR12]] [ "nonnull"(i8* [[RET]]) ] ; NOT_CGSCC_OPM-NEXT: ret i8* [[RET]] ; -; IS__CGSCC_OPM: Function Attrs: nofree nosync nounwind willreturn +; IS__CGSCC_OPM: Function Attrs: inaccessiblememonly nofree nosync nounwind willreturn ; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@test2A ; IS__CGSCC_OPM-SAME: (i1 [[C:%.*]], i8* nofree nonnull readnone returned "no-capture-maybe-returned" [[RET:%.*]]) #[[ATTR0:[0-9]+]] { ; IS__CGSCC_OPM-NEXT: br i1 [[C]], label [[A:%.*]], label [[B:%.*]] @@ -70,7 +70,7 @@ define i8* @test2B(i1 %c, i8* %ret) { ; ATTRIBUTOR: define nonnull dereferenceable(4) i8* @test2B(i1 %c, i8* nofree nonnull readnone returned dereferenceable(4) %ret) -; NOT_CGSCC_OPM: Function Attrs: nofree nosync nounwind willreturn +; NOT_CGSCC_OPM: Function Attrs: inaccessiblememonly nofree nosync nounwind willreturn ; NOT_CGSCC_OPM-LABEL: define {{[^@]+}}@test2B ; NOT_CGSCC_OPM-SAME: (i1 [[C:%.*]], i8* nofree nonnull readnone returned dereferenceable(4) "no-capture-maybe-returned" [[RET:%.*]]) #[[ATTR0]] { ; NOT_CGSCC_OPM-NEXT: br i1 [[C]], label [[A:%.*]], label [[B:%.*]] @@ -81,7 +81,7 @@ ; NOT_CGSCC_OPM-NEXT: call void @llvm.assume(i1 noundef true) #[[ATTR12]] [ "dereferenceable"(i8* [[RET]], i32 4) ] ; NOT_CGSCC_OPM-NEXT: ret i8* [[RET]] ; -; IS__CGSCC_OPM: Function Attrs: nofree nosync nounwind willreturn +; IS__CGSCC_OPM: Function Attrs: inaccessiblememonly nofree nosync nounwind willreturn ; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@test2B ; IS__CGSCC_OPM-SAME: (i1 [[C:%.*]], i8* nofree nonnull readnone returned dereferenceable(4) "no-capture-maybe-returned" [[RET:%.*]]) #[[ATTR0]] { ; IS__CGSCC_OPM-NEXT: br i1 [[C]], label [[A:%.*]], label [[B:%.*]] @@ -335,14 +335,14 @@ ; ATTRIBUTOR_OPM: define i8* @test10 ; ATTRIBUTOR_NPM: define nonnull i8* @test10 define i8* @test10(i8* %a, i64 %n) { -; NOT_CGSCC_OPM: Function Attrs: nofree nosync nounwind willreturn +; NOT_CGSCC_OPM: Function Attrs: inaccessiblememonly nofree nosync nounwind willreturn ; NOT_CGSCC_OPM-LABEL: define {{[^@]+}}@test10 ; NOT_CGSCC_OPM-SAME: (i8* nofree readnone "no-capture-maybe-returned" [[A:%.*]], i64 [[N:%.*]]) #[[ATTR0]] { ; NOT_CGSCC_OPM-NEXT: call void @llvm.assume(i1 noundef true) #[[ATTR12]] ; NOT_CGSCC_OPM-NEXT: [[B:%.*]] = getelementptr inbounds i8, i8* [[A]], i64 [[N]] ; NOT_CGSCC_OPM-NEXT: ret i8* [[B]] ; -; IS__CGSCC_OPM: Function Attrs: nofree nosync nounwind willreturn +; IS__CGSCC_OPM: Function Attrs: inaccessiblememonly nofree nosync nounwind willreturn ; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@test10 ; IS__CGSCC_OPM-SAME: (i8* nofree readnone "no-capture-maybe-returned" [[A:%.*]], i64 [[N:%.*]]) #[[ATTR0]] { ; IS__CGSCC_OPM-NEXT: call void @llvm.assume(i1 noundef true) #[[ATTR13]] @@ -1718,7 +1718,7 @@ attributes #0 = { null_pointer_is_valid } attributes #1 = { nounwind willreturn} ;. -; IS__TUNIT____: attributes #[[ATTR0]] = { nofree nosync nounwind willreturn } +; IS__TUNIT____: attributes #[[ATTR0]] = { inaccessiblememonly nofree nosync nounwind willreturn } ; IS__TUNIT____: attributes #[[ATTR1]] = { nofree nosync nounwind readnone willreturn } ; IS__TUNIT____: attributes #[[ATTR2]] = { nofree noreturn nosync nounwind readnone } ; IS__TUNIT____: attributes #[[ATTR3]] = { noreturn } @@ -1734,7 +1734,7 @@ ; IS__TUNIT____: attributes #[[ATTR13]] = { nofree nosync nounwind readonly } ; IS__TUNIT____: attributes #[[ATTR14]] = { readonly willreturn } ;. -; IS__CGSCC_OPM: attributes #[[ATTR0]] = { nofree nosync nounwind willreturn } +; IS__CGSCC_OPM: attributes #[[ATTR0]] = { inaccessiblememonly nofree nosync nounwind willreturn } ; IS__CGSCC_OPM: attributes #[[ATTR1]] = { nofree norecurse nosync nounwind readnone willreturn } ; IS__CGSCC_OPM: attributes #[[ATTR2]] = { nofree noreturn nosync nounwind readnone } ; IS__CGSCC_OPM: attributes #[[ATTR3]] = { nofree nosync nounwind readnone willreturn } @@ -1751,7 +1751,7 @@ ; IS__CGSCC_OPM: attributes #[[ATTR14]] = { nofree nosync nounwind readonly } ; IS__CGSCC_OPM: attributes #[[ATTR15]] = { readonly willreturn } ;. -; IS__CGSCC_NPM: attributes #[[ATTR0]] = { nofree nosync nounwind willreturn } +; IS__CGSCC_NPM: attributes #[[ATTR0]] = { inaccessiblememonly nofree nosync nounwind willreturn } ; IS__CGSCC_NPM: attributes #[[ATTR1]] = { nofree norecurse nosync nounwind readnone willreturn } ; IS__CGSCC_NPM: attributes #[[ATTR2]] = { nofree noreturn nosync nounwind readnone } ; IS__CGSCC_NPM: attributes #[[ATTR3]] = { noreturn } diff --git a/llvm/test/Transforms/InstCombine/annotation-intrinsic.ll b/llvm/test/Transforms/InstCombine/annotation-intrinsic.ll --- a/llvm/test/Transforms/InstCombine/annotation-intrinsic.ll +++ b/llvm/test/Transforms/InstCombine/annotation-intrinsic.ll @@ -13,8 +13,7 @@ ; CHECK-NEXT: entry: ; CHECK-NEXT: [[TMP0:%.*]] = load i32, i32* [[C:%.*]], align 4 ; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.annotation.i32(i32 [[TMP0]], i8* undef, i8* undef, i32 undef) -; CHECK-NEXT: [[TMP2:%.*]] = load i32, i32* [[C]], align 4 -; CHECK-NEXT: [[ADD:%.*]] = add nsw i32 [[TMP1]], [[TMP2]] +; CHECK-NEXT: [[ADD:%.*]] = add nsw i32 [[TMP1]], [[TMP0]] ; CHECK-NEXT: ret i32 [[ADD]] ; entry: