[sanitizer] Improve FreeBSD ASLR detection
[llvm-project.git] / llvm / test / Transforms / DeadArgElim / returned.ll
bloba029c0755e4b8aeb2f8e66279757f36cdcebccda
1 ; RUN: opt < %s -passes=deadargelim -S | FileCheck %s
3 %Ty = type { i32, i32 }
5 ; Validate that the argument and return value are both dead
6 ; CHECK-LABEL: define internal void @test1()
8 define internal %Ty* @test1(%Ty* %this) {
9   ret %Ty* %this
12 ; do not keep alive the return value of a function with a dead 'returned' argument
13 ; CHECK-LABEL: define internal void @test2()
15 define internal %Ty* @test2(%Ty* returned %this) {
16   ret %Ty* %this
19 ; dummy to keep 'this' alive
20 @dummy = global %Ty* null 
22 ; Validate that return value is dead
23 ; CHECK-LABEL: define internal void @test3(%Ty* %this)
25 define internal %Ty* @test3(%Ty* %this) {
26   store volatile %Ty* %this, %Ty** @dummy
27   ret %Ty* %this
30 ; keep alive return value of a function if the 'returned' argument is live
31 ; CHECK-LABEL: define internal %Ty* @test4(%Ty* returned %this)
33 define internal %Ty* @test4(%Ty* returned %this) {
34   store volatile %Ty* %this, %Ty** @dummy
35   ret %Ty* %this
38 ; don't do this if 'returned' is on the call site...
39 ; CHECK-LABEL: define internal void @test5(%Ty* %this)
41 define internal %Ty* @test5(%Ty* %this) {
42   store volatile %Ty* %this, %Ty** @dummy
43   ret %Ty* %this
46 ; Drop all these attributes
47 ; CHECK-LABEL: define internal void @test6
48 define internal align 8 dereferenceable_or_null(2) noundef noalias i8* @test6() {
49   ret i8* null
52 define %Ty* @caller(%Ty* %this) {
53   %1 = call %Ty* @test1(%Ty* %this)
54   %2 = call %Ty* @test2(%Ty* %this)
55   %3 = call %Ty* @test3(%Ty* %this)
56   %4 = call %Ty* @test4(%Ty* %this)
57 ; ...instead, drop 'returned' form the call site
58 ; CHECK: call void @test5(%Ty* %this)
59   %5 = call %Ty* @test5(%Ty* returned %this)
60   %6 = call i8* @test6()
61   ret %Ty* %this