Skip to content

Commit

Permalink
Revert "calculate builtin_object_size if argument is a removable poin…
Browse files Browse the repository at this point in the history
…ter"

Revert r262337 as "check-llvm ubsan" step failed on
sanitizer-x86_64-linux-fast buildbot.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@262349 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
petar-jovanovic committed Mar 1, 2016
1 parent 9079741 commit 7a9adc7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 53 deletions.
25 changes: 6 additions & 19 deletions lib/Transforms/InstCombine/InstructionCombining.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1941,25 +1941,6 @@ Instruction *InstCombiner::visitAllocSite(Instruction &MI) {
// true or false as appropriate.
SmallVector<WeakVH, 64> Users;
if (isAllocSiteRemovable(&MI, Users, TLI)) {
for (unsigned i = 0, e = Users.size(); i != e; ++i) {
// Lowering all @llvm.objectsize calls first because they may
// use a bitcast/GEP of the alloca we are removing.
Instruction *I = cast_or_null<Instruction>(&*Users[i]);
if (!I) continue;

if (IntrinsicInst *II = dyn_cast<IntrinsicInst>(I)) {
if (II->getIntrinsicID() == Intrinsic::objectsize) {
uint64_t Size;
if (!getObjectSize(II->getArgOperand(0), Size, DL, TLI)) {
ConstantInt *CI = cast<ConstantInt>(II->getArgOperand(1));
Size = CI->isZero() ? -1ULL : 0;
}
replaceInstUsesWith(*I, ConstantInt::get(I->getType(), Size));
eraseInstFromFunction(*I);
Users[i] = nullptr; // Skip examining in the next loop.
}
}
}
for (unsigned i = 0, e = Users.size(); i != e; ++i) {
Instruction *I = cast_or_null<Instruction>(&*Users[i]);
if (!I) continue;
Expand All @@ -1970,6 +1951,12 @@ Instruction *InstCombiner::visitAllocSite(Instruction &MI) {
C->isFalseWhenEqual()));
} else if (isa<BitCastInst>(I) || isa<GetElementPtrInst>(I)) {
replaceInstUsesWith(*I, UndefValue::get(I->getType()));
} else if (IntrinsicInst *II = dyn_cast<IntrinsicInst>(I)) {
if (II->getIntrinsicID() == Intrinsic::objectsize) {
ConstantInt *CI = cast<ConstantInt>(II->getArgOperand(1));
uint64_t DontKnow = CI->isZero() ? -1ULL : 0;
replaceInstUsesWith(*I, ConstantInt::get(I->getType(), DontKnow));
}
}
eraseInstFromFunction(*I);
}
Expand Down
34 changes: 0 additions & 34 deletions test/Transforms/InstCombine/builtin-object-size-ptr.ll

This file was deleted.

0 comments on commit 7a9adc7

Please sign in to comment.