Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions llvm/lib/Analysis/ConstantFolding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3807,6 +3807,9 @@ bool llvm::isMathLibCallNoop(const CallBase *Call,
case LibFunc_log10f:
return Op.isNaN() || (!Op.isZero() && !Op.isNegative());

case LibFunc_ilogb:
return !Op.isNaN() && !Op.isZero() && !Op.isInfinity();

case LibFunc_expl:
case LibFunc_exp:
case LibFunc_expf:
Expand Down
26 changes: 20 additions & 6 deletions llvm/lib/ObjCopy/ELF/ELFObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -766,8 +766,14 @@ Error SymbolTableSection::removeSymbols(
function_ref<bool(const Symbol &)> ToRemove) {
Symbols.erase(
std::remove_if(std::begin(Symbols) + 1, std::end(Symbols),
[ToRemove](const SymPtr &Sym) { return ToRemove(*Sym); }),
std::end(Symbols));
[ToRemove](const SymPtr &Sym) {
if (ToRemove(*Sym)) {
dbgs()<<"Symbols Removed:"<<Sym->Name<< "\n";
return true;
}
return false;
}));

auto PrevSize = Size;
Size = Symbols.size() * EntrySize;
if (Size < PrevSize)
Expand Down Expand Up @@ -2240,10 +2246,18 @@ Error Object::removeSections(

// Transfer removed sections into the Object RemovedSections container for use
// later.
std::move(Iter, Sections.end(), std::back_inserter(RemovedSections));
// Now finally get rid of them all together.
Sections.erase(Iter, std::end(Sections));
return Error::success();
for(auto &KeepSec : make_range(std::begin(Sections) , Iter))
{

if (Error E = KeepSec->removeSectionReferences(
AllowBrokenLinks, [&RemoveSections](const SectionBase *Sec) {
return RemoveSections.find(Sec) != RemoveSections.end();
}))
std::move(Iter, Sections.end(), std::back_inserter(RemovedSections));
dbgs()<<"Sections Removed:"<<KeepSec->Name<<'\n';
Sections.erase(Iter, std::end(Sections));
return Error::success();
}
}

Error Object::replaceSections(
Expand Down
213 changes: 213 additions & 0 deletions llvm/test/Transforms/InstSimplify/pr122582.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
; RUN: opt < %s -passes=instsimplify -S | FileCheck %s

define i32 @ilogbf_const1() {
; CHECK-LABEL: define i32 @ilogbf_const1() {
; CHECK-NEXT: [[R:%.*]] = call i32 @ilogbf(float 7.000000e+00)
; CHECK-NEXT: ret i32 2
;
%r = call i32 @ilogbf(float 7.000000e+00)
ret i32 %r
}

define i32 @ilogb_const1() {
; CHECK-LABEL: define i32 @ilogb_const1() {
; CHECK-NEXT: [[R:%.*]] = call i32 @ilogb(double -7.000000e+00)
; CHECK-NEXT: ret i32 2
;
%r = call i32 @ilogb(double -7.000000e+00)
ret i32 %r
}

define i32 @ilogbf_const2() {
; CHECK-LABEL: define i32 @ilogbf_const2() {
; CHECK-NEXT: [[R:%.*]] = call i32 @ilogbf(float 5.000000e-01)
; CHECK-NEXT: ret i32 -1
;
%r = call i32 @ilogbf(float 5.000000e-01)
ret i32 %r
}

define i32 @ilogb_const2() {
; CHECK-LABEL: define i32 @ilogb_const2() {
; CHECK-NEXT: [[R:%.*]] = call i32 @ilogb(double -5.000000e-01)
; CHECK-NEXT: ret i32 -1
;
%r = call i32 @ilogb(double -5.000000e-01)
ret i32 %r
}

define i32 @ilogbf_zero() {
; CHECK-LABEL: define i32 @ilogbf_zero() {
; CHECK-NEXT: [[R:%.*]] = call i32 @ilogbf(float 0.000000e+00)
; CHECK-NEXT: ret i32 [[R]]
;
%r = call i32 @ilogbf(float 0.000000e+00)
ret i32 %r
}

define i32 @ilogb_zero() {
; CHECK-LABEL: define i32 @ilogb_zero() {
; CHECK-NEXT: [[R:%.*]] = call i32 @ilogb(double 0.000000e+00)
; CHECK-NEXT: ret i32 [[R]]
;
%r = call i32 @ilogb(double 0.000000e+00)
ret i32 %r
}

define i32 @ilogbf_neg_zero() {
; CHECK-LABEL: define i32 @ilogbf_neg_zero() {
; CHECK-NEXT: [[R:%.*]] = call i32 @ilogbf(float -0.000000e+00)
; CHECK-NEXT: ret i32 [[R]]
;
%r = call i32 @ilogbf(float -0.000000e+00)
ret i32 %r
}

define i32 @ilogb_neg_zero() {
; CHECK-LABEL: define i32 @ilogb_neg_zero() {
; CHECK-NEXT: [[R:%.*]] = call i32 @ilogb(double -0.000000e+00)
; CHECK-NEXT: ret i32 [[R]]
;
%r = call i32 @ilogb(double -0.000000e+00)
ret i32 %r
}

define i32 @ilogbf_inf() {
; CHECK-LABEL: define i32 @ilogbf_inf() {
; CHECK-NEXT: [[R:%.*]] = call i32 @ilogbf(float 0x7FF0000000000000)
; CHECK-NEXT: ret i32 [[R]]
;
%r = call i32 @ilogbf(float 0x7FF0000000000000)
ret i32 %r
}

define i32 @ilogb_inf() {
; CHECK-LABEL: define i32 @ilogb_inf() {
; CHECK-NEXT: [[R:%.*]] = call i32 @ilogb(double 0x7FF0000000000000)
; CHECK-NEXT: ret i32 [[R]]
;
%r = call i32 @ilogb(double 0x7FF0000000000000)
ret i32 %r
}

define i32 @ilogbf_nan() {
; CHECK-LABEL: define i32 @ilogbf_nan() {
; CHECK-NEXT: [[R:%.*]] = call i32 @ilogbf(float 0x7FF8000000000000)
; CHECK-NEXT: ret i32 [[R]]
;
%r = call i32 @ilogbf(float 0x7FF8000000000000)
ret i32 %r
}

define i32 @ilogb_nan() {
; CHECK-LABEL: define i32 @ilogb_nan() {
; CHECK-NEXT: [[R:%.*]] = call i32 @ilogb(double 0x7FF8000000000000)
; CHECK-NEXT: ret i32 [[R]]
;
%r = call i32 @ilogb(double 0x7FF8000000000000)
ret i32 %r
}

define i32 @ilogbf_zero_readnone() {
; CHECK-LABEL: define i32 @ilogbf_zero_readnone() {
; CHECK-NEXT: [[R:%.*]] = call i32 @ilogbf(float 0.000000e+00) #[[ATTR1:[0-9]+]]
; CHECK-NEXT: ret i32 [[R]]
;
%r = call i32 @ilogbf(float 0.000000e+00) readnone
ret i32 %r
}

define i32 @ilogb_zero_readnone() {
; CHECK-LABEL: define i32 @ilogb_zero_readnone() {
; CHECK-NEXT: [[R:%.*]] = call i32 @ilogb(double 0.000000e+00) #[[ATTR1]]
; CHECK-NEXT: ret i32 [[R]]
;
%r = call i32 @ilogb(double 0.000000e+00) readnone
ret i32 %r
}

define i32 @ilogbf_neg_zero_readnone() {
; CHECK-LABEL: define i32 @ilogbf_neg_zero_readnone() {
; CHECK-NEXT: [[R:%.*]] = call i32 @ilogbf(float -0.000000e+00) #[[ATTR1]]
; CHECK-NEXT: ret i32 [[R]]
;
%r = call i32 @ilogbf(float -0.000000e+00) readnone
ret i32 %r
}

define i32 @ilogb_neg_zero_readnone() {
; CHECK-LABEL: define i32 @ilogb_neg_zero_readnone() {
; CHECK-NEXT: [[R:%.*]] = call i32 @ilogb(double -0.000000e+00) #[[ATTR1]]
; CHECK-NEXT: ret i32 [[R]]
;
%r = call i32 @ilogb(double -0.000000e+00) readnone
ret i32 %r
}

define i32 @ilogbf_inf_readnone() {
; CHECK-LABEL: define i32 @ilogbf_inf_readnone() {
; CHECK-NEXT: [[R:%.*]] = call i32 @ilogbf(float 0x7FF0000000000000) #[[ATTR1]]
; CHECK-NEXT: ret i32 [[R]]
;
%r = call i32 @ilogbf(float 0x7FF0000000000000) readnone
ret i32 %r
}

define i32 @ilogb_inf_readnone() {
; CHECK-LABEL: define i32 @ilogb_inf_readnone() {
; CHECK-NEXT: [[R:%.*]] = call i32 @ilogb(double 0x7FF0000000000000) #[[ATTR1]]
; CHECK-NEXT: ret i32 [[R]]
;
%r = call i32 @ilogb(double 0x7FF0000000000000) readnone
ret i32 %r
}

define i32 @ilogbf_nan_readnone() {
; CHECK-LABEL: define i32 @ilogbf_nan_readnone() {
; CHECK-NEXT: [[R:%.*]] = call i32 @ilogbf(float 0x7FF8000000000000) #[[ATTR1]]
; CHECK-NEXT: ret i32 [[R]]
;
%r = call i32 @ilogbf(float 0x7FF8000000000000) readnone
ret i32 %r
}

define i32 @ilogb_nan_readnone() {
; CHECK-LABEL: define i32 @ilogb_nan_readnone() {
; CHECK-NEXT: [[R:%.*]] = call i32 @ilogb(double 0x7FF8000000000000) #[[ATTR1]]
; CHECK-NEXT: ret i32 [[R]]
;
%r = call i32 @ilogb(double 0x7FF8000000000000) readnone
ret i32 %r
}

define i32 @ilogbf_poison() {
; CHECK-LABEL: define i32 @ilogbf_poison() {
; CHECK-NEXT: [[R:%.*]] = call i32 @ilogbf(float poison)
; CHECK-NEXT: ret i32 [[R]]
;
%r = call i32 @ilogbf(float poison)
ret i32 %r
}

define i32 @ilogb_poison() {
; CHECK-LABEL: define i32 @ilogb_poison() {
; CHECK-NEXT: [[R:%.*]] = call i32 @ilogb(double poison)
; CHECK-NEXT: ret i32 [[R]]
;
%r = call i32 @ilogb(double poison)
ret i32 %r
}

define i32 @ilogb_const1_1() strictfp {
; CHECK-LABEL: define i32 @ilogb_const1_1(
; CHECK-SAME: ) #[[ATTR0:[0-9]+]] {
; CHECK-NEXT: [[R:%.*]] = call i32 @ilogb(double -7.000000e+00)
; CHECK-NEXT: ret i32 2
;
%r = call i32 @ilogb(double -7.000000e+00)
ret i32 %r
}

declare i32 @ilogbf(float)
declare i32 @ilogb(double)
2 changes: 2 additions & 0 deletions llvm/tools/llvm-objcopy/CommonOpts.td
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ def regex

def version : Flag<["--"], "version">,
HelpText<"Print the version and exit.">;
def verbose : Flag<["--"], "verbose">,
HelpText<"Prints the removed symbols and sections">;
def V : Flag<["-"], "V">,
Alias<version>,
HelpText<"Alias for --version">;
Expand Down
Loading