[llvm] r284591 - [Sparc][LEON] Detects an erratum on UT699 LEON 3 processors involving rounding mode changes and issues an appropriate user error message.
Galina Kistanova via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 19 11:07:11 PDT 2016
Hello Chris,
This revision broke couple or our builders:
http://lab.llvm.org:8011/builders/clang-with-lto-ubuntu/builds/947
http://lab.llvm.org:8011/builders/clang-with-thin-lto-ubuntu/builds/6
Please have a look?
Thanks
Galina
On Wed, Oct 19, 2016 at 7:01 AM, Chris Dewhurst via llvm-commits <
llvm-commits at lists.llvm.org> wrote:
> Author: lerochris
> Date: Wed Oct 19 09:01:06 2016
> New Revision: 284591
>
> URL: http://llvm.org/viewvc/llvm-project?rev=284591&view=rev
> Log:
> [Sparc][LEON] Detects an erratum on UT699 LEON 3 processors involving
> rounding mode changes and issues an appropriate user error message.
>
> Differential Revision: https://reviews.llvm.org/D24665
>
> Added:
> llvm/trunk/test/CodeGen/SPARC/LeonDetectRoundChangePassUT.ll (with
> props)
> Modified:
> llvm/trunk/lib/Target/Sparc/LeonFeatures.td
> llvm/trunk/lib/Target/Sparc/LeonPasses.cpp
> llvm/trunk/lib/Target/Sparc/LeonPasses.h
> llvm/trunk/lib/Target/Sparc/SparcSubtarget.cpp
> llvm/trunk/lib/Target/Sparc/SparcSubtarget.h
> llvm/trunk/lib/Target/Sparc/SparcTargetMachine.cpp
>
> Modified: llvm/trunk/lib/Target/Sparc/LeonFeatures.td
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/
> Sparc/LeonFeatures.td?rev=284591&r1=284590&r2=284591&view=diff
> ============================================================
> ==================
> --- llvm/trunk/lib/Target/Sparc/LeonFeatures.td (original)
> +++ llvm/trunk/lib/Target/Sparc/LeonFeatures.td Wed Oct 19 09:01:06 2016
> @@ -66,6 +66,14 @@ def ReplaceFMULS : SubtargetFeature<
> "LEON erratum fix: Replace FMULS instruction with FMULD and relevant
> conversion instructions"
> >;
>
> +def DetectRoundChange : SubtargetFeature<
> + "detectroundchange",
> + "DetectRoundChange",
> + "true",
> + "LEON3 erratum detection: Detects any rounding mode change "
> + "request: use only the round-to-nearest rounding mode"
> +>;
> +
> def FixAllFDIVSQRT : SubtargetFeature<
> "fixallfdivsqrt",
> "FixAllFDIVSQRT",
>
> Modified: llvm/trunk/lib/Target/Sparc/LeonPasses.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/
> Sparc/LeonPasses.cpp?rev=284591&r1=284590&r2=284591&view=diff
> ============================================================
> ==================
> --- llvm/trunk/lib/Target/Sparc/LeonPasses.cpp (original)
> +++ llvm/trunk/lib/Target/Sparc/LeonPasses.cpp Wed Oct 19 09:01:06 2016
> @@ -16,6 +16,7 @@
> #include "llvm/CodeGen/MachineInstr.h"
> #include "llvm/CodeGen/MachineInstrBuilder.h"
> #include "llvm/CodeGen/MachineRegisterInfo.h"
> +#include "llvm/IR/DiagnosticInfo.h"
> #include "llvm/IR/LLVMContext.h"
> #include "llvm/Support/raw_ostream.h"
> using namespace llvm;
> @@ -269,6 +270,50 @@ bool ReplaceFMULS::runOnMachineFunction(
> }
> }
> }
> + }
> +
> + return Modified;
> +}
> +
> +
> +//*********************************************************
> ********************
> +//**** DetectRoundChange pass
> +//*********************************************************
> ********************
> +// To prevent any explicit change of the default rounding mode, this pass
> +// detects any call of the fesetround function.
> +// A warning is generated to ensure the user knows this has happened.
> +//
> +// Detects an erratum in UT699 LEON 3 processor
> +
> +char DetectRoundChange::ID = 0;
> +
> +DetectRoundChange::DetectRoundChange(TargetMachine &tm)
> + : LEONMachineFunctionPass(tm, ID) {}
> +
> +bool DetectRoundChange::runOnMachineFunction(MachineFunction &MF) {
> + Subtarget = &MF.getSubtarget<SparcSubtarget>();
> +
> + bool Modified = false;
> + for (auto MFI = MF.begin(), E = MF.end(); MFI != E; ++MFI) {
> + MachineBasicBlock &MBB = *MFI;
> + for (auto MBBI = MBB.begin(), E = MBB.end(); MBBI != E; ++MBBI) {
> + MachineInstr &MI = *MBBI;
> + unsigned Opcode = MI.getOpcode();
> + if (Opcode == SP::CALL && MI.getNumOperands() > 0) {
> + MachineOperand &MO = MI.getOperand(0);
> +
> + if (MO.isGlobal()) {
> + StringRef FuncName = MO.getGlobal()->getName();
> + if (FuncName.compare_lower("fesetround") == 0) {
> + errs() << "Error: You are using the detectroundchange "
> + "option to detect rounding changes that will "
> + "cause LEON errata. The only way to fix this "
> + "is to remove the call to fesetround from "
> + "the source code.\n";
> + }
> + }
> + }
> + }
> }
>
> return Modified;
>
> Modified: llvm/trunk/lib/Target/Sparc/LeonPasses.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/
> Sparc/LeonPasses.h?rev=284591&r1=284590&r2=284591&view=diff
> ============================================================
> ==================
> --- llvm/trunk/lib/Target/Sparc/LeonPasses.h (original)
> +++ llvm/trunk/lib/Target/Sparc/LeonPasses.h Wed Oct 19 09:01:06 2016
> @@ -84,6 +84,20 @@ public:
> }
> };
>
> +class LLVM_LIBRARY_VISIBILITY DetectRoundChange
> + : public LEONMachineFunctionPass {
> +public:
> + static char ID;
> +
> + DetectRoundChange(TargetMachine &tm);
> + bool runOnMachineFunction(MachineFunction &MF) override;
> +
> + StringRef getPassName() const override {
> + return "DetectRoundChange: Leon erratum detection: detect any
> rounding "
> + "mode change request: use only the round-to-nearest rounding
> mode";
> + }
> +};
> +
> class LLVM_LIBRARY_VISIBILITY FixAllFDIVSQRT : public
> LEONMachineFunctionPass {
> public:
> static char ID;
>
> Modified: llvm/trunk/lib/Target/Sparc/SparcSubtarget.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/
> Sparc/SparcSubtarget.cpp?rev=284591&r1=284590&r2=284591&view=diff
> ============================================================
> ==================
> --- llvm/trunk/lib/Target/Sparc/SparcSubtarget.cpp (original)
> +++ llvm/trunk/lib/Target/Sparc/SparcSubtarget.cpp Wed Oct 19 09:01:06
> 2016
> @@ -44,6 +44,7 @@ SparcSubtarget &SparcSubtarget::initiali
> FixFSMULD = false;
> ReplaceFMULS = false;
> FixAllFDIVSQRT = false;
> + DetectRoundChange = false;
>
> // Determine default and user specified characteristics
> std::string CPUName = CPU;
>
> Modified: llvm/trunk/lib/Target/Sparc/SparcSubtarget.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/
> Sparc/SparcSubtarget.h?rev=284591&r1=284590&r2=284591&view=diff
> ============================================================
> ==================
> --- llvm/trunk/lib/Target/Sparc/SparcSubtarget.h (original)
> +++ llvm/trunk/lib/Target/Sparc/SparcSubtarget.h Wed Oct 19 09:01:06 2016
> @@ -48,6 +48,7 @@ class SparcSubtarget : public SparcGenSu
> bool FixFSMULD;
> bool ReplaceFMULS;
> bool FixAllFDIVSQRT;
> + bool DetectRoundChange;
> bool PerformSDIVReplace;
>
> SparcInstrInfo InstrInfo;
> @@ -93,6 +94,7 @@ public:
> bool fixFSMULD() const { return FixFSMULD; }
> bool replaceFMULS() const { return ReplaceFMULS; }
> bool fixAllFDIVSQRT() const { return FixAllFDIVSQRT; }
> + bool detectRoundChange() const { return DetectRoundChange; }
>
> /// ParseSubtargetFeatures - Parses features string setting specified
> /// subtarget options. Definition of function is auto generated by
> tblgen.
>
> Modified: llvm/trunk/lib/Target/Sparc/SparcTargetMachine.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/
> Sparc/SparcTargetMachine.cpp?rev=284591&r1=284590&r2=284591&view=diff
> ============================================================
> ==================
> --- llvm/trunk/lib/Target/Sparc/SparcTargetMachine.cpp (original)
> +++ llvm/trunk/lib/Target/Sparc/SparcTargetMachine.cpp Wed Oct 19
> 09:01:06 2016
> @@ -157,6 +157,9 @@ void SparcPassConfig::addPreEmitPass(){
> {
> addPass(new ReplaceFMULS(getSparcTargetMachine()));
> }
> + if (this->getSparcTargetMachine().getSubtargetImpl()->detectRoundChange())
> {
> + addPass(new DetectRoundChange(getSparcTargetMachine()));
> + }
> if (this->getSparcTargetMachine().getSubtargetImpl()->fixAllFDIVSQRT())
> {
> addPass(new FixAllFDIVSQRT(getSparcTargetMachine()));
>
> Added: llvm/trunk/test/CodeGen/SPARC/LeonDetectRoundChangePassUT.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/SPARC/
> LeonDetectRoundChangePassUT.ll?rev=284591&view=auto
> ============================================================
> ==================
> --- llvm/trunk/test/CodeGen/SPARC/LeonDetectRoundChangePassUT.ll (added)
> +++ llvm/trunk/test/CodeGen/SPARC/LeonDetectRoundChangePassUT.ll Wed Oct
> 19 09:01:06 2016
> @@ -0,0 +1,22 @@
> +; RUN: llc %s -O0 -march=sparc -mcpu=leon3 -mattr=+detectroundchange -o
> - |& grep "detect rounding changes"
> +
> +; Function Attrs: nounwind
> +declare i32 @fesetround(i32)
> +
> +define void @test_round_change() {
> +entry:
> + %call = call i32 @fesetround(i32 2048)
> +
> + ret void
> +}
> +; RUN: llc %s -O0 -march=sparc -mcpu=leon3 -mattr=+detectroundchange -o
> - |& grep "detect rounding changes"
> +
> +; Function Attrs: nounwind
> +declare i32 @fesetround(i32)
> +
> +define void @test_round_change() {
> +entry:
> + %call = call i32 @fesetround(i32 2048)
> +
> + ret void
> +}
>
> Propchange: llvm/trunk/test/CodeGen/SPARC/LeonDetectRoundChangePassUT.ll
> ------------------------------------------------------------
> ------------------
> svn:eol-style = native
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161019/7cc227a7/attachment.html>
More information about the llvm-commits
mailing list