| Issue |
63323
|
| Summary |
`DeadArgumentEliminationPass` removes `allocsize` attribute
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
arnetheduck
|
```llvm
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128"
target triple = "x86_64-apple-darwin10.0"
declare noalias i8* @malloc2(i64) nounwind inaccessiblememonly
define internal noalias i8* @malloc3(i64 %size) noinline nounwind allockind("alloc,uninitialized") allocsize(0) inaccessiblememonly {
%xx = call i8* @malloc2(i64 %size)
ret i8* %xx
}
declare void @escape(i8*)
define i8 @test_malloc(i8* %p) {
%v1 = load i8, i8* %p
%obj = call i8* @malloc3(i64 16)
%v2 = load i8, i8* %p
%sub = sub i8 %v1, %v2
call void @escape(i8* %obj)
ret i8 %sub
}
```
```
opt -opt-bisect-limit=-1 -Os test.ll | llvm-dis
```
```llvm
; ModuleID = '<stdin>'
source_filename = "test.ll"
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128"
target triple = "x86_64-apple-darwin10.0"
; Function Attrs: nounwind memory(inaccessiblemem: readwrite)
declare noalias ptr @malloc2(i64) local_unnamed_addr #0
; Function Attrs: noinline nounwind allockind("alloc,uninitialized") memory(inaccessiblemem: readwrite)
define internal fastcc noalias ptr @malloc3() unnamed_addr #1 {
%xx = tail call ptr @malloc2(i64 16)
ret ptr %xx
}
declare void @escape(ptr) local_unnamed_addr
define i8 @test_malloc(ptr nocapture readnone %p) local_unnamed_addr {
%obj = tail call fastcc dereferenceable_or_null(16) ptr @malloc3()
tail call void @escape(ptr %obj)
ret i8 0
}
attributes #0 = { nounwind memory(inaccessiblemem: readwrite) }
attributes #1 = { noinline nounwind allockind("alloc,uninitialized") memory(inaccessiblemem: readwrite) }
```
I've bisected this to the `DeadArgumentEliminationPass` - since instcombine is rune after, it misses out on size-based optimizations.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs