Skip to content

Commit

Permalink
Inline Imf::sampleCount; this is an ABI-breaking change.
Browse files Browse the repository at this point in the history
gcc generates calls to sampleCount via PLT indirection even within libIlmImf.
As such, they are not inlined and must be treated as having arbitrary side
effects (because of ELF symbol interposition.)  Making addressing computations
visible at call sites allows a much wider range of optimizations by the
compiler beyond simply eliminating the function call overhead.
  • Loading branch information
John Loy authored and nickrasmussen committed Aug 8, 2018
1 parent 148f1c2 commit 5aa0afd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 24 deletions.
20 changes: 0 additions & 20 deletions OpenEXR/IlmImf/ImfMisc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,26 +132,6 @@ bytesPerLineTable (const Header &header,
return maxBytesPerLine;
}


const int&
sampleCount(const char* base, int xStride, int yStride, int x, int y)
{
const char* ptr = base + y * yStride + x * xStride;
int* intPtr = (int*) ptr;

return *intPtr;
}

int&
sampleCount(char* base, int xStride, int yStride, int x, int y)
{
char* ptr = base + y * yStride + x * xStride;
int* intPtr = (int*) ptr;

return *intPtr;
}


size_t
bytesPerDeepLineTable (const Header &header,
int minY, int maxY,
Expand Down
20 changes: 16 additions & 4 deletions OpenEXR/IlmImf/ImfMisc.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,26 @@ size_t bytesPerLineTable (const Header &header,
// pointer, xStride and yStride.
//

IMF_EXPORT
inline
int&
sampleCount(char* base, int xStride, int yStride, int x, int y);
sampleCount(char* base, int xStride, int yStride, int x, int y)
{
char* ptr = base + y * yStride + x * xStride;
int* intPtr = (int*) ptr;

return *intPtr;
}

IMF_EXPORT

inline
const int&
sampleCount(const char* base, int xStride, int yStride, int x, int y);
sampleCount(const char* base, int xStride, int yStride, int x, int y)
{
const char* ptr = base + y * yStride + x * xStride;
int* intPtr = (int*) ptr;

return *intPtr;
}

//
// Build a table that lists, for each scanline in a DEEP file's
Expand Down

0 comments on commit 5aa0afd

Please sign in to comment.