[cfe-commits] r40992 - /cfe/trunk/CodeGen/CGExpr.cpp
Chris Lattner
sabre at nondot.org
Fri Aug 10 09:33:59 PDT 2007
Author: lattner
Date: Fri Aug 10 11:33:59 2007
New Revision: 40992
URL: http://llvm.org/viewvc/llvm-project?rev=40992&view=rev
Log:
Fix a bug handling function -> pointer decay and avoid emitting a noop
bitcast.
Modified:
cfe/trunk/CodeGen/CGExpr.cpp
Modified: cfe/trunk/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CodeGen/CGExpr.cpp?rev=40992&r1=40991&r2=40992&view=diff
==============================================================================
--- cfe/trunk/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/CodeGen/CGExpr.cpp Fri Aug 10 11:33:59 2007
@@ -91,6 +91,9 @@
if (isa<PointerType>(DstTy)) {
const llvm::Type *DestTy = ConvertType(DstTy);
+ if (Val.getVal()->getType() == DestTy)
+ return Val;
+
// The source value may be an integer, or a pointer.
assert(Val.isScalar() && "Can only convert from integer or pointer");
if (isa<llvm::PointerType>(Val.getVal()->getType()))
@@ -260,8 +263,6 @@
/// this method emits the address of the lvalue, then loads the result as an
/// rvalue, returning the rvalue.
RValue CodeGenFunction::EmitLoadOfLValue(LValue LV, QualType ExprType) {
- ExprType = ExprType.getCanonicalType();
-
if (LV.isSimple()) {
llvm::Value *Ptr = LV.getAddress();
const llvm::Type *EltTy =
@@ -271,6 +272,9 @@
if (EltTy->isFirstClassType())
return RValue::get(Builder.CreateLoad(Ptr, "tmp"));
+ if (ExprType->isFunctionType())
+ return RValue::get(Ptr);
+
// Otherwise, we have an aggregate lvalue.
return RValue::getAggregate(Ptr);
}
More information about the cfe-commits
mailing list