Chris Lattner wrote:
There is still one unneeded LongTy in LowerInvoke.cpp - something like this pseudo-diff should probably get applied.
What does this impact?
This causes code like
write(2, (&(l227_abortmsg[0ll])), 95);
in the CBE, which not all 32-bit compilers do like.
Ah ok, in that case, the CBE should be fixed. There are other cases that could cause long arguments to exist on 32-bit systems. If the C compiler takes issue with this, it would be best to tell the CBE to emit casts to C (long) or something.
-Chris
-Chris
Index: LowerInvoke.cpp
RCS file: /var/cvs/llvm/llvm/lib/Transforms/Scalar/LowerInvoke.cpp,v
retrieving revision 1.23
diff -r1.23 LowerInvoke.cpp
160c160
< std::vector<Constant*> GEPIdx(2, Constant::getNullValue(Type::LongTy));
---
std::vector<Constant*> GEPIdx(2,
Constant::getNullValue(XXX::IntPtrTy));
173c173
< std::vector<Constant*> GEPIdx(2, Constant::getNullValue(Type::LongTy));
---
std::vector<Constant*> GEPIdx(2,
Constant::getNullValue(XXX::IntPtrTy));
-Chris
-Chris
Ah ok, in that case, the CBE should be fixed. There are other cases that could cause long arguments to exist on 32-bit systems. If the C compiler takes issue with this, it would be best to tell the CBE to emit casts to C (long) or something.
Actually that's the only case I stumbled over this problem in a somewhat larger C++ program, and it's clearly the wrong type in LowerInvoke.cpp - it really should be IntPtrTy. But maybe we could use just IntTy here to avoid target dependencies.
Note that this is perfectly legal llvm code and the CBE should work on it. The reason this doesn't show up often is because the instcombine pass shrinks longs to ints on 32-bit targets. This is a property of the optimizer though, and the CBE should work on all valid llvm code. That said, I assume you're just getting compiler warnings, not errors? If so, it's not that big of a deal. I'll fixed LowerInvoke.cpp in any case.
-Chris
Index: LowerInvoke.cpp
RCS file: /var/cvs/llvm/llvm/lib/Transforms/Scalar/LowerInvoke.cpp,v
retrieving revision 1.23
diff -r1.23 LowerInvoke.cpp
160c160
< std::vector<Constant*> GEPIdx(2, Constant::getNullValue(Type::LongTy));
---
std::vector<Constant*> GEPIdx(2,
Constant::getNullValue(XXX::IntPtrTy));
173c173
< std::vector<Constant*> GEPIdx(2, Constant::getNullValue(Type::LongTy));
---
std::vector<Constant*> GEPIdx(2,
Constant::getNullValue(XXX::IntPtrTy));
-Chris
-Chris
-Chris
Wait a minute. You want to lower a 64 bit thing to a 32 bit and "avoid
target dependencies" when the right type is a pointer? You know the
64-bit targets won't like this one bit.
Andrew
The code is fine, 64-bit targets support 32-bit gep offsets just like 32-bit targets support 64-bit offsets. We're talking about the constant zero here, so there are no bits to lose. See LangRef.html for more info.
-Chris