Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TLI] Check that malloc argument has type size_t
DSE assumes that this is the case when forming a calloc from a malloc + memset pair. For tests, either update the malloc signature or change the data layout.
- Loading branch information
Showing
7 changed files
with
42 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
llvm/test/Transforms/DeadStoreElimination/wrong-malloc-size.ll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py | ||
; RUN: opt -S -dse < %s | FileCheck %s | ||
|
||
; malloc should have i64 argument under default data layout | ||
declare noalias i8* @malloc(i32) | ||
|
||
define i8* @malloc_and_memset_intrinsic(i32 %n) { | ||
; CHECK-LABEL: @malloc_and_memset_intrinsic( | ||
; CHECK-NEXT: [[CALL:%.*]] = call i8* @malloc(i32 [[N:%.*]]) | ||
; CHECK-NEXT: call void @llvm.memset.p0i8.i32(i8* align 1 [[CALL]], i8 0, i32 [[N]], i1 false) | ||
; CHECK-NEXT: ret i8* [[CALL]] | ||
; | ||
%call = call i8* @malloc(i32 %n) | ||
call void @llvm.memset.p0i8.i32(i8* align 1 %call, i8 0, i32 %n, i1 false) | ||
ret i8* %call | ||
} | ||
|
||
declare void @llvm.memset.p0i8.i32(i8* nocapture writeonly, i8, i32, i1 immarg) #2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters