Hi,

could a gatekeeper please help review the fix bug962(
https://bugs.open64.net/show_bug.cgi?id=962)?

A cut-down case below:

a sample case:

unsigned long copy_user_generic_string(void *to, const void *from, unsigned
len);
unsigned long copy_user_generic_unrolled(void *to, const void *from,
unsigned
len);

unsigned long
copy_user_generic(void *to, const void *from, unsigned len)
{
unsigned ret;

asm volatile ("661:\n\t" "call %P[old]" "\n662:\n" ".section
.altinstructions,\"a\"\n" " " ".balign 8" " " "\n" " " ".quad" " " "661b\n"
" "
".quad" " " "663f\n" "    .word " "(3*32+16)" "\n" "      .byte
662b-661b\n" "
  .byte 664f-663f\n" ".previous\n" ".section .discard,\"aw\",@progbits\n"
"
.byte 0xff + (664f-663f) - (662b-661b)\n" ".previous\n" ".section
.altinstr_replacement, \"ax\"\n" "663:\n\t" "call %P[new]" "\n664:\n"
".previous" : "=a" (ret), "=D" (to), "=S" (from), "=d" (len) : [old] "i"
(copy_user_generic_unrolled), [new] "i" (copy_user_generic_string), "1"
(to),
"2" (from), "3" (len) : "memory", "rcx", "r8", "r9", "r10", "r11");
return ret;
}

opencc fails with:
 opencc -c bug962 <https://bugs.open64.net/show_bug.cgi?id=962>.c
"bug962 <https://bugs.open64.net/show_bug.cgi?id=962>.c", line 9: Error:
Invalid 'asm' constrain : Cannot find immediate
operand for ASM

Analysis:
copy_user_generic_unrolled and copy_user_generic_string are function
symbols, it should be allowed as "i" constraint, since they are link time
constants. we should not miss them.

Suggested patch:
osprey/be/cg/x8664/cgtarget.cxx    -- 631099e..52257fb 100644
--- a/osprey/be/cg/x8664/cgtarget.cxx
+++ b/osprey/be/cg/x8664/cgtarget.cxx
@@ -3624,8 +3624,11 @@ CGTARG_TN_For_Asm_Operand (const char* constraint,
     if (!(load && (WN_operator(load) == OPR_INTCONST ||
                        (WN_operator(load) == OPR_LDA &&
                         // &var.field is also allowed, bug916 open64.net
+                        // function sym is also allowed, bug962 open64.net
                         (ST_sym_class(WN_st(load)) == CLASS_VAR ||
-                         ST_sym_class(WN_st(load)) == CLASS_CONST))))) {
+                         ST_sym_class(WN_st(load)) == CLASS_CONST ||
+                         ST_sym_class(WN_st(load)) == CLASS_FUNC
+                         ))))) {
       ErrMsgSrcpos(EC_Invalid_Asm_Constrain, WN_Get_Linenum(asm_wn),
                     ": Cannot find immediate operand for ASM");
     }

Thanks in advance for the review.

Regards
Gang
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Open64-devel mailing list
Open64-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/open64-devel

Reply via email to