[llvm-bugs] [Bug 43616] New: [globalopt] optimization leaves store to a constant global
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Oct 8 22:31:24 PDT 2019
https://bugs.llvm.org/show_bug.cgi?id=43616
Bug ID: 43616
Summary: [globalopt] optimization leaves store to a constant
global
Product: libraries
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: normal
Priority: P
Component: Interprocedural Optimizations
Assignee: unassignedbugs at nondot.org
Reporter: juneyoung.lee at sf.snu.ac.kr
CC: llvm-bugs at lists.llvm.org
Created attachment 22643
--> https://bugs.llvm.org/attachment.cgi?id=22643&action=edit
input
```
$ opt -version
LLVM (http://llvm.org/):
LLVM version 10.0.0svn
Optimized build with assertions.
Default target: x86_64-apple-darwin19.0.0
Host CPU: skylake
$ cat input.ll
declare {}* @llvm.invariant.start.p0i8(i64 %size, i8* nocapture %ptr)
define void @test1(i8* %ptr) {
call {}* @llvm.invariant.start.p0i8(i64 4, i8* %ptr)
ret void
}
@object1 = global i32 0
define void @ctor1() {
store i32 -1, i32* @object1
%A = bitcast i32* @object1 to i8*
call void @test1(i8* %A)
ret void
}
@llvm.global_ctors = appending constant
[1 x { i32, void ()*, i8* }]
[ { i32, void ()*, i8* } { i32 65535, void ()* @ctor1, i8* null } ]
$ opt -globalopt -S -o - input.ll
@object1 = constant i32 -1
@llvm.global_ctors = appending constant [0 x { i32, void ()*, i8* }]
zeroinitializer
; Function Attrs: argmemonly nounwind willreturn
declare {}* @llvm.invariant.start.p0i8(i64 immarg, i8* nocapture) #0
define void @test1(i8* %ptr) local_unnamed_addr {
%1 = call {}* @llvm.invariant.start.p0i8(i64 4, i8* %ptr)
ret void
}
define void @ctor1() local_unnamed_addr {
store i32 -1, i32* @object1
%A = bitcast i32* @object1 to i8*
call void @test1(i8* %A)
ret void
}
attributes #0 = { argmemonly nounwind willreturn }
```
Running -globalopt leaves a store to @object1, which is a constant global,
which may cause crash because LangRef states that it can be placed in the
read-only section of an executable.
LangRef says:
A variable may be defined as a global constant, which indicates that the
contents of the variable will never be modified (enabling better optimization,
allowing the global data to be placed in the read-only section of an
executable, etc).
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20191009/1e8a74ad/attachment-0001.html>
More information about the llvm-bugs
mailing list