Add volatile qualifications to two blocks of inline asm to stop GCC from
eliminating them as dead code.
Both volatile and "memory" are used because of some concern that the compiler
may still cache values across the asm block without it, and because this was
such a painful debugging session that I wanted to ensure that it's never
repeated.
(cherry picked from commit 7753a3a684)
This commit is contained in:
committed by
Andy Polyakov
parent
7e569022c5
commit
45d010255f
@@ -189,7 +189,7 @@ BN_ULONG bn_add_words (BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,int
|
|||||||
|
|
||||||
if (n <= 0) return 0;
|
if (n <= 0) return 0;
|
||||||
|
|
||||||
asm (
|
asm volatile (
|
||||||
" subq %0,%0 \n" /* clear carry */
|
" subq %0,%0 \n" /* clear carry */
|
||||||
" jmp 1f \n"
|
" jmp 1f \n"
|
||||||
".p2align 4 \n"
|
".p2align 4 \n"
|
||||||
@@ -201,7 +201,7 @@ BN_ULONG bn_add_words (BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,int
|
|||||||
" sbbq %0,%0 \n"
|
" sbbq %0,%0 \n"
|
||||||
: "=&r"(ret),"+c"(n),"+r"(i)
|
: "=&r"(ret),"+c"(n),"+r"(i)
|
||||||
: "r"(rp),"r"(ap),"r"(bp)
|
: "r"(rp),"r"(ap),"r"(bp)
|
||||||
: "cc"
|
: "cc", "memory"
|
||||||
);
|
);
|
||||||
|
|
||||||
return ret&1;
|
return ret&1;
|
||||||
@@ -214,7 +214,7 @@ BN_ULONG bn_sub_words (BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,int
|
|||||||
|
|
||||||
if (n <= 0) return 0;
|
if (n <= 0) return 0;
|
||||||
|
|
||||||
asm (
|
asm volatile (
|
||||||
" subq %0,%0 \n" /* clear borrow */
|
" subq %0,%0 \n" /* clear borrow */
|
||||||
" jmp 1f \n"
|
" jmp 1f \n"
|
||||||
".p2align 4 \n"
|
".p2align 4 \n"
|
||||||
@@ -226,7 +226,7 @@ BN_ULONG bn_sub_words (BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,int
|
|||||||
" sbbq %0,%0 \n"
|
" sbbq %0,%0 \n"
|
||||||
: "=&r"(ret),"+c"(n),"+r"(i)
|
: "=&r"(ret),"+c"(n),"+r"(i)
|
||||||
: "r"(rp),"r"(ap),"r"(bp)
|
: "r"(rp),"r"(ap),"r"(bp)
|
||||||
: "cc"
|
: "cc", "memory"
|
||||||
);
|
);
|
||||||
|
|
||||||
return ret&1;
|
return ret&1;
|
||||||
|
|||||||
Reference in New Issue
Block a user