diff options
| author | simonm <unknown> | 1999-05-07 13:44:00 +0000 |
|---|---|---|
| committer | simonm <unknown> | 1999-05-07 13:44:00 +0000 |
| commit | dea97ac372ee53bd337907910e6269ad0cb31aca (patch) | |
| tree | 20861a34ba9b75e080a5cbff9a254aaa73fce660 /ghc/compiler/codeGen | |
| parent | bbc652466faf9f4809d7aaf840be5be861fcd49f (diff) | |
| download | haskell-dea97ac372ee53bd337907910e6269ad0cb31aca.tar.gz | |
[project @ 1999-05-07 13:44:00 by simonm]
Fix bug in tagToEnum#: if the amode of the tag overlapped with node,
bogus code would be generated. Now load the tag into a temporary
before doing the table lookup.
Diffstat (limited to 'ghc/compiler/codeGen')
| -rw-r--r-- | ghc/compiler/codeGen/CgExpr.lhs | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/ghc/compiler/codeGen/CgExpr.lhs b/ghc/compiler/codeGen/CgExpr.lhs index 7b11429f4e..5c4cd9b08a 100644 --- a/ghc/compiler/codeGen/CgExpr.lhs +++ b/ghc/compiler/codeGen/CgExpr.lhs @@ -1,7 +1,7 @@ % % (c) The GRASP/AQUA Project, Glasgow University, 1992-1998 % -% $Id: CgExpr.lhs,v 1.23 1999/04/23 13:53:29 simonm Exp $ +% $Id: CgExpr.lhs,v 1.24 1999/05/07 13:44:00 simonm Exp $ % %******************************************************** %* * @@ -126,17 +126,19 @@ cgExpr (StgCon (PrimOp op@(CCallOp _ _ may_gc@True _)) args res_ty) -- and perform an appropriate return. cgExpr (StgCon (PrimOp TagToEnumOp) [arg] res_ty) - | isEnumerationTyCon tycon = - getArgAmode arg `thenFC` \amode -> - performReturn (CAssign (CReg node) + = ASSERT(isEnumerationTyCon tycon) + getArgAmode arg `thenFC` \amode -> + -- save the tag in a temporary in case amode overlaps + -- with node. + absC (CAssign dyn_tag amode) `thenC` + performReturn ( + CAssign (CReg node) (CTableEntry (CLbl (mkClosureTblLabel tycon) PtrRep) - amode PtrRep)) - (\ sequel -> mkDynamicAlgReturnCode tycon amode sequel) - - | otherwise = panic "cgExpr: tagToEnum# of non-enumerated type" - + dyn_tag PtrRep)) + (\ sequel -> mkDynamicAlgReturnCode tycon dyn_tag sequel) where + dyn_tag = CTemp (mkBuiltinUnique 0) IntRep (Just (tycon,_)) = splitTyConApp_maybe res_ty |
