mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-24 22:24:54 +00:00
GlobalOpt: Don't optimize dllimport for initializers
Referencing a dllimport variable requires actually instructions, not just a relocation. This fixes PR19955. Differential Revision: http://reviews.llvm.org/D4249 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211571 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -1980,10 +1980,12 @@ isSimpleEnoughValueToCommit(Constant *C,
|
||||
static bool isSimpleEnoughValueToCommitHelper(Constant *C,
|
||||
SmallPtrSet<Constant*, 8> &SimpleConstants,
|
||||
const DataLayout *DL) {
|
||||
// Simple integer, undef, constant aggregate zero, global addresses, etc are
|
||||
// all supported.
|
||||
if (C->getNumOperands() == 0 || isa<BlockAddress>(C) ||
|
||||
isa<GlobalValue>(C))
|
||||
// Simple global addresses are supported, do not allow dllimport globals.
|
||||
if (auto *GV = dyn_cast<GlobalValue>(C))
|
||||
return !GV->hasDLLImportStorageClass();
|
||||
|
||||
// Simple integer, undef, constant aggregate zero, etc are all supported.
|
||||
if (C->getNumOperands() == 0 || isa<BlockAddress>(C))
|
||||
return true;
|
||||
|
||||
// Aggregate values are safe if all their elements are.
|
||||
@@ -2054,8 +2056,7 @@ static bool isSimpleEnoughPointerToCommit(Constant *C) {
|
||||
return false;
|
||||
|
||||
if (GlobalVariable *GV = dyn_cast<GlobalVariable>(C))
|
||||
// Do not allow weak/*_odr/linkonce/dllimport/dllexport linkage or
|
||||
// external globals.
|
||||
// Do not allow weak/*_odr/linkonce linkage or external globals.
|
||||
return GV->hasUniqueInitializer();
|
||||
|
||||
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(C)) {
|
||||
|
Reference in New Issue
Block a user