6805427: adlc compiler may generate incorrect machnode emission code
Reviewed-by: kvn, twisti
This commit is contained in:
parent
decdeea77d
commit
a82243d887
@ -1217,13 +1217,17 @@ void InstructForm::rep_var_format(FILE *fp, const char *rep_var) {
|
|||||||
// Seach through operands to determine parameters unique positions.
|
// Seach through operands to determine parameters unique positions.
|
||||||
void InstructForm::set_unique_opnds() {
|
void InstructForm::set_unique_opnds() {
|
||||||
uint* uniq_idx = NULL;
|
uint* uniq_idx = NULL;
|
||||||
uint nopnds = num_opnds();
|
int nopnds = num_opnds();
|
||||||
uint num_uniq = nopnds;
|
uint num_uniq = nopnds;
|
||||||
uint i;
|
int i;
|
||||||
|
_uniq_idx_length = 0;
|
||||||
if ( nopnds > 0 ) {
|
if ( nopnds > 0 ) {
|
||||||
// Allocate index array with reserve.
|
// Allocate index array. Worst case we're mapping from each
|
||||||
uniq_idx = (uint*) malloc(sizeof(uint)*(nopnds + 2));
|
// component back to an index and any DEF always goes at 0 so the
|
||||||
for( i = 0; i < nopnds+2; i++ ) {
|
// length of the array has to be the number of components + 1.
|
||||||
|
_uniq_idx_length = _components.count() + 1;
|
||||||
|
uniq_idx = (uint*) malloc(sizeof(uint)*(_uniq_idx_length));
|
||||||
|
for( i = 0; i < _uniq_idx_length; i++ ) {
|
||||||
uniq_idx[i] = i;
|
uniq_idx[i] = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1238,8 +1242,8 @@ void InstructForm::set_unique_opnds() {
|
|||||||
_parameters.reset();
|
_parameters.reset();
|
||||||
while( (name = _parameters.iter()) != NULL ) {
|
while( (name = _parameters.iter()) != NULL ) {
|
||||||
count = 0;
|
count = 0;
|
||||||
uint position = 0;
|
int position = 0;
|
||||||
uint uniq_position = 0;
|
int uniq_position = 0;
|
||||||
_components.reset();
|
_components.reset();
|
||||||
Component *comp = NULL;
|
Component *comp = NULL;
|
||||||
if( sets_result() ) {
|
if( sets_result() ) {
|
||||||
@ -1255,6 +1259,7 @@ void InstructForm::set_unique_opnds() {
|
|||||||
}
|
}
|
||||||
if( strcmp(name, comp->_name)==0 ) {
|
if( strcmp(name, comp->_name)==0 ) {
|
||||||
if( ++count > 1 ) {
|
if( ++count > 1 ) {
|
||||||
|
assert(position < _uniq_idx_length, "out of bounds");
|
||||||
uniq_idx[position] = uniq_position;
|
uniq_idx[position] = uniq_position;
|
||||||
has_dupl_use = true;
|
has_dupl_use = true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -101,6 +101,7 @@ public:
|
|||||||
const char *_ins_pipe; // Instruction Scheduline description class
|
const char *_ins_pipe; // Instruction Scheduline description class
|
||||||
|
|
||||||
uint *_uniq_idx; // Indexes of unique operands
|
uint *_uniq_idx; // Indexes of unique operands
|
||||||
|
int _uniq_idx_length; // Length of _uniq_idx array
|
||||||
uint _num_uniq; // Number of unique operands
|
uint _num_uniq; // Number of unique operands
|
||||||
ComponentList _components; // List of Components matches MachNode's
|
ComponentList _components; // List of Components matches MachNode's
|
||||||
// operand structure
|
// operand structure
|
||||||
@ -257,11 +258,13 @@ public:
|
|||||||
void set_unique_opnds();
|
void set_unique_opnds();
|
||||||
uint num_unique_opnds() { return _num_uniq; }
|
uint num_unique_opnds() { return _num_uniq; }
|
||||||
uint unique_opnds_idx(int idx) {
|
uint unique_opnds_idx(int idx) {
|
||||||
if( _uniq_idx != NULL && idx > 0 )
|
if( _uniq_idx != NULL && idx > 0 ) {
|
||||||
|
assert(idx < _uniq_idx_length, "out of bounds");
|
||||||
return _uniq_idx[idx];
|
return _uniq_idx[idx];
|
||||||
else
|
} else {
|
||||||
return idx;
|
return idx;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Operands which are only KILLs aren't part of the input array and
|
// Operands which are only KILLs aren't part of the input array and
|
||||||
// require special handling in some cases. Their position in this
|
// require special handling in some cases. Their position in this
|
||||||
|
Loading…
x
Reference in New Issue
Block a user