[PATCH] D11804: Fix an alignment error in `llvm::expandAtomicRMWToCmpXchg` without breaking the build where X86 isn't enabled.

Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 6 09:55:49 PDT 2015


This revision was automatically updated to reflect the committed changes.
Closed by commit rL244229: Fix an alignment error in `llvm::expandAtomicRMWToCmpXchg` without breaking… (authored by diamond).

Changed prior to commit:
  http://reviews.llvm.org/D11804?vs=31450&id=31453#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D11804

Files:
  llvm/trunk/lib/CodeGen/AtomicExpandPass.cpp
  llvm/trunk/test/Transforms/AtomicExpand/X86/expand-atomic-rmw-initial-load.ll
  llvm/trunk/test/Transforms/AtomicExpand/X86/lit.local.cfg

Index: llvm/trunk/test/Transforms/AtomicExpand/X86/expand-atomic-rmw-initial-load.ll
===================================================================
--- llvm/trunk/test/Transforms/AtomicExpand/X86/expand-atomic-rmw-initial-load.ll
+++ llvm/trunk/test/Transforms/AtomicExpand/X86/expand-atomic-rmw-initial-load.ll
@@ -0,0 +1,11 @@
+; RUN: opt -S %s -atomic-expand -mtriple=i686-linux-gnu | FileCheck %s
+
+; This file tests the function `llvm::expandAtomicRMWToCmpXchg`.
+; It isn't technically target specific, but is exposed through a pass that is.
+
+define i8 @test_initial_load(i8* %ptr, i8 %value) {
+  %res = atomicrmw nand i8* %ptr, i8 %value seq_cst
+  ret i8 %res
+}
+; CHECK-LABEL: @test_initial_load
+; CHECK-NEXT:    %1 = load i8, i8* %ptr, align 1
Index: llvm/trunk/test/Transforms/AtomicExpand/X86/lit.local.cfg
===================================================================
--- llvm/trunk/test/Transforms/AtomicExpand/X86/lit.local.cfg
+++ llvm/trunk/test/Transforms/AtomicExpand/X86/lit.local.cfg
@@ -0,0 +1,2 @@
+if not 'X86' in config.root.targets:
+  config.unsupported = True
Index: llvm/trunk/lib/CodeGen/AtomicExpandPass.cpp
===================================================================
--- llvm/trunk/lib/CodeGen/AtomicExpandPass.cpp
+++ llvm/trunk/lib/CodeGen/AtomicExpandPass.cpp
@@ -550,7 +550,7 @@
   Builder.SetInsertPoint(BB);
   LoadInst *InitLoaded = Builder.CreateLoad(Addr);
   // Atomics require at least natural alignment.
-  InitLoaded->setAlignment(AI->getType()->getPrimitiveSizeInBits());
+  InitLoaded->setAlignment(AI->getType()->getPrimitiveSizeInBits() / 8);
   Builder.CreateBr(LoopBB);
 
   // Start the main loop block now that we've taken care of the preliminaries.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D11804.31453.patch
Type: text/x-patch
Size: 1728 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150806/27bc1022/attachment.bin>


More information about the llvm-commits mailing list