I wrote some code that fell over when it encountered this ConstantExpr: i32 add (i32 24, i32 ptrtoint ([20 x %"struct.stlpmtx_std::string"]* @_ZN12BulletMLNode11name2stringE to i32))) because it expected the LHS of the add to be another ConstantExpr. (This is the first time that bit of code has fallen over, despite having compiled thousands of test cases and many megabytes of C and C++ source, so constant expressions like this must at least be pretty rare.) Is there a rule, or a convention, that the plain old constant should go on the RHS of an add like this? If so, I'll try to track down what created this constant expression. Otherwise I won't bother! Thanks, Jay.
On Fri, 2 May 2008, Jay Foad wrote:> I wrote some code that fell over when it encountered this ConstantExpr: > i32 add (i32 24, i32 ptrtoint ([20 x %"struct.stlpmtx_std::string"]* > @_ZN12BulletMLNode11name2stringE to i32))) > > because it expected the LHS of the add to be another ConstantExpr. (This is > the first time that bit of code has fallen over, despite having compiled > thousands of test cases and many megabytes of C and C++ source, so constant > expressions like this must at least be pretty rare.) > > Is there a rule, or a convention, that the plain old constant should go on > the RHS of an add like this? If so, I'll try to track down what created this > constant expression. Otherwise I won't bother!The compiler shouldn't crash, VMCore or ConstantFolding in this case (which I assume is what is crashing) should do the canonicalization. Please file a bug! -Chris -- http://nondot.org/sabre/ http://llvm.org/
> On Fri, 2 May 2008, Jay Foad wrote: > > I wrote some code that fell over when it encountered this > ConstantExpr: > > i32 add (i32 24, i32 ptrtoint ([20 x %"struct.stlpmtx_std::string"]* > > @_ZN12BulletMLNode11name2stringE to i32))) > > > > because it expected the LHS of the add to be another ConstantExpr. > (This is > > the first time that bit of code has fallen over, despite having > compiled > > thousands of test cases and many megabytes of C and C++ source, so > constant > > expressions like this must at least be pretty rare.) > > > > Is there a rule, or a convention, that the plain old constant should > go on > > the RHS of an add like this? If so, I'll try to track down what > created this > > constant expression. Otherwise I won't bother! > > The compiler shouldn't crash, VMCore or ConstantFolding in this case > (which I assume is what is crashing) should do the canonicalization.No, it was an LLVM pass that I wrote myself that was crashing. I can't see any code in lib/VMCore/ that tries to canonicalize the order of operands of an add. Thanks, Jay.