[llvm] r190357 - Don't shrink atomic ops to bool in GlobalOpt.
Eli Friedman
eli.friedman at gmail.com
Mon Sep 9 15:00:13 PDT 2013
Author: efriedma
Date: Mon Sep 9 17:00:13 2013
New Revision: 190357
URL: http://llvm.org/viewvc/llvm-project?rev=190357&view=rev
Log:
Don't shrink atomic ops to bool in GlobalOpt.
LLVM IR doesn't currently allow atomic bool load/store operations, and the
transformation is dubious anyway because it isn't profitable on all platforms.
PR17163.
Modified:
llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp
llvm/trunk/test/Transforms/GlobalOpt/atomic.ll
Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp?rev=190357&r1=190356&r2=190357&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Mon Sep 9 17:00:13 2013
@@ -2046,11 +2046,14 @@ bool GlobalOpt::ProcessInternalGlobal(Gl
// Otherwise, if the global was not a boolean, we can shrink it to be a
// boolean.
- if (Constant *SOVConstant = dyn_cast<Constant>(GS.StoredOnceValue))
- if (TryToShrinkGlobalToBoolean(GV, SOVConstant)) {
- ++NumShrunkToBool;
- return true;
+ if (Constant *SOVConstant = dyn_cast<Constant>(GS.StoredOnceValue)) {
+ if (GS.Ordering == NotAtomic) {
+ if (TryToShrinkGlobalToBoolean(GV, SOVConstant)) {
+ ++NumShrunkToBool;
+ return true;
+ }
}
+ }
}
return false;
Modified: llvm/trunk/test/Transforms/GlobalOpt/atomic.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GlobalOpt/atomic.ll?rev=190357&r1=190356&r2=190357&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/GlobalOpt/atomic.ll (original)
+++ llvm/trunk/test/Transforms/GlobalOpt/atomic.ll Mon Sep 9 17:00:13 2013
@@ -1,10 +1,25 @@
; RUN: opt -globalopt < %s -S -o - | FileCheck %s
@GV1 = internal global i64 1
+ at GV2 = internal global i32 0
+
; CHECK: @GV1 = internal unnamed_addr constant i64 1
+; CHECK: @GV2 = internal unnamed_addr global i32 0
define void @test1() {
entry:
%0 = load atomic i8* bitcast (i64* @GV1 to i8*) acquire, align 8
ret void
}
+
+; PR17163
+define void @test2a() {
+entry:
+ store atomic i32 10, i32* @GV2 seq_cst, align 4
+ ret void
+}
+define i32 @test2b() {
+entry:
+ %atomic-load = load atomic i32* @GV2 seq_cst, align 4
+ ret i32 %atomic-load
+}
More information about the llvm-commits
mailing list