summaryrefslogtreecommitdiff
path: root/test/Transforms/DSAnalysis/physicalsubtype.ll
blob: d16943024a0a4595b0eae515fcc4f21907048e75 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
; A test for "physical subtyping" used in some C programs...
;
; RUN: llvm-upgrade < %s | llvm-as | opt -analyze -tddatastructure
;
%ST = type { int, int* }            ; "Subtype"
%DT = type { int, int*, int }       ; "derived type"

int %test(%DT* %DT) {
	%DTp = getelementptr %DT* %DT, long 0, uint 0
	%A = load int* %DTp
	%ST = cast %DT* %DT to %ST*
	%STp = getelementptr %ST* %ST, long 0, uint 0
	%B = load int* %STp
	%C = sub int %A, %B         ; A & B are equal, %C = 0
	ret int %C
}