From 4dc895164a8b3a26792dc7fe5db391e7218968be Mon Sep 17 00:00:00 2001 From: Hans Wennborg Date: Fri, 20 Jun 2014 00:38:12 +0000 Subject: Don't build switch lookup tables for dllimport or TLS variables We would previously put dllimport variables in switch lookup tables, which doesn't work because the address cannot be used in a constant initializer. This is basically the same problem that we have in PR19955. Putting TLS variables in switch tables also desn't work, because the address of such a variable is not constant. Differential Revision: http://reviews.llvm.org/D4220 llvm-svn: 211331 --- llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'llvm/lib/Transforms') diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp index e155daf6fcc..ff2f2a03622 100644 --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -3313,6 +3313,10 @@ static bool ForwardSwitchConditionToPHI(SwitchInst *SI) { static bool ValidLookupTableConstant(Constant *C) { if (ConstantExpr *CE = dyn_cast(C)) return CE->isGEPWithNoNotionalOverIndexing(); + if (C->isThreadDependent()) + return false; + if (C->isDLLImportDependent()) + return false; return isa(C) || isa(C) || -- cgit v1.2.3