Skip to content

Commit

Permalink
Forbid lea without index and base. (dotnet#10771)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Andreenko authored Apr 10, 2017
1 parent 37a68ef commit 25ae09a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
33 changes: 19 additions & 14 deletions src/jit/codegencommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1869,26 +1869,26 @@ bool CodeGen::genCreateAddrMode(GenTreePtr addr,
The following indirections are valid address modes on x86/x64:

[ icon] * not handled here
[reg ] * not handled here
[reg ]
[reg + icon]
[reg2 + reg1 ]
[reg2 + reg1 + icon]
[reg2 + 2 * reg1 ]
[reg2 + 4 * reg1 ]
[reg2 + 8 * reg1 ]
[ 2 * reg1 + icon]
[ 4 * reg1 + icon]
[ 8 * reg1 + icon]
[reg2 + 2 * reg1 + icon]
[reg2 + 4 * reg1 + icon]
[reg2 + 8 * reg1 + icon]
[reg1 + reg2 ]
[reg1 + reg2 + icon]
[reg1 + 2 * reg2 ]
[reg1 + 4 * reg2 ]
[reg1 + 8 * reg2 ]
[ 2 * reg2 + icon]
[ 4 * reg2 + icon]
[ 8 * reg2 + icon]
[reg1 + 2 * reg2 + icon]
[reg1 + 4 * reg2 + icon]
[reg1 + 8 * reg2 + icon]

The following indirections are valid address modes on arm64:

[reg]
[reg + icon]
[reg2 + reg1]
[reg2 + reg1 * natural-scale]
[reg1 + reg2]
[reg1 + reg2 * natural-scale]

*/

Expand Down Expand Up @@ -2448,6 +2448,11 @@ bool CodeGen::genCreateAddrMode(GenTreePtr addr,

noway_assert(FitsIn<INT32>(cns));

if (rv1 == nullptr && rv2 == nullptr)
{
return false;
}

/* Success - return the various components to the caller */

*revPtr = rev;
Expand Down
1 change: 1 addition & 0 deletions src/jit/gentree.h
Original file line number Diff line number Diff line change
Expand Up @@ -4165,6 +4165,7 @@ struct GenTreeAddrMode : public GenTreeOp
GenTreeAddrMode(var_types type, GenTreePtr base, GenTreePtr index, unsigned scale, unsigned offset)
: GenTreeOp(GT_LEA, type, base, index)
{
assert(base != nullptr || index != nullptr);
gtScale = scale;
gtOffset = offset;
}
Expand Down

0 comments on commit 25ae09a

Please sign in to comment.