diff options
author | Dan Gohman <dan433584@gmail.com> | 2016-04-21 23:59:48 +0000 |
---|---|---|
committer | Dan Gohman <dan433584@gmail.com> | 2016-04-21 23:59:48 +0000 |
commit | 04e7fb778dbe8f99ea95bb40f57f5063a75669fd (patch) | |
tree | 3bc6471721d2948a0c24fdd1fd65b9319b28cbed /llvm/lib/Target | |
parent | 5be6064974db2ae9f9e412dac6a29655a7deb585 (diff) | |
download | bcm5719-llvm-04e7fb778dbe8f99ea95bb40f57f5063a75669fd.tar.gz bcm5719-llvm-04e7fb778dbe8f99ea95bb40f57f5063a75669fd.zip |
[WebAssembly] Limit alignment hints to natural alignment.
This follows the current binary format rules.
llvm-svn: 267082
Diffstat (limited to 'llvm/lib/Target')
-rw-r--r-- | llvm/lib/Target/WebAssembly/WebAssemblySetP2AlignOperands.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblySetP2AlignOperands.cpp b/llvm/lib/Target/WebAssembly/WebAssemblySetP2AlignOperands.cpp index 9ffd04e581d..4ebea68c58a 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblySetP2AlignOperands.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblySetP2AlignOperands.cpp @@ -83,7 +83,7 @@ bool WebAssemblySetP2AlignOperands::runOnMachineFunction(MachineFunction &MF) { case WebAssembly::STORE16_I32: case WebAssembly::STORE8_I64: case WebAssembly::STORE16_I64: - case WebAssembly::STORE32_I64: + case WebAssembly::STORE32_I64: { assert(MI.getOperand(3).getImm() == 0 && "ISel should set p2align operands to 0"); assert(MI.hasOneMemOperand() && @@ -95,9 +95,15 @@ bool WebAssemblySetP2AlignOperands::runOnMachineFunction(MachineFunction &MF) { assert(MI.getDesc().OpInfo[3].OperandType == WebAssembly::OPERAND_P2ALIGN && "Load and store instructions should have a p2align operand"); - MI.getOperand(3).setImm( - Log2_64((*MI.memoperands_begin())->getAlignment())); + uint64_t P2Align = Log2_64((*MI.memoperands_begin())->getAlignment()); + + // WebAssembly does not currently support supernatural alignment. + P2Align = std::min( + P2Align, uint64_t(WebAssembly::GetDefaultP2Align(MI.getOpcode()))); + + MI.getOperand(3).setImm(P2Align); break; + } default: break; } |