From 6c4d255bf3d64fd2ecb48334e780c87f060f1280 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 28 Oct 2009 23:59:40 +0000 Subject: Implement clang support for indirect branch and address of label using the new LLVM support for this. This is temporarily hiding behind horrible and ugly #ifdefs until the time when the optimizer is stable (hopefully a week or so). Until then, lets make it "opt in" :) llvm-svn: 85446 --- clang/lib/CodeGen/CGExprConstant.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'clang/lib/CodeGen/CGExprConstant.cpp') diff --git a/clang/lib/CodeGen/CGExprConstant.cpp b/clang/lib/CodeGen/CGExprConstant.cpp index f8923efd24a1..dc0aa9e7c421 100644 --- a/clang/lib/CodeGen/CGExprConstant.cpp +++ b/clang/lib/CodeGen/CGExprConstant.cpp @@ -776,11 +776,17 @@ public: } case Expr::AddrLabelExprClass: { assert(CGF && "Invalid address of label expression outside function."); +#ifndef USEINDIRECTBRANCH unsigned id = CGF->GetIDForAddrOfLabel(cast(E)->getLabel()); llvm::Constant *C = llvm::ConstantInt::get(llvm::Type::getInt32Ty(VMContext), id); return llvm::ConstantExpr::getIntToPtr(C, ConvertType(E->getType())); +#else + llvm::Constant *Ptr = + CGF->GetAddrOfLabel(cast(E)->getLabel()); + return llvm::ConstantExpr::getBitCast(Ptr, ConvertType(E->getType())); +#endif } case Expr::CallExprClass: { CallExpr* CE = cast(E); -- cgit v1.2.3