llvm-6502/test/Analysis/DSGraph/GlobalsGraphFuncPtr.ll
Reid Spencer fd90dd5d55 For PR872:
Shrinkify LLVM's footprint by removing the analyze tool and moving its
functionality into the opt tool. THis eliminates one of the largest tools
from LLVM and doesn't make opt much bigger because it already included
most of the analysis passes.  To get the old analyze functionality pass
the -analyze option to opt. Note that the integeration here is dead
simple. The "main" of analyze was just copied to opt and invoked if the
-analyze option was given. There may be opportunities for further
integration such as removing the distinction between transform passes
and analysis passes.

To use the analysis functionality, if you previously did this:
  analyze $FNAME -domset -disable-verify
you would now do this:
  opt -analyze $FNAME -domset -disable-verify
Pretty simple.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29762 91177308-0d34-0410-b5e6-96231b3b80d8
2006-08-18 06:34:30 +00:00

68 lines
2.1 KiB
LLVM

; Test resolvable and unresolvable calls through function pointers:
; -- both should be retained in function graphs until resolved or until main
; -- former should get resolved in or before main() and never appear in GG
; -- latter should remain unresolved in main() and copied to GG
; -- globals in GG pointed to by latter should be marked I, but not other nodes
;
; FIXME: KnownPtr should be just S.
; RUN: opt -analyze %s -datastructure-gc -dsgc-check-flags=KnownPtr:SI,UnknownPtr:SI -dsgc-dspass=bu
%Z = internal global int 0
%X = internal global int 0
%M = internal global int 0
%.str_1 = internal constant [9 x sbyte] c"&Z = %p\0A\00"
implementation
declare int %printf(sbyte*, ...)
declare void %exit_dummy(int*)
internal void %makeCalls(void (int*)* %GpKnown.1, void (int*)* %GpUnknown.1,
int* %GpKnownPtr, int* %GpUnknownPtr) {
%tmp.0 = load int* %Z
%tmp.1.not = setne int %tmp.0, 0
br bool %tmp.1.not, label %else, label %then
then:
; pass to exit_dummy: never resolved
call void %GpUnknown.1( int* %GpUnknownPtr )
%tmp.61 = load int* %Z
%inc1 = add int %tmp.61, 1
store int %inc1, int* %Z
%tmp.71 = call int (sbyte*, ...)* %printf( sbyte* getelementptr ([9 x sbyte]* %.str_1, long 0, long 0), int* %Z )
ret void
else:
; pass to knownF: resolved in main
call void %GpKnown.1( int* %GpKnownPtr )
%tmp.6 = load int* %Z
%inc = add int %tmp.6, 1
store int %inc, int* %Z
; "known external": resolved here
%tmp.7 = call int (sbyte*, ...)* %printf( sbyte* getelementptr ([9 x sbyte]* %.str_1, long 0, long 0), int* %Z )
ret void
}
internal void %knownF(int* %Y.1) {
%tmp.1 = seteq int* %Y.1, null
br bool %tmp.1, label %then, label %UnifiedExitNode
then:
call void %knownF( int* %Y.1 ) ; direct call to self: resolved here
br label %UnifiedExitNode
UnifiedExitNode:
ret void
}
int %main(int %argc.1) {
%KnownPtr = alloca int
%UnknownPtr = alloca int
store int 1, int* %Z
call void %makeCalls( void (int*)* %knownF, void (int*)* %exit_dummy,
int* %KnownPtr, int* %UnknownPtr )
ret int 0
}