[cfe-commits] r54837 - in /cfe/trunk/lib/CodeGen: CGExprConstant.cpp CGExprScalar.cpp
Daniel Dunbar
daniel at zuster.org
Fri Aug 15 18:41:47 PDT 2008
Author: ddunbar
Date: Fri Aug 15 20:41:47 2008
New Revision: 54837
URL: http://llvm.org/viewvc/llvm-project?rev=54837&view=rev
Log:
Add CodeGen support for AddrLabelExpr in initializers.
Modified:
cfe/trunk/lib/CodeGen/CGExprConstant.cpp
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
Modified: cfe/trunk/lib/CodeGen/CGExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprConstant.cpp?rev=54837&r1=54836&r2=54837&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprConstant.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprConstant.cpp Fri Aug 15 20:41:47 2008
@@ -378,6 +378,14 @@
return EmitSizeAlignOf(E->getArgumentType(), E->getType(), E->isSizeOf());
}
+ llvm::Constant *VisitAddrLabelExpr(const AddrLabelExpr *E) {
+ assert(CGF && "Invalid address of label expression outside function.");
+ llvm::Constant *C =
+ llvm::ConstantInt::get(llvm::Type::Int32Ty,
+ CGF->GetIDForAddrOfLabel(E->getLabel()));
+ return llvm::ConstantExpr::getIntToPtr(C, ConvertType(E->getType()));
+ }
+
// Unary operators
llvm::Constant *VisitUnaryPlus(const UnaryOperator *E) {
return Visit(E->getSubExpr());
Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=54837&r1=54836&r2=54837&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Fri Aug 15 20:41:47 2008
@@ -123,10 +123,11 @@
return EmitSizeAlignOf(E->getArgumentType(), E->getType(), E->isSizeOf());
}
Value *VisitAddrLabelExpr(const AddrLabelExpr *E) {
- Value *V = llvm::ConstantInt::get(llvm::Type::Int32Ty,
- CGF.GetIDForAddrOfLabel(E->getLabel()));
- return Builder.CreateIntToPtr(V,
- llvm::PointerType::getUnqual(llvm::Type::Int8Ty));
+ llvm::Value *V =
+ llvm::ConstantInt::get(llvm::Type::Int32Ty,
+ CGF.GetIDForAddrOfLabel(E->getLabel()));
+
+ return Builder.CreateIntToPtr(V, ConvertType(E->getType()));
}
// l-values.
More information about the cfe-commits
mailing list