Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
benchmark
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
benchmark
Commits
80514584
Commit
80514584
authored
Mar 30, 2015
by
Eric Fiselier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add workaround to DoNotOptimize(...) for clang inline assembly bug.
parent
b5dd1506
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
2 deletions
+11
-2
benchmark_api.h
include/benchmark/benchmark_api.h
+11
-2
No files found.
include/benchmark/benchmark_api.h
View file @
80514584
...
@@ -190,10 +190,19 @@ void UseCharPointer(char const volatile*);
...
@@ -190,10 +190,19 @@ void UseCharPointer(char const volatile*);
// expression from being optimized away by the compiler. This function is
// expression from being optimized away by the compiler. This function is
// intented to add little to no overhead.
// intented to add little to no overhead.
// See: http://stackoverflow.com/questions/28287064
// See: http://stackoverflow.com/questions/28287064
#if defined(__GNUC__)
#if defined(__clang__) && defined(__GNUC__)
// TODO(ericwf): Clang has a bug where it tries to always use a register
// even if value must be stored in memory. This causes codegen to fail.
// To work around this we remove the "r" modifier so the operand is always
// loaded into memory.
template
<
class
Tp
>
template
<
class
Tp
>
inline
BENCHMARK_ALWAYS_INLINE
void
DoNotOptimize
(
Tp
const
&
value
)
{
inline
BENCHMARK_ALWAYS_INLINE
void
DoNotOptimize
(
Tp
const
&
value
)
{
asm
volatile
(
""
:
"+r"
(
const_cast
<
Tp
&>
(
value
)));
asm
volatile
(
""
:
"+m"
(
const_cast
<
Tp
&>
(
value
)));
}
#elif defined(__GNUC__)
template
<
class
Tp
>
inline
BENCHMARK_ALWAYS_INLINE
void
DoNotOptimize
(
Tp
const
&
value
)
{
asm
volatile
(
""
:
"+rm"
(
const_cast
<
Tp
&>
(
value
)));
}
}
#else
#else
template
<
class
Tp
>
template
<
class
Tp
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment