[llvm] 0a22510 - [value-tracking] see through returned attribute.
Florian Mayer via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 13 12:52:45 PDT 2021
Author: Florian Mayer
Date: 2021-09-13T20:52:26+01:00
New Revision: 0a22510f3e649d5d84cc404690cfb374fab46238
URL: https://github.com/llvm/llvm-project/commit/0a22510f3e649d5d84cc404690cfb374fab46238
DIFF: https://github.com/llvm/llvm-project/commit/0a22510f3e649d5d84cc404690cfb374fab46238.diff
LOG: [value-tracking] see through returned attribute.
Reviewed By: vitalybuka
Differential Revision: https://reviews.llvm.org/D109675
Added:
Modified:
llvm/lib/Analysis/ValueTracking.cpp
llvm/test/Instrumentation/HWAddressSanitizer/stack-safety-analysis.ll
llvm/unittests/Analysis/ValueTrackingTest.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 53d7ddf075266..8d18d1332ea12 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -4533,6 +4533,12 @@ AllocaInst *llvm::findAllocaForValue(Value *V, bool OffsetZero) {
if (OffsetZero && !GEP->hasAllZeroIndices())
return nullptr;
AddWork(GEP->getPointerOperand());
+ } else if (CallBase *CB = dyn_cast<CallBase>(V)) {
+ Value *Returned = CB->getReturnedArgOperand();
+ if (Returned)
+ AddWork(Returned);
+ else
+ return nullptr;
} else {
return nullptr;
}
diff --git a/llvm/test/Instrumentation/HWAddressSanitizer/stack-safety-analysis.ll b/llvm/test/Instrumentation/HWAddressSanitizer/stack-safety-analysis.ll
index b14445bde1f03..51d7cb56608df 100644
--- a/llvm/test/Instrumentation/HWAddressSanitizer/stack-safety-analysis.ll
+++ b/llvm/test/Instrumentation/HWAddressSanitizer/stack-safety-analysis.ll
@@ -164,8 +164,7 @@ entry:
; SAFETY: call {{.*}}__hwasan_generate_tag
; SAFETY-NOT: call {{.*}}__hwasan_store
; NOSTACK-NOT: call {{.*}}__hwasan_generate_tag
- ; TODO: Do not emit this store.
- ; NOSTACK: call {{.*}}__hwasan_store
+ ; NOSTACK-NOT: call {{.*}}__hwasan_store
%buf.sroa.0 = alloca i8, align 4
call void @llvm.lifetime.start.p0i8(i64 1, i8* nonnull %buf.sroa.0)
%ptr = call i8* @retptr(i8* %buf.sroa.0)
diff --git a/llvm/unittests/Analysis/ValueTrackingTest.cpp b/llvm/unittests/Analysis/ValueTrackingTest.cpp
index c07c76c0b3ced..4c4067ea920b8 100644
--- a/llvm/unittests/Analysis/ValueTrackingTest.cpp
+++ b/llvm/unittests/Analysis/ValueTrackingTest.cpp
@@ -2256,6 +2256,22 @@ const FindAllocaForValueTestParams FindAllocaForValueTests[] = {
ret void
})",
false, false},
+ {R"(
+ declare i32* @retptr(i32* returned)
+ define void @test(i1 %cond) {
+ %a = alloca i32
+ %r = call i32* @retptr(i32* %a)
+ ret void
+ })",
+ true, true},
+ {R"(
+ declare i32* @fun(i32*)
+ define void @test(i1 %cond) {
+ %a = alloca i32
+ %r = call i32* @fun(i32* %a)
+ ret void
+ })",
+ false, false},
};
TEST_P(FindAllocaForValueTest, findAllocaForValue) {
More information about the llvm-commits
mailing list