diff options
author | Bruno Cardoso Lopes <bruno.cardoso@gmail.com> | 2014-08-25 17:51:14 +0000 |
---|---|---|
committer | Bruno Cardoso Lopes <bruno.cardoso@gmail.com> | 2014-08-25 17:51:14 +0000 |
commit | e2a1fa35dfba8efbec2d4468d1dc44c7ecf7f2d7 (patch) | |
tree | 2909ab164b41ad8ed9ece82e69c9a8979bb4def0 /llvm/lib/Transforms/Utils/GlobalStatus.cpp | |
parent | 356c4ac88b6a488536c19b743747c4decab92a21 (diff) | |
download | bcm5719-llvm-e2a1fa35dfba8efbec2d4468d1dc44c7ecf7f2d7.tar.gz bcm5719-llvm-e2a1fa35dfba8efbec2d4468d1dc44c7ecf7f2d7.zip |
Remove dangling initializers in GlobalDCE
GlobalDCE deletes global vars and updates their initializers to nullptr
while leaving underlying constants to be cleaned up later by its uses.
The clean up may never happen, fix this by forcing it every time it's
safe to destroy constants.
Final patch by Rafael Espindola
http://reviews.llvm.org/D4931
<rdar://problem/17523868>
llvm-svn: 216390
Diffstat (limited to 'llvm/lib/Transforms/Utils/GlobalStatus.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/GlobalStatus.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/GlobalStatus.cpp b/llvm/lib/Transforms/Utils/GlobalStatus.cpp index 33e34a9941e..97a0b4ee5ac 100644 --- a/llvm/lib/Transforms/Utils/GlobalStatus.cpp +++ b/llvm/lib/Transforms/Utils/GlobalStatus.cpp @@ -35,6 +35,9 @@ bool llvm::isSafeToDestroyConstant(const Constant *C) { if (isa<GlobalValue>(C)) return false; + if (isa<ConstantInt>(C) || isa<ConstantFP>(C)) + return false; + for (const User *U : C->users()) if (const Constant *CU = dyn_cast<Constant>(U)) { if (!isSafeToDestroyConstant(CU)) |