[PATCH] D87306: [AttributeFuncs] Consider `noundef` in `typeIncompatible`
Johannes Doerfert via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 8 11:27:13 PDT 2020
jdoerfert created this revision.
jdoerfert added a reviewer: fhahn.
Herald added subscribers: bollu, hiraditya.
Herald added a project: LLVM.
jdoerfert requested review of this revision.
Drop `noundef` for return values that are replaced by void and make it
illegal to put `noundef` on a void value.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D87306
Files:
llvm/lib/IR/Attributes.cpp
llvm/test/Transforms/DeadArgElim/returned.ll
llvm/test/Verifier/noundef.ll
Index: llvm/test/Verifier/noundef.ll
===================================================================
--- /dev/null
+++ llvm/test/Verifier/noundef.ll
@@ -0,0 +1,7 @@
+; RUN: not llvm-as < %s -o /dev/null 2>&1 | FileCheck %s
+
+; CHECK: Wrong types for attribute: inalloca nest noalias nocapture noundef nonnull readnone readonly signext sret zeroext byref(void) byval(void) preallocated(void) align 1 dereferenceable(1) dereferenceable_or_null(1)
+; CHECK-NEXT: @noundef_void
+define noundef void @noundef_void() {
+ ret void
+}
Index: llvm/test/Transforms/DeadArgElim/returned.ll
===================================================================
--- llvm/test/Transforms/DeadArgElim/returned.ll
+++ llvm/test/Transforms/DeadArgElim/returned.ll
@@ -45,7 +45,7 @@
; Drop all these attributes
; CHECK-LABEL: define internal void @test6
-define internal align 8 dereferenceable_or_null(2) noalias i8* @test6() {
+define internal align 8 dereferenceable_or_null(2) noundef noalias i8* @test6() {
ret i8* null
}
Index: llvm/lib/IR/Attributes.cpp
===================================================================
--- llvm/lib/IR/Attributes.cpp
+++ llvm/lib/IR/Attributes.cpp
@@ -1859,6 +1859,10 @@
.addByValAttr(Ty)
.addByRefAttr(Ty);
+ // Some attributes can apply to all "values" but there are no `void` values.
+ if (Ty->isVoidTy())
+ Incompatible.addAttribute(Attribute::NoUndef);
+
return Incompatible;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87306.290540.patch
Type: text/x-patch
Size: 1453 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200908/3f2d5b9c/attachment.bin>
More information about the llvm-commits
mailing list