[llvm-commits] CVS: llvm-gcc/gcc/llvm-expand.c
Chris Lattner
lattner at cs.uiuc.edu
Sun Feb 20 15:30:42 PST 2005
Changes in directory llvm-gcc/gcc:
llvm-expand.c updated: 1.84 -> 1.85
---
Log message:
Implement SAVE_EXPR for aggregate types correctly. This fixes PR522: http://llvm.cs.uiuc.edu/PR522 and
test/Regression/CFrontend/2005-02-20-AggregateSAVEEXPR.c
---
Diffs of the changes: (+15 -5)
llvm-expand.c | 20 +++++++++++++++-----
1 files changed, 15 insertions(+), 5 deletions(-)
Index: llvm-gcc/gcc/llvm-expand.c
diff -u llvm-gcc/gcc/llvm-expand.c:1.84 llvm-gcc/gcc/llvm-expand.c:1.85
--- llvm-gcc/gcc/llvm-expand.c:1.84 Sat Feb 19 11:10:19 2005
+++ llvm-gcc/gcc/llvm-expand.c Sun Feb 20 17:30:29 2005
@@ -6221,11 +6221,13 @@
SAVE_EXPR_LLVM(exp) = Val;
/* Expand the saved expression */
- SEVal = llvm_expand_expr(Fn, TREE_OPERAND(exp, 0), DestLoc);
+ SEVal = llvm_expand_expr(Fn, TREE_OPERAND(exp, 0), Val);
TREE_USED(exp) = 1;
- if (DestTy != VoidTy) {
+ if (DestTy == VoidTy) {
+ /* noop */
+ } else if (SEVal) { /* Scalar Value */
/* If the value expanded does not match the required type, we must need
to promote it. Insert a cast now.
*/
@@ -6238,10 +6240,15 @@
from the stored value. */
Result = SEVal;
break;
+ } else { /* Aggregate value */
+ unsigned Align = TYPE_ALIGN(TREE_TYPE(exp))/8;
+ llvm_copy_aggregate(Fn, DestLoc, Val, 0, 0, Align);
}
}
- if (DestTy != VoidTy) {
+ if (DestTy == VoidTy) {
+ return 0; /* If it is a void expression, return null */
+ } else if (!DestLoc) { /* Scalar value */
llvm_value *V = SAVE_EXPR_LLVM(exp);
/* If this assert fires, we need to insert a cast here */
assert(GET_POINTER_TYPE_ELEMENT(V->Ty) == DestTy &&
@@ -6249,9 +6256,12 @@
/* Emit a load of the saved value */
Result = append_inst(Fn, create_load_inst("se_val", V, 0));
- break;
+ } else { /* Aggregate value */
+ llvm_value *Val = SAVE_EXPR_LLVM(exp);
+ unsigned Align = TYPE_ALIGN(TREE_TYPE(exp))/8;
+ llvm_copy_aggregate(Fn, DestLoc, Val, 0, 0, Align);
}
- return 0; /* If it is a void expression, return null */
+ break;
case UNSAVE_EXPR:
Result = llvm_expand_expr(Fn, TREE_OPERAND(exp, 0), DestLoc);
More information about the llvm-commits
mailing list