[llvm-commits] [gcc-plugin] r82914 - /gcc-plugin/trunk/llvm-convert.cpp

Duncan Sands baldrick at free.fr
Sun Sep 27 13:02:05 PDT 2009


Author: baldrick
Date: Sun Sep 27 15:02:04 2009
New Revision: 82914

URL: http://llvm.org/viewvc/llvm-project?rev=82914&view=rev
Log:
The only cast required here should be useless (useless_type_conversion_p),
which means that a bitcast should suffice.  At the same time, by not calling
getCastOpcode (and not doing anything if the types are the same - the builder
takes care of this) we don't crash here when returning a complex type.

Modified:
    gcc-plugin/trunk/llvm-convert.cpp

Modified: gcc-plugin/trunk/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/gcc-plugin/trunk/llvm-convert.cpp?rev=82914&r1=82913&r2=82914&view=diff

==============================================================================
--- gcc-plugin/trunk/llvm-convert.cpp (original)
+++ gcc-plugin/trunk/llvm-convert.cpp Sun Sep 27 15:02:04 2009
@@ -820,10 +820,7 @@
       // and return it.
       tree TreeRetVal = DECL_RESULT(FnDecl);
       Value *RetVal = Builder.CreateLoad(DECL_LOCAL(TreeRetVal), "retval");
-      bool RetValSigned = !TYPE_UNSIGNED(TREE_TYPE(TreeRetVal));
-      Instruction::CastOps opcode = CastInst::getCastOpcode(
-          RetVal, RetValSigned, Fn->getReturnType(), RetValSigned);
-      RetVal = Builder.CreateCast(opcode, RetVal, Fn->getReturnType());
+      RetVal = Builder.CreateBitCast(RetVal, Fn->getReturnType());
       RetVals.push_back(RetVal);
     } else {
       Value *RetVal = DECL_LOCAL(DECL_RESULT(FnDecl));





More information about the llvm-commits mailing list