1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 12:41:49 +01:00

[AttributeFuncs] Consider noundef in typeIncompatible

Drop `noundef` for return values that are replaced by void and make it
illegal to put `noundef` on a void value.

Reviewed By: fhahn

Differential Revision: https://reviews.llvm.org/D87306
This commit is contained in:
Johannes Doerfert 2020-09-08 10:13:11 -05:00
parent 5dc5457fbf
commit e6334e7ecd
4 changed files with 13 additions and 2 deletions

View File

@ -1859,6 +1859,10 @@ AttrBuilder AttributeFuncs::typeIncompatible(Type *Ty) {
.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;
}

View File

@ -45,7 +45,7 @@ define internal %Ty* @test5(%Ty* %this) {
; 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
}

View File

@ -6,7 +6,7 @@ define void @align_non_pointer1(i32 align 4 %a) {
ret void
}
; CHECK: Wrong types for attribute: inalloca nest noalias nocapture nonnull readnone readonly signext zeroext byref(void) byval(void) preallocated(void) sret(void) align 1 dereferenceable(1) dereferenceable_or_null(1)
; CHECK: Wrong types for attribute: inalloca nest noalias nocapture noundef nonnull readnone readonly signext zeroext byref(void) byval(void) preallocated(void) sret(void) align 1 dereferenceable(1) dereferenceable_or_null(1)
; CHECK-NEXT: @align_non_pointer2
define align 4 void @align_non_pointer2(i32 %a) {
ret void

7
test/Verifier/noundef.ll Normal file
View File

@ -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 zeroext byref(void) byval(void) preallocated(void) sret(void) align 1 dereferenceable(1) dereferenceable_or_null(1)
; CHECK-NEXT: @noundef_void
define noundef void @noundef_void() {
ret void
}