Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ConstantMerge] Don't merge thread_local constants with non-thread_local constants #105

Merged
merged 1 commit into from
Apr 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions llvm/lib/Transforms/IPO/ConstantMerge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ isUnmergeableGlobal(GlobalVariable *GV,
// Only process constants with initializers in the default address space.
return !GV->isConstant() || !GV->hasDefinitiveInitializer() ||
GV->getType()->getAddressSpace() != 0 || GV->hasSection() ||
// Don't touch thread-local variables.
GV->isThreadLocal() ||
// Don't touch values marked with attribute(used).
UsedGlobals.count(GV);
}
Expand Down
12 changes: 12 additions & 0 deletions llvm/test/Transforms/ConstantMerge/dont-merge.ll
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,15 @@ define void @test4(i32** %P1, i32** %P2, i32** %P3, i32** %P4, i32** %P5, i32**
store i32* @T4D2, i32** %P8
ret void
}

; CHECK: @T5tls
; CHECK: @T5ua

@T5tls = private thread_local constant i32 555
@T5ua = private unnamed_addr constant i32 555

define void @test5(i32** %P1, i32** %P2) {
store i32* @T5tls, i32** %P1
store i32* @T5ua, i32** %P2
ret void
}