Skip to content

Commit f64ca30

Browse files
[llvm] Use LazyValueInfo to improve llvm.objectsize computation
Using LazyValueInfo, it is possible to compute valuable information for allocation functions, GEP and alloca, even in the presence of dynamic information. llvm.objectsize plays an important role in _FORTIFY_SOURCE definitions, so improving its diagnostic in turns improves the security of compiled application. As a side note, as a result of recent optimization improvements, clang no longer passes https://github.com/serge-sans-paille/builtin_object_size-test-suite This commit restores the situation and greatly improves the scope of code handled by the static version of __builtin_object_size.
1 parent 2804762 commit f64ca30

17 files changed

+277
-53
lines changed

llvm/include/llvm/Analysis/MemoryBuiltins.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class IntegerType;
4242
class IntrinsicInst;
4343
class IntToPtrInst;
4444
class LLVMContext;
45+
class LazyValueInfo;
4546
class LoadInst;
4647
class PHINode;
4748
class SelectInst;
@@ -160,8 +161,10 @@ struct ObjectSizeOpts {
160161
/// though they can't be evaluated. Otherwise, null is always considered to
161162
/// point to a 0 byte region of memory.
162163
bool NullIsUnknownSize = false;
163-
/// If set, used for more accurate evaluation
164+
/// If set, used for more accurate evaluation.
164165
AAResults *AA = nullptr;
166+
/// If set, used for more accurate evaluation.
167+
LazyValueInfo *LVI = nullptr;
165168
};
166169

167170
/// Compute the size of the object pointed by Ptr. Returns true and the
@@ -186,6 +189,12 @@ Value *lowerObjectSizeCall(
186189
const TargetLibraryInfo *TLI, AAResults *AA, bool MustSucceed,
187190
SmallVectorImpl<Instruction *> *InsertedInstructions = nullptr);
188191

192+
Value *lowerObjectSizeCall(
193+
IntrinsicInst *ObjectSize, const DataLayout &DL,
194+
const TargetLibraryInfo *TLI, AAResults *AA, LazyValueInfo *LVI,
195+
bool MustSucceed,
196+
SmallVectorImpl<Instruction *> *InsertedInstructions = nullptr);
197+
189198
/// SizeOffsetType - A base template class for the object size visitors. Used
190199
/// here as a self-documenting way to handle the values rather than using a
191200
/// \p std::pair.
@@ -275,6 +284,7 @@ class ObjectSizeOffsetVisitor
275284
OffsetSpan visitExtractValueInst(ExtractValueInst &I);
276285
OffsetSpan visitGlobalAlias(GlobalAlias &GA);
277286
OffsetSpan visitGlobalVariable(GlobalVariable &GV);
287+
OffsetSpan visitGetElementPtr(GetElementPtrInst &GEP);
278288
OffsetSpan visitIntToPtrInst(IntToPtrInst &);
279289
OffsetSpan visitLoadInst(LoadInst &I);
280290
OffsetSpan visitPHINode(PHINode &);

llvm/include/llvm/Transforms/InstCombine/InstCombiner.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ namespace llvm {
3737
class AAResults;
3838
class AssumptionCache;
3939
class OptimizationRemarkEmitter;
40+
class LazyValueInfo;
4041
class ProfileSummaryInfo;
4142
class TargetLibraryInfo;
4243
class TargetTransformInfo;
@@ -72,6 +73,7 @@ class LLVM_LIBRARY_VISIBILITY InstCombiner {
7273
// Required analyses.
7374
AssumptionCache &AC;
7475
TargetLibraryInfo &TLI;
76+
LazyValueInfo &LVI;
7577
DominatorTree &DT;
7678
const DataLayout &DL;
7779
SimplifyQuery SQ;
@@ -101,14 +103,15 @@ class LLVM_LIBRARY_VISIBILITY InstCombiner {
101103
InstCombiner(InstructionWorklist &Worklist, BuilderTy &Builder,
102104
bool MinimizeSize, AAResults *AA, AssumptionCache &AC,
103105
TargetLibraryInfo &TLI, TargetTransformInfo &TTI,
104-
DominatorTree &DT, OptimizationRemarkEmitter &ORE,
105-
BlockFrequencyInfo *BFI, BranchProbabilityInfo *BPI,
106-
ProfileSummaryInfo *PSI, const DataLayout &DL,
106+
LazyValueInfo &LVI, DominatorTree &DT,
107+
OptimizationRemarkEmitter &ORE, BlockFrequencyInfo *BFI,
108+
BranchProbabilityInfo *BPI, ProfileSummaryInfo *PSI,
109+
const DataLayout &DL,
107110
ReversePostOrderTraversal<BasicBlock *> &RPOT)
108111
: TTIForTargetIntrinsicsOnly(TTI), Builder(Builder), Worklist(Worklist),
109-
MinimizeSize(MinimizeSize), AA(AA), AC(AC), TLI(TLI), DT(DT), DL(DL),
110-
SQ(DL, &TLI, &DT, &AC, nullptr, /*UseInstrInfo*/ true,
111-
/*CanUseUndef*/ true, &DC),
112+
MinimizeSize(MinimizeSize), AA(AA), AC(AC), TLI(TLI), LVI(LVI), DT(DT),
113+
DL(DL), SQ(DL, &TLI, &DT, &AC, nullptr, /*UseInstrInfo*/ true,
114+
/*CanUseUndef*/ true, &DC),
112115
ORE(ORE), BFI(BFI), BPI(BPI), PSI(PSI), RPOT(RPOT) {}
113116

114117
virtual ~InstCombiner() = default;

llvm/include/llvm/Transforms/Scalar/LowerConstantIntrinsics.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ namespace llvm {
2222
class DominatorTree;
2323
class Function;
2424
class TargetLibraryInfo;
25+
class LazyValueInfo;
2526

2627
bool lowerConstantIntrinsics(Function &F, const TargetLibraryInfo &TLI,
27-
DominatorTree *DT);
28+
DominatorTree *DT, LazyValueInfo *LVI);
2829

2930
struct LowerConstantIntrinsicsPass :
3031
PassInfoMixin<LowerConstantIntrinsicsPass> {

llvm/lib/Analysis/MemoryBuiltins.cpp

Lines changed: 76 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
#include "llvm/ADT/STLExtras.h"
1717
#include "llvm/ADT/Statistic.h"
1818
#include "llvm/Analysis/AliasAnalysis.h"
19+
#include "llvm/Analysis/AssumptionCache.h"
20+
#include "llvm/Analysis/LazyValueInfo.h"
1921
#include "llvm/Analysis/TargetFolder.h"
2022
#include "llvm/Analysis/TargetLibraryInfo.h"
2123
#include "llvm/Analysis/Utils/Local.h"
@@ -590,19 +592,28 @@ Value *llvm::lowerObjectSizeCall(IntrinsicInst *ObjectSize,
590592
const TargetLibraryInfo *TLI,
591593
bool MustSucceed) {
592594
return lowerObjectSizeCall(ObjectSize, DL, TLI, /*AAResults=*/nullptr,
593-
MustSucceed);
595+
/*LazyValueInfo=*/nullptr, MustSucceed);
594596
}
595597

596598
Value *llvm::lowerObjectSizeCall(
597599
IntrinsicInst *ObjectSize, const DataLayout &DL,
598600
const TargetLibraryInfo *TLI, AAResults *AA, bool MustSucceed,
599601
SmallVectorImpl<Instruction *> *InsertedInstructions) {
602+
return lowerObjectSizeCall(ObjectSize, DL, TLI, AA, /*LazyValueInfo=*/nullptr,
603+
MustSucceed, InsertedInstructions);
604+
}
605+
606+
Value *llvm::lowerObjectSizeCall(
607+
IntrinsicInst *ObjectSize, const DataLayout &DL,
608+
const TargetLibraryInfo *TLI, AAResults *AA, LazyValueInfo *LVI,
609+
bool MustSucceed, SmallVectorImpl<Instruction *> *InsertedInstructions) {
600610
assert(ObjectSize->getIntrinsicID() == Intrinsic::objectsize &&
601611
"ObjectSize must be a call to llvm.objectsize!");
602612

603613
bool MaxVal = cast<ConstantInt>(ObjectSize->getArgOperand(1))->isZero();
604614
ObjectSizeOpts EvalOptions;
605615
EvalOptions.AA = AA;
616+
EvalOptions.LVI = LVI;
606617

607618
// Unless we have to fold this to something, try to be as accurate as
608619
// possible.
@@ -716,7 +727,6 @@ OffsetSpan ObjectSizeOffsetVisitor::computeImpl(Value *V) {
716727
// value that is passed to computeImpl.
717728
IntTyBits = DL.getIndexTypeSizeInBits(V->getType());
718729
Zero = APInt::getZero(IntTyBits);
719-
720730
OffsetSpan ORT = computeValue(V);
721731

722732
bool IndexTypeSizeChanged = InitialIntTyBits != IntTyBits;
@@ -794,6 +804,17 @@ OffsetSpan ObjectSizeOffsetVisitor::visitAllocaInst(AllocaInst &I) {
794804
Size = Size.umul_ov(NumElems, Overflow);
795805
return Overflow ? ObjectSizeOffsetVisitor::unknown()
796806
: OffsetSpan(Zero, align(Size, I.getAlign()));
807+
} else if (Options.LVI) {
808+
ConstantRange CR =
809+
Options.LVI->getConstantRange(const_cast<Value *>(ArraySize), &I, true);
810+
if (CR.isFullSet())
811+
return ObjectSizeOffsetVisitor::unknown();
812+
APInt Bound;
813+
if (Options.EvalMode == ObjectSizeOpts::Mode::Max)
814+
Bound = CR.getUnsignedMax();
815+
else
816+
Bound = CR.getUnsignedMin();
817+
return OffsetSpan(Zero, align(Bound, I.getAlign()));
797818
}
798819
return ObjectSizeOffsetVisitor::unknown();
799820
}
@@ -811,7 +832,23 @@ OffsetSpan ObjectSizeOffsetVisitor::visitArgument(Argument &A) {
811832
}
812833

813834
OffsetSpan ObjectSizeOffsetVisitor::visitCallBase(CallBase &CB) {
814-
if (std::optional<APInt> Size = getAllocSize(&CB, TLI))
835+
if (std::optional<APInt> Size =
836+
getAllocSize(&CB, TLI, [&CB, this](const Value *V) -> const Value * {
837+
if (!Options.LVI)
838+
return V;
839+
if (!V->getType()->isIntegerTy())
840+
return V;
841+
ConstantRange CR = Options.LVI->getConstantRange(
842+
const_cast<Value *>(V), &CB, true);
843+
if (CR.isFullSet())
844+
return V;
845+
APInt Bound;
846+
if (Options.EvalMode == ObjectSizeOpts::Mode::Max)
847+
Bound = CR.getUnsignedMax();
848+
else
849+
Bound = CR.getUnsignedMin();
850+
return ConstantInt::get(V->getType(), Bound);
851+
}))
815852
return OffsetSpan(Zero, *Size);
816853
return ObjectSizeOffsetVisitor::unknown();
817854
}
@@ -856,6 +893,42 @@ OffsetSpan ObjectSizeOffsetVisitor::visitGlobalVariable(GlobalVariable &GV) {
856893
return OffsetSpan(Zero, align(Size, GV.getAlign()));
857894
}
858895

896+
OffsetSpan ObjectSizeOffsetVisitor::visitGetElementPtr(GetElementPtrInst &GEP) {
897+
OffsetSpan PtrData = computeImpl(GEP.getPointerOperand());
898+
if (!PtrData.bothKnown())
899+
return ObjectSizeOffsetVisitor::unknown();
900+
901+
if (!Options.LVI)
902+
return ObjectSizeOffsetVisitor::unknown();
903+
904+
if (Options.EvalMode == ObjectSizeOpts::Mode::Min ||
905+
Options.EvalMode == ObjectSizeOpts::Mode::Max) {
906+
unsigned BitWidth = PtrData.After.getBitWidth();
907+
APInt ConstantOffset = Zero;
908+
SmallMapVector<Value *, APInt, 4> VariableOffsets;
909+
if (!GEP.collectOffset(DL, BitWidth, VariableOffsets, ConstantOffset))
910+
return ObjectSizeOffsetVisitor::unknown();
911+
912+
ConstantRange AccumulatedRange = ConstantOffset;
913+
for (auto const &VO : VariableOffsets) {
914+
ConstantRange CR = Options.LVI->getConstantRange(VO.first, &GEP, true);
915+
if (CR.isFullSet())
916+
return ObjectSizeOffsetVisitor::unknown();
917+
918+
AccumulatedRange = AccumulatedRange.add(CR.multiply(VO.second));
919+
}
920+
921+
APInt Bound;
922+
if (Options.EvalMode == ObjectSizeOpts::Mode::Min)
923+
Bound = AccumulatedRange.getSignedMax();
924+
else
925+
Bound = AccumulatedRange.getSignedMin();
926+
927+
return {PtrData.Before + Bound, PtrData.After - Bound};
928+
}
929+
return ObjectSizeOffsetVisitor::unknown();
930+
}
931+
859932
OffsetSpan ObjectSizeOffsetVisitor::visitIntToPtrInst(IntToPtrInst &) {
860933
// clueless
861934
return ObjectSizeOffsetVisitor::unknown();

llvm/lib/CodeGen/PreISelIntrinsicLowering.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,8 @@ bool PreISelIntrinsicLowering::lowerIntrinsics(Module &M) const {
350350
Function *Parent = CI->getParent()->getParent();
351351
TargetLibraryInfo &TLI = LookupTLI(*Parent);
352352
// Intrinsics in unreachable code are not lowered.
353-
bool Changed = lowerConstantIntrinsics(*Parent, TLI, /*DT=*/nullptr);
353+
bool Changed = lowerConstantIntrinsics(*Parent, TLI, /*DT=*/nullptr,
354+
/*LVI=*/nullptr);
354355
return Changed;
355356
});
356357
break;

llvm/lib/Transforms/InstCombine/InstCombineInternal.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,13 @@ class LLVM_LIBRARY_VISIBILITY InstCombinerImpl final
6363
InstCombinerImpl(InstructionWorklist &Worklist, BuilderTy &Builder,
6464
bool MinimizeSize, AAResults *AA, AssumptionCache &AC,
6565
TargetLibraryInfo &TLI, TargetTransformInfo &TTI,
66-
DominatorTree &DT, OptimizationRemarkEmitter &ORE,
67-
BlockFrequencyInfo *BFI, BranchProbabilityInfo *BPI,
68-
ProfileSummaryInfo *PSI, const DataLayout &DL,
66+
LazyValueInfo &LVI, DominatorTree &DT,
67+
OptimizationRemarkEmitter &ORE, BlockFrequencyInfo *BFI,
68+
BranchProbabilityInfo *BPI, ProfileSummaryInfo *PSI,
69+
const DataLayout &DL,
6970
ReversePostOrderTraversal<BasicBlock *> &RPOT)
70-
: InstCombiner(Worklist, Builder, MinimizeSize, AA, AC, TLI, TTI, DT, ORE,
71-
BFI, BPI, PSI, DL, RPOT) {}
71+
: InstCombiner(Worklist, Builder, MinimizeSize, AA, AC, TLI, TTI, LVI, DT,
72+
ORE, BFI, BPI, PSI, DL, RPOT) {}
7273

7374
virtual ~InstCombinerImpl() = default;
7475

llvm/lib/Transforms/InstCombine/InstructionCombining.cpp

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
#include "llvm/Analysis/GlobalsModRef.h"
4949
#include "llvm/Analysis/InstructionSimplify.h"
5050
#include "llvm/Analysis/LazyBlockFrequencyInfo.h"
51+
#include "llvm/Analysis/LazyValueInfo.h"
5152
#include "llvm/Analysis/MemoryBuiltins.h"
5253
#include "llvm/Analysis/OptimizationRemarkEmitter.h"
5354
#include "llvm/Analysis/ProfileSummaryInfo.h"
@@ -3317,8 +3318,9 @@ Instruction *InstCombinerImpl::visitAllocSite(Instruction &MI) {
33173318
if (IntrinsicInst *II = dyn_cast<IntrinsicInst>(I)) {
33183319
if (II->getIntrinsicID() == Intrinsic::objectsize) {
33193320
SmallVector<Instruction *> InsertedInstructions;
3320-
Value *Result = lowerObjectSizeCall(
3321-
II, DL, &TLI, AA, /*MustSucceed=*/true, &InsertedInstructions);
3321+
Value *Result =
3322+
lowerObjectSizeCall(II, DL, &TLI, AA, &LVI, /*MustSucceed=*/true,
3323+
&InsertedInstructions);
33223324
for (Instruction *Inserted : InsertedInstructions)
33233325
Worklist.add(Inserted);
33243326
replaceInstUsesWith(*I, Result);
@@ -5460,9 +5462,9 @@ void InstCombiner::computeBackEdges() {
54605462
static bool combineInstructionsOverFunction(
54615463
Function &F, InstructionWorklist &Worklist, AliasAnalysis *AA,
54625464
AssumptionCache &AC, TargetLibraryInfo &TLI, TargetTransformInfo &TTI,
5463-
DominatorTree &DT, OptimizationRemarkEmitter &ORE, BlockFrequencyInfo *BFI,
5464-
BranchProbabilityInfo *BPI, ProfileSummaryInfo *PSI,
5465-
const InstCombineOptions &Opts) {
5465+
LazyValueInfo &LVI, DominatorTree &DT, OptimizationRemarkEmitter &ORE,
5466+
BlockFrequencyInfo *BFI, BranchProbabilityInfo *BPI,
5467+
ProfileSummaryInfo *PSI, const InstCombineOptions &Opts) {
54665468
auto &DL = F.getDataLayout();
54675469
bool VerifyFixpoint = Opts.VerifyFixpoint &&
54685470
!F.hasFnAttribute("instcombine-no-verify-fixpoint");
@@ -5501,8 +5503,8 @@ static bool combineInstructionsOverFunction(
55015503
LLVM_DEBUG(dbgs() << "\n\nINSTCOMBINE ITERATION #" << Iteration << " on "
55025504
<< F.getName() << "\n");
55035505

5504-
InstCombinerImpl IC(Worklist, Builder, F.hasMinSize(), AA, AC, TLI, TTI, DT,
5505-
ORE, BFI, BPI, PSI, DL, RPOT);
5506+
InstCombinerImpl IC(Worklist, Builder, F.hasMinSize(), AA, AC, TLI, TTI,
5507+
LVI, DT, ORE, BFI, BPI, PSI, DL, RPOT);
55065508
IC.MaxArraySizeForCombine = MaxArraySize;
55075509
bool MadeChangeInThisIteration = IC.prepareWorklist(F);
55085510
MadeChangeInThisIteration |= IC.run();
@@ -5552,6 +5554,7 @@ PreservedAnalyses InstCombinePass::run(Function &F,
55525554
auto &TLI = AM.getResult<TargetLibraryAnalysis>(F);
55535555
auto &ORE = AM.getResult<OptimizationRemarkEmitterAnalysis>(F);
55545556
auto &TTI = AM.getResult<TargetIRAnalysis>(F);
5557+
auto &LVI = AM.getResult<LazyValueAnalysis>(F);
55555558

55565559
auto *AA = &AM.getResult<AAManager>(F);
55575560
auto &MAMProxy = AM.getResult<ModuleAnalysisManagerFunctionProxy>(F);
@@ -5561,8 +5564,8 @@ PreservedAnalyses InstCombinePass::run(Function &F,
55615564
&AM.getResult<BlockFrequencyAnalysis>(F) : nullptr;
55625565
auto *BPI = AM.getCachedResult<BranchProbabilityAnalysis>(F);
55635566

5564-
if (!combineInstructionsOverFunction(F, Worklist, AA, AC, TLI, TTI, DT, ORE,
5565-
BFI, BPI, PSI, Options))
5567+
if (!combineInstructionsOverFunction(F, Worklist, AA, AC, TLI, TTI, LVI, DT,
5568+
ORE, BFI, BPI, PSI, Options))
55665569
// No changes, all analyses are preserved.
55675570
return PreservedAnalyses::all();
55685571

@@ -5580,6 +5583,7 @@ void InstructionCombiningPass::getAnalysisUsage(AnalysisUsage &AU) const {
55805583
AU.addRequired<TargetTransformInfoWrapperPass>();
55815584
AU.addRequired<DominatorTreeWrapperPass>();
55825585
AU.addRequired<OptimizationRemarkEmitterWrapperPass>();
5586+
AU.addRequired<LazyValueInfoWrapperPass>();
55835587
AU.addPreserved<DominatorTreeWrapperPass>();
55845588
AU.addPreserved<AAResultsWrapperPass>();
55855589
AU.addPreserved<BasicAAWrapperPass>();
@@ -5597,6 +5601,7 @@ bool InstructionCombiningPass::runOnFunction(Function &F) {
55975601
auto &AC = getAnalysis<AssumptionCacheTracker>().getAssumptionCache(F);
55985602
auto &TLI = getAnalysis<TargetLibraryInfoWrapperPass>().getTLI(F);
55995603
auto &TTI = getAnalysis<TargetTransformInfoWrapperPass>().getTTI(F);
5604+
auto &LVI = getAnalysis<LazyValueInfoWrapperPass>().getLVI();
56005605
auto &DT = getAnalysis<DominatorTreeWrapperPass>().getDomTree();
56015606
auto &ORE = getAnalysis<OptimizationRemarkEmitterWrapperPass>().getORE();
56025607

@@ -5612,8 +5617,9 @@ bool InstructionCombiningPass::runOnFunction(Function &F) {
56125617
getAnalysisIfAvailable<BranchProbabilityInfoWrapperPass>())
56135618
BPI = &WrapperPass->getBPI();
56145619

5615-
return combineInstructionsOverFunction(F, Worklist, AA, AC, TLI, TTI, DT, ORE,
5616-
BFI, BPI, PSI, InstCombineOptions());
5620+
return combineInstructionsOverFunction(F, Worklist, AA, AC, TLI, TTI, LVI, DT,
5621+
ORE, BFI, BPI, PSI,
5622+
InstCombineOptions());
56175623
}
56185624

56195625
char InstructionCombiningPass::ID = 0;
@@ -5630,6 +5636,7 @@ INITIALIZE_PASS_DEPENDENCY(TargetTransformInfoWrapperPass)
56305636
INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
56315637
INITIALIZE_PASS_DEPENDENCY(AAResultsWrapperPass)
56325638
INITIALIZE_PASS_DEPENDENCY(GlobalsAAWrapperPass)
5639+
INITIALIZE_PASS_DEPENDENCY(LazyValueInfoWrapperPass)
56335640
INITIALIZE_PASS_DEPENDENCY(OptimizationRemarkEmitterWrapperPass)
56345641
INITIALIZE_PASS_DEPENDENCY(LazyBlockFrequencyInfoPass)
56355642
INITIALIZE_PASS_DEPENDENCY(ProfileSummaryInfoWrapperPass)

llvm/lib/Transforms/Scalar/LowerConstantIntrinsics.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "llvm/Analysis/DomTreeUpdater.h"
1919
#include "llvm/Analysis/GlobalsModRef.h"
2020
#include "llvm/Analysis/InstructionSimplify.h"
21+
#include "llvm/Analysis/LazyValueInfo.h"
2122
#include "llvm/Analysis/MemoryBuiltins.h"
2223
#include "llvm/Analysis/TargetLibraryInfo.h"
2324
#include "llvm/IR/BasicBlock.h"
@@ -100,7 +101,7 @@ static bool replaceConditionalBranchesOnConstant(Instruction *II,
100101
}
101102

102103
bool llvm::lowerConstantIntrinsics(Function &F, const TargetLibraryInfo &TLI,
103-
DominatorTree *DT) {
104+
DominatorTree *DT, LazyValueInfo *LVI) {
104105
std::optional<DomTreeUpdater> DTU;
105106
if (DT)
106107
DTU.emplace(DT, DomTreeUpdater::UpdateStrategy::Lazy);
@@ -144,7 +145,7 @@ bool llvm::lowerConstantIntrinsics(Function &F, const TargetLibraryInfo &TLI,
144145
IsConstantIntrinsicsHandled++;
145146
break;
146147
case Intrinsic::objectsize:
147-
NewValue = lowerObjectSizeCall(II, DL, &TLI, true);
148+
NewValue = lowerObjectSizeCall(II, DL, &TLI, nullptr, LVI, true);
148149
LLVM_DEBUG(dbgs() << "Folding " << *II << " to " << *NewValue << "\n");
149150
ObjectSizeIntrinsicsHandled++;
150151
break;
@@ -160,7 +161,8 @@ bool llvm::lowerConstantIntrinsics(Function &F, const TargetLibraryInfo &TLI,
160161
PreservedAnalyses
161162
LowerConstantIntrinsicsPass::run(Function &F, FunctionAnalysisManager &AM) {
162163
if (lowerConstantIntrinsics(F, AM.getResult<TargetLibraryAnalysis>(F),
163-
AM.getCachedResult<DominatorTreeAnalysis>(F))) {
164+
AM.getCachedResult<DominatorTreeAnalysis>(F),
165+
&AM.getResult<LazyValueAnalysis>(F))) {
164166
PreservedAnalyses PA;
165167
PA.preserve<DominatorTreeAnalysis>();
166168
return PA;

0 commit comments

Comments
 (0)