From d4b0982cc0cc01d7b333dfc9610c3a42dd5ccafa Mon Sep 17 00:00:00 2001 From: Hideto Ueno Date: Fri, 30 Aug 2019 10:00:32 +0000 Subject: [PATCH] [Attributor] Implement AANoAliasCallSiteArgument initialization Summary: This patch adds an appropriate `initialize` method for `AANoAliasCallSiteArgument`. Reviewers: jdoerfert, sstefan1 Reviewed By: jdoerfert Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D66927 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@370456 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/IPO/Attributor.cpp | 6 ++++-- test/Transforms/FunctionAttrs/noalias_returned.ll | 15 ++++++++++----- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/Transforms/IPO/Attributor.cpp b/lib/Transforms/IPO/Attributor.cpp index dff7011061a..05686921a65 100644 --- a/lib/Transforms/IPO/Attributor.cpp +++ b/lib/Transforms/IPO/Attributor.cpp @@ -1592,8 +1592,10 @@ struct AANoAliasCallSiteArgument final : AANoAliasImpl { /// See AbstractAttribute::initialize(...). void initialize(Attributor &A) override { - // TODO: It isn't sound to initialize as the same with `AANoAliasImpl` - // because `noalias` may not be valid in the current position. + // See callsite argument attribute and callee argument attribute. + ImmutableCallSite ICS(&getAnchorValue()); + if (ICS.paramHasAttr(getArgNo(), Attribute::NoAlias)) + indicateOptimisticFixpoint(); } /// See AbstractAttribute::updateImpl(...). diff --git a/test/Transforms/FunctionAttrs/noalias_returned.ll b/test/Transforms/FunctionAttrs/noalias_returned.ll index d7c4eadb983..ce28ed3f29a 100644 --- a/test/Transforms/FunctionAttrs/noalias_returned.ll +++ b/test/Transforms/FunctionAttrs/noalias_returned.ll @@ -142,8 +142,7 @@ define i8* @test8(i32* %0) nounwind uwtable { ; TEST 9 ; Simple Argument Test define internal void @test9(i8* %a, i8* %b) { -; FIXME: missing noalias -; CHECK: define internal void @test9(i8* %a, i8* %b) +; CHECK: define internal void @test9(i8* noalias %a, i8* %b) ret void } define void @test9_helper(i8* %a, i8* %b) { @@ -156,12 +155,18 @@ define void @test9_helper(i8* %a, i8* %b) { ; TEST 10 ; Simple CallSite Test -declare void @test10_helper(i8* %a) +declare void @test10_helper_1(i8* %a) +define void @test10_helper_2(i8* noalias %a) { + ret void +} define void @test10(i8* noalias %a) { ; CHECK: define void @test10(i8* noalias %a) ; FIXME: missing noalias -; CHECK-NEXT: tail call void @test10_helper(i8* %a) - tail call void @test10_helper(i8* %a) +; CHECK-NEXT: tail call void @test10_helper_1(i8* %a) + tail call void @test10_helper_1(i8* %a) + +; CHECK-NEXT: tail call void @test10_helper_2(i8* noalias %a) + tail call void @test10_helper_2(i8* %a) ret void } -- 2.40.0