[PATCH] D93927: [ArgPromotion] Copy !range metadata for loads.
Chenguang Wang via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 11 15:36:01 PST 2021
wecing updated this revision to Diff 330086.
wecing added a comment.
update test cases:
- remove irrelevant constructions in test cases
- use update_test_checks.py to generate regex-based checks
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D93927/new/
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,45 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --scrub-attributes
+; RUN: opt < %s -argpromotion -S | FileCheck %s
+
+define i32 @should_copy_range(i32* %x) {
+; CHECK-LABEL: define {{[^@]+}}@should_copy_range
+; CHECK-SAME: (i32* [[X:%.*]]) {
+; CHECK-NEXT: [[X_VAL:%.*]] = load i32, i32* [[X]], align 4, !range !0
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @f_load_range(i32 [[X_VAL]])
+; CHECK-NEXT: ret i32 [[TMP1]]
+;
+ %1 = call i32 @f_load_range(i32* %x)
+ ret i32 %1
+}
+
+define internal i32 @f_load_range(i32* %v) {
+; CHECK-LABEL: define {{[^@]+}}@f_load_range
+; CHECK-SAME: (i32 [[V_VAL:%.*]]) {
+; CHECK-NEXT: ret i32 [[V_VAL]]
+;
+ %1 = load i32, i32* %v, align 4, !range !0
+ ret i32 %1
+}
+
+define i32* @should_copy_nonnull(i32** %x) {
+; CHECK-LABEL: define {{[^@]+}}@should_copy_nonnull
+; CHECK-SAME: (i32** [[X:%.*]]) {
+; CHECK-NEXT: [[X_VAL:%.*]] = load i32*, i32** [[X]], align 4, !nonnull !1
+; CHECK-NEXT: [[TMP1:%.*]] = call i32* @f_load_nonnull(i32* [[X_VAL]])
+; CHECK-NEXT: ret i32* [[TMP1]]
+;
+ %1 = call i32* @f_load_nonnull(i32** %x)
+ ret i32* %1
+}
+
+define internal i32* @f_load_nonnull(i32** %v) {
+; CHECK-LABEL: define {{[^@]+}}@f_load_nonnull
+; CHECK-SAME: (i32* [[V_VAL:%.*]]) {
+; CHECK-NEXT: ret i32* [[V_VAL]]
+;
+ %1 = load i32*, i32** %v, align 4, !nonnull !1
+ ret i32* %1
+}
+
+!0 = !{i32 0, i32 4}
+!1 = !{}
Index: llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
===================================================================
--- llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
+++ llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
@@ -312,6 +312,12 @@
AAMDNodes AAInfo;
OrigLoad->getAAMetadata(AAInfo);
newLoad->setAAMetadata(AAInfo);
+ // And other metadata.
+ newLoad->copyMetadata(
+ *OrigLoad,
+ {LLVMContext::MD_nontemporal, LLVMContext::MD_nonnull,
+ LLVMContext::MD_dereferenceable, LLVMContext::MD_align,
+ LLVMContext::MD_noundef, LLVMContext::MD_range});
Args.push_back(newLoad);
ArgAttrVec.push_back(AttributeSet());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D93927.330086.patch
Type: text/x-patch
Size: 2407 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210311/9b41e0a4/attachment.bin>
More information about the llvm-commits
mailing list