[llvm-commits] [dragonegg] r96218 - /dragonegg/trunk/llvm-backend.cpp
Duncan Sands
baldrick at free.fr
Mon Feb 15 06:20:08 PST 2010
Author: baldrick
Date: Mon Feb 15 08:20:04 2010
New Revision: 96218
URL: http://llvm.org/viewvc/llvm-project?rev=96218&view=rev
Log:
If the fixed adjustment justs adds zero, then skip it.
Modified:
dragonegg/trunk/llvm-backend.cpp
Modified: dragonegg/trunk/llvm-backend.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-backend.cpp?rev=96218&r1=96217&r2=96218&view=diff
==============================================================================
--- dragonegg/trunk/llvm-backend.cpp (original)
+++ dragonegg/trunk/llvm-backend.cpp Mon Feb 15 08:20:04 2010
@@ -1652,12 +1652,15 @@
FoundThis = true; // The current argument is 'this'.
assert(isa<PointerType>(AI->getType()) && "Wrong type for 'this'!");
+ Value *This = AI;
// Adjust 'this' according to the thunk offsets. First, the fixed offset.
- Value *This = Builder.CreatePtrToInt(AI, IntPtrTy);
- Value *Offset = ConstantInt::get(IntPtrTy, node->thunk.fixed_offset);
- This = Builder.CreateNSWAdd(This, Offset);
- This = Builder.CreateIntToPtr(This, AI->getType());
+ if (node->thunk.fixed_offset) {
+ This = Builder.CreatePtrToInt(This, IntPtrTy);
+ Value *Offset = ConstantInt::get(IntPtrTy, node->thunk.fixed_offset);
+ This = Builder.CreateNSWAdd(This, Offset);
+ This = Builder.CreateIntToPtr(This, AI->getType());
+ }
// Then by the virtual offset, if any.
if (node->thunk.virtual_offset_p)
@@ -1704,10 +1707,12 @@
RetVal = ApplyVirtualOffset(RetVal, node->thunk.virtual_value, Builder);
// Then move 'this' by the fixed offset.
- RetVal = Builder.CreatePtrToInt(RetVal, IntPtrTy);
- Value *Offset = ConstantInt::get(IntPtrTy, node->thunk.fixed_offset);
- RetVal = Builder.CreateNSWAdd(RetVal, Offset);
- RetVal = Builder.CreateIntToPtr(RetVal, Thunk->getType());
+ if (node->thunk.fixed_offset) {
+ RetVal = Builder.CreatePtrToInt(RetVal, IntPtrTy);
+ Value *Offset = ConstantInt::get(IntPtrTy, node->thunk.fixed_offset);
+ RetVal = Builder.CreateNSWAdd(RetVal, Offset);
+ RetVal = Builder.CreateIntToPtr(RetVal, Thunk->getType());
+ }
// Return the adjusted value.
Builder.CreateRet(RetVal);
More information about the llvm-commits
mailing list