[PATCH] D93927: [ArgPromotion] Copy !range metadata for loads.
Chenguang Wang via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 29 17:06:54 PST 2020
wecing created this revision.
wecing added a reviewer: fhahn.
Herald added a subscriber: hiraditya.
wecing requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Current ArgPromotion implementation does not copy it: https://godbolt.org/z/zzTKof
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D93927
Files:
llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
llvm/test/Transforms/ArgumentPromotion/metadata.ll
Index: llvm/test/Transforms/ArgumentPromotion/metadata.ll
===================================================================
--- /dev/null
+++ llvm/test/Transforms/ArgumentPromotion/metadata.ll
@@ -0,0 +1,23 @@
+; RUN: opt < %s -argpromotion -S | FileCheck %s
+
+define i32 @should_copy_range({ i32, i32 }* %x) {
+; CHECK-LABEL: define i32 @should_copy_range(
+; CHECK: %x.idx = getelementptr { i32, i32 }, { i32, i32 }* %x, i64 0, i32 0
+; CHECK-NEXT: %x.idx.val = load i32, i32* %x.idx, align 4, !range !0
+; CHECK-NEXT: %1 = call i32 @f_load_range(i32 %x.idx.val)
+; CHECK-NEXT: ret i32 %1
+;
+ %1 = call i32 @f_load_range({ i32, i32 }* %x)
+ ret i32 %1
+}
+
+define internal i32 @f_load_range({ i32, i32 }* %v) {
+; CHECK-LABEL: define internal i32 @f_load_range(
+; CHECK: ret i32
+;
+ %1 = getelementptr inbounds { i32, i32 }, { i32, i32 }* %v, i64 0, i32 0
+ %2 = load i32, i32* %1, align 4, !range !0
+ ret i32 %2
+}
+
+!0 = !{i32 0, i32 4}
Index: llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
===================================================================
--- llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
+++ llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
@@ -306,6 +306,8 @@
AAMDNodes AAInfo;
OrigLoad->getAAMetadata(AAInfo);
newLoad->setAAMetadata(AAInfo);
+ // And other metadata.
+ newLoad->copyMetadata(*OrigLoad, {LLVMContext::MD_range});
Args.push_back(newLoad);
ArgAttrVec.push_back(AttributeSet());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D93927.314040.patch
Type: text/x-patch
Size: 1528 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201230/db220e03/attachment.bin>
More information about the llvm-commits
mailing list