[PATCH] D133157: Add -sanitizer-coverage-control-flow
Navid Emamdoost via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 1 16:52:14 PDT 2022
Navidem marked an inline comment as done.
Navidem added inline comments.
================
Comment at: llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp:1062
+ for (auto SuccBB : successors(&BB)) {
+ if (SuccBB == &F.getEntryBlock())
+ CFs.push_back((Constant *)IRB.CreatePointerCast(&F, IntptrPtrTy));
----------------
kcc wrote:
> Navidem wrote:
> > kcc wrote:
> > > hmmm... is it even possible?
> > I was being cautious here for the branches (like `goto`) to the beginning of the function.
> > But later once checked a concrete example, I was not able to produce such scenario.
> >
> > something like the following code breaks the entry basic block:
> >
> > ```
> > int foo (int x) {
> > top:
> > x += 5;
> > if (x > 5)
> > bar(x);
> > else
> > goto top;
> >
> > return x;
> > }
> > ```
> > ```
> > define dso_local i32 @foo(i32 noundef %x) #0 {
> > entry:
> > %x.addr = alloca i32, align 4
> > store i32 %x, ptr %x.addr, align 4
> > br label %top
> >
> > top: ; preds = %if.else, %entry
> > %0 = load i32, ptr %x.addr, align 4
> > %add = add nsw i32 %0, 5
> > store i32 %add, ptr %x.addr, align 4
> > %1 = load i32, ptr %x.addr, align 4
> > %cmp = icmp sgt i32 %1, 5
> > br i1 %cmp, label %if.then, label %if.else
> >
> > if.then: ; preds = %top
> > %2 = load i32, ptr %x.addr, align 4
> > call void @bar(i32 noundef %2)
> > br label %if.end
> >
> > if.else: ; preds = %top
> > br label %top
> >
> > if.end: ; preds = %if.then
> > %3 = load i32, ptr %x.addr, align 4
> > ret i32 %3
> > }
> > ```
> >
> > If you think it is impossible, I am fine with simplifying the code here.
> yea, please simplify. ok to leave an assert
Happy to!
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D133157/new/
https://reviews.llvm.org/D133157
More information about the llvm-commits
mailing list