Skip to content

Commit 74c396a

Browse files
[DSE] Remove uninitialized from allockind when creating dummy zeroed variant function (#149336)
cc #138299 rustc sets `allockind("uninitialized")` - if we copy the attributes as-is when creating a dummy function, Verify complains about `allockind("uninitialized,zeroed")` conflicting, so we need to clear the flag. Co-authored-by: Jamie Hill-Daniel <[email protected]>
1 parent 2a1869b commit 74c396a

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2079,6 +2079,7 @@ struct DSEState {
20792079
AllocFnKind AllocKind =
20802080
Attrs.getFnAttr(Attribute::AllocKind).getAllocKind() |
20812081
AllocFnKind::Zeroed;
2082+
AllocKind &= ~AllocFnKind::Uninitialized;
20822083
Attrs =
20832084
Attrs.addFnAttribute(Ctx, Attribute::getWithAllocKind(Ctx, AllocKind))
20842085
.removeFnAttribute(Ctx, "alloc-variant-zeroed");

llvm/test/Transforms/DeadStoreElimination/zeroed-missing.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ define ptr @undeclared_customalloc(i64 %size, i64 %align) {
1212
ret ptr %call
1313
}
1414

15-
declare ptr @customalloc2(i64, i64) allockind("alloc") "alloc-family"="customalloc2" "alloc-variant-zeroed"="customalloc2_zeroed"
15+
declare ptr @customalloc2(i64, i64) allockind("alloc,uninitialized") "alloc-family"="customalloc2" "alloc-variant-zeroed"="customalloc2_zeroed"
1616
; CHECK-DAG: declare ptr @customalloc2_zeroed(i64, i64) #[[CA2ATTR:[0-9]+]]
1717
; CHECK-DAG: attributes #[[CA2ATTR]] = { allockind("alloc,zeroed") "alloc-family"="customalloc2" }

0 commit comments

Comments
 (0)