Reid Spencer | 6c38f0b | 2006-11-27 01:05:10 +0000 | [diff] [blame] | 1 | ; test that casted mallocs get converted to malloc of the right type |
Reid Spencer | ce38056 | 2007-01-26 08:25:06 +0000 | [diff] [blame] | 2 | ; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine | llvm-dis | \ |
| 3 | ; RUN: not grep bitcast |
Reid Spencer | 6c38f0b | 2006-11-27 01:05:10 +0000 | [diff] [blame] | 4 | |
Reid Spencer | ce38056 | 2007-01-26 08:25:06 +0000 | [diff] [blame] | 5 | ; The target datalayout is important for this test case. We have to tell |
| 6 | ; instcombine that the ABI alignment for a long is 4-bytes, not 8, otherwise |
| 7 | ; it won't do the transform. |
Chris Lattner | 682918f | 2007-02-15 00:54:16 +0000 | [diff] [blame] | 8 | target datalayout = "e-i64:32:64" |
Reid Spencer | 6c38f0b | 2006-11-27 01:05:10 +0000 | [diff] [blame] | 9 | int* %test(uint %size) { |
| 10 | %X = malloc long, uint %size |
| 11 | %ret = bitcast long* %X to int* |
| 12 | ret int* %ret |
| 13 | } |